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

DApp handlers for Issue and Burn events

Open hav-noms opened this issue 5 years ago • 10 comments

  • sUSD.issue: updates collat state
  • sUSD.burn: updates collat state

hav-noms avatar Oct 25 '19 03:10 hav-noms

I've started looking into this. Is the idea that we calculate new balances based on the event? It seems like the event gets triggered many times, which makes this tricky.

So I guess I'll do something like this? Is that what you had in mind?

snxJSConnector.snxJS.sUSD.contract.on('Issued', () => getBalances());

Also I can seem to mint or burn on Kovan. Minting throws an error when I type in the input box and Burning fails after a while (Metamask is saying No conversion rate available) Any idea why that might be the case?

@clementbalestrat

0xjocke avatar Feb 13 '20 10:02 0xjocke

@bachstatter you can filter on your address. So if the event is yours you can refresh your collat state. as you would have just locked/unlocked your SNX.

contract.on("Issued", (address, amount) => { console.log("address", address); console.log("amount", amount.toString()); }

hav-noms avatar Feb 14 '20 03:02 hav-noms

Yea ok that make sense. I still say it's less error prone to just refetch the new balance, but for the sake of minimising request it might be worth doing it this way.

Do we have any test networks that mintr works on?

0xjocke avatar Feb 14 '20 03:02 0xjocke

All of them - kovan, rinkeby and ropsten

jjgonecrypto avatar Feb 14 '20 03:02 jjgonecrypto

@bachstatter yes I agree. If we wire up all the event handlers at least we can fetch data when the state changes and even be more clever about what data to fetch when what state changes. We don't need to poll for everything.

hav-noms avatar Feb 14 '20 04:02 hav-noms

@hav-noms any reason you closed this issue?

0xclem avatar Feb 19 '20 08:02 0xclem

I thought that was weird too. I've started on it, just been a bit smashed this week.

Just to confirm, the plan is to listen to events then fetch just the data necessary?

0xjocke avatar Feb 19 '20 20:02 0xjocke

@bachstatter @clementbalestrat sorry boys I did not mean to close this.

yeah listen to mint and burn for your address and I think these events are so critical you need to refresh almost everything. Collat state till change synth balances

hav-noms avatar Feb 19 '20 21:02 hav-noms

@hav-noms are you sure mint and burn for your address is enough? any burn/mint will change the system's state right?

0xclem avatar Feb 19 '20 22:02 0xclem

but then we might end up refreshing the data a lot..

0xclem avatar Feb 19 '20 23:02 0xclem