synthetix-mintr icon indicating copy to clipboard operation
synthetix-mintr copied to clipboard

Add sUSD rate to avoid 1:1 ratio with USD

Open 0xclem opened this issue 5 years ago • 11 comments

0xclem avatar Nov 11 '19 03:11 0xclem

It seems like it is already using the sUSD rate: https://github.com/Synthetixio/synthetix-mintr/blob/staging/src/screens/Dashboard/Dashboard.js#L110 Multiplying the balance with the price.

But snxJSConnector.snxJS.ExchangeRates.ratesForCurrencies (inside fetchData.js) gives back a sUSD rate of 1 even though https://coinmarketcap.com/currencies/susd/ has it at ~0.99

Not sure whats going on there.

0xjocke avatar Nov 17 '19 03:11 0xjocke

Also should the Synths and the Debt really be multiplied with the sUSD price? I think NO but wanted to confirm in case I'm missing something. https://github.com/Synthetixio/synthetix-mintr/blob/staging/src/screens/Dashboard/Dashboard.js#L114

0xjocke avatar Nov 17 '19 03:11 0xjocke

No is right - I believe it’s just an oversight right @clementbalestrat? It should show in sUSD terms

jjgonecrypto avatar Nov 17 '19 22:11 jjgonecrypto

No is right - I believe it’s just an oversight right @clementbalestrat? It should show in sUSD terms

The table column header should probably be sUSD instead of USD then?

0xjocke avatar Nov 17 '19 22:11 0xjocke

Yeah this is a tricky one. @kaiynne wants mintr to display the sUSD market price but the whole system works of $1 peg value to issue and burn. I think it would be misleading to users to show the market price unless the system used it which it does not. @kaiynne what do you want to do here?

hav-noms avatar Nov 17 '19 23:11 hav-noms

I feel like a dashboard is supposed to show you the real value of your assets, so maybe USD should be used here. If not maybe we should think about another way to display this table as sUSD, Synths and Debt row values are just duplicates.

0xclem avatar Nov 18 '19 00:11 0xclem

@bachstatter @hav-noms Kain is happy with USD.

@hav-noms any idea what's the best source to get sUSD/USD rate?

0xclem avatar Nov 20 '19 03:11 0xclem

OK, but considering the best liquidity is via the sETH pool on uniswap, should not that rate be used? Price everything in sETH terms, use the sETH to ETH rate from the pool, and then ETH to USD. It's more complicated, but it's more reliable than the sUSD price IMO.

jjgonecrypto avatar Nov 20 '19 03:11 jjgonecrypto

Good point.

But then Mintr Dashboard will be tied to Eth price fluctuation. Does it make sense to have your balances decreasing by 5% if ETHUSD drops by 5%?

0xclem avatar Nov 20 '19 04:11 0xclem

As explained in person it doesn’t matter because we multiply by the rate then divide by it.

E.g Assuming sETH:ETH is 0.997 when ETHUSD is 100:1, 100 sUSD is 1 sETH = 0.997 ETH = 99.7 USD When ETHUSD doubles, 100 sUSD is 0.5 sETH = 0.4985 ETH = 99.7 USD

Basically we’re going into and out of ETH simply because it’s got the most liquidity

jjgonecrypto avatar Nov 21 '19 08:11 jjgonecrypto

@bachstatter, so here are the steps:

  • balances in sUSD
  • get sUSD/sETH exchange rate from our ExchangeRates smart contract (I can show you how to do to it)
  • get sETH/ETH exchange rate from Uniswap API (https://uniswap-api.loanscan.io/v1/ticker?exchangeAddress=0xe9cf7887b93150d4f2da7dfc6d502b216438f244). invPrice is probably the value to pick.
  • get ETH/USD exchange rate from our ExchangeRates smart contract (the value is already in the code)
  • convert sUSD -> sETH -> ETH -> USD

0xclem avatar Nov 22 '19 04:11 0xclem