Futures 👾
Here is our degen's guide to perpetual and quarterly futures on RiskSwap complemented with some general facts. Enjoy your reading!

# Introduction to Futures

If you're hardly a newbie trader, just skip this section and move on to some more sophisticated things. Or enjoy refreshing your knowledge to be 100% sure that you are a master of futures trading.
A futures contract is an agreement between two parties that commits one party to buy (or sell) an underlying asset and another party to sell (buy) that asset on a specified date and at a pre-determined price in the future. The underlying asset can be whatever – commodities, stocks, or crypto.
For better understanding, let us give you an example of how futures work:

## Margin

Futures initial margin is the amount of money you are required to keep in your account to enter into a futures position (long or short), as a percentage of the full value of the futures contract.
To keep the position open you will need a maintenance margin – some free capital on your account that is used to cover potential losses.
In general:
If your margin > initial margin – everything is fine and you are able to open new positions.
If initial margin > your margin > maintenance margin – you can't open new positions but you're not subject to liquidation.
If maintenance margin > your margin, then your position might be liquidated.
On RiskSwap, there's no initial and maintenance margin, both of them refer to the collateral.
Liquidation means that losing positions are forced-exited to prevent traders from falling into a negative balance. The larger is the leverage, the higher is the risk that the position will be liquidated as a result of a minor price movement, so traders need to be very careful when choosing the leverage.

## Quick summary

Pros
Cons
Traders can use futures to speculate on the direction in the price of an underlying asset.
In case the trader's prognosis is incorrect, the position can be liquidated which results in losses.
Futures allow for hedging the risks of price movements.
At the same time, risk hedging may cause missing out on some potential revenues.
Futures require a deposit of a fraction of the contract amount, not the whole sum.
Futures are associated with leveraged trading which amplifies both potential returns and losses.

# RiskSwap's Futures

The theory part is over, so we can move on to exploring the nature of RiskSwap's futures and be sure that you will understand all the details.
First of all, RiskSwap offers a decentralized way to trade futures contracts meaning that traders have no need to rely on centralized exchanges and trust their funds to a single entity. Instead, funds are stored on user's wallets e.g. Metamask. Thus, RiskSwap assumes the integrity of security and privacy for traders of derivatives similar to DEX whilst embedding a Central Limit Order Book model of trade execution. The immediacy of trade settlement with the Order Book model allows for seamless intermedial trading backed by the AMM pool to ensure sufficient liquidity.
The experience of futures trading on RiskSwap is quite similar to centralized exchanges but for a few minor differentiators. Long story short, here's a quick lifespan of your futures trade:
1.
Connect your wallet to RiskSwap.
2.
Deposit funds to a Margin Account (which is a smart contract). In the blockchain, the funds of all users on margin accounts are placed in a vault, where each transfer is assigned a number to indicate who owns what funds.
3.
Create a futures position by choosing an asset, position size, leverage.
4.
Collateral for this position is temporarily locked on your account (the collateral size depends on the position size and asset volatility).
5.
Each time settlement happens unrealized PnL and funding amounts are either added to or deducted from your margin account.
6.
Close your position which results in settlement of the funds.
7.
Withdraw returns from the Margin Account to your wallet.
Note that if you have an open position and want to withdraw funds to your wallet, you can easily do that, but the collateral will remain locked. In case you suffer losses for this position, there will be no funds on your account to compensate for them, which will result in liquidation.
When a net position is opened or increased on the user's account, the guarantee collateral is blocked – this is the amount that the trader cannot withdraw from his margin account because it secures the position open to him.
Margin is the amount of funds in the user's wallet available for buying or selling assets. The client himself chooses how much to allocate as a margin. In the blockchain, this money is transferred to the storage, i.e. are separated from the funds on the user's wallet.

## Perpetual and quarterly futures

RiskSwap will utilize two types of futures contracts: perpetual and quarterly.
Perpetual Futures differ from traditional futures in that they have no predetermined date of expiry, so they can be kept open as long as you wish.
Quarterly futures do have a predetermined expiry date. Quarterly futures positions, which were not exercised before the expiration will be settled using the expiration prices specified in the contracts. The price of a futures contract is determined by the use of on-chain oracles that supply price data off of the data provider.
A quarterly futures ticker consists of the name of the trading pair and a set of numbers representing the month and the year of expiration, for example, BTCUSD_0921 is a contract with expiration on 09.24.2021 at 03:00 UTC.

## RiskSwap's BTC futures contracts specification: Examples

