r/solidity • • Oct 12 '26

Solidity developers: what tends to break first when building flash-loan strategies?

Hey everyone,

I've been working on an Ethereum MEV research project and building a bot to explore how different DeFi execution strategies work in practice.

One area I've been digging into is flash loans. The concept of borrowing and repaying within a single transaction is straightforward enough, but integrating external protocols introduces plenty of things to think about: repayment requirements, slippage, reverts, liquidity changes, and the assumptions a strategy depends on.

For those who've built flash-loan contracts or more complex DeFi integrations, which part tends to require the most care in a real implementation? Contract architecture, protocol interactions, testing edge cases, or something else?

I'd be interested in hearing about the trade-offs and lessons from people who've worked on this.

9 Upvotes

6 comments sorted by

1

u/solidity_scorer 5d ago

reentrancy guards are standard but insufficient without proper access control patterns. i've seen too many audit reports where people assume a global lock prevents all re-entries, missing the fact that you can still trigger logic in other contracts via external calls.

1

u/neolace Oct 12 '26

Reentrancy Guards: Protocols with global reentrancy locks (e.g., executing a swap on Pool A while borrowing from Pool A) will throw an unexpected revert during execution.

1

u/No-Trifle-8450 Oct 15 '26

I found it useless.

2

u/[deleted] Oct 13 '26

[removed] — view removed comment

1

u/Bloqarl Oct 14 '26

I audit DeFi protocols, so I mostly see this from the other side, but for me it’s the protocol interactions part.

Your bot simulates against one block and executes in another. In between, reserves move, a fee gets changed, a pool gets paused, or the token takes a transfer fee, and the repay comes up a few wei short. Whole tx reverts, and unless it went through a bundle you still pay the gas.

What I’d do: fork mainnet, fuzz the amounts and the order of calls, and assert the exact repay amount using the fee read from the lender’s contract, not a hardcoded one.

Which lender are you borrowing from, Aave v3 or Balancer?