solendprotocol / tvl-calculator-example

Pure javascript utility to compute total deposits and borrows from on-chain data.
7 stars 8 forks source link

Example does not calculate accurate TVL's for tokens #3

Open AuthorOfTheSurf opened 3 years ago

AuthorOfTheSurf commented 3 years ago

I am working on fixing an issue within step.finance regarding the accurate display of deposited tokens

We were told that we were displaying the cTOKEN values instead of the actual Token values

I investigated this repo and found that we are basing our implementation off the example code here, and that the example code is also making the same mistake

index_js_—_tvl-calculator-example-solend_and_Solend___Lend_and_borrow_on_Solana

I will continue with finding a fix via cTOKEN vs. Token conversion. If anyone could provide a hint it would be appreciated. I intend to provide the fix to this repo, as well as our solend integration

Edit: My PR #2 can be run and will print out numbers as seen in the attached image

nope-finance commented 3 years ago

the way to do ctoken conversion rate is (availableAmount + borrowedAmount)/cTokenMintSupply

nope-finance commented 3 years ago

ill just approve your prs they seem fine