defiscan.live icon indicating copy to clipboard operation
defiscan.live copied to clipboard

Total liquidity/locked value calculation matrix

Open fuxingloh opened this issue 3 years ago • 3 comments

Technical Design

The DFI price resolution on ocean.defichain.com is using a decentralized design, it's not calling any external services. Price is resolved locally via pool pairs. The price resolution matrix is designed before the introduction of pricing oracles.

Current Implementation

Currently, the price of DFI is resolved via USDT & USDC average where 1 USDT/USDC = 1 USD.

However, for all the DUSD pairs, it's resolved by taking 1 DUSD = 1 USD. This is thus very misleading as 1 DUSD != USD and 1 USDT/USDC is also not equal to 1 USD, but it's close to 1 USD.

What can we do?

One option is to change all TVL resolutions to not take DUSD as face value and resolve it via DFI price.

  • Making DUSD price resolved via DUSD-DFI -> DFI-USDC + DFI-USDT pair.
  • Loan Token will be resolved via LOANTOKEN-DUSD -> DUSD-DFI -> DFI-USDC + DFI-USDT pair.

Another option is to take pricing oracle as the source of truth for all pricing resolutions, this is tricky as you will be relying on Pricing Oracle for all PoolPair introduction, which isn't very decentralized.

fuxingloh avatar Dec 14 '21 02:12 fuxingloh

@fuxingloh: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the DeFiCh/oss-governance-bot repository.

defichain-bot avatar Dec 14 '21 02:12 defichain-bot

To help the decision around using the oracles or not, a few prompting questions:

  1. what is the side effect to DeFiChain operation if oracles are down or inaccessible?
  2. Is this a breaking change?
  3. Is the impact to the chain's operation of an oracle being down made any worse with this change?
  4. How necessary is it that this TVL calculation report accurate data? The price oracle is a core requirement of token minting to set reference prices, so if this TVL logic DOESN'T call the same price oracle then there should be some "it's not that important" justification documented around it.
  5. Could one approach over another confuse future maintenance of this logic? E.g. "why does X client show TVL and Y client shows TVL'"

Think it's important to honor role assignment in a complex ecosystem - if price oracles are for prices, then every part of the system should get it's pricing from there.

The oracles themselves can be made more resilient/decentralized if it becomes critical chain infrastructure (maybe it already is?)

rkalla avatar Dec 14 '21 02:12 rkalla

Prior-Art discussion https://github.com/DeFiCh/scan/issues/598#issuecomment-982282164 with a similar topic around Pricing Oracles and DEX.

fuxingloh avatar Dec 14 '21 07:12 fuxingloh