synthetix icon indicating copy to clipboard operation
synthetix copied to clipboard

Hack Idea: Debt Tracker

Open kaiynne opened this issue 5 years ago • 3 comments

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.

kaiynne avatar Nov 09 '19 00:11 kaiynne

I can pick this up - tagging for later

Qaaj avatar Nov 19 '19 23:11 Qaaj

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 :)

Qaaj avatar Dec 04 '19 08:12 Qaaj

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: - When User1 issues 100, ido = 1, deo = 0 (1) (ido = initial debt ownership, dei = debt entry index (value at that index)) - And User2 issues 25, ido = 0.25, Dei = 1 (1 - 25/100 = 0.75) - Then User1 dbo = 125 * (0.75/1 * 1) = 93.75 (dbo = debt balance of) - And User2 dbo = 125 * (0.75/0.75 * 0.25) = 31.25 - When User2 Issues 50, Ido = (50 + 31.25) / (125 + 50) = 0.464, Dei = 2 (0.75 * (1 - 50/175)) = 0.5357 - Then User1 duo = 175 * (0.5357/1*1) = 93.745 - And User2 dbo = 175 * (0.5356/0.5357 * 0.464) = 81.2

I hope that makes sense.

jjgonecrypto avatar Dec 05 '19 22:12 jjgonecrypto