> For the complete documentation index, see [llms.txt](https://vanilaprotocol.gitbook.io/vanila/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vanilaprotocol.gitbook.io/vanila/vanila-protocol/examples.md).

# Examples

## **Approach**

We have 4 pools:

* A liquidity pool (L pool) with a pool of DAI and a pool of ETH.

The L pool is the pool used by the exchange to borrow assets for the hedging.

* An exchange pool (E pool) with a pool of DAI and a pool of ETH\
  The E pool is the pool kept by the exchange to remain solvent at any time and this is where the hedges are stored.&#x20;

## **Assumptions**

* The spot price of ETHDAI is equal to 100
* There is no leverage, i.e. all positions are fully funded
* There are no transaction fees
* We consider a yearly futures
* The borrowing rate is determined using the Aave formulas which depend on the utilisation ratio of each pool
* The futures prices are derived using the borrowing rates of each asset.

## **Buy example**

### **Pricing**

The initial pool is as below:

|     | Tot Borrow | Tot Liquidity | Utilisation rate | U\_optimal | Base | Slope 1 | Slope 2 | Borrowing rate |
| --- | ---------- | ------------- | ---------------- | ---------- | ---- | ------- | ------- | -------------- |
| DAI | 2500       | 10000         | 25.00%           | 80%        | 0%   | 4%      | 75%     | 1.25%          |
| ETH | 10         | 1000          | 10.00%           | 65%        | 0%   | 8%      | 100%    | 1.23%          |

A user wants to buy 1 futures, hence the new liquidity pool would be<br>

|     | Tot Borrow | Tot Liquidity | Utilisation rate | U\_optimal | Base | Slope 1 | Slope 2 | Borrowing rate |
| --- | ---------- | ------------- | ---------------- | ---------- | ---- | ------- | ------- | -------------- |
| DAI | 2600       | 10000         | 26.00%           | 80%        | 0%   | 4%      | 75%     | 1.30%          |
| ETH | 10         | 1000          | 10.00%           | 65%        | 0%   | 8%      | 100%    | 1.23%          |

The price to buy 1 futures is P=100\*exp(1\*0.013)=101.31

### **Execution**

* Trader buys 1 ETH at 101.31 DAI on the futures market
* Protocol borrows 100 DAI at 1.3% from the B pool and hence will owe 100\*exp(0.013)=101.31 DAI in 1 year
* Protocol buys 1 ETH with the borrowed DAI and put them in the E pool.

## **Sell example**

### **Pricing**

The initial pool is as below:

|     | Tot Borrow | Tot Liquidity | Utilisation rate | U\_optimal | Base | Slope 1 | Slope 2 | Borrowing rate |
| --- | ---------- | ------------- | ---------------- | ---------- | ---- | ------- | ------- | -------------- |
| DAI | 2500       | 10000         | 25.00%           | 80%        | 0%   | 4%      | 75%     | 1.25%          |
| ETH | 10         | 1000          | 10.00%           | 65%        | 0%   | 8%      | 100%    | 1.23%          |

A user wants to sell 1 futures, hence the new liquidity pool would be<br>

|     | Tot Borrow | Tot Liquidity | Utilisation rate | U\_optimal | Base | Slope 1 | Slope 2 | Borrowing rate |
| --- | ---------- | ------------- | ---------------- | ---------- | ---- | ------- | ------- | -------------- |
| DAI | 2500       | 10000         | 25.00%           | 80%        | 0%   | 4%      | 75%     | 1.25%          |
| ETH | 11         | 1000          | 11.00%           | 65%        | 0%   | 8%      | 100%    | 1.35%          |

The price to sell 1 futures is P=100\*exp(-1\*0.0135)=98.66

### **Execution**

* Trader sells 1 Futures for 98.66 DAI on the futures market
* Protocol borrows 0.9866 ETH from the liquidity pool at 1.35% and hence will owe 0.9866\*exp(1\*0.0135)=1ETH in 3 months
* Protocol sells 0.9866 ETH in the spot market for 98.66 DAI
