Comment on page

# Leverage

Amplifying trading potential and maximizing returns through margin trading

Opening and maintaining a position on Carbon derivatives market allows for the use of leverage. Users can allocate as much margin or as little margin as they wish for each position, up to the margin requirements stated below.

As Carbon currently allows for isolated margin (only), positions on each market is margined separately. Liquidations therefore only affect a single market / position at a time.

There are two types of margin requirements for each market -

`Initial Margin`

and `Maintenance Margin`

. They differ for each market and can be derived from the market parameters in GET Markets. The following describes how to calculate each margin requirement based on the market parameters.Intital margin is the amount of collateral required to open (or increase) a position.

This margin requirement is based on a fraction (

`IMF`

) of the position value:`InitialMargin = IMF * Position Size * Entry Price`

The initial margin fraction (

`IMF`

) is given by:`IMF = initial_margin_base + floor(Position Size / risk_step_size) * initial_margin_step`

For a BTC perp where:

# https://api.carbon.network/carbon/market/v1/markets/cmkt%252F118

risk_step_size = 0.1 # this is in human decimals (i.e. 0.1 BTC). Add &raw=true to the above request for raw values.

initial_margin_base = 0.01 # this is a fraction

initial_margin_step = 0.000005 # this is a fraction

Opening a 10 BTC long position at $30,000 will require:

`(0.01 + floor(10 / 0.1) * 0.000005) * 10 * 30,000 = 3,150 USDC`

This gives an effective leverage of:

`300,000 / 3,150`

= `95.23x`

One can quickly find that

`1 / initial_margin_base`

is the maximium leverage for a market (for position sizes that are smaller than `risk_step_size`

).For the example above, that would be

`1 / 0.01 = 100x`

.Maintenance margin is the amount of collateral required to hold a position open.

If the effective margin (allocated margin + unrealized PnL) of a position drops below the required maintenance margin, the position will be liquidated according to the rules here.

This margin requirement is based on a fraction of the initial margin requirement for a position:

`MaintenanceMargin = InitialMargin * maintenance_margin_ratio`

.For a BTC perp where:

# GET https://api.carbon.network/carbon/market/v1/markets/cmkt%252F118

risk_step_size = 0.1 # this is in human decimals (i.e. 0.1 BTC). Add &raw=true to the above request for raw values.

initial_margin_base = 0.01 # this is a fraction

initial_margin_step = 0.000005 # this is a fraction

maintenance_margin_ratio = 0.7 # this is a fraction

Opening a 10 BTC long position at $30,000 will require:

`(0.01 + floor(10 / 0.1) * 0.000005) * 10 * 30,000 = 3,150 USDC`

Maintaining this position requires that:

`InitialMargin + Unrealized PnL > (3,150 * 0.7 = 2,205 USDC)`

Assuming the user opens this position at maximum leverage (allocated margin = initial margin = 3,150), then the user's position will be liquidated if the market moves against them such that they incurs more than

`3,150 - 2,205 = 945 USDC`

of unrealized losses.This entails the user's position being taken over by the liquidation engine, and the user will lose the full allocated margin for this position. See the Liquidation section for the full liquidation procedure.

For the above example, this will occur when the Mark Price of the market reaches

`(10 * $30,000 - 945) / 10 = $29,905.50`

.Users can protect this position by manually adding more margin or decreasing their leverage for the market, such that their allocated margin increases above the maintenance margin requirements.

Last modified 1mo ago