# Oracles and ROI computation

## Price oracles

### cvgOracle

To compute bonds price, Convergence bonds embed a tailored, *generic on-chain oracle* called **`cvgOracle`**. The **`cvgOracle`** can get bonded assets price from multiple AMMs (Uniswap V2\&V3, Sushiswap, Curve...) and is called each time a user buys a bond.

When a bond is deployed, the most liquid pools are targeted by the **`cvgOracle`** (the team will manually set up each bond parameter).

{% content-ref url="oracles-and-roi-computation/targeted-pools" %}
[targeted-pools](https://docs.cvg.finance/bonds-and-treasury/bonds/oracles-and-roi-computation/targeted-pools)
{% endcontent-ref %}

### Chainlink price feeds

Convergence bonds also include an additional security check based on *Chainlink Price Feeds* (**`CPF`**). Each time a user buys a bond, after the **`cvgOracle`** returns a price, this price is compared to the corresponding asset price given by **`CPF`**. The transaction will fail if the price difference between both Oracles exceeds a given percentage.&#x20;

This security check has been implemented to prevent Convergence bonds from being "exploited" by someone manipulating an underlying pool while allowing the bonding mechanism to function properly during volatility periods.

## ROI computation

Once both oracles returned a corresponding price, the discount (**ROI**) that the bond buyer will get is computed with a mechanism that considers the previous buying activity and the expected buying activity.

For each bond, we define the **ROI** as a function of ( ***NtB(t)**, **Ntr(t)*** ) where ***Ntr(t)*** is the amount of token distributed over time, and ***NtB(t)*** is defined as :

$$
NtB(t) =\sqrt{ \dfrac{t}{T} }\*N
$$

Where ***T*** is the duration of the bond, ***N*** is the total amount of token released, and ***t*** is the duration since the bond has been opened.

The ROI is defined as :

<figure><img src="https://3871803507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fisfz381fHt1aLzQ8jnV2%2Fuploads%2FxWvRphhlegRwX4OQY5cb%2F7.PNG?alt=media&#x26;token=3c84741b-bde8-4e2b-bb97-ab004d34d123" alt=""><figcaption></figcaption></figure>

More precisely, the **ROI** increases and tends towards the upper bound **ROI** if, during the *bonding round,* the number of **`CVG`** elapsed (***Ntr(t)***) is lower than the theoretical points (***NtB(t)***). It decreases progressively towards zero when ***Ntr(t)*** is higher than ***NtB(t)***.&#x20;

The figure below gives an insight of the ROI behavior :

<figure><img src="https://3871803507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fisfz381fHt1aLzQ8jnV2%2Fuploads%2FRhkbr8fu7jyHQBtg4CeY%2FCapture10.PNG?alt=media&#x26;token=51891b4d-6dc3-42de-94c2-238e7bb92f17" alt=""><figcaption><p>ROI behavior</p></figcaption></figure>
