# Equilibrium Docs

This is a documentation portal about the Equilibrium parachain and the technology behind the protocol.

## Equilibrium&#x20;

Equilibrium is a DeFi 2.0 cross-chain money market protocol with high leverage. With Equilibrium users can:

* **Lend:** lend out assets and earn interest fees.&#x20;
* **Borrow:** borrow assets for trading, leveraging, and hedging using portfolios of collateral.
* **Trade:** exchange crypto assets and trade spot markets on margin
* **Insure:** provide liquidity to cover potential borrower losses, and earn a yield on it
* **Earn:** passive income via market maker liquidity pools and liquidity farming incentives

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MKcq7cTUXDFECQu-h5F%2F-MKdF7F3DQP7NTjGuSyR%2Fequilibrium-high-lvl.PNG?alt=media\&token=6d951f9d-18fb-4c4e-af72-2a8df2e01ea7)


# Equilibrium Overview

This is a high level overview of the Equilibrium parachain and the functionality behind it.

## Equilibrium parachain

Equilibrium introduces the first DeFi 2.0 protocol on Polkadot with novel on-chain approach to risk and pricing for asset portfolios. It enables borrowing with minimum collateralization as low as 105% and margin trading with up to 20X leverage.

The innovative design of Equilibrium's bailout mechanism for liquidations that is low friction and does not need auctions allows for the introduction of the first fully on-chain order book based  decentralized exchange with high leverage.

Here is what sets Equilibrium apart from other well-known known DeFi protocols:

* There are no arbitrary governance-set interest rates. They are determined by a borrower’s portfolio, borrower debt, overall system liquidity, and the market's risks and dynamics.<br>
* There are no arbitrarily set LTV requirements. The system makes sure every position remains solvent at a 100% collateralization ratio.<br>
* There are no arbitrarily set liquidation penalties, and no hidden fees when borrowers default on their loan.<br>
* Most loans in popular money markets (AAVE and Compound) are taken in major stablecoins for new investment opportunities. But users need to switch to other applications as there is no trading functionality on the initial platforms. Equilibrium solves this problem efficiently<br>
* The Equilibrium assets module supports:<br>

  1. asset lending.
  2. fractional reserve system and synthetic asset creation.
  3. an exchange that lets users engage in leveraged trading.
  4. portfolio hedging.<br>

  The Assets module logic lets Equilibrium introduce a broad line of DeFi products within one blockchain, practically out of the box.<br>
* The thought-out design of Polkadot’s consensus and finality mechanisms guarantees the security of the Equilibrium substrate on the blockchain level. Approximately 10 collators manage the Equilibrium parachain with a POA consensus and shared GRANDPA finality and blockchain security provided out of the box by Polkadot.<br>
* Equilibrium achieves cross-chain compatibility by way of Polkadot’s integration of third party bridges to different blockchains. Ecosystem-wide interoperability is further achieved with the help of the Polkadot's XCM protocol.&#x20;


# Use Cases

This page gives a detailed overview of services and capabilities that will be available to crypto users within the Equilibrium parachain.

## Liquidity and Deposits

Before any use cases are actually made available to Equilibrium users, there has to be some liquidity  inside the parachain. There are two ways to get liquidity inside Equilibrium:&#x20;

* Users who have EQ tokens allocations may use them as insurance liquidity or collateral. Lending of EQ tokens is prohibited at the moment.&#x20;
* Users who want to be borrowers/lenders/insurers in the Equilibrium ecosystem can bring other crypto assets into our parachain via different Polkadot bridges and the XCM&#x20;

### Bridges

