Brokex Docs
Docs/PROTOCOL MECHANICS/LONG Trading

LONG Trading

Exact mechanics, formulas, and numerical example for leveraged LONG positions.

LONG Position LifecycleBase Mainnet · 1.0x–2.0x
1. Trader MarginUSDC → BrokexRouter2. Vault Borrow(L−1)×M + 0.10% Fee3. Aerodrome SwapUSDC → NVDAc Spot4. Share CustodyHeld in LongManagerInterest accrues (2%–40% APR)5. Sell NVDAcSwap back to USDC6. Repay Vault DebtPrincipal + Interest7. Close Fee0.10% (50% LP / 50% BROKEX)8. Trader PayoutRemaining USDC → Wallet

Formulas (LongManager.sol)

  • borrowedUsdc = Math.mulDiv(marginUsdc, leverageBps - BPS, BPS) (floor)
  • grossNotional = marginUsdc + borrowedUsdc
  • openFee = Math.mulDiv(grossNotional, fc.longOpenFeeBps, BPS) (floor; requires marginUsdc > openFee)
  • newDebtShares = Math.mulDiv(borrowedUsdc, RAY, idx, Math.Rounding.Ceil)
  • Open LTV Check: Math.mulDiv(posDebtUsdc, BPS, posValueUsdc) <= cfg.longMaxLtvBps (6000 bps = 60%).