Overhead shot of fund admin working at a WeWork lounge table, portfolio printouts spread out, laptop showing tokenized asset performance, casual work session.
Protocols

Margin and Collateralization Framework

Comprehensive technical standard for how collateral is valued, cross-margined, and liquidated on the dYdX chain, including the precise formulas for initial margin, maintenance margin, and insurance fund mechanics.
introduction
MARGIN AND COLLATERALIZATION FRAMEWORK

Introduction

The formal standard defining how collateral is valued, cross-margined, and liquidated on the dYdX chain.

The Margin and Collateralization Framework is the core risk primitive of the dYdX protocol, establishing the precise mathematical rules for calculating initial margin, maintenance margin, and liquidation prices for all open positions. This standard governs how the protocol values collateral assets, applies haircuts, and determines whether a subaccount is adequately collateralized. For institutional traders and risk teams, this framework is the authoritative source for modeling portfolio risk, as it defines the exact conditions under which a position transitions from healthy to liquidatable.

The framework specifies a cross-margining model where all positions within a subaccount share a single collateral pool, allowing offsetting positions to reduce overall margin requirements. It details the stepwise liquidation process triggered when a subaccount's net collateral falls below its maintenance margin requirement, including the insurance fund's role as a backstop for unprofitable liquidations. Key parameters—such as initial_margin_fraction, maintenance_margin_fraction, and oracle price deviation bounds—are adjustable through on-chain governance, meaning risk profiles can shift with each governance vote.

Operators of liquidation bots, institutional trading desks, and exchange risk teams must implement this framework precisely to avoid failed liquidations, incorrect margin calls, or unexpected position closures. Chainscore Labs provides margin parameter risk analysis and liquidation model review, helping teams validate that their internal risk engines match the protocol's on-chain behavior before governance changes take effect or new markets are listed.

MARGIN AND COLLATERALIZATION FRAMEWORK

Quick Facts

Core parameters and operational facts for the dYdX margin system, collateral valuation, and liquidation mechanics.

FieldValueWhy it matters

Collateral Types

USDC and other governance-approved assets

Defines what assets can be deposited; integrators must support the full set for accurate portfolio valuation.

Margin Model

Cross-margin with isolated market sub-accounts

Determines how PnL and collateral are netted; risk teams model portfolio-wide liquidation risk against this structure.

Initial Margin Fraction (IMF)

Governance-set per market

Controls maximum leverage for opening positions; a change directly impacts trader capital efficiency and protocol risk.

Maintenance Margin Fraction (MMF)

Governance-set per market, lower than IMF

Triggers liquidation if breached; the gap between IMF and MMF is the protocol's first loss-absorption buffer.

Oracle Price Source

Decentralized oracle network (e.g., Pyth, Chainlink) via governance-designated feeds

Liquidation prices and collateral values depend entirely on oracle integrity; stale or manipulated prices cause wrongful liquidations.

Liquidation Engine

Automated, stepwise partial liquidation process

Ensures under-collateralized positions are reduced without unnecessary full closure; liquidation bot operators must match this spec.

Insurance Fund

Protocol-controlled backstop funded by liquidation fees

Absorbs losses when a position's collateral is insufficient to cover its debt at liquidation; fund size is a critical systemic risk metric.

Governance Control

dYdX community governance can adjust IMF, MMF, and oracle sources

Parameter changes can alter risk profiles instantly; risk managers must monitor governance proposals for margin-impacting changes.

technical-mechanism
MARGIN AND LIQUIDATION LOGIC

Technical Mechanism

The precise mathematical framework for valuing collateral, calculating margin requirements, and executing liquidations on the dYdX chain.

The dYdX Margin and Collateralization Framework defines the protocol's core risk engine, translating volatile market positions into a deterministic set of solvency conditions. It operates on a cross-margin model, where all of a subaccount's open positions and deposited collateral are aggregated into a single portfolio for risk assessment. The framework specifies the exact formulas for calculating the Initial Margin Requirement (IMR) to open a position and the Maintenance Margin Requirement (MMR) to keep it open. These requirements are derived from an IMF (International Monetary Fund) standard methodology adapted for crypto assets, using a combination of exponentially weighted moving average (EWMA) volatility and tail-risk shock factors to determine the minimum collateral needed against adverse price movements.

The framework's operational core is the liquidation process, which is triggered when a subaccount's total net collateral value falls below its total MMR. The protocol does not liquidate entire positions at once; instead, it employs a stepwise liquidation mechanism. A liquidation bot, operating off-chain, identifies an undercollateralized subaccount and submits a transaction to partially reduce its riskiest position by a fixed percentage. The bot receives a gas rebate and a small liquidation fee, while the remaining position stays open. This process repeats in subsequent blocks until the subaccount is recapitalized above the MMR or all positions are closed. The Insurance Fund acts as a backstop, automatically covering any remaining shortfall if a liquidation cannot be completed before a subaccount's equity turns negative, ensuring the protocol never carries bad debt.

