Ok, so I implemented a basic polling mechanism. Some notes, both to test and feedback:
It happens at the _app.tsx level.
If the user is borrowing or managing a position, it refreshes the ERC20 tokens with our sdk.
Otherwise, we only trigger a native token balance update with @web3-onboard.
Updating happens every 15 seconds, but I added a constant we can quickly change.
Since a lot of things can go south, I added a number of checks to the collateral/debt updates. Namely: there can't be any actions going on (if the store variables isExecuting or isSigning are true, we don't do anything) and before updating the values we make an extra check to see if the chains haven't changed.
I took the opportunity to change constants to match the sdk a bit more.
I added a little thing and now, once the user makes a tx, in history store's watch function, as soon as we have a receipt I check if the tx happened on main chain and trigger the same native token balance update -that way, if there was a noticeable gas fee, the user will see it pretty quickly.
Ok, so I implemented a basic polling mechanism. Some notes, both to test and feedback:
_app.tsx
level.ERC20
tokens with oursdk
.@web3-onboard
.constant
we can quickly change.isExecuting
orisSigning
are true, we don't do anything) and before updating the values we make an extra check to see if the chains haven't changed.constants
to match thesdk
a bit more.watch
function, as soon as we have a receipt I check if the tx happened on main chain and trigger the same native token balance update -that way, if there was a noticeable gas fee, the user will see it pretty quickly.