Synthetixio / synthetix

Synthetix Solidity smart contracts
https://synthetix.io/
MIT License
1.2k stars 594 forks source link

Hack Idea: Debt Tracker #320

Open kaiynne opened 4 years ago

kaiynne commented 4 years ago

Build a dashboard to track the debt of a wallet over time vs the synth balance over time to see net performance of each wallet.

Qaaj commented 4 years ago

I can pick this up - tagging for later

Qaaj commented 4 years ago

Synth balance over time I have. Calculating Debt would be that person's locked SNX versus Total SNX locked and then see what % of the global debt he owns? I can dive in to the smart contracts later but some pointers would be great :)

jjgonecrypto commented 4 years ago

Well everyone has a Synthetix.debtBalanceOf which is their debt % multiplied by totalIssuedSynths: https://github.com/Synthetixio/synthetix/blob/v2.14.0/contracts/Synthetix.sol#L747-L775

So your % is your issuanceData[account].initialDebtOwnership - this only changes when you issue or burn, however the % claim you have changes with every other issue & burn - so that you have the same amount but a different % as the total size has expanded (via someone's mint) or contracted (via a burn).

However, your debtBalanceOf is totalSynths * (lastDebtEntry / your debt index entry value * your initial Debt ownership), eg:

I hope that makes sense.