> For the complete documentation index, see [llms.txt](https://vendorfinance.gitbook.io/vendor-finance-v2-developer-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vendorfinance.gitbook.io/vendor-finance-v2-developer-documentation/contracts/oracle.md).

# Oracle

## Why do we need an oracle?

Since the mint ratio of the pool is fixed, a situation where pool is lending more value than accepts as collateral is possible.&#x20;

Example: Alice creates a pool with lend ratio of 1000 USDC per 1 WETH when ETH price was 1500$. Imagine that in 2 weeks ETH price drops to 900$. Alice will still lend 1000$ worth of USDC while only taking $900 as collateral. This will result in pool being drained, since once can use borrowed funds to buy more wETH and borrow again until the pool is empty.&#x20;

## Data Sources

We primarily rely on the Chainlink data feeds as they are least likely to be manipulated.

## Data Returned

In order to get the price of the supported token the caller need to use the function called:

```solidity
function getPriceUSD(address _base) public view returns (int256);
```

This function will return the USD price for the `_base` token in 8 decimals. One thing to keep in mind while using this function is that it will return a signed value. That is because if the token price can not be retrieved (if feed is not available, or oracle is stale) then function will return `-1`

## Special Tokens

Not all tokens have a chainlink oracle, in that case we can add custom logic into the function called

```solidity
_specialPriceComputation(address _base) private view returns (int256);
```

For example in case of gOHM we are able to query the index from the gOHM contract and then multiply it by the price of OHM we get from Chainlink. This function should also return `-1` if the price was no computed in this function.

## Non Upgradable

Once the price feed for the token is set, it can not be updated or changed. Special tokens price computations can not be changed either because contracts are also not upgradable. The only way to change the feed is to deploy a new oracle. That will only affect the pools deployed after that point though. This way lenders can rest assured that there is no trust involved for the Vendor team.

## What happens if there is no price for a token?

This could happen if the token does not have a chainlink oracle for example. In that case pool should be deployed with a a very high `maxLTV` value equal to the max value of `uint48`. That would essentially disable the oracle check. In that case if the LTV grows too high, lender will need to pause borrowing manually.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://vendorfinance.gitbook.io/vendor-finance-v2-developer-documentation/contracts/oracle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
