Synthetixio / synthetix-mintr

Synthetix's Mintr v2.0: Lock up SNX to mint sUSD, claim weekly SNX and sUSD rewards for staking in the system..
https://mintr.synthetix.io/
75 stars 69 forks source link

DApp handlers for Issue and Burn events #30

Open hav-noms opened 5 years ago

hav-noms commented 5 years ago
0xjocke commented 4 years ago

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

hav-noms commented 4 years ago

@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()); }

0xjocke commented 4 years ago

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?

jjgonecrypto commented 4 years ago

All of them - kovan, rinkeby and ropsten

hav-noms commented 4 years ago

@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.

0xclem commented 4 years ago

@hav-noms any reason you closed this issue?

0xjocke commented 4 years ago

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?

hav-noms commented 4 years ago

@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

0xclem commented 4 years ago

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

0xclem commented 4 years ago

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