subgraphs icon indicating copy to clipboard operation
subgraphs copied to clipboard

Notional-Finance Ethereum: Revenue and TVL calculation issues

Open ishraq8 opened this issue 2 years ago • 10 comments

TVL: TVL is currently being calculated by adding deposits and subtracting withdrawals. This doesn't take into account the interest generated.

@dmelotik suggested using the contract calls that will return real amounts.

Revenue: If the subgraph is only taking interest paid via the net fcash amount bought and sold the docs recommends the following: Revenue from lending and borrowing service. Interests paid by borrowers to lenders. Different from Aave or Compound, Notional operates like a trading platform of zero-interest coupon (buying and selling fCASH), so the interests paid by borrowers to lenders do not accrue per block, but rather happens when each trade takes place. To simplify, we take the difference between the cTOKEN value and fCASH future value as the interest paid. For any given period, the higher of borrowing interests paid (selling fCASH) and lending interest paid (buying fCASH) is the interest revenue for that period. For more details please refer to Appendix: Consideration on Interest Revenue For Notional. To simplify, the formula of Notional's lending and borrowing revenue is:

Revenue = value of fCASH transacted* interest rate annualized * (loan duration in days / 365)

This doesn't take into account the 0.3% exchange fees.

The current subgraph is calculating this as: amountUSD * .3% = revenue with 80% to supply. but this is the total revenue of the exchange and not the lending protocol. The revenue from exchange is 80% protocol and 20% supply. the docs say this is not what is being measured here.

ishraq8 avatar Dec 06 '22 14:12 ishraq8

@fortysevenlabs DMing you on discord

ishraq8 avatar Dec 06 '22 14:12 ishraq8

-Add to document whether account level data is included in TVL. -Add to document how TVL is calculated sum of pool (deposits-withdrawals)

ishraq8 avatar Jan 03 '23 16:01 ishraq8

zero out the total borrow balance.

ishraq8 avatar Jan 03 '23 16:01 ishraq8

Related issue here: https://github.com/messari/subgraphs/issues/1765

bye43 avatar Feb 16 '23 19:02 bye43

@dhruv-chauhan can you take this issue over? You should have a good understanding of where this is at and what the next steps are by reading through the current PR: https://github.com/messari/subgraphs/pull/1725

Feel free to reuse any code in that PR too

melotik avatar Jun 01 '23 22:06 melotik

@dmelotik I picked this back yesterday since arbitrum and across are finished (dev finished, in-qa). I'll go ahead and push out the changes this weekend. May be @dhruv-chauhan can review and thumbs up. Sound good?

fortysevenlabs avatar Jun 02 '23 02:06 fortysevenlabs

sgtm @fortysevenlabs

melotik avatar Jun 02 '23 16:06 melotik

@ishraq8 fix for notional here: https://okgraph.xyz/?q=fortysevenlabs%2Fnotional-finance-ethereum

  • pending version - includes all market pools, use this for full QA
  • current version - used this to test supply side revenue for a single market pool 3-1640736000, use this for single market pool QA

bye43 avatar Jun 05 '23 13:06 bye43

new version syncing failed for this/

ishraq8 avatar Jun 13 '23 13:06 ishraq8

@ishraq8 Use the current version (the pending version synced, current failed pending version is intentional) https://subgraphs.messari.io/subgraph?endpoint=https://api.thegraph.com/subgraphs/id/QmTFvfuzGQRamaCbEVpcMV5kruGTXoV9hn4R4qqMxLKs9L&tab=protocol

fortysevenlabs avatar Jun 13 '23 13:06 fortysevenlabs