Parameter
Quarterly Futures
Perpetual futures
Underlying asset
Pyth Network BTC/USD Index
Pyth Network BTC/USD Index
Ticker
BTCUSD_mmyy
BTC‑PERP
BTCUSDC
BTCUSDC
Quantity step
0.0001
0.0001
Max position
100 BTC
100 BTC
Tick size
1 USDC
1 USDC
Futures price (currency)
USDC
USDC
Expiry time
Last working Friday of each quarter, 03:00 UTC
No expiry
Expiration price
TWAP 02:00-03:00 UTC of last trading day
Margin type (currency)
USDC (RISK, DAI, BTC, ETH, SOL to be added in v.2)
USDC (RISK, DAI, BTC, ETH, SOL to be added in v.2)
Margin ratio
10%
10%
Mark price
The price at which the contract is priced during trading. The mark price may differ from the actual bidding price. Mark price = 30 sec. volume-weighted average trading price.
The price at which the contract is priced during trading. The mark price may differ from the actual bidding price. Mark price = 30 sec. volume-weighted average trading price.
Settlement type (currency)
USDC
USDC
Fees
Taker = 0.1%, Maker = 0.05% excluding RISK staking or holding discounts and trading volumes
Taker = 0.1%, Maker = 0.05% excluding RISK staking or holding discounts and trading volumes
Liquidation fee
2.5%
2.5%

## Collateral

The collateral is the amount of funds blocked in the user's margin account when placing an order or increasing the net position. This is insurance that guarantees the fulfilment of their obligations by the trader.
Calculation of the standard collateral for BTC futures:
$Sm=0.1*S*mP$
Sm – Standard collateral S – Position size mP – Mark price
Collateral in absolute terms is a dynamic parameter, as the price can change.

### Dynamic collateral

If the change in the futures price is >25% in 24 hours, then collateral = previous collateral * 1.1. If, after increasing the collateral within 24 hours, the change in the futures price is <25%, then the collateral returns to the previous value. Minimum collateral for BTC futures will be 10%; maximum collateral will be 21%.

## Unrealized PnL

Unrealized PnL is the unrealized amount of the user's profit or loss if closing a position at the current prices.
$uPnL =(mP-pP)*S*(±1)$
uPnL – Unrealized PnL mP – 30-second Mark price pP – position's open price S – Position size. If the position is long, then the equation is multiplied by +1, if short, then by -1.
Example: Alice has 10,000 USDC on her margin account, and Bob has 6,000 USDC on his margin account. The BTC price is 33,520 USDC. At 15:00 Alice sells 1 BTC futures and Bob buys 1 BTC futures. The collateral for a position in both cases is 10%, or 0.1 BTC or 3,350 USDC. Suppose the BTC price rises by 5% to 35,200 USDC by 22:00. Alice's uPnL will be -1680 USDC, and Bob's uPnL will be 1,680 USDC. The total amount of users' funds is equal to the amount of funds on the margin account + uPnL. For example, Alice's funds are: 10,000 USDC - 1,680 USDC = 8,320 USDC. Collateral is still 10% of the price, or 3,520 USDC. uPnL is converted to the total margin amount when the trade is closed.

## Margin ratio & Liquidation

The margin ratio is used to assess the risk of a protocol user's position.
Margin ratio calculation:
$kM = (M+uPnL)/L$
kM – Margin ratio L – Position's collateral uPnL – Unrealized PnL M – User account margin
The following rules are used depending on the value of the margin ratio:
If, after the user has made a trade, his kM >= 1, then there is no risk of opening new positions.
If 1 < kM < 0.7, then the user cannot open new positions, but he is not subject to liquidation either.
If kM < 0.7, a partial liquidation of user positions is possible.
A trader cannot withdraw funds from his account if kM < 1 or if, as a result of his withdrawal, kM falls below 1.
If kM < 0.4, the complete liquidation of the user's positions is possible.
The commission for closing a position paid to the liquidator is 1.5% of the value of the closed position, and another 1% is sent to the insurance fund. On a separate tab of the interface, a list of users is created, ranked from lowest to highest by margin ratio.

### Liquidation terms:

