Flash Builder
Combine up to 12 actions, including swaps, borrowing and repayments in one atomic transaction using flash loan. The contract executes them in your chosen order and sends any remaining tokens to your wallet. If any action fails, the entire transaction reverts.
On this page
- On the roadmap
- V2 Execution
- Flash loans and lending
- Morpho Blue and more
- Flash loan fee
- 0
- Actions
- 12
- Transactions
- 1
Execution order
Use Flash Builder for multi-step trades, arbitrage and DeFi operations. Set up the blocks without writing a contract:
- Arbitrage between two pools: Borrow through a flash loan, buy in one pool, sell in another, repay the loan and keep the profit.
- Rebuild a position: Repay a loan, withdraw collateral, swap it and borrow on another market, all in one transaction.
- Reduce liquidation risk: Use a flash loan to repay part of your debt, withdraw collateral and swap it to repay the flash loan, improving your loan’s health.
You send the set: the flash loan, the blocks and your limits
Every block, token, pool, market and cap is checked before anything moves
Morpho Blue lends the flash loan, with no fee $50,000 USDC
Block 1 buys in one pool 25 WETH
Block 2 sells in the other, for at least its minimum $50,500 USDC
The fee goes to the fee recipient $100 USDC
Morpho takes the flash loan back $50,000 USDC
The rest comes back to you $400 USDC
SETTLEDOne transaction. Every block landed, and the loan was repaid.
- Checks: Validates the flash loan and all 1–12 blocks before moving tokens.
- Flash loan: Protocols provide the borrowed assets. Your signed authorization is used where required.
- Blocks run in your chosen order. If one fails,
StepFailed(index, reason)identifies it. - Settlement: The fee is paid, the protocol receives the exact borrowed amount and remaining tokens go to your wallet.
If anything fails, the entire transaction reverts, including the flash loan. Only gas is spent.
Transaction fee
fee = flashAssets * feeBps / 10_000
+ (flashOut - flashIn) * profitFeeBps / 10_000
feeBps = 20
profitFeeBps = 0One fee per transaction, paid in the flash loan token regardless of block count. Check the fee before signing with quoteFee(flashAssets, profit).
- Flash loan
- $50,000 USDC
- Bought
- 25 WETH
- Sold for
- $50,500 USDC
- Flash loan repaid
- $50,000 USDC
- Left after repaying
- $500 USDC
- Fee, 50,000 × 20 ÷ 10,000
- $100 USDC
- To your wallet
- $400 USDC
- Transactions
- 1
Set minReturn to $400 USDC or less and maxFee to at least $100 USDC. The transaction enforces your limits: maxFee, minReturn, minHealth, deadline and each swap’s minOut.
Price changes and borrowing risk
- Slippage and competition: Prices may change. If a swap falls below
minOutor the transaction missesminReturn, everything reverts and you still pay gas fees. - Pausing stops new executions. Your loan position remains accessible directly.