← Protocols
Dolomite
01Description

Margin-trading-aware lending and borrowing protocol on Arbitrum, Berachain, Mantle, X-Layer and Ethereum. Supports 1,000+ unique assets while keeping deposited tokens 'native' — staking rewards, votes and governance pass through to depositors.

02Best for
  • 01money-market frontends with long-tail asset support
  • 02margin trading / leveraged yield strategies
  • 03preserving native asset utility (staking, governance) while collateralized
  • 04cross-asset borrowing on Berachain / Arbitrum
  • 05looped LST / LRT positions
03Install
  • pnpm add @dolomite-exchange/dolomite-margin viem
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_DOLOMITE_NETWORKClient`arbitrum`, `berachain`, `mantle`, `x-layer`, or `ethereum` — selects the DolomiteMargin proxy address.
NEXT_PUBLIC_RPC_URLClientRPC URL for the selected network.
05Prompt snippet
Use viem with the `DolomiteMargin` core contract. Each user has numbered `accountNumber` sub-accounts; `accountNumber = 0` is the default supply account, > 0 are isolation/borrow positions. Build atomic operations with `operate(accounts, actions)` — actions are an array of `{ actionType: Deposit|Withdraw|Transfer|Buy|Sell|Trade|Liquidate, amount, primaryMarketId, secondaryMarketId, otherAddress, otherAccountId, data }`. Read account health via `getAccountValues(account)` returning supply/borrow par values, and `getMarketPrice(marketId)` for oracle prices. Use the `BorrowPositionProxy` for one-shot borrow/leverage flows.
06Gotchas
  • Dolomite is account-number based, NOT one-position-per-wallet — isolation borrow positions live in numbered sub-accounts (e.g. accountNumber 100, 101...). Querying `getAccountValues(user, 0)` only shows the main supply account.
  • Many supported assets are 'wrapped' isolation modes (e.g. GMX GLP, Pendle PT, Plutus plvGLP, BeraChain LSTs). These positions can only borrow specific debt assets and have isolation-mode collateral factors — read `getMarketIsClosing` and the IsolationModeRegistry before showing borrow options.
  • Native rewards pass-through means rebasing/yield-bearing tokens (e.g. wstETH, sFRAX, BeraChain validator delegations) keep accruing to the depositor inside Dolomite. Withdrawals account for accrued par-to-wei conversion — quote in wei, not par.
  • Liquidation pays a 5% premium by default but isolation positions and 'risky' assets can go up to 15%. Health is `borrow value × marginPremium ≤ supply value × marginPremium` — check `marginRatio` before assuming a position is safe.
  • Each network has its own asset whitelist — a marketId (e.g. 0 = WETH on Arbitrum) is NOT the same on Berachain. Always resolve marketId by token address via `getMarketIdByTokenAddress`.
  • Oracle dependencies vary by asset (Chainlink, Redstone, Pyth, custom price oracles). Stale oracles pause borrow/withdraw on that market — a UI must surface this rather than retrying blindly.
07Alternatives