If kM < 0.7, the user's position can be liquidated.
The kM of the liquidator after liquidation must be > 1.
The liquidator takes the liquidated position of the user (or its part) and 1.5% of the value of the liquidated position of the user as a reward.
The liquidator is not obliged to “buy back” the entire position of the liquidated person available for closing, the minimum liquidation is 1 contract.
The user's position can be liquidated until his kM becomes greater than or equal to 0.7, taking into account the penalty charged for liquidation.
Example: Alice has a long futures position worth 0.3 BTC. The BTC price is 33,330 USDC, the collateral for this position is 1,000 USDC. Alice's margin is 2,100 USDC and uPnL is -1,105 USDC. kM equals to (2,100 + (-1,105)) / 1000 = 0.995. Alice's position can not be liquidated, but she cannot open new positions either. The BTC price drops to 31,990 USDC, Alice's uPnL becomes -1507 USDC, collateral equals to 959.7 USDC, and margin remains 2,100 USDC. kM equals to (2,100 + (-1507)) / 959.7 = 0.618. Bob's margin account is 200 USDC. For Alice's kM to be equal to 0.7 or higher, her collateral must be reduced to 783.755, so 0.055 BTC can be liquidated. Bob liquidates 0.055 BTC of Alice's position and gets her uPnL, the amount of funds from Alice's margin equal to uPnL, as well as a fine of 1.5% or 26.4 USDC. 17.59 USDC of Alice's funds is sent to the insurance fund. Bob's position is: long 0.055 BTC, his collateral is 175.95 USDC, uPnL is 276.28 USDC, margin account balance is 520.27 USDC, so kM = 1.39. Bob can close the position or continue holding it.
Alice's position is: long 0.245 BTC, her collateral is 783.76 USDC, uPnL – 1230.72 USDC, margin account balance is 1779.73 USDC and kM = 0.7.
When the position is subject to liquidation, the smart contract checks all the necessary on-chain parameters. Information on the site is displayed off-chain.
The maximum allowable leverage is calculated based on the collateral. If the collateral is 10%, the maximum leverage is x10, because if this value is exceeded, the margin ratio will be insufficient to maintain the position, which may lead to liquidation.

## Cross margin & Isolated margin

When opening a position, the trader chooses whether it will be opened using a cross or isolated margin.
If the user has chosen the cross-margin mode, then all his collateral located in the margin account is used to calculate the margin ratio. If a trader chooses an isolated margin, then the next step is to deposit collateral to a separate account (subaccount) for this position. Technically, the money remains in the same wallet, in the GUI the user sees a separate subaccount where the funds for this position are placed. The smart contract records information that the user has opened a sub-account, the margin ratio for which is calculated separately from other positions.
By default, all positions are opened with cross-margin.
Cross-margin will be implemented in v1 of the protocol. When it is used and the margin ratio is to be calculated, the indicators of all positions are taken into account including their total uPnL and collateral.
Example: Bob deposited 10,000 USDC to his margin account and bought 1 BTC futures at 40,000 USDC and 10 ETH futures at 3,600 USDC. His margin ratio equals to:
$kM = (10,000 + 0)/((0,1*40,000 *1) + (0,1 * 3,750 * 10)) = 1.316$
The BTC price dropped to 37,000 USDC, and the ETH price increased to 3750 USDC, so Bob's margin ratio is:
$kM = ((10,000 + (-3,000 + 1500))/((0,1*40,000 *1) + (0,1 * 3,750 * 10)) = 1.14$
Isolated margin (v2 functionality) is a more specific tool. When using it (it is selected when opening a position and applies only to it), the margin ratio is calculated individually for this position. In the event of a sharp decrease in kM, only the collateral deposited on the subaccount for this position can be liquidated, the same is true for a cross-margin account, kM on it is counted separately, and liquidation will not affect positions on other accounts.

## Multi-asset margining (v2 functionality)

Multi-asset margining allows traders to use different assets as collateral for derivatives trading. While in v1 the user can deposit only USDC as collateral, in v2 it will be possible to use other cryptocurrencies, for example, RISK, BTC, ETH, SOL. In order to use them as collateral, it is necessary to express the price of cryptocurrencies in USDC, for which the Pyth Network Oracle will be used.
Depending on the volatility of the asset, a discount coefficient is assigned to it, by which the value of the cryptocurrency is multiplied to determine the margin that this asset adds. The discount coefficient is set by the project administration for each cryptocurrency separately, and in the future, it can be changed through the DAO's proposals and votes, as well as the list of assets supported as collateral.
Initial discount ratios and list of supported assets:
USDC – 1
USDT – 1
DAI – 0.9 (not yet on Pyth Network)
BTC – 0.8
ETH – 0.7
SOL – 0.5
RISK – 0.5 (not yet on Pyth Network)
FTT – 0.5