Position Playbooks
← Flash Loan Desk

Position Playbooks

Four ways to alter, scale or restructure a live margin position inside a single block — without closing it out, without depositing new cash, and without exposing the intermediate steps to front-running. Each one is a different use of the same primitive: borrowed liquidity that must be returned before the block ends.

⚡ Where the money comes from — and why it has to go back

Every playbook here opens by borrowing liquidity from one of Atomic’s integrated lending pools — the Trading desk integrates it, prices it and routes the transaction. There is no credit relationship to underwrite, so there is nothing to approve you for.

What makes these workflows possible is atomicity. The borrow, every intermediate step, and the repayment all execute inside one transaction. If the pool is not made whole by the final instruction — or any safety bound you set is breached — the entire sequence reverts and the chain keeps no record of it having been attempted. You are out the gas and nothing else.

That is also why no step in the middle can be front-run. There is no moment where your position sits half-restructured and exposed: the intermediate states never exist on-chain as observable, interruptible facts.

1

One-block leverage scaling

Raise the leverage on a live position — say 1.5× to 4× — without running borrow‑swap‑deposit cycles across many blocks, and without out-of-pocket capital.

Built · fork-tested
ONE TRANSACTION — ALL OF IT, OR NONE OF IT Lending pool source of the flash credit Atomic receiver your strategy contract DEX router / aggregator Your margin vault existing position 1 2 USDC → 50 ETH 3 deposit ETH 4 borrow $150k 5 repay principal + fee Position grows by 50 ETH · no cash in · no intermediate state to front-run
Liquidity is drawn from the lending pool, converted, added to the position, and refinanced out of the position's own new borrowing capacity — then returned.
  1. Draw flash credit. Borrow $150,000 USDC from the lending pool.
  2. Convert to collateral. Swap it for roughly 50 ETH through a DEX router.
  3. Top up the position. Deposit the 50 ETH into your existing margin vault.
  4. Draw new debt. Borrow $150,000 USDC against the borrowing capacity that collateral just created.
  5. Settle. Return the principal plus fee to the pool, same transaction.
ResultPosition size increases by ~50 ETH with zero capital out of pocket. Your debt rises by the flash fee, and your leverage rises with it — which is the point, and also the risk.
Read this before using itLeverage is the fastest route to the liquidation the desk exists to help you avoid. Atomic builds this operation but does not promote it: a 4× position is liquidated by a far smaller price move than a 1.5× one. Set the health floor deliberately.

Contract function: leverageLoop() — proven end-to-end against live lending and DEX protocols on Ethereum and BNB Chain.

2

Deleveraging without out-of-pocket cash

Cut your loan-to-value and lift your health factor when volatility threatens liquidation — using nothing but the position's own collateral.

Built as a full close
ONE TRANSACTION — ALL OF IT, OR NONE OF IT Lending pool source of flash credit Atomic receiver your strategy contract DEX sell only what is needed Your margin vault debt down · collateral out You keep the remainder 1 2 repay debt 3 collateral out 4 5 repay principal + fee 6 surplus back Debt cleared · leftover collateral returned to you · no cash required
The position pays for its own deleveraging: freed collateral is partly sold to repay the pool, and whatever is left over comes back to you.
  1. Draw the debt principal. Flash-borrow the debt asset from the pool.
  2. Pay down the vault. Repay the outstanding borrow in your margin position.
  3. Withdraw freed collateral. With the debt cleared, the collateral unlocks.
  4. Sell only what is needed. Swap enough collateral to cover the repayment, bounded by a slippage limit you set.
  5. Settle. Return principal plus fee to the pool.
  6. Keep the rest. All unsold collateral transfers straight back to you.
ResultYour debt is cleared and the surplus collateral is yours, without needing a cent of outside money. On a position facing liquidation this also avoids the liquidator's penalty — typically 5% of the collateral seized.
How this differs from the workflow as usually describedThe version above is often written as a partial paydown — flash $50k against a larger debt, cut LTV, carry on. Atomic's selfLiquidate() does not support that: it requires flashing the full outstanding debt and closes the position completely. Partial deleveraging is a legitimate pattern and a reasonable thing to build, but it is not built, and we would rather say so than draw you a picture of it.

Contract function: selfLiquidate() — full close only. Fork-tested on Ethereum and BNB Chain.

3

In-place collateral swap

Change what backs your loan — say $1M of WBTC to $1M of ETH — while the debt stays exactly where it is. No close-out, no unbonding queue.

Built · fork-tested
ONE TRANSACTION — THE DEBT NEVER MOVES Lending pool flash: the new collateral Atomic receiver your strategy contract DEX old asset → new asset Your margin vault WBTC out · ETH in debt unchanged throughout 1 2 supply ETH first 3 then withdraw WBTC 4 5 repay principal + fee Exposure shifts WBTC → ETH in one block · the loan continues uninterrupted
The new collateral goes in before the old comes out, so the position's health never dips mid-operation — the ordering is the safety property.
  1. Flash the new collateral asset. Borrow the ETH you intend to back the loan with.
  2. Supply it first. Deposit the ETH into the vault while the old collateral is still in place.
  3. Withdraw the old collateral. Now safe to remove, because the position is already over-collateralised by the new asset.
  4. Sell the old asset. Swap the WBTC for ETH, bounded by your slippage limit.
  5. Settle. Return principal plus fee to the pool.
ResultSame loan, same debt, entirely different collateral — in roughly twelve seconds, with no close-out and no window where the position is unbacked.

Contract function: swapCollateral() — fork-tested moving a live position's collateral from WETH to WBTC on Ethereum with the debt untouched throughout.

4

Debt refinancing and rate arbitrage

Cut the interest you pay by moving the debt to wherever it is cheapest — without unwinding the position or finding bridge capital.

Built across venues
ONE TRANSACTION — NO SWAP LEG, SO NO SLIPPAGE Lending pool flash: the debt asset Atomic receiver your strategy contract Expensive venue debt repaid · collateral out 6.83% APY Cheaper venue collateral in · debt reopened 3.60% APY 1 2 repay · pull collateral 3 supply · re-borrow 4 repay principal + fee Same collateral, same debt, a lower rate · only the fee is added to your new debt
Because nothing is swapped, this flow has no slippage, no price-oracle dependency and no MEV surface — which is why it is the most thoroughly tested of the four.
  1. Flash the outstanding debt. Borrow the full amount owed, read live on-chain so accrued interest is covered exactly.
  2. Clear the expensive venue. Repay the debt and pull the collateral out.
  3. Reopen on the cheaper venue. Supply the collateral and re-borrow the same asset at the better rate.
  4. Settle. Return principal plus fee to the pool. Only the fee is added to your new debt — never the unused buffer.
ResultIdentical collateral, identical debt, a lower rate. The Borrow Desk computes this saving live for any address: at the time of writing the same stablecoin debt carries a 3.23 percentage-point spread between venues — roughly $1,600 a year on a $50,000 debt.
How this differs from the workflow as usually describedThe version above is often framed as swapping the debt asset — USDT debt becoming USDC debt inside the same protocol. Atomic's refinance() instead moves the venue, keeping the same asset. Both are real rate arbitrage and both are worth having; only the venue move is built.

Contract function: refinance() — fork-tested moving a live position between venues, with property tests proving the new debt is exactly the old debt plus the fee.

What is actually built

The honest version of the table, since none of it is live yet. Everything marked built has been executed against forked mainnet using the real protocols — not mocked.

PlaybookFunctionStatus
1 · Leverage scalingleverageLoop()As described
2 · DeleveragingselfLiquidate()Full close only — no partial paydown
3 · Collateral swapswapCollateral()As described
4 · Rate arbitragerefinance()Across venues — not debt-asset swaps
Execution for customersNot audited · not deployed

If you are building this yourself

The three things that most often go wrong, from having got them wrong.

Price any of this against live liquidity

The desk reads capacity and fees from the lending contracts at the current block and tells you the edge a route has to beat. That part is live today.

Open the Flash Loan Desk →
Capacity, fees and rates referenced on this page are read live from the lending protocols on the Flash Loan Desk and Borrow Desk. Flash credit is supplied by those protocols, not by Atomic — we route and price the transaction and never take custody. Execution is not available: the contract described here has not been independently audited or deployed. Nothing on this page is investment, tax or legal advice, and none of these workflows avoids a taxable event by construction — that depends on your jurisdiction and your facts.  ·  Terms  ·  Privacy