ATOMICThree things you can do in one signature
Each action is a fixed recipe of contract calls that runs inside a single flash-loan callback. Below: what every step does, which contracts it touches, the live numbers behind it and the guardrails that make it revert instead of half-succeed.
Open the appPerpetual. one deposit, up to 2.6x
You bring USDG. The router flash-borrows the rest, buys the stock on Uniswap, posts it as collateral on Morpho, borrows USDG against it and repays the flash loan. What is left is a leveraged long, opened in one signature.
- You want more exposure to a name than your cash allows, without a margin account
- You want the loan priced by an on-chain rate curve instead of a broker's margin rate
- You want the whole position visible and closable on-chain at any hour
- 01Morpho.flashLoan(USDG, flashAmount, data)Fee-free, must be repaid before the callback returns
- 02SwapRouter02.exactInputSingle({ tokenIn: USDG, tokenOut: STOCK, fee, amountOutMinimum })amountOutMinimum comes from the quote you saw, minus your slippage tolerance
- 03Morpho.supplyCollateral(market, tokens, onBehalf: you)Collateral is credited to your address, not the router
- 04Morpho.borrow(market, debt, onBehalf: you, receiver: router)Requires a one-time Morpho authorization for the router
- 05USDG.transfer(Morpho, flashAmount)Closes the flash loan inside onMorphoFlashLoan
- /The app refuses to open above 90% of the liquidation threshold
- /The swap reverts if output falls below your minimum, and with it the whole transaction
- /Borrow is blocked when the market's idle USDG is smaller than your debt
Rotate. swap collateral, keep the loan
Move a position from one stock to another without closing it. The router flash-borrows your debt amount, repays it to release the old collateral, swaps that collateral, supplies the new one, borrows the same debt again and repays the flash loan.
- You want to rotate sectors, NVDA into AAPL, without cash sitting idle for a settlement cycle
- You are happy with your loan size and only want to change what backs it
- A market for the destination stock has enough idle USDG to re-open your debt
- 01Morpho.flashLoan(USDG, debt, data)Sized from your live borrow shares
- 02Morpho.repay(oldMarket, debt, onBehalf: you)Clears the loan so the collateral can leave
- 03Morpho.withdrawCollateral(oldMarket, tokens, onBehalf: you, receiver: router)Router holds the tokens only for this transaction
- 04SwapRouter02.exactInput(path)Path is chosen by the quoter: direct, via USDG or via WETH
- 05Morpho.supplyCollateral(newMarket) then Morpho.borrow(newMarket, debt)Debt is re-opened at the same USDG amount
- /Blocked when the destination LTV would sit above 98% of its liquidation threshold
- /Blocked when the destination market cannot supply your debt
- /Slippage on the stock-to-stock leg is bounded by your minimum output
Arbitrage. zero balance, borrowed inventory
The same stock trades in several pools. When one prices it below another by more than both pool fees, the router flash-borrows USDG, buys at the cheap venue, sells at the dear one and repays. Whatever clears is yours, and if nothing clears the transaction reverts and costs only gas.
- Weekends and after-hours, when the underlying is closed and pools drift apart
- Right after large trades, before other bots rebalance the pools
- Any time the scanner shows a net spread above zero on a ticker with two or more venues
- 01Morpho.flashLoan(USDG, size, data)Or a Uniswap v3 flash if the route needs WETH
- 02SwapRouter02.exactInputSingle(USDG -> STOCK) on venue AUniswap v3 and forks; v4 via the Universal Router
- 03SwapRouter02.exactInputSingle(STOCK -> USDG) on venue BamountOutMinimum is set to size plus your minimum profit
- 04require(profit >= minProfit)Otherwise revert: no partial fills, no inventory left behind
- /Net spread ignores price impact, so size stays small until the router simulates the exact fill
- /A minimum-profit check makes an unprofitable attempt revert instead of executing
- /Gas is the only cost of a failed attempt
Every action needs a live market or a live pool
Leverage and rotate need a Morpho market with USDG supply. Arb only needs two venues pricing the same token.