Bridges are secure communication protocols between two different blockchains: Bitcoin, Ethereum, BSC, Cosmos, Solana, and many more are all compatible with Polkadot and Equilibrium. \
\
Equilibrium integrates [ChainBridge ](https://github.com/ChainSafe/ChainBridge)as a means for communicating with the Ethereum and ETH-like blockchains. Thanks to Chainbridge modules, users will be able to deposit assets from Ethereum, BSC, HECO, Polygon networks to Equilibrium, as well as bridge EQ tokens from Equilibrium into all of these blockchain. &#x20;

However, more trusted solution is ultimately needed. Unfortunately there is no native bridge solution in the ecosystem at the moment, so the option Equilibrium has on the table is to integrate with bridges supported by Moonbeam parachain. Moonbeam is an EVM chain which supports EVM to EVM bridging working with several well known bridges: Celer, Synapse, Axelar, Multichain, LayerZero.&#x20;

The typical bridging process may look something very similar to the following:

* A user locks his assets in the smart contract on the source blockchain. He specifies a destination blockchain and address where he wants to receive a wrapped representation of his assets.
* Relayers (third parties who run bridging software in a decentralized fashion) process the corresponding user transaction and reach consensus on minting assets to a user's address in the destination blockchain.&#x20;

Unwrapping and receiving assets on the native blockchain works same way, but in opposite direction.

From the user perspective, it's a matter of sending for example ETH to the designated Ethereum address, then waiting a period of time for inclusion and finality confirmation, given different the specifics of different blockchains. &#x20;

Now that you know how liquidity gets into Equilibrium, let's talk about use cases Equilibrium offers for liquidity holders.&#x20;

## Borrowing

You may borrow assets in Equilibrium in a collateralised fashion. There are no per-asset debt "positions," and Equilibrium treats your assets and liabilities as a complete portfolio. \
\
If the value of your assets exceeds the value of your liabilities, you're safe as a borrower and are not subject to liquidation. Liquidation is a simple balance purge where all of your assets and liabilities are transferred to insurance pool as described in [Margining section](https://docs.equilibrium.io/under-the-hood/margining). \
\
The interest you pay depends on your portfolio risk and the portfolio collateralization levels we talked about in the [Interest Rate Model](/under-the-hood/interest-rate-model) section. Interest is payable in EQ tokens, and when you don't have a sufficient EQ token balance, the system will automatically sell your collateral to pay interest fees, so make sure you always have enough EQ liquidity to avoid unnecessary swaps. &#x20;

## Lending

You may lend assets in Equilibrium and earn interest for doing so. The beauty of lending assets via Equilibrium comes from the fact that lenders transfer the liquidation risk to the insurers. When borrowers default, system transfers their debt to insurers, once insurers cover liquidated debt,  lenders are able to redeem their liquidity back.

The protocol does not guarantee liquidity, instead it relies on the interest rate model to incentivise it. In periods of extreme demand for an asset, the liquidity of the protocol (the tokens available to withdraw or borrow) will decline; when this occur, interest rates rise, incentivising supply, and disincentivizing borrowing.&#x20;

### An example

Consider the following BTC borrow + liquidation example (1 BTC = 20 ETH for simplicity's sake).&#x20;

#### 1. Initial state

We have two bailsmen, two borrowers, and one lender in our simple example. The *Lendable* column shows the total number of tokens in the system available for lending.&#x20;

| Asset | Bailsman1 | Bailsman2 | Borrower1 | Borrower2 | Lendable |
| ----- | :-------: | :-------: | :-------: | :-------: | :------: |
| BTC   |     5     |     0     |     0     |     0     |    10    |
| ETH   |     0     |    100    |    100    |     0     |     0    |

#### 2. Borrower1 **borrows 5 BTC (transfers 5 BTC to Borrower2)** from Lender

| Asset | Bailsman1 | Bailsman2 | Borrower1 | Borrower2 | Lendable |
| ----- | --------- | --------- | --------- | --------- | -------- |
| BTC   | 5         | 0         | **-5**    | **5**     | 10       |
| ETH   | 0         | 100       | 100       | 0         | 0        |

#### 3. Borrower defaults

Since we have set 1 BTC = 20 ETH, bailsmen have equal value of liquidity and thus split Borrower1's debt and collateral evenly:

| Asset | Bailsman1 | Bailsman2 | Borrower1 | Borrower2 | Lendable |
| ----- | :-------: | :-------: | :-------: | :-------: | :------: |
| BTC   |  **2.5**  |  **-2.5** |   **0**   |     5     |    10    |
| ETH   |   **50**  |  **150**  |   **0**   |     0     |     0    |

Notice that following invariant holds inside Equilibrium:&#x20;

$$
Total\ Collateral - Total\ Debt = CONST
$$

Where:&#x20;

* *Total Collateral = Total Borrower Collateral + Total Bailsman Collateral + Total Master Account balance + Total Lendable*
* *Total Debt = Total Borrower Debt + Total Bailsman Debt*

The difference between the above two aggregates is the amount of physical asset brought into the system. When user borrows X amount of an asset from the lending pool the following checks happen:&#x20;

* *X + Total Debt <= Total Lendable*
* *X + Total Debt <= Total Collateral - Total Debt*&#x20;

### Interest rates

The interest that borrowers pay gets redistributed among bailsmen and lenders. The following breakdown applies:&#x20;

| Interest rate component | Value                        |
| ----------------------- | ---------------------------- |
| Base Lender Rate        | 0.5% APR                     |
| Base Insurance Rate     | 1.0% APR                     |
| Base Treasury Rate      | 1.0% APR                     |
| Primary Borrower Rate   | \~ Leverage \* Volatility    |
| Lender share            | 30% of Primary Borrower Rate |
| Bailsman share          | 70% of Primary Borrower Rate |

So the minimum possible interest rate borrowers pay is 2.5% APR, while the biggest contributor to the final interest rate figure is the Primary Borrower Rate which depends on the leverage the borrower undertakes and the risk (volatility) of the borrower portfolio. 30% of the Primary Borrower Rate is funnelled to lenders, while 70% is funnelled to insurers (bailsmen).&#x20;

## Insurance

Bailsmen provide liquidity in advance to cover for borrower liquidations. When borrowers default on their loans, their collateral and debt get distributed among bailsmen on a pro-rata basis. The only way bailsmen are able to get negative balances (liabilities) is through borrower liquidation. Bailsmen receive 5% extra reward in a form of borrower collateral which borrowers pay as a penalty (see [Margining section](https://docs.equilibrium.io/under-the-hood/margining) for details) \
\
Bailsmen are the keepers of the system. They make sure it stays solvent all the time, and receive interest rewards for bearing liquidation risks. 70% of the interest rate that the system collects from borrowers goes to the bailsmen. The other 30% is funnelled to Lenders.&#x20;

## Margin trading

Our interoperable DeFi platform allows for leveraged trades on margin up to 20% (5x leverage).

### Support of different assets

Equilibrium has the capability to go beyond the limits of current Ethereum-based decentralized exchanges. There is opportunity to add tokens from the Polkadot ecosystem (as well as from other blockchains) to the exchange. In doing so, the traded pairs on Equilibrium's DEX will not be limited to ERC-20 tokens (as it would be elsewhere), but can land on any blockchain that can be connected to the Polkadot ecosystem.

### High leverage

Equilibrium’s approach to modeling collateralized loans allows for competitively low levels of collateralization of user portfolios. This means that high leverage is achievable.

### DEX

Building an on-chain decentralized exchange where all orders interact directly with each other on-chain achieves extensive decentralisation, but leads to horrible user experience. All the transactions are expensive and slow, as users pay fees and wait for transactions to mine. Paying for placing, cancelling and modifying an order is plain terrible approach to building DeFi for people and should be avoided at all costs. \
\
Off-chain order books, where market-makers broadcast orders to be filled on-chain, partially solve the problems of the on-chain order books (as outlined above), but have several issues of their own:

* Front-running: MMs, validators/off-chain workers get to see orders before they get mined.
* Trade failures: for example, an order is visible in the order book while pending settlement at the same time (the transaction is being mined).
* Cancellation: Users need to pay transaction fees to cancel an order, updating an order becomes expensive. Furthermore, there's no support for complex order types. &#x20;

Scalability of substrate and Polkadot technology let Equilibrium overcome these issues. There’s no mining involved, and consensus is reached much faster in Polkadot compared to Ethereum, for example.

Furthermore, designated off-chain workers and unsigned transactions can potentially make traders’ lives easier, as they allow for the separation of trade matching and settlement. This would let users place numerous orders without paying transaction fees, allow for trades to be dispatched to blockchain in batches, further improving the scalability and the speed of the DEX.&#x20;

Equilibrium currently runs fully on-chain order book DEX where users pay transaction fees for placing orders, cancelling orders and marking trades. Moving order book off-chain is something that needs to be thoroughly analysed in terms of implications and should involve governance discussion and decision. <br>


# Assets and Balances

This section describes how user assets, or rather portfolios of assets, are organised within Equilibrium.

### Assets in Equilibrium

"Asset" is a generic term describing some cryptocurrency. Assets can be thought of as tokens inside the Polkadot ecosystem, at least to the extent that they also have some supply, as well as logic governing changes to this supply. Users can obtain assets on their account balance in one of the following ways:

* **Deposit:** bring assets like BTC, ETH, and ERC-20 tokens into other blockchains by way of purpose-built bridges.
* **Claim:** claim EQ tokens distributed during the token swap.
* **Receive:** someone transfers assets to user's account.&#x20;
* **Trade:** exchange or swap one asset for another

Equilibrium's assets are fundamentally different from Polkadot’s assets and currency in that we do not define mint / burn / transfer operations for them. An asset module is purely a storage of assets parameters. We have different asset types within the system:

* **Native:** EQ for Equilibrium, GENS for Genshiro - these are our native asset for respective parachains in Polkadot and Kusama.&#x20;
* **Physical:** Any asset that is bridgeable into our parachain. Kusama and Polkadot based assets are available via XCM, other blockchain based assets (BTC, ETH, BNB, e.t.c.) are available via  cross-chain bridges.
* **Synthetic:** We have a native stable coin called EQD (Equilibrium dollar) which is synthetic in a sense that its supply may increase or decrease based on the demand for the stablecoin (mints and burns).&#x20;
* **LP tokens:** Liquidity Pool Tokens from Curve and Yield AMMs.

### User Balances

This sections covers some of the aspects of the Equilibrium design in relation to Borrowers, Insurers and Lenders, as well as briefly covers all of the places inside the protocol where users might have asset balances.&#x20;

#### Borrower and Bailsman sub-accounts

Equilibrium uses the substrate balances module to store and modify user account balances. There are several key features that distinguish Equilibrium balances module from the [standard balances pallet](https://github.com/paritytech/substrate/blob/master/frame/balances/src/lib.rs), which we describe further in this section.&#x20;

First of all, we have a master account in Equilibrium, which acts like a wallet and a starting entry point to our blockchain products (very similar to [Polygon wallet](https://wallet.polygon.technology/wallet)), then each master account may have separate sub-accounts with following types:&#x20;

<table data-header-hidden><thead><tr><th width="189.52367007831202">Sub-account type</th><th>Description</th></tr></thead><tbody><tr><td>Sub-account type</td><td>Description</td></tr><tr><td>Borrower</td><td>Borrower sub-accounts are used for borrowing and trading and may have both positive balances (collateral) and negative balances (debt) </td></tr><tr><td>Bailsman</td><td>Users must meet a minimum liquidity requirement in order to register as a bailsman. Bailsman may have a negative balances (debt or liabilities) in cases when borrowers default. </td></tr></tbody></table>

Each user sub-account may hold different asset portfolios. Borrower and Bailsman sub-accounts may also have liabilities (debt), which are represented with negative balances in that corresponding asset — negative balances represent borrowed assets. Consider the following totally viable example of an account balance configuration in Equilibrium:

| Asset | Positive Balance                  | Negative Balance                     |
| ----- | --------------------------------- | ------------------------------------ |
| BTC   | <p>1.51 BTC <br>($ 20,000.00)</p> | <p>0.00 BTC <br>($ 0.00)</p>         |
| ETH   | <p>0.00 ETH <br>($ 0.00)</p>      | <p>10.00 ETH <br>($ 4,000.00)</p>    |
| USD   | <p>0.00 USD <br>($ 0.00)</p>      | <p>6,500.00 USD <br>($ 6,500.00)</p> |

*The table above shows an account with BTC in assets having USD and ETH borrowed against it. Judging by the balance values, the collateralization is slightly less than 200% here.*&#x20;

Accounts with liabilities are subject to margin requirements, meaning that the total value of their assets should always stay above the total value of their liabilities, otherwise they get liquidated. In theory, Equilibrium's risk and pricing model allows for margin requirement of 0% (collateral value = debt value), but due to block time and price oracle limitations in practice, we risk having untimely market data in the event of abrupt market decline. That's why we limit the critical margin to 5%, allowing 5% wiggle room for possible delays.

No account can hold positive and negative balances in the same asset simultaneously. To see a positive balance in a particular asset, the user must get rid of the negative balance first, and vice versa.

#### Lending pool&#x20;

Unlike Borrower or Bailsman sub-accounts lending in Equilibrium is done in a pooled manner: Liquidity providers stake assets they want to lend into asset-specific pools and earn floating interest rates when borrowers and traders borrow assets.&#x20;

Equilibrium protocol does not guarantee liquidity, instead it relies on the interest rate model to incentivise it. In periods of extreme demand for an asset, the liquidity of the protocol (the tokens available to withdraw or borrow) will decline; when this occur, interest rates rise, incentivising supply, and disincentivizing borrowing. Users may deposit liquidity into lending pools directly from their master accounts. &#x20;

### Example of leverage in Equilibrium

While users generate debt tokens or debt assets directly to their blockchain addresses in traditional DeFi, borrowing in Equilibrium is always a transfer of value to another account. This approach lets us simplify an exchange logic. Consider a leveraged asset buy example:&#x20;

| Classical DeFi approach                                                                                                                                                                                                                                                       | Equilibrium approach                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ol><li> Deposit a collateral asset. </li><li>Flash borrow more of the collateral asset. </li><li>Generate stablecoins against asset collateral. </li><li>Go to a DEX and buy collateral asset with minted stablecoins.</li><li>Return the flash loan from step 2. </li></ol> | <ol><li>Deposit an asset.</li><li>Exchange USD (gain a negative balance in USD) for positive balance in an asset that acts as collateral. </li></ol> |


# Risk model

This page describes Equilibrium's approach on assessing system risk.

Synthetic assets and decentralized stablecoins will continue to be stable in value if borrowers either have excess collateral or if the insurance pool is sufficiently capitalized. Equilibrium stress tests collateral and bailsman pools on-chain, and the incentivizes borrowers or bailsmen  by scaling the [interest rate](/under-the-hood/interest-rate-model), depending on the available liquidity.&#x20;

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MKidYvdxuL9XFPihXzj%2F-MKj2NNqXaSU_ofejmix%2Fimage.png?alt=media\&token=cd7e85a8-b8df-4226-9d71-abbba5c31e3f)

Equilibrium uses a methodology similar to the SEC’s Theoretical Intermarket Margining System (TIMS). The idea is that margin should be set to the maximum loss the portfolio would incur under adverse market scenarios.&#x20;

Equilibrium calculates system losses in the following way:

* Calculate value of the collateral/bailsman/debt pool in normal market conditions.
* Calculate collateral/bailsman/debt pool risk (portfolio volatility).&#x20;
* Calculate discounts (Value at Risk) for each pool given confidence value and pool volatility. &#x20;
* Calculate the value of the collateral/bailsman/debt pool in stressed market conditions.
* Calculate insufficient collateral:  `insufficient_collateral = max[0, debt_value * (1 + debt_discount) - collateral_value *(1 - collateral_discount)]`
* Calculate stressed funds: `stressed_funds = stressed_insurance_pool_value - insufficient_collateral`
* Calculate Solvency: `solvency = insurance_pool_value / (insurance_pool_value + stressed_funds)`
* Calculate Scale: `scale = max[min[1/solvency; 2]; 0.5]`
* If there is more insufficient collateral than there is stressed bailsman liquidity, the scale is > 1 and the borrowers' interest rates scale higher. If there is excess bailsman liquidity, the scale is < 1 and borrower interest rates scale lower. This market mechanic strives to achieve equilibrium in system solvency.&#x20;

Insufficient collateral, however, can be a deceptive measure. Consider the following hypothetical system configuration:

| User      | Collateral | Debt     | LTV      |
| --------- | ---------- | -------- | -------- |
| Borrower1 | $ 500,000  | $1       | 5000000% |
| Borrower2 | $ 500,000  | $400,000 | 125%     |

It makes no sense to include Borrower1's collateral and debt into aggregate values when calculating system risk, as this position is virtually risk-free and would lead to improper calculation of insufficient collateral. Equilibrium sets a cap on portfolio LTV, beyond which the portfolio is considered to be riskless.\
\
So far we've covered risks related to expected and unexpected losses, but we haven't touched on the risks related to excess losses going beyond the stress levels we've set (the right tail in the chart above). In other words, what do we do when the bailsmen themselves get liquidated? Equilibrium uses treasury pool as a third line of defence, where EQ funds that accumulate from interest fees in the treasury are used to cover bailsmen losses.     &#x20;


# Interest rates model

This page describes how Equilibrium calculates interest rates on the loans in the system.

## Pricing&#x20;

The problem of pricing a collateralised loan comes from the realms of traditional finance and stock loans. Associated research on this was pioneered by [Xia and Zhou (2007)](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1467-9965.2006.00305.x). Under the Black–Scholes model, they derived a closed-form pricing formula for the infinite-maturity stock loan by solving the related optimal stopping problem. \
\
Equilibrium adapts the approach proposed by Xia and Zhou, and comes up with an elegant pricing solution that depends on borrower portfolio risk and the level of portfolio collateralization.&#x20;

$$
Interest\ rate \approx Leverage \* (Portfolio\ volatility \* Scale\  factor)
$$

The interest that borrowers pay gets redistributed across the system components. The following breakdown applies:&#x20;

| Interest rate component | Value                        |
| ----------------------- | ---------------------------- |
| Base Lender Rate        | 0.5% APR                     |
| Base Insurance Rate     | 1.0% APR                     |
| Base Treasury Rate      | 1.0% APR                     |
| Primary Borrower Rate   | \~ Leverage \* Volatility    |
| Lender share            | 30% of Primary Borrower Rate |
| Bailsman share          | 70% of Primary Borrower Rate |

So the minimum possible interest rate borrowers pay is 2.5% APR, while the biggest contributor to the final interest rate figure is the Primary Borrower Rate which depends on the leverage the borrower undertakes and the risk (volatility) of the borrower portfolio. 30% of the Primary Borrower Rate is funnelled to lenders, while 70% is funnelled to insurers (bailsmen).&#x20;

The base treasury rate is split among treasury and collators in a 50 / 50 proportion, so collators earn a 0.5% APR on top of their trx. fees rewards. \
\
Assuming the default values for risk parameters, here's the approximate interest rate breakdown (how much borrowers pay to bailsmen and lenders respectively) for a borrower portfolio, given its leverage and volatility.&#x20;

<figure><img src="https://399939398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MK_3P6RnPHvv_Gsa_wJ%2Fuploads%2FLLFUYq5TH7Kl1iNN7b8Q%2Fimage.png?alt=media&amp;token=18ff40eb-561b-421a-9be6-b4ea8a2f3141" alt=""><figcaption><p>How much borrower pays to bailsmen and lenders given the leverage and portfolio risk (volatility)</p></figcaption></figure>

Further improvements to the pricing model may include adapting the jump diffusion process to model the collateral risk, as well as adapting the model to account for margin calls and LTV requirements. This is subject of our ongoing R\&D work.&#x20;

&#x20;<br>


# Margining

This section explains how equilibrium calculates margin for user accounts when they borrow and trade on the DEX

## Margining

In Equilibrium both borrower and bailsman sub-accounts may hold multiple assets and liabilities (debts) and thus are subject to collateralization requirements (margin levels). At any point in time user account's *current margin* is calculated the following way:

$$current\_margin = \frac{total\_collateral\_value \ -\ total\_debt\_value}{total\_collateral\_value}$$, expressed in %

These levels apply both to borrower and bailsman sub-accounts, and work both for money market and the DEX. When trading on the DEX, active user orders in the order book also affect margin requirements as explained in detail here.

<table><thead><tr><th width="210.44420267329815">Margin</th><th width="150">Value%</th><th>Description</th></tr></thead><tbody><tr><td>Initial margin</td><td>20%</td><td>If current margin &#x3C; initial margin, users may not borrow more</td></tr><tr><td>Maintenance margin</td><td>10%</td><td>If current margin falls below maintenance margin, a user has 24 hours to top up their accounts' current margin to initial margin level or higher. Otherwise user will default and his portfolio will be liquidated.</td></tr><tr><td>Critical margin</td><td>5%</td><td>If current margin falls below critical margin level, system liquidates user's portfolio and distributes his assets and debts to the bailsman pool. There is an implicit penalty of 5% for liquidation.</td></tr></tbody></table>

### DEX order margining

Both limit and market orders are subject to margin requirements when trading on Equilibrium DEX. When users place orders system checks their account margin and compare it to the initial margin level from the table above. Users can’t place orders which bring their account margin below the initial margin requirement.&#x20;

The margining system can handle different scenarios where users sell an asset they own (no margin required vs. short selling) or buy an asset with EQD stable coins they physically possess (no margin required vs leveraged long).&#x20;

## Portfolios

One of the most important features that distinguishes Equilibrium from traditional money markets and classical stablecoin protocols like is the fact that instead of using single collateral positions, Genshiro allows users to work with portfolios. There are obvious benefits to such approach:&#x20;

* A well diversified portfolio of assets may reduce risks associated with user's portfolio and lead to reduction in interest fees.&#x20;
* Diversification in turn allows to significantly reduce margin requirements and allow for competitive leverage which is much higher than theoretical limit of 2x (given typical 150%+ collateralization requirements).&#x20;
* Flexibility and the absence of the need to keep multiple "collateralised debt positions" in different assets.&#x20;

### Collateral discounts

Even though Equilibrium’s unique approach allows to diversify this risk away by using collateral portfolios, we can never be sure that there won’t be any malicious actors who will use the system to opt out of their token allocations even with a penalty - a good alternative to selling tokens on a thin market.

A good initial measure which mitigates risk outlined above is a system of discounts for collateral tokens which addresses the nature and relative magnitude of risks each asset bears. Generally speaking, price predictability and lower associated risks result in lower discounts (higher coefficients when calculating collateral value), as bailsmen have a high degree of certainty that the full amount of the loan can be covered if the collateral must be liquidated.&#x20;

{% hint style="warning" %}
Discounts affect portfolio margin! Be careful when buying assets with high discount on the DEX, as buying it with borrowed funds will decrease you portfolio margin.&#x20;
{% endhint %}

The following table shows discounts Equilibrium will set initially on some of the supported assets.

<table><thead><tr><th width="162">Asset type</th><th width="103">Asset</th><th width="99">Discount</th></tr></thead><tbody><tr><td>Stablecoin</td><td>EQD</td><td>1</td></tr><tr><td></td><td>USDT</td><td>1</td></tr><tr><td></td><td>USDC</td><td>1</td></tr><tr><td></td><td>FRAX</td><td>1</td></tr><tr><td></td><td>LP Curve</td><td>1</td></tr><tr><td>Native</td><td>BTC</td><td>0.95</td></tr><tr><td></td><td>ETH</td><td>0.95</td></tr><tr><td></td><td>DOT</td><td>0.9</td></tr><tr><td></td><td>BNB</td><td>0.9</td></tr><tr><td>Speculative</td><td>GLMR</td><td>0.5</td></tr><tr><td></td><td>ACA</td><td>0.5</td></tr><tr><td></td><td>ASTR</td><td>0.5</td></tr><tr><td></td><td>INTR</td><td>0.5</td></tr><tr><td></td><td>EQ</td><td>0.5</td></tr></tbody></table>


# Market maker pools

An overview of the liquidity staking for market makers

## Overview

Liquidity is a core component of any successful exchange. To promote liquidity network effects and incentivise professional liquidity providers, Equilibrium launches market maker pool where users may stake EQD stablecoin (and potentially others, including LP tokens from Curve stablecoin pools) and earn rewards for doing so. Governance-approved market makers may then use this liquidity to make markets on the Equilibrium DEX.&#x20;

### **Why do we need MM pools?** <a href="#id-2408" id="id-2408"></a>

Liquidity is a crucial part of any exchange that attracts active traders. Though, its depth and tiny spreads provided by market makers to an order book require quite a bit of inventory. We are solving this chicken or egg problem by incentivising liquidity providers who got used to having DeFi-like incomes to put their funds into dedicated  market maker pools.

### **How will liquidity providers benefit?** <a href="#b86b" id="b86b"></a>

Similarly to regular DeFi protocols, liquidity providers don’t need to take any actions and will receive a passive income on their stakes in Equilibrium MM pools.&#x20;

Here is how this income will be generated:

* Our liquidity farming program offers staking rewards in our native tokens.&#x20;
* Market makers will be sharing up to 50% of their trading profits with the pools eventually.&#x20;

### **Mechanics for market makers**

The flow for market makers will be as follows:

* Market makers will be subject to a revolving credit agreement with liquidity (margin) providers.
* Market maker accounts can borrow EQD and other stablecoins from MM pools.
* Market makers place orders to the order book and make markets in different assets with EQD as the quote currency.
* Market makers borrow base assets (e.g. BTC) directly from lending pools when their sell orders get filled.&#x20;
* If withdrawals from the pool are higher in magnitude than what’s left un-borrowed from the pool, market makers are required to repay assets back to the pool at the end of the **next epoch.**&#x20;
* Failure to return funds results in **default** and possible liability (debt in EQD stablecoins) on the MM account in the amount of the shortfall. Defaulted market makers are restricted from further borrowing from any of the pools until the liability is covered in full.

We expect MM pool to become a robust instrument to facilitate user activity on our order book DEX. We are planning to run liquidity bootstrapping events to raise initial funding for the pool. These events will offer additional bonuses for their participants on top of regular staking rewards.&#x20;

### **Market maker incentives** <a href="#id-08c4" id="id-08c4"></a>

Designated market makers will be acting in favour of liquidity providers by borrowing liquidity from MM pools and placing orders to the order book. These entities will be reputable and known trading companies with an extensive track record. Their access to liquidity will be free of charge and we will be even rewarding them for active trading with our native tokens.

Market makers are eligible for volume rewards if they generate over 5% of trading volume on the exchange and comply with the following parameters of order book maintenance:

* spread is less than 2%,
* more than 20 orders booked on each side,
* more than 5,000 EQD booked at 5% spread,
* more than 20,000 EQD booked at 10% spread,
* more than 50,000 EQD booked at 20% spread.

Volume rewards will be distributed in native tokens proportionally to overall market volume for all market makers across the platform

### **Staking and unstaking in MM pool** <a href="#id-3ac2" id="id-3ac2"></a>

The following operations are available for stakers:

* Deposit EQD into the corresponding pool.
* Request withdrawal of EQD from the corresponding pool.
* Withdraw EQD requested for withdrawal at the end of the next epoch.

Accounting will be done once per epoch (1 Equilibrium epoch = 28 days). Liquidity providers can submit a withdrawal request at any time within the current epoch. They will receive funds at the end of the next epoch. Funds requested for withdrawal do not earn rewards. The following example clarifies this mechanic:

<figure><img src="https://399939398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MK_3P6RnPHvv_Gsa_wJ%2Fuploads%2FLhl4uAObRLvIcEKBq7DN%2Fimage.png?alt=media&amp;token=ea549ded-061e-4081-a972-ec97f744bf83" alt=""><figcaption><p>MM pool unstaking mechanics</p></figcaption></figure>

### Staking risks <a href="#f895" id="f895"></a>

Market makers borrowing stablecoins from the liquidity staking pool cannot move borrowed funds outside of the protocol. But still, staked assets could be lost if a market maker were to lose funds due to unprofitable trading and be unable to replenish its borrowed allocations.

In this case, staker’s funds may be subject to socialised losses: the number of funds lost will be split among all withdrawing users pro-rata their withdraw amounts.&#x20;

In case of a default, the market maker loses the ability to borrow additional funds from the pool he defaulted on and may be a subject to liability in a form of EQD stablecoin debt to compensate liquidity providers.


# Tokenomics

## EQ Token

Equilibrium will have a native token called EQ. EQ token serves several functions within Equilibrium’s DeFi ecosystem:

**Key features:**

* **Staking opportunities:** EQ holders receive rewards on their tokens staked in governance, lending, and market making pools
* **Bailout and collateral liquidity:** EQ tokens can be locked in bailout pools to secure loans and earn yield or used as collateral to take out loans
* **Platform currency:** Users pay transaction fees for transacting on Equilibrium parachain and product fees in EQ
* **Governance:** token EQ holders have a say  in system changes

### **Fees**

#### **Transaction Fees**

Resources in a blockchain network are limited. That includes for storage and computation. Transaction fees prevent individual users from consuming too many resources. Equilibrium uses Polkadot’s weight-based fee model.&#x20;

Fees on the Equilibrium Substrate chain are calculated based on three parameters:

* A per-byte fee (also known as the "length fee")
* A weight fee
* A tip (optional)

The length fee is the product of a constant per-byte fee and the size of the transaction in bytes.

Weights are a fixed number designed to manage the time it takes to validate a block. Each transaction has a base weight that accounts for the overhead of inclusion (e.g. signature verification) as well as a dispatch weight that accounts for the time to execute the transaction. The total weight is multiplied by a per-weight fee to calculate the transaction's weight fee.

Tips are an optional transaction fee that users can add to give a transaction higher priority.

Together, these three fees constitute the inclusion fee. This fee is deducted from the sender's account prior to transaction execution. A portion of the fee will go to the block producer and the remainder will go to the Treasury. At Equilibrium's genesis, this will be set to 80% and 20%, respectively.

#### DEX Fees

Equilibrium DEX will charge trading fees. We are looking at fees presumably starting  in the 0.03% - 0.06% range and then falling based on trade volume, so there will be a commission tier tied to average trading volumes per a specified period of time. The DEX is currently in the making, so actual numbers will be available after we perform some extensive unit and stress testing.\
\
The biggest challenge here is to figure out how to avoid transaction costs when placing an order, while at the same time discouraging network spamming by multiple orders. Equilibrium is developing a blended solution of unsigned transaction validation mechanisms and hard-set limits on tradable quantities of instruments.&#x20;

#### Interest Fees

Interest fees within Equilibrium are determined within the [**risk** ](/under-the-hood/risk-modeling)and [**interest rate**](/under-the-hood/interest-rate-model) modules and are based on each individual borrower’s portfolio of assets and the amount of debt/ liabilities this portfolio bears.

In short: the risk model increases borrower rates when bailsmen liquidity compared to collateral liquidity deteriorates and/ or entire system collateral becomes riskier, and vice versa: The risk model decreases borrower rates when liquidity from bailsmen picks up and/ or the entire system collateral becomes less risky.&#x20;

### Governance

The governance for Equilibrium will be driven by an on-chain process and will make use of the [Democracy ](https://docs.rs/pallet-democracy/2.0.0/pallet_democracy/)and [Council](https://docs.rs/pallet-collective/2.0.0/pallet_collective/) pallets similar to how Kusama and the Polkadot chains are governed. The overall intent of these modules is to allow the majority of tokens on the network to determine the outcomes of key decisions around the network. These decisions come in the form of stake-weighted voting on proposed referenda and get enacted by an autonomous enactment system that ensures that user’s decisions are binding.&#x20;

Some of the main components of this governance model include:

* **Council** — A group of elected individuals who have special voting rights within the system. Council members are expected to propose referenda for voting and have an ability to veto publicly-sourced referenda. There are rolling elections for council members where EQ token holders will vote on new or existing council members.<br>
* **Referendum** — A proposal for a change to the Equilibrium system including values for key parameters, code upgrades, or changes to the governance system itself.<br>
* **Voting** — Referenda will be voted on by EQ token holders on a stake-weighted basis. Referenda which pass are subject to delayed enactment such that people that disagree with the direction of the decision have time to exit the network.

#### Governance Decentralisation Roadmap

1. Initially, while developing, testing and finalising our core logic, Equilibrium will run on PoA consensus with a centralised sudo approach used for applying changes to the network.<br>
2. After Equilibrium onboards as a parachain and delivers its line of products, we will introduce a governing council which will make Equilibrium-related decisions and changes to be visible on-chain. Changes to the protocol will still be managed via a SUDO. Council members will be elected from nominees on a basis, similar to what Polkadot does but with Equilibrium-specific parameters. <br>
3. At final stage, when system proves to be stable, we will enable recurring council elections, public and council proposed referenda, tallying, adaptive quorum biasing. We will publish the detailed list of system parameters the governance will be able to monitor and change.


# Governance resources

Equilibrium plans to introduce governance according to the roadmap outlined in the [tokenomics ](/governance/tokenomics#governance-decentralisation-roadmap)section


# Collator resources

### Hardware requirements

* **CPU**
  * x86-64 compatible;
  * Intel Ice Lake, or newer (Xeon or Core series); AMD Zen3, or newer (EPYC or Ryzen);
  * 4 physical cores @ 3.4GHz;
  * Simultaneous multithreading disabled (Hyper-Threading on Intel, SMT on AMD);
  * Prefer single-threaded performance over higher cores count. A comparison of single-threaded performance can be found [here](https://www.cpubenchmark.net/singleThread.html).
* **Storage**
  * An NVMe SSD of 1 TB (As it should be reasonably sized to deal with blockchain growth). An estimation of current chain snapshot sizes can be found [here](https://paranodes.io/DBSize). In general, the latency is more important than the throughput.
* **Memory**
  * 16GB DDR4 ECC.
* **System**
  * Linux Kernel 5.16 or newer.
* **Network**
  * The minimum symmetric networking speed is set to 500 Mbit/s (= 62.5 MB/s). This is required to support a large number of parachains and allow for proper congestion control in busy network situations.

The specs posted above are not a *hard* requirement to run a validator, but are considered best practice. Running a validator is a responsible task; using professional hardware is a must in any way.

### How to deploy parachain node

You need to pull the docker image of our node from the docker hub. By default for security reasons exposed only port 30333 for peering.

For equilibrium parachain testnet docker-compose.yml example:

```
version: '3'
services:
  parachain-collator:
    image: equilab/eq-node-testnet:latest
    container_name: parachain-collator
    command:
      - --execution=wasm
      - --wasm-execution=compiled
      - --prometheus-external
      - --rpc-methods=Unsafe
      - --offchain-worker=Always
      - --collator
      - --no-private-ipv4
      - --chain=/etc/eq-paraspec.json
      - -d=/data/parachain
      - --
      - --execution=wasm
      - --keep-blocks=10000
      - --sync=Fast
      - -d=/data/relaychain
      - --chain=/etc/polkadot-local-raw.json
    ports:
      - "30333:30333"
    volumes:
      - './data:/data'z// Some code
```

For equilibrium parachain mainnet docker-compose.yml example:

```
version: '3'
services:
  parachain-collator:
    image: equilab/eq-para:latest
    container_name parachain-collator
    command:
      - --execution=wasm
      - --wasm-execution=compiled
      - --prometheus-external
      - --rpc-methods=Unsafe
      - --offchain-worker=Always
      - --collator
      - --no-private-ipv4
      - --
      - --chain=polkadot
      - --execution=wasm
      - --keep-blocks=10000
      - --sync=Fast
    ports:
      - "30333:30333"
    volumes:
      - './data:/data'
```

Store this content into the file docker-compose.yml in your home directory and run `sudo docker-compose up -d`&#x20;

Wait until your node is synced.

For the next step, you need polkadot extension for your browser <https://polkadot.js.org/extension/>

For mainnet please select URL from the list on the left pane, for testnet please open Development -> custom endpoint on the left pane and set as: wss\://testnet.equilibrium.io/eq/collator/api/wss

Create an account and ask the account replenishment from the equilibrium team

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MK_3P6RnPHvv_Gsa_wJ%2Fuploads%2F2S457Glk9I7tY0AP8ted%2Fimage.png?alt=media\&token=9856b20d-b276-40ab-8fd1-fbf6a794741a)

Store your mnemonic seed and account id for further steps.

Create your collator keys for equilibrium parachain by command `docker exec parachain-collator getkeys` Your output will be like something:

```
{
  "aura": "0xd0f8adc669e563562958f6d50859cd72c4e900f67b2dbdcf8c29bde67f0a6148",
  "eqRate": "0x6055f6b23ba8479e8ab45771a0210f90ec51adfe5fbaabad97b5e9b5ab4269ad"
}
```

Return to the polkadot,js app, move to the Developer -> Extrinsics and select Session -> setKeys. Insert your keys from JSON result. In the proof field set 0x00 as in the picture below:

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MK_3P6RnPHvv_Gsa_wJ%2Fuploads%2F2FxOxkaB0vHqqcOr9bCe%2Fimage.png?alt=media\&token=3bf54d3c-8b5b-44a8-96df-c7d377c7476b)

Sign the request with your account key and provide Equilibrium your the relevant Validator account


# How to use Oracle

## Pre-requirements

1. [Subkey tool](https://www.substrate.io/kb/integrate/subkey) to create substrate account&#x20;
2. [Polkadot.js](https://polkadot.js.org/) "apps wallet" to connect to nodes

## How to become an oracle

1. If you don't have substrate account yet you can generate it using subkey tool.&#x20;
   1. Use this command: `subkey generate --scheme Sr25519` to generate account with Sr25519 scheme.
   2. Successful result will look like on a picture, but with different values.

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPWzIsyMaw22AJxEiX%2FSnipaste_2021-04-15_18-19-33.png?alt=media\&token=d6407a25-1ecb-471e-968e-fa608742b8d7)

2\.  Insert account key in keystore via polkadot.js

1. Use `Developer`  and `RPC calls`. Endpoint `author` and `insertKey`.
2. `KeyType` is “orac“, `suri` is secret phrase from substrate account and `publicKey` is public key from substrate account.
3. Appearance of the request with the result of execution can be seen on a picture
4. To check that execution was successful you can call `hasKey`, providing your account public key and `keyType` = "orac"

![Point 2.3. Successfully inserted key](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MZD5UX8Y6I2oHOu84jv%2F-MZD70X5i2GwYpL5Ek0D%2FSnipaste_2021-04-26_15-20-36.png?alt=media\&token=d514c0aa-f0d7-4a58-81cd-48d120e09cb9)

![Point 2.4. Check that key was successfully added](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPdIrOCbxLq0ZOOud_%2FSnipaste_2021-04-16_15-20-52.png?alt=media\&token=87e273fc-a850-41c3-b423-cb801fb3bfde)

3\. Add account to white list in polkadot.js

1. Ask Equilibrium team to add your account to whitelist.
2. To check that execution was successful you can call `Developer` and `Chain state`, query `whitelists` and `whiteList`, providing substrate account id or SS58 Address.

![Point 3.2. Check that account was whitelisted successfully](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPfqFEozChogwOJHL1%2FSnipaste_2021-04-16_12-22-00.png?alt=media\&token=3ec91023-f975-4980-be87-9b9390480b96)

4\. Choose resource type and add resource type to off-chain local storage.

1. Available resource types are:
   * “cryptocompare“ in hex representation (0x63727970746f636f6d70617265) for cryptocompare with api key as source.
   * “custom“ in hex representation (0x637573746f6d) for custom source.
2. To add resource type to off-chain local storage use `Developer`  and `RPC calls`. Endpoint `offchain` and `localStorageSet`. Kind is `PERSISTENT`, key is `“oracle::resource_type“` in hex representation

   (0x6f7261636c653a3a7265736f757263655f74797065). Value is your choosed resource type.
3. To check that execution was successful you can call endpoint `offchain` and `localStorageGet`. Kind is `PERSISTENT`, key is `“oracle::resource_type“`  in hex representation

   (0x6f7261636c653a3a7265736f757263655f74797065). The result is your choosed resource type.

![Point 4.2. Successfully added "custom" resource type.](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPllJ4MdhP0PX23Q2-%2FSnipaste_2021-04-16_12-52-38.png?alt=media\&token=b0be1eec-dd53-42ba-be9e-c95a639ec98a)

![Point 4.2. Sucessfully added "cryptocompare" resource type.](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPluxhXoNJYroiiEDJ%2FSnipaste_2021-04-16_12-52-59.png?alt=media\&token=ae26c32c-9c96-4a99-9414-d316e9e4e234)

![Point 4.3. Check that resource type was successfully added for "cryptocompare".](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPoNNCtMNjQs-IR_my%2FSnipaste_2021-04-16_16-13-52.png?alt=media\&token=4e541200-0054-4bee-bd9f-83df729cf82a)

## Configure resource

**Important note:** You can add only one resource.

### Cryptocompare

For cryptocompare resource type you will need to add cryptocompare api key to off-chain local storage.&#x20;

1. Use `Developer`  and `RPC calls`. Endpoint `offchain` and `localStorageSet`. Kind is `PERSISTENT`, key is `“oracle::cryptocompare_api_key“` in hex representation (0x6f7261636c653a3a63727970746f636f6d706172655f6170695f6b6579) and value is `cryptocompare_api_key` in hex representation.
2. To check that execution was successful you can call endpoint `offchain` and `localStorageGet`. Kind is `PERSISTENT`, key is `“oracle::cryptocompare_api_key“` in hex representation (0x6f7261636c653a3a63727970746f636f6d706172655f6170695f6b6579). The result is your cryptocompare api key in hex representation.

![Point 1. Add cryptocompare api key](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPtNFuHfc__CtglWVh%2FInkedSnipaste_2021-04-16_13-01-59_LI_Moment.jpg?alt=media\&token=c0328c4e-18e1-407c-b094-f9a1ec10fbf3)

![Point 2. Check that cryptocompare api key was successfully added](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPvTRUs7rAGVgUsieq%2FSnipaste_2021-04-16_16-41-11.png?alt=media\&token=fe33f13b-3123-447a-9d91-ff22e9f05ad1)

### Custom type

For custom type you will need to add query to off-chain local storage, key is `“oracle::custom_query”` in hex representation (0x6f7261636c653a3a637573746f6d5f7175657279). Value&#x20;

1. Use `Developer`  and `RPC calls`. Endpoint `offchain` and `localStorageSet`. Kind is `PERSISTENT`, key is `“oracle::custom_query”` in hex representation (0x6f7261636c653a3a637573746f6d5f7175657279) and value is query in hex representation.
2. To check that execution was successful you can call endpoint `offchain` and `localStorageGet`. Kind is `PERSISTENT`, key is `“oracle::custom_query”` in hex representation (0x6f7261636c653a3a637573746f6d5f7175657279). The result is your cryptocompare api key in hex representation.

Here is examples for different sources:

1. **Hitbtc**
   * query:  `json(https://api.hitbtc.com/api/2/public/ticker/{$}USD).last`
   * value: `0x6a736f6e2868747470733a2f2f6170692e6869746274632e636f6d2f6170692f322f7075626c69632f7469636b65722f7b247d555344292e6c617374`
2. **Binance**
   * query:  `json(https://api.binance.com/api/v3/ticker/price?symbol={$}USDT).price`
   * value:  `0x6a736f6e2868747470733a2f2f6170692e62696e616e63652e636f6d2f6170692f76332f7469636b65722f70726963653f73796d626f6c3d7b247d55534454292e7072696365`
3. **GDAX**
   * query:  `json(https://api.pro.coinbase.com/products/{$}-USD/ticker).price`
   * value:  `0x6a736f6e2868747470733a2f2f6170692e70726f2e636f696e626173652e636f6d2f70726f64756374732f7b247d2d5553442f7469636b6572292e7072696365`
4. **Kraken**
   * &#x20;query: `json(https://api.kraken.com/0/public/Ticker?pair={$}USD).result.{$}USD.c[0]`
   * value:  `0x6a736f6e2868747470733a2f2f6170692e6b72616b656e2e636f6d2f302f7075626c69632f5469636b65723f706169723d7b247d555344292e726573756c742e7b247d5553442e635b305d`
5. **Bitstamp**
   * query:  `json(https://www.bitstamp.net/api/ticker/{$}usd).last`
   * value:  `0x6a736f6e2868747470733a2f2f7777772e6269747374616d702e6e65742f6170692f7469636b65722f7b247d757364292e6c617374`
6. **Bitfinex**
   * query:  `json(https://api-pub.bitfinex.com/v2/ticker/t{$}USD).[6]`
   * value: `0x6a736f6e2868747470733a2f2f6170692d7075622e62697466696e65782e636f6d2f76322f7469636b65722f747b247d555344292e5b365d`
7. **Huobi**
   * query:  `json(https://api.huobi.pro/market/history/trade?symbol={$}usdt&size=1).data[0].data[0].price`
   * value:  `0x6a736f6e2868747470733a2f2f6170692e68756f62692e70726f2f6d61726b65742f686973746f72792f74726164653f73796d626f6c3d7b247d757364742673697a653d31292e646174615b305d2e646174615b305d2e7072696365`

Here is screenshots for Hitbtc source. Similar to any other.

![Point 1. Add query](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYQ0zTTLwjdPvqisk-i%2FSnipaste_2021-04-16_12-54-48.png?alt=media\&token=5a4bc4ff-ac40-4fa2-a000-0bfbd84392be)

![Point 2. Check that query was successfully added](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYQ0q7TxqPIC2sL5Z_u%2FSnipaste_2021-04-16_17-12-02.png?alt=media\&token=f9c2ca13-9b06-4e58-a778-8af539a00cd1)

## Price periodicity

Add price periodicity setting.

1. Use `Developer`  and `RPC calls`. Endpoint `offchain` and `localStorageSet`. Kind is `PERSISTENT`, key is `“oracle::price_periodicity”` in hex representation (0x6f7261636c653a3a70726963655f706572696f646963697479) and value is bloks amount in hex representation. Minimal value is 1. Example for peridoicity = 2 blocks.
2. To check that execution was successful you can call endpoint `offchain` and `localStorageGet`. Kind is `PERSISTENT`, key is `“oracle::price_periodicity”` in hex representation (0x6f7261636c653a3a70726963655f706572696f646963697479). The result is your price periodicity in blocks.

![Point 1. Add price periodicity setting](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPycN9vJ9LF33ftyxz%2FSnipaste_2021-04-16_13-02-46.png?alt=media\&token=2c03aea1-6ba1-47b2-8e6e-718acafc37e8)

![Point 2. Check that price periodicity was successfully set](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MYP8FWn7bJYGesofErF%2F-MYPzfLwY1VTktfwQM6E%2FSnipaste_2021-04-16_17-03-40.png?alt=media\&token=891935a7-2cc4-4e0b-8630-b9eb2498b2d2)

## Check that oracle is working

Use this utility to convert your account ss58 address to polkadot representation. In "Change Address Prefix (Prefix Lookup)" section you can past your ss58 address and "67" as prefix to get your polkadot address.

{% embed url="<https://www.shawntabrizi.com/substrate-js-utilities/>" %}

Here is how it looks like. You can see on a screenshot for point 3.2. in "how to become an oracle" that the same address is displayed there.

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MZHTyrbd7j9XPZMy03J%2F-MZIEJF5yl0C5owCwaN_%2FSnipaste_2021-04-27_15-08-58.png?alt=media\&token=f98726d7-8129-4524-9ab1-102b84eb92d8)

To check that your account is working as an oracle and updating prices you can call `Developer` and `Chain state`, query `oracle`and `pricePoints` for any currency. In `data_points` array there should be instance with your account address.

![](https://399939398-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK_3P6RnPHvv_Gsa_wJ%2F-MZHTyrbd7j9XPZMy03J%2F-MZIEQhfxfZfvV97XF-K%2FSnipaste_2021-04-27_14-56-44.png?alt=media\&token=a9fc26ba-264c-4273-ba09-930c1560a820)


# Security and Audits

## Audits

Audit of Equilibrium's code base is an ongoing process. We designed the system to be safe and secure, and we want to ensure that Equilibrium product matches the highest security standards. We will update the table below to reflect current audit progress.&#x20;

| Date      | Description                                                                | Auditor                               | Report                                                                  |
| --------- | -------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------- |
| Dec. 2020 | Basic Mainnet functioanlity with Balances, Claims and Vesting of EQ tokens | [Quantstamp](https://quantstamp.com/) | [Final report](http://equilibrium.io/docs/equilibrium-report-final.pdf) |


# FAQ

Some of the most frequent questions our users ask are covered here.

**Q**: **I have transferred EQ tokens to Moonbeam but don’t see them in my Metamask wallet. What should I do?**

**A**: You need to add xcEQ to Metamask. Here is a quick guide:

1. Select Moonbeam network
2. Click "import tokens" &#x20;
3. Select "custom token"
4. Paste 0xFFFFFFFF8F6267E040D8A0638C576DFBA4F0F6D6 in "token contract address"&#x20;
5. Click "add custom token"

**Q**: **I have transferred EQ tokens to Ethereum but don’t see them in my Metamask wallet. What should I do?**

**A**: You need to add erc-20 EQ tokens to Metamask. Here is a quick guide:

1. Select Ethereum network
2. Click "import tokens" &#x20;
3. Select "custom token"
4. Paste 0xA5eDE2FEE620ac3d68065EC01F26F9dd99850B82 in "token contract address"&#x20;
5. Click "add custom token"

**Q**: **What is sibling2004?**

**A**: Moonbeam's sovereign address in Equilibrium parachain will show up as "sibling:2004" in explorer when withdrawing EQ to Moonbeam network. This is due to the way addresses are encoded for scalability purposes.<br>

<figure><img src="https://lh5.googleusercontent.com/96Thp4TuQeQhFnmQNnTsmdGiKuCNSs_2ap3WnR48hdS5Op0yVZVzNalQXp_031AR0Q2z7_ZWXJC-mAAo8ux4_VLmWTaNYQ8MwuZCzk1Ms6j3hooIrOrO-qxHs718kK2G7Mz0dGAlVsrdP_TITBM75Fo" alt=""><figcaption></figcaption></figure>

**Q**: **Will I earn APR with only EQ staking?**

**A**: No, staking EQ does not earn EQ rewards directly. Instead it multiplies EQ farming rewards earned in other pools. <br>

**Q**: **Infinite loading screen with cube and "Please wait..."**

**A**: Clear browser cash and add a different Moonbeam node (try <https://rpc.ankr.com/moonbeam>). If this does not solve the issue, try other nodes from [this list](< https://chainlist.org/?search=moonbeam>). Reinstalling Metamask might help as well. If none of the above works, please contact support on Discord [here](https://discord.com/channels/861990169666256916/1034056827815600188) <br>

**Q**: **How to withdraw EQ from Borrow**

**A**: You can withdraw your EQ by submitting a transaction manually using the following guide:

1. Go [here](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fnode.pol.equilibrium.io%2F#/extrinsics)
2. Select your account. You might need to clear cache and reinstall Polkadot.js extension for your account to be detected
3. Select “subaccounts” in “submit the following extrinsic” field
4. Select “Borrower” in subaccType
5. Input 25969 in “asset: u64 (Asset)”
6. Input desired amount in “amount:128 (balance)” and add nine zeros to it (fraction).&#x20;
7. Click “Submit transaction”

Here is an example of what the submit extrinsic page should look like:<br>

<figure><img src="https://lh3.googleusercontent.com/XCeMwGVkUNlZcUIiHspyAhIRcTOqba7e78OQRCbL-NIbla1aaL8Qv8tsMWU6Q2b0n_3bASpW1fZCo658jdDsgeJU4dS5y77pj7mkD792WOmgiGTdgsIkNVU1bUwAYELePMGuvT5EufjMCyciOZDVW0Y" alt=""><figcaption></figcaption></figure>

**Q**: **I participated in a Republic event, where I can claim my tokens?**

**A**: Navigate to Earn - Pools - EQ Staking - My staking or use the direct link: <https://app.equilibrium.io/earn/eq-staking&#x20>;

<figure><img src="https://lh6.googleusercontent.com/hofQD5Pkfv1tlbSLqpy63iIEp-PDgXh394NhMX-FOTF8lDbO_oyK6hFq5NULz0YHRZVlIAltzt6-1nGG38AjECbrvKj545vNwghHZJmIjfol-HXpp_4cfuKy5EpeOoISmrtIk8z0JX1B4boLbK4zDok" alt=""><figcaption></figcaption></figure>

**Q**: **Where can I find my crowdloan rewards?**

**A**: Navigate to More - Allocation or use [direct link](https://app.equilibrium.io/allocation/vesting)<br>

<figure><img src="https://lh6.googleusercontent.com/9fblNmASUl_lD5A4oWUlzORT4TH3EBZf-pTRih-VBrqipKH9SrTispOkb4_XDOrUAs1WRGB6cdPwJqbGTk4JWAdxPZLnibMGSNRBZIaiFbr7xPQoZfnC0vSGowHYwy-rtDPORP_JC2EsJy2pit19JM8" alt=""><figcaption></figcaption></figure>

**Q**: **How long do Moonbeam and ETH withdrawals/deposits take?**

**A**: Please allow up to 15 mins for Moonbeam withdrawals and up to 60 mins for Ethereum transactions to go through.&#x20;

**Q**: **Why does my collateral decrease when I borrow assets against it?**

**A**: This happens if a user doesn't have EQ tokens in the borrower account. Please make sure to always keep EQ in the borrower account to pay interest fees.

**Q**: **How much EQ should I keep in my borrower account?**

**A**: To get an estimate of how much EQ would be taken from account please refer to [Interest rates model section](/under-the-hood/interest-rate-model)

**Q**: **I can not claim EQ from NUT swap in "Allocation". What should I do?**&#x20;

**A**: You need to copy the error message, sign it externally and paste back in using the following guide:

1. Copy message to clipboard
2. Delete "TEST" from the message
3. Go [here](https://app.mycrypto.com/sign-message) and sign the message using this [guide](https://app.tango.us/app/workflow/Manual-TX-signature-c217f711dce54b76bd71e843e6889e52).
4. Paste the signed message<br>

<figure><img src="https://lh4.googleusercontent.com/m_3sl7Rx6KrKk_gNADfetjM4oZzEFnuNJyoaBBn3TUVeclcc0PvfK7SNy9bK3pwS42J2MiDZUj4bx-TKyfVThLVeKaseXQxwtj9ITQK7XJCTpALJBPwin8E9fSl8JAhVu9NPkZvtPYX9MeQSA5DNl8c" alt=""><figcaption></figcaption></figure>

Q: I have withdrawn my assets to an exchange but they haven't arrived. What should I do?\
A: Do not withdraw assets directly to an exchange. Always withdraw to your Polkadot wallet first otherwise you will lose the assets.&#x20;


