Skip to main content

Trading on the DLEX

Ammalgam’s DLEX is a full-featured trading engine where users can take leveraged positions directly against the liquidity pools they help supply. The unified interface and deposit mechanism lets users swap, long, short, and hedge while earning yield.

Perpetuals Engine Overview

The DLEX operates based on a perpetuals-style engine that allows for directional exposure with margin. Unlike traditional perps, positions are opened directly within Dual-Purpose Pools (DP Pools), enabling native access to liquidity and removing the need for external matching engines or segregated order books.

All positions are:

  • Isolated to individual AMM pairs (e.g., WBTC/USDC)
  • Overcollateralized with assets from your pool deposit
  • Continuously adjusted based on real-time pool state, oracles, and utilization rates

Every trade is collateralized with productive capital that's still earning protocol yield in the background.

Opening & Closing Positions

To open a position, go to the Trade tab and choose your asset pair.

  • Long: Borrow the counter-asset to gain upside exposure (e.g., borrow USDC to buy ETH).
  • Short: Borrow the target asset and sell it to take a bearish stance (e.g., borrow ETH and receive USDC).

Trades use your existing vault deposits as margin. Once you approve the assets, you can submit the order, which is instantly routed through the pool. There's no need to swap between protocols or wrap/unwrap assets.

To close a position, simply reverse the trade. PnL is automatically settled back into the pool.

Positions are visible directly in the pool view and DLEX dashboard, with real-time metrics on margin ratio, entry price, liquidation level, and unrealized PnL.

Order Types (Market, Limit, Conditional)

Ammalgam's DLEX supports multiple order types for flexibility:

  • Market Order: Execute instantly at the current pool price.
  • Limit Order (upcoming): Set your own price and wait for it to be filled.
  • Conditional Order (upcoming): Trigger positions based on external price movements, oracle thresholds, or liquidation signals.

All trades are matched directly against on-chain liquidity. You're trading with the pool rather than an external counterparty.

Margin Requirements

Ammalgam uses isolated margin per pool pair. Your margin is calculated from your deposit in that specific vault. Key points:

  • You cannot be liquidated due to positions in another pool.
  • You can borrow up to your pair's Max LTV, adjusted dynamically based on utilization and price volatility.
  • Positions that exceed safe LTV thresholds are eligible for liquidation via the price-dependent liquidation mechanism.

This system prevents contagion and limits systemic risk, even during market turbulence.

Profit and Loss (PnL), Liquidations, Funding

The DLEX calculates PnL based on the current pool price vs. your entry price. Gains and losses accrue in the margin asset you used to open the position.

Liquidations are handled using Price-Dependent Liquidations, a Dutch auction-style mechanic that dynamically adjusts incentives for liquidators based on how far the price has moved past the liquidation threshold. This protects borrowers from premature liquidation while still securing the protocol. We also include a funding rate system, similar to perpetual futures:

  • Funding rates are driven by pool utilization, not external open interest.
  • If demand to long/short becomes unbalanced, funding costs adjust to incentivize the other side.
  • This results in natural rebalancing of open interest and protection from one-sided risk buildup.

Fees Breakdown

Fees on the DLEX are designed to reward LPs and ensure sustainability:

Fee TypeDetails
Swap FeePaid to LPs during any trade (configurable per pool)
Borrow SpreadLPs earn interest; traders pay based on utilization tier
Liquidation Premium/DiscountApplied during forced closures, scaling with price deviation
Funding PaymentsContinuous rebalancing paid between longs/shorts via utilization curve
Exit Fee (if applicable)Used to discourage short-term farming and reward longer-term liquidity