Outstanding_loan, intrest_index, reward_index - What do they mean? AnchorCLI

Hey there,

I am working myself through the protocol queries and AnchorCLI. I would ultimately know what my current LTV is based on the outstanding_loan.

a) So far I only got the loan_amount. Where can I get the outstanding_loan for an address?
b) Also it would be perfect to have that accumulated ANC rewards for a given address.

(I have found Intrest_Index and Reward_Index, but dont know how to use them. There is no documentation about it.)

@saad.najafi - can you help here?

Indexing is how all interest protocols get your balance.

Deposit 100 UST at a 1.0002 index you will receive 99.980003999200159968006398720256

The index then appreciates as index + (index * rate / year * time_delta)

Due to blocks being the only every x period, they need to work with that so the yar * time delta is likely not how they get it but its the same concept.

From what i see in their EthAnchor they use this which updates every 6 hours and compounds.

(1000122025379685199-1e18)*(31536000/21600)

this comes to about 17.8% as the APR which converts to about 19-20% APY

You then withdraw at a 1.0015 index and you receive 100.12997400519896020795840831834

This is just an example and didn’t use any actual rates to come up with the indexes but calculations can be done to figure that out.

Also, this is all done through integers which add more complexity to the actual formula but the above is the basics.