Skip to content

feat: arbitrary asset support on ethereum#124

Open
shivam-ef wants to merge 38 commits into
masterfrom
feat/eth-asset-support
Open

feat: arbitrary asset support on ethereum#124
shivam-ef wants to merge 38 commits into
masterfrom
feat/eth-asset-support

Conversation

@shivam-ef

@shivam-ef shivam-ef commented May 15, 2026

Copy link
Copy Markdown
Contributor

Note

High Risk
Large new surface for user-signed swaps, cross-chain bridging, and role-gated fund redirects between TopUp and TradingSafe; mistakes in signature binding, hold timing, or redirect guards could move or strand user assets.

Overview
Adds a mainnet trading-account stack so users can hold and trade assets on Ethereum that are not supported on the OP cash rail, wired to the existing OP TopUp flow.

Trading safes & lens: Introduces TradingSafe / TradingSafeFactory (deterministic addresses from the source TopUp/safe identity) and TradingLens for supported trading tokens and balance/USD reads. Shared safe logic moves into EtherFiSafeCore; OP EtherFiSafe becomes a thin wrapper. Factory deploy init now targets EtherFiSafeCore.initialize; EtherFiSafeFactory.reinitialize is removed.

Swap modules: New AcrossSwapModule (signed request → optional CashModule withdrawal hold → executeSwap replays Across depositV3 or origin periphery calldata) and EnsoSwapModule (same lifecycle via pinned Enso router calldata; same-chain minOut balance check). On mainnet trading DataProvider (cashModule == 0), swaps run immediately at request; on OP they use the hold/delay path.

TopUp ↔ TradingSafe recovery: TopUpFactory gains setTradingSafeFactory, redirectToTradingSafe / batch (role-gated; trading-supported, not topup-supported tokens). TradingSafeFactory mirrors with redirectToTopUp for topup-supported assets, using TradingLens / TopUp factory oracles.

Deploy & ops: EtherFiDeployer (CREATE3), scripts for bootstrap, full mainnet trading deploy (atomic proxy init, address prediction), OP module rollout, standalone Enso deploy; dev deployment JSONs and mainnet fixture updates. Certora patches switch EnumerableSet to OpenZpelin on EtherFiSafeCore / factory.

Reviewed by Cursor Bugbot for commit a42d1cc. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/trading-safe/TradingLens.sol Outdated
Comment thread src/trading-safe/TradingLens.sol
Comment thread test/upgrade-bytecode-verification/VerifyOPMainnet.t.sol

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6917f88cc7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ownership-bridge/OwnershipBridgeReceiver.sol Outdated
Comment thread src/ownership-bridge/OwnershipBridgeSender.sol Outdated

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 091c4b64-214a-45d8-898c-4ace70ed542f
  • Commit: 6917f88
Job Result VERIFIED Link
EtherFiSafe.conf 0 Link
CashModuleCore.conf --rule "p03" 2 Link

Comment thread src/interfaces/IOwnershipBridgeSender.sol Outdated

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: e68acfeb-97b1-4f87-818c-86bc69d7ef65
  • Commit: 2f6a428
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

Comment thread test/safe/modules/midas/MidasModule.t.sol Outdated
Comment thread src/trading-safe/TradingLens.sol
Comment thread src/ownership-bridge/OwnershipBridgeReceiver.sol Outdated
@github-actions

Copy link
Copy Markdown

Certora Run Started (Certora verification)

  • Group ID: 05e7e318-cd3e-4433-9f9a-b8422af08651
Config Status Link Log File
CashModuleCore.conf --rule "p03" Failed (1) - certora/confs/CashModuleCore.conf-cdbc211b4f0d.log
EtherFiSafe.conf Failed (1) - certora/confs/EtherFiSafe.conf-b8d8b9153287.log

Certora Run Summary

  • Started 0 jobs
  • 2 jobs failed

Download Logs

@github-actions

Copy link
Copy Markdown

Certora Run Started (Certora verification)

  • Group ID: a261349d-ad0a-49f8-9385-edfad7502780
Config Status Link Log File
CashModuleCore.conf --rule "p03" Failed (1) - certora/confs/CashModuleCore.conf-5dfadce0cb82.log
EtherFiSafe.conf Failed (1) - certora/confs/EtherFiSafe.conf-dbc90fda445f.log

Certora Run Summary

  • Started 0 jobs
  • 2 jobs failed

Download Logs

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 1b5d25d9-fec1-4599-8cad-d9048abc7c75
  • Commit: 9398ab9
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

Comment thread src/top-up/TopUpFactory.sol
Comment thread src/safe/EtherFiSafeFactory.sol

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 94a8041d-e624-40ef-960c-a39dcbf6deb1
  • Commit: c6e3430
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 4cf1583f-f86b-45a7-9b06-7fff2bc3e6cc
  • Commit: 360b5c8
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: acef44d5-65f8-4d5e-9c9f-27c40141dd20
  • Commit: 51dc4fa
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: f16fbc55-c107-44e9-9a41-9c2039562aa8
  • Commit: f09a80c
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

