fix: single-sided liquidity max button uses stale balance#4226
fix: single-sided liquidity max button uses stale balance#4226JohnnyWyles wants to merge 2 commits intostagefrom
Conversation
Fixed issue where clicking max button in single-sided liquidity mode would use stale balance value instead of querying fresh balance. - Query current balance from _queryBalances instead of reading config.amount - Ensures max button always uses latest balance matching the displayed value 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
|
How to test:
|
WalkthroughIn single-amount-in mode, ObservableAddLiquidityConfig.setMax now fetches a fresh on-chain balance for the sender's selected sendCurrency and uses that balance (via setAmountAt with isMax=true) instead of using the stored config.amount. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Caller (UI)
participant Config as ObservableAddLiquidityConfig
participant Balance as BalanceService
UI->>Config: setMax(index)
Config->>Config: mark config as max
alt single-amount-in mode
Config->>Balance: queryBalance(sender, sendCurrency)
Balance-->>Config: Balance (bigint/Decimal)
Config->>Config: format balance -> amountStr
Config->>Config: setAmountAt(index, amountStr, {isMax: true})
else other modes
Config->>Config: use existing flow (no fresh balance)
end
Config->>Config: unmark config as max
Config-->>UI: updated config state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/stores/src/ui-config/manage-liquidity/add-liquidity.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: greg-nagy
Repo: osmosis-labs/osmosis-frontend PR: 3954
File: packages/web/modals/review-order.tsx:132-136
Timestamp: 2024-11-15T10:08:23.742Z
Learning: In `packages/web/modals/review-order.tsx`, the calculation of `wouldExceedSpendLimit` in the `ReviewOrder` component handles optional chaining and null values correctly, and does not require providing default values to avoid potential `NaN` results.
📚 Learning: 2024-11-15T10:08:23.742Z
Learnt from: greg-nagy
Repo: osmosis-labs/osmosis-frontend PR: 3954
File: packages/web/modals/review-order.tsx:132-136
Timestamp: 2024-11-15T10:08:23.742Z
Learning: In `packages/web/modals/review-order.tsx`, the calculation of `wouldExceedSpendLimit` in the `ReviewOrder` component handles optional chaining and null values correctly, and does not require providing default values to avoid potential `NaN` results.
Applied to files:
packages/stores/src/ui-config/manage-liquidity/add-liquidity.ts
📚 Learning: 2024-11-23T16:36:41.685Z
Learnt from: greg-nagy
Repo: osmosis-labs/osmosis-frontend PR: 3954
File: packages/web/components/alert/prettify.ts:43-44
Timestamp: 2024-11-23T16:36:41.685Z
Learning: In `packages/web/components/alert/prettify.ts`, when handling overspend error messages related to `uusdc`, assuming 6 decimal places is acceptable because `uusdc` uses 6 decimals.
Applied to files:
packages/stores/src/ui-config/manage-liquidity/add-liquidity.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Summary
|
Will sync another time on this - I tried doing the same with TON since I have an out of range position again now and it worked fine :/ |
What is the purpose of the change:
Fixed issue where clicking max button in single-sided liquidity mode would use stale balance value instead of querying fresh balance.
Linear Task
https://linear.app/osmosis/issue/FE-1554/max-button-for-single-sided-add-liquidity-not-displaying-correct-value
Brief Changelog
Testing and Verifying
This change has been tested locally by rebuilding the website and verified content and links are expected