Skip to content

Reentrancy protection on swaps#227

Merged
naddison36 merged 2 commits into
nicka/withdraw-on-swapfrom
nicka/reentrancy
May 18, 2026
Merged

Reentrancy protection on swaps#227
naddison36 merged 2 commits into
nicka/withdraw-on-swapfrom
nicka/reentrancy

Conversation

@naddison36
Copy link
Copy Markdown
Collaborator

Summary

Adds reentrancy protection around ARM liquidity-moving entrypoints to prevent nested swap callbacks from reusing the same pre-payout liquidity balance during buy-side swaps.

Changes

  • Inherits ReentrancyGuardUpgradeable in AbstractARM.
  • Initializes the guard during ARM initialization.
  • Applies nonReentrant to:
    • both swapExactTokensForTokens entrypoints
    • both swapTokensForExactTokens entrypoints
    • collectFees
  • Adds a focused regression test using a callback-capable mock base token that attempts to reenter a buy-side swap during transferFrom.

Verification

  • forge test --match-path test/unit/OriginARM/Reentrancy.sol
  • forge test --match-path 'test/unit/OriginARM/*.sol'

Notes

forge build --sizes shows OriginARM remains under the EIP-170 limit, but LidoARM and EtherFiARM exceed it, so this fix may need a smaller mitigation before merging for all ARM implementations.

@naddison36 naddison36 changed the title WIP Reentrancy protection on swaps Reentrancy protection on swaps May 18, 2026
@naddison36 naddison36 marked this pull request as ready for review May 18, 2026 09:17
@naddison36 naddison36 merged commit 59504bd into nicka/withdraw-on-swap May 18, 2026
8 checks passed
@naddison36 naddison36 deleted the nicka/reentrancy branch May 18, 2026 09:29
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.

1 participant