-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4] feat(balances): update balances for priority tokens #3417
Conversation
… into feat/balances-and-allowances # Conflicts: # apps/cowswap-frontend/tsconfig.json # tsconfig.base.json
…protocol/cowswap into feat/refactor-balances
…ol/cowswap into refactor/remove-uniswap-multicall
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
setLoadingState?: boolean | ||
} | ||
|
||
export function usePersistBalancesAndAllowances(params: PersistBalancesAndAllowancesParams) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is actually just extracted from BalancesAndAllowancesUpdater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense that you refactored this logic so you can use it in the 2 updaters. I wonder if we should even have a sigle updater, and just pass the refresh (so any lib can tell this updater the refresh interval).
If we do that, we might want to extract the native into its own updater, which sounds like a good idea, as its completly separated logic and clients of this lib could use it in isolation.
a645cce
to
e34ce1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! And is enough to get the problem solved!
One small thing though, is that, the selected token and any other tokens in the prioty queue will be queried twice. Also, it's a bit rigid in case we want finer control.
Anyways, no need to address these things, lets not overoptimise. This is already a great improvement. Let's see what are the new bottlenecks and potential improvements instead.
Really good work these 4 PRs. Thanks!!!
@shoom3301 Do you think is possible to trigger eagerly the refresh of a token in some situations? For example:
|
@@ -175,8 +175,14 @@ export function OrderRow({ | |||
|
|||
const showCancellationModal = orderActions.getShowCancellationModal(order) | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alfetopito please, take a look on the fix, I'm not sure if it's correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here - like with hasEnoughAllowance
- is to only set the warning if we know there's no valid permit.
hasValidPendingPermit
can be undefined
, when we don't know/can't tell.
Was that causing any issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that this has been reverted on #3487
… feat/priority-tokens-updater # Conflicts: # apps/cowswap-frontend/src/legacy/hooks/useTokenAllowance.ts # apps/cowswap-frontend/src/modules/ordersTable/pure/OrdersTableContainer/utils/getOrderParams.test.ts # apps/cowswap-frontend/src/modules/ordersTable/pure/OrdersTableContainer/utils/getOrderParams.ts # apps/cowswap-frontend/src/modules/tokensList/pure/TokenListItem/index.tsx # libs/balances-and-allowances/src/hooks/useNativeTokenBalance.ts # libs/balances-and-allowances/src/index.ts # libs/balances-and-allowances/src/state/allowancesAtom.ts # libs/balances-and-allowances/src/state/balancesAtom.ts # libs/balances-and-allowances/src/updaters/BalancesAndAllowancesUpdater.ts
const { data, isLoading } = useSWR(['useCowFromLockedGnoBalances', account, allocated, tokenDistro], async () => { | ||
if (account && tokenDistro && allocated.greaterThan(0)) { | ||
return tokenDistro.balances(account) | ||
} | ||
|
||
return null | ||
}) | ||
|
||
const claimed = useMemo(() => CurrencyAmount.fromRawAmount(_COW, data ? data.claimed.toString() : 0), [data]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been tested?
(Not saying this is wrong, just thinking out loud)
@@ -175,8 +175,14 @@ export function OrderRow({ | |||
|
|||
const showCancellationModal = orderActions.getShowCancellationModal(order) | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that this has been reverted on #3487
libs/multicall/src/multiCall.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shoom3301 is it intentional to have multicall
and multiCall
?
Summary
Fixes: #3430, #3429, #3426, #3423, #3428
Since the regular balances+allowances updating polling happens only every ~30 seconds, it might be annoying if you order was just filled and you don't see balances updater. Or you just approved your token spending and still see "Approve token" state.
To fix that, I've created
PriorityTokensUpdater
that is almost the same asBalancesAndAllowancesUpdater
.The only difference is that the priority updater updates only assets from the current trade state + from pending orders. And it does it quite often - every ~10 seconds.
To Test