Onchain Atlas

Margin Trading

Borrowing extra funds against your deposited collateral so a trade controls more capital than you actually put in, amplifying both gains and losses.

Also called: leveraged trading · borrow-to-trade · cross-margin accounts

What it is

Margin trading lets a user put up collateral (say, $1,000) and borrow additional funds against it to open a larger position than their own capital would allow. The borrowed funds come from a lending pool or protocol-owned liquidity, and the user pays interest on that borrowed amount for as long as the position stays open. Because the position is bigger than the user's own equity, price moves are magnified — a 10% favorable move on a 5x-leveraged position returns roughly 50% on the user's actual capital, but a 10% adverse move can wipe it out.

How it works

  1. A user deposits collateral into a margin or credit account managed by the protocol.
  2. The protocol values that collateral (often applying a haircut for volatile assets) and lets the user borrow against it up to a set loan-to-value ratio, drawing from a shared lending pool.
  3. Borrowed assets are typically swapped or deployed into the user's chosen position (e.g., a bigger spot buy, a leveraged perpetual, or a yield strategy), so the account now holds both the collateral and the borrowed exposure.
  4. The protocol continuously tracks the account's health factor: the ratio of collateral value to debt value, adjusted for the position's current price.
  5. If the market moves against the position and the health factor falls below a maintenance threshold, the account becomes eligible for liquidation — a keeper or liquidator repays some or all of the debt and seizes a portion of the collateral, usually earning a liquidation bonus.
  6. Interest accrues on the borrowed amount over time, paid to lenders who supplied the pool, and the user can add collateral, repay debt, or close the position at any time to stop accruing interest and remove liquidation risk.

Why designers use it

  • Lets users express a larger view on price than their capital alone would support, increasing capital efficiency for both traders and the protocol's fee revenue.
  • Creates a lending market that generates yield for depositors who supply the borrowed side of the pool.
  • Enables more sophisticated strategies (hedging, basis trades, delta-neutral farming) that require holding leveraged exposure alongside collateral.
  • Keeps solvency risk contained to individual accounts via liquidation, rather than socializing losses across the whole protocol — provided liquidations fire in time.

Failure modes

  • Cascading liquidations: a sharp price move triggers many accounts' health factors to breach thresholds simultaneously, and the resulting liquidation selling pushes price further, triggering more liquidations (a liquidation spiral).
  • Oracle lag or manipulation: if the price feed used to compute health factors is stale or manipulable, positions can be liquidated unfairly or, worse, remain under-collateralized without being flagged.
  • Liquidator under-incentivization: if the liquidation bonus is too small or gas costs too high relative to position size, no one bothers to liquidate small unhealthy positions, leaving bad debt on the books.
  • Thin liquidity for the underlying asset: liquidators can't actually sell the seized collateral without heavy slippage, meaning the protocol absorbs a loss even though the liquidation "succeeded" on paper.
  • Interest rate model mismatches: if borrow rates don't rise fast enough as utilization approaches 100%, lenders can't withdraw and the whole pool becomes illiquid.

What to check before using it

  • Verify the liquidation engine has been stress-tested against fast, large price moves (flash crashes), not just gradual ones.
  • Check the oracle's update frequency, manipulation resistance, and what happens if it goes stale.
  • Confirm liquidation incentives are large enough, net of gas, to reliably attract liquidators at all position sizes.
  • Model utilization and interest rate curves under high-borrow scenarios to ensure lenders can still exit.
  • Understand the maximum leverage offered and whether maintenance margin requirements leave enough buffer for realistic volatility.

Experiments that used it · 2

Shown oldest first, so you can watch the design evolve.

Mars Protocol Rover Credit Accounts
NFT-represented, cross-collateralized 'credit accounts' on Mars Protocol let Cosmos users lend, borrow, spot trade, margin trade, and leverage-farm from a single composable position instead of siloed money-market deposits.
2023 ongoing
Pendle Boros
Pendle's funding-rate derivatives venue that tokenizes perpetual-futures funding into tradable Yield Units (YU), letting traders go long/short or hedge funding-rate exposure on margin.
2025 too early to judge