Oracle price data
Last updated
Last updated
Protects price accuracy
Oracles are used widely across web3 for protocols to interpret any sort of data from outside the blockchain. This goes for prices too. Like almost every other protocol wanting to protect itself against price manipulation or flash loans, DegenPrime uses an oracle for a price feed of its assets. Using two different oracles, we are able to calculate the price of an asset using multiple independent sources.
The first oracle used on DegenPrime is the one from . RedStone, supporting protocols such as Lido, Ethena, and Morpho, provides DegenPrime with a price feed for all of its borrowable assets. Assets that are borrowable have the biggest impact on the solvency of , and thus DegenPrime.
A price feed from RedStone is therefore a hard requirement for any asset to be borrowable. This prevents any price manipulation or flash loan attack from impacting loans on DegenPrime, and protects ' precious assets.
The other oracle that is used in DegenPrime is one that takes a more pragmatic approach. Our DEX-oracle looks at multiple on-chain pools, present on DEXs, and determines how much an asset can practically be swapped for. It does not only look at the price of a pool, but also the liquidity within that pool in case an asset needs to be swapped. The result of this is an oracle that is right in the trenches with the Degens, reflecting the prices from the ground.
Our DEX oracle includes two different ways, which it applies to all integrated DEXs and pools, for determining the price of an asset;
TWAP 30, a simulated swap over a period of 30 seconds: This prevents manipulation from flash loans due to looking over multiple price points instead of one potentially manipulated one. From these values, the lowest value is taken to ensure a successful swap can be performed.
Price_from_quote, a direct price at the time of swapping: This price is a single point in time, and takes into account the liquidity on DEXes and the real price a swap would get. From the quotes, the DEX oracle looks at the highest one it receives.
Taking these two values (the lowest TWAP and the highest price_from_quote), the DEX oracle assumes the lowest value. There are two outcomes from this:
If the TWAP has the lowest value, it means the DEX oracle leans on the side of caution. It would assume a slightly lower price for a token than it would receive in practice. This caution ensures that, if an asset needs to be swapped, the result would be positive since a lower price was assumed.
If the TWAP is not the lower value, it would mean the highest price_from_quote from all the pools is lower than the lowest TWAP. This may occur in highly volatile periods where liquidity may be lower. The quotes (i.e. simulated swaps) is the price the assets can be sold for, at that specific point in time. In this case, the DEX oracle is still on the side of caution due to assuming a lower price than the lowest TWAP.
Either option results in a price feed that is more conservative than what is expected. Taking the lower value a slightly worse price than the swap would receive in reality. This safeguards the solvency of every Degen Account and the protocol. Note, that this is solely for the price-feed. Any swap performed in the Degen Account uses the Paraswap aggregator and provides the best possible swap for the user, i.e. best price.
This approach of using two oracles for their specific use-cases provides DegenPrime with the best of both worlds.
RedStone is used for the larger more liquid assets. These include the assets from our Diamond Hands; the backbone of DegenPrime. With the price feed coming from RedStone, this will provide a solid foundation required to facilitate the Degen activity of DegenPrime.
The DEX oracle on the other hand is used for the smaller more volatile assets. For these assets, a price feed coming directly from DEXs, which respond the quickest to any market movement, will provide a most practical price feed needed. It enables DegenPrime to respond to market movements, and their effects on price, just as fast as the DEXs. This leads to DegenPrime adhering to real-time prices of the assets without any delays.
Additionally, the DEX oracle enables us to iterate quickly and get tokens in fast. So if you don't see a token on DegenPrime that you would must have, hop into our and shill us your favorite token. Pinky promise we won't front-run you. That would be degenerate.