Comment thread src/across/AcrossSwapModule.sol Outdated

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: a809f2bb-504b-4466-b306-bc62c5216756
  • Commit: 8055a24
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 78587657-db5b-482f-97fc-58b5716a4d33
  • Commit: c178cb7
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 422f6aa6-3483-4ef7-a827-a775221ed043
  • Commit: 117f602
Job Result VERIFIED Link
EtherFiSafe.conf 14 Link
CashModuleCore.conf --rule "p03" 2 Link

jtfirek and others added 3 commits July 6, 2026 14:17
Mirrors AcrossSwapModule's request/execute lifecycle but forwards
BE-supplied Enso router calldata, enabling same-chain asset swaps that
Across cannot serve. Includes deploy script, trading-account wiring
(OP + mainnet), and full test coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
feat: add EnsoSwapModule for same-chain + cross-chain swaps
Once a stored swap passes its `order.deadline`, `executeSwap` can never
succeed again (it reverts `OrderExpired`), yet the swap and its CashModule
solvency hold sit locked until an owner signs `cancelSwap`. This blocks the
one-active-order-per-safe slot and leaves the withdrawal hold in place,
forcing the user to sign a cancel just to recover.

Add `cancelExpiredSwap(address safe)` to both EnsoSwapModule and
AcrossSwapModule (covers all trading order types: buy/sell/swap). It takes
no signature and can be called by anyone (e.g. the backend keeper) once
`block.timestamp > order.deadline`, mirroring `cancelSwap`'s clearing path
(`cancelWithdrawalByModule`, or direct delete when `cashModule == 0`).

Safe by construction: it can only run after expiry (when execution is
already impossible) and merely refunds the safe's own funds back to the
safe and clears state — there is no fund-movement authority to abuse.

Reverts `OrderNotExpired` at/before the deadline and `NoActiveOrder` when
nothing is stored. Adds forge coverage for both modules.

Co-authored-by: Cursor <cursoragent@cursor.com>
jtfirek and others added 11 commits July 10, 2026 15:28
…red-swap

feat: permissionless cancelExpiredSwap for stuck trading orders
Remove the undeployed LayerZero ownership-sync system so Optimism
EtherFiSafes and mainnet TradingSafes manage owners and recovery
independently on their own chains.

- Delete OwnershipBridgeSender/Receiver, OwnerBridgePublisher,
  TradingOwnerBridgeReceiver, OwnershipBridgeMessageLib, their
  interfaces, the wire script, and bridge tests.
- Drop the _publish* hooks from EtherFiSafeBase/MultiSig/RecoveryManager
  and simplify EtherFiSafe/TradingSafe to EtherFiSafeCore.
- Make configureOwners/setThreshold/recoverSafe/cancelRecovery
  nonpayable (no LZ fee), which also removes the trapped-ETH path (L-04).
- Remove ownershipBridgeSender storage/API from EtherFiDataProvider.
- Update trading-account deploy scripts, dev deployment JSON, and
  trading-safe tests for the chain-local model.

Eliminates audit findings M-02, M-03, M-04, M-07, L-04, L-07 and the
bridge-sender informationals I-04/I-05/I-06.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…-ownership

fix: address Certora trading account audit findings
Signed-off-by: Jacob T Firek <106350168+jtfirek@users.noreply.github.com>
"BeHYPEStakeModule": "0x6477daec9a81AC76A7276e3f62136E0A10ca7A68",
"AssetRecoveryModule": "0xD0134F725b025723f9B5C6acDD0fF8BAacC5E2c6",
"MidasModule": "0x292B353d262E00a215E096A97596b55F8AFb00Df",
"AcrossSwapModule": "0x2D749A1A0cdB663780b16b401d55e9D31FE85C7b"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken deployments JSON syntax

High Severity

The new AcrossSwapModule entry is missing a trailing comma, so the file is invalid JSON. Scripts and tooling that call stdJson.readAddress / vm.readFile on this deployment artifact will fail to parse it. MidasModule is also duplicated.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e5d41c5. Configure here.

Signed-off-by: Jacob T Firek <106350168+jtfirek@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a42d1cc. Configure here.

to[2] = swap.order.srcToken;
data[2] = abi.encodeCall(IERC20.approve, (ensoRouter, 0));

IEtherFiSafe(safe).execTransactionFromModule(to, values, data);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native ETH source swaps fail

Medium Severity

_dispatchSwap always approves order.srcToken and sends value = 0 to the Enso router. Native ETH (0xEee…) is allowed by validation and handled as an output, but as an input the approve targets a non-token and no ETH is forwarded, so ETH→token swaps cannot execute.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a42d1cc. Configure here.

@certora-run certora-run Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification Results

  • Group ID: 2a0a2c42-b10e-4b02-bb11-23bb835feaef
  • Commit: a42d1cc
JobResultVERIFIED
EtherFiSafe.…14
CashModuleCo…2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants