-
Notifications
You must be signed in to change notification settings - Fork 111
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
fix(combinedBalances): Optimize balance diff calculations #5082
fix(combinedBalances): Optimize balance diff calculations #5082
Conversation
@yvesfracari is attempting to deploy a commit to the cow Team on Vercel. A member of the Team first needs to authorize it. |
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.
Thanks for the fix
return | ||
} | ||
const accountBalancesDiff = preHooksBalancesDiff[account.toLowerCase()] || {} | ||
setBalancesCombined(applyBalanceDiffs(tokenBalances, accountBalancesDiff)) |
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.
Do you know why this is being re-computed still every few seconds?

Maybe this can help to figure it out https://github.com/simbathesailor/use-what-changed
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.
IIUC is because the tokenBalances
state is updated every few seconds.
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.
Then our fault, we will need to look at this tomorrow, cause my balance were not changing, so probably is not correctly memorized and its likely there's a lot more parts of the app that gets redrawn because of this
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey @yvesfracari , when I imported a LP on Sepolia (0x9d5899bd9220515a6d9300a3f4071b1daf0fd337), the app got crashed: Steps that I did:
This does not happen on Develop. in this PR only |
Some more questions:
|
I've placed an order with a pre-hook, and set the max amount to sell including incrementation. All simulations showed successful reports, but in the end my order never got executed :( |
@elena-zh Thanks for the testing.
|
Hey @yvesfracari , there is an error in the code that prevents from the PR deployemtn. Could you please fix this? As for this issue:
I've verified this with the BE team. The order is not executed due to 'insufficient balance' error. But when the order was placed, at the auction creation, the pool info changes, and the output amount becomes insufficient (here is the simulation report in the same block https://www.tdly.co/shared/simulation/1b85ee97-beab-40ca-873c-c696e0705f96) The most possible way how to reproduce this:
|
The deployment is fixed now. Looking at the simulation it seems to be the problem with the slippage. I increased the slippage to 1% (it was 0% before). This would make the withdrawal execution more robust. However, it can generate dust (since the |
Hey @yvesfracari , for the the order creation still fails (insufficient balance) with the slippage changes that you've added. As for this
I've clarified this internally. For consistency, if a simulation runs on the order confirm modal, it would be nice to show a link to the simulation report there as well :) All the rest changes LGTM |
We are making hook swaps partially fillable for now, just to account for small changes that reduce the received tokens |
@elena-zh @yvesfracari could we merge if this one is stable and follow up in a new PR any enhancement. As this PR primary fixes the diff calculations, if that part works I would suggest to not mix UI issues with this PR |
sure |
3a5bdba
to
824b94c
Compare
Summary
On the current implementation of the
combinedBalances
module the swap widget on the Hook tab is slow / stuck. This is happening because theapplyBalanceDiffs
to add the token amount changes from pre-hooks is slow and is being triggered more times than it should be.This PR resolves these two issues by:
combinedBalances
from memory to a state;applyBalanceDiffs
function knowing that thecurrentBalances
object is larger than thebalanceDiff
object.To Test
Also, this modification shouldn't impact the other widgets or pages of the app.