For institutional traders and risk teams, this framework is the single source of truth for modeling portfolio risk and pre-trade capital requirements. The precise parameters—IMF shock factors, liquidation step sizes, and fee percentages—are not static; they are subject to on-chain governance proposals that can recalibrate the entire risk surface of the exchange. A governance vote to adjust the MMR for a specific market tier directly impacts the leverage available to all participants and the liquidation cascade risk during high-volatility events. Builders of liquidation bots, monitoring dashboards, and trading clients must implement their systems against this exact specification to correctly predict liquidation prices and respond to state changes, making the framework's deterministic logic a critical integration dependency.

MARGIN FRAMEWORK IMPACT

Affected Actors

Portfolio Risk Recalculation

Institutional trading desks must recalibrate their risk models against the precise initial and maintenance margin formulas. Changes to cross-margining logic directly alter portfolio-level collateral efficiency and liquidation thresholds.

Action items:

  • Recalculate margin requirements for existing open positions under the new framework.
  • Update internal risk dashboards to reflect new liquidation price curves.
  • Test portfolio margin behavior under volatility scenarios that approach maintenance levels.

Chainscore can provide independent margin parameter risk analysis and validate that your internal models match the on-chain liquidation engine behavior before governance finalizes changes.

implementation-impact
MARGIN FRAMEWORK INTEGRATION

Implementation Impact

The Margin and Collateralization Framework defines the core risk engine for the dYdX protocol. Changes to these parameters directly impact liquidation risk, capital efficiency, and the solvency of the insurance fund. Integrators must ensure their systems correctly model these formulas.

01

Risk Parameter Reconfiguration

Governance can adjust Initial Margin Fraction (IMF) and Maintenance Margin Fraction (MMF) for any market. Trading systems and risk dashboards must dynamically consume these on-chain parameters rather than using hardcoded values. A mismatch between a trading firm's internal risk model and the protocol's live parameters can lead to unexpected liquidations or missed trading opportunities. Chainscore can review your integration to ensure it correctly subscribes to governance-driven parameter changes.

02

Liquidation Engine Compliance

The stepwise liquidation process defined in this framework is the authoritative specification for liquidation bots. An incorrect implementation of the maintenance margin check or the liquidation price calculation will result in failed transactions, wasted gas, and potential losses for the bot operator. Bots must precisely replicate the protocol's formula for determining when an account is undercollateralized and the size of the position to be liquidated. Chainscore can audit your liquidation bot logic against the canonical specification.

03

Cross-Margining Model Impact

The framework's cross-margining logic allows unrealized profits in one position to offset margin requirements for another. Portfolio margin systems must correctly calculate the total net open notional and aggregate margin requirements across all of a subaccount's positions. A failure to model this correctly can lead to a false view of an account's health, either overstating risk or unnecessarily restricting trading. Institutional trading desks should validate their internal risk engines against the protocol's exact cross-margining formulas.

04

Insurance Fund Drawdown Triggers

The insurance fund backstops losses when a liquidated account's collateral is insufficient to cover its debt. Integrators and risk teams must monitor the precise conditions under which the insurance fund is drawn upon, as defined by this standard. A large drawdown event signals systemic risk. Monitoring systems should be configured to alert on these specific on-chain events to trigger immediate risk assessment. Chainscore can help design monitoring and alerting for insurance fund solvency thresholds.

05

Oracle Price Dependency Analysis

The margin framework's calculations are entirely dependent on the oracle price provided for each market. The standard defines how this price is consumed but not the oracle's own failure modes. A stale, incorrect, or manipulated oracle price will directly cause false liquidations or allow unsafe leverage. Integrators must model the combined risk of the margin framework and the specific oracle implementation for each market. Chainscore provides integrated risk assessments that analyze both the margin logic and its oracle dependencies.

06

API and Indexer Data Reconciliation

Indexers and portfolio management APIs must surface the exact margin and liquidation data as computed on-chain. Any discrepancy between an indexer's calculated account health and the protocol's state will cause users to make incorrect decisions. Data teams should implement reconciliation checks that compare their computed values for initial margin, maintenance margin, and liquidation price against the canonical on-chain state for a sample of accounts. Chainscore can validate your data pipeline's fidelity to the protocol's risk calculations.

MARGIN AND COLLATERALIZATION FRAMEWORK

Risk Matrix

Operational and systemic risks introduced by the margin framework's design, parameterization, and dependency assumptions. Institutional traders, risk teams, and protocol operators should evaluate each area for potential failure modes.

RiskFailure modeSeverityMitigation

Oracle price feed deviation

Stale or manipulated oracle prices cause incorrect collateral valuation, leading to unfair liquidations or insolvent positions

Critical

Monitor oracle update frequency and deviation thresholds; implement circuit breakers on price feed staleness

Cross-margin contagion

A single volatile market in a cross-margined portfolio triggers cascading liquidations across unrelated positions

High

Stress-test portfolio margin models under multi-market volatility scenarios; review correlation assumptions

Insurance fund depletion

A large-scale liquidation event during extreme volatility exhausts the insurance fund, leaving underwater positions on the protocol

Critical

Model insurance fund adequacy against historical drawdowns and tail-risk scenarios; verify governance replenishment mechanics

Liquidation bot failure

Liquidation bots fail to operate during network congestion or gas spikes, allowing underwater positions to accumulate uncollateralized losses

High

Ensure liquidation bot infrastructure has priority fee logic and fallback nodes; test under mainnet congestion conditions

Parameter change governance attack

A malicious or captured governance vote lowers maintenance margin requirements, enabling systemic under-collateralization

High

Monitor governance proposals for margin parameter changes; implement timelock delays on critical risk parameter updates

Collateral asset depeg

A collateral asset loses its peg or experiences a sharp price decline, reducing the real value of all positions using it as margin

Critical

Diversify accepted collateral types; set conservative collateral haircuts and monitor on-chain liquidity depth for each asset

Cross-chain bridge latency

Delayed or censored cross-chain messages prevent timely deposit of margin or withdrawal of collateral, trapping positions

Medium

Monitor IBC channel health and Noble chain relay latency; set operational alerts on bridge transaction delays

Incorrect margin calculation implementation

A client or exchange integration miscomputes initial or maintenance margin, exposing the user or the protocol to unintended risk

High

Verify margin calculation logic against the canonical protocol specification; Chainscore can review integration implementations for correctness

MARGIN FRAMEWORK READINESS

Operator and Integrator Checklist

A practical checklist for risk teams, exchange operators, and institutional integrators to validate their systems against the dYdX Margin and Collateralization Framework. Each item identifies a critical control point, explains its operational significance, and specifies the signal that confirms correct implementation.

What to check: Confirm that your internal risk models and any dependent trading systems are using the exact same oracle price feeds, update frequencies, and staleness tolerances defined in the Oracle Interface and Price Feed Standard.

Why it matters: A mismatch in the price source or a failure to handle a stale price can cause your system to misjudge account health. This can lead to premature liquidations of your own positions or a failure to liquidate underwater accounts, resulting in losses.

Readiness signal: Your system's calculated account equity and margin usage for a test account match the protocol's on-chain state query exactly, within a tolerance of 0.01%, during both normal and oracle update boundary conditions.

Chains We Build On

Looking to build on a specific blockchain?

We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.

EVM ecosystems

  • Ethereum logo
    Ethereum
  • Arbitrum logo
    Arbitrum
  • Optimism logo
    Optimism
  • Polygon logo
    Polygon
  • Avalanche logo
    Avalanche
  • Cronos logo
    Cronos

Non-EVM ecosystems

  • Solana logo
    Solana
  • Sui logo
    Sui
  • Aptos logo
    Aptos
  • Hedera logo
    Hedera
  • Stellar logo
    Stellar
  • NEAR logo
    NEAR

Additional ecosystems

  • Polkadot logo
    Polkadot
  • Cosmos logo
    Cosmos
  • TON logo
    TON
  • Cardano logo
    Cardano
  • Algorand logo
    Algorand
  • Tempo logo
    Tempo

Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.

MARGIN AND COLLATERALIZATION FRAMEWORK

Frequently Asked Questions

Common operational and risk questions from teams integrating with or monitoring the dYdX margin and collateralization system.

The Initial Margin Fraction (IMF) is the minimum collateral required to open a position, expressed as a percentage of the position's notional value. It is calculated using a combination of:

  • Base IMF: A protocol-level parameter set per market by governance.
  • Risk Tier Adjustment: Higher-risk or lower-liquidity markets carry a higher IMF.
  • Position Size Scaling: The IMF increases as the position size grows relative to the market's open interest or liquidity depth, using a piecewise linear function defined in the protocol parameters.

Why it matters: Underestimating IMF can lead to failed order placement. Overestimating it reduces capital efficiency. Trading firms must model the exact IMF curve for each market to size positions correctly.

What to check: Query the x/perpetuals module state for the current initial_margin_fraction parameters and the x/clob module for open interest. Validate your local calculation against the on-chain GetPosition query response.

Trusted by Industry Leaders

Delivering blockchain solutions for 5+ years.

We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.

Selected Partners & Clients

ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
“I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.”
L
Lee Erswell
CEO, Telos Foundation
how to get started

How to get started?

If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.

01

Exploration & Strategy

Define your product goals and choose the right blockchain architecture for your use case.

02

Architecture & Design

Design the smart contracts, tokenomics, and security parameters of your system.

03

Development & Integration

Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.

04

Security & Launch

Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.

Start a build

Need a blockchain engineering team?

Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.