feat: auto-select best pool fee tier for trades#37
Merged
Conversation
When a user enters a trade amount, all pools matching the token pair are queried sequentially (bPredictOnly=1) and the one returning the highest buy amount is selected automatically. Adds a fee tier picker showing a "Best" badge on the winning pool with manual override and an "Auto" reset button. - New onFindBestPool saga action queries each fee tier and dispatches setCurrentPool with the winner (takeLatest cancels stale searches) - activePool memo replaced with matchedPools + manualKind/bestKind state so auto and manual selections are tracked independently - Amount inputs format with thousands separators in real time; Input.tsx strips commas before REG_AMOUNT validation so typing is never blocked; useValidation strips commas in the isMax check - formatPredictAmount preserves full decimal precision (no rounding) - Clearing the active input now also clears the predicted output - Fee tier picker is consistent across embedded and non-embedded layouts; helpers moved to module level - Fix: saga filter cast and duplicate clean:true in webpack config
…hell bg Scroll / layout - App: Scrollbars view uses overflow-x hidden + overscroll-behavior none; hide tracks when not needed; optional body/html overscroll-behavior in global styles. - Global: html/body/#root overflow-x hidden, width chains; remove body min-width that forced horizontal overflow; #root block + height 100% for Scrollbars. - Global: body.web / body.mobile + html:has(...) use --color-dark-blue and min-height 100vh so the shell fills the viewport behind TopNav (not only the Window content column). - Container: width 100% + max-width 914px; optional wide (980px) for embedded trade; TradePool embedded uses wide. - Window, SwapPoolsHome, EmbeddedLayout, AssetsSection, InlineSelect: min-width, overflow-x, and grid column width (620px trade column) to avoid clip/scroll; InlineSelect min-width 200px and flex-shrink 0 so control/menu stay readable. - poolFlowLayout Line: max-width 412px instead of fixed width. Asset selector (react-select custom-filter) - Menu portaled to document.body with position fixed so dropdown is not clipped by overflow ancestors. - SCSS: menu/menu-portal z-index, control min-width, option/menu overflow, tighter menu-list padding; styles consolidated from inline TS where possible. - ReactSelect: layout via Linaria (grid row + ellipsis); removed unused inline StylesConfig blob; portal props kept in component. Metadata - getOptions / asset labels use SN from parsed metadata (short ticker), then UN, then N; shared assetShortLabel helper in appUtils.
- Default both amount fields to 0; paired field resets to 0 when quote clears - Focus clears placeholder 0; blur restores 0 if the user entered nothing - Share amount focus/blur handlers; dedupe fee-tier UI and token select handlers - Drop redundant embedded checks in the full-page trade branch
…ade summary - DAO Fee, LP Fee, and Total Fee rows now show the FROM token (currentToken) instead of the TO token, matching contract output where fee_dao and fee_pool are denominated in the payment asset - "You buy" row in the full view now correctly shows the TO token (secondToken) - "Total Pay" row in the full view now correctly shows the FROM token - formatNumber now uses maximumFractionDigits: 8 so small fee values (e.g. 0.00300123) are no longer truncated to 3 decimal places
Extract poolAmountInput (parseAmount, grouping, caret-safe onChange, createAmountFieldHandlers, formatPredictedFieldDisplay) and wire TradePool, AddLiquidity, and WithdrawPool to use it for consistent placeholders and number formatting. Keep add/withdraw as single slim container files; move predicted display helpers into the shared module to avoid duplicated logic.
- When several pools match, detect if the from/to amount exceeds every pool’s relevant reserve; show ErrorHint and AssetsSection error ring and red numbers instead of a toast, and skip trade requests while isMax on that side. - findBestPool: only setCurrentPool when bestBuy > 0. - poolFlowLayout: add HintRow and ErrorHint styled components.
- Replace ReactSelect token pickers with AssetSearchModal / AssetSelectorButton in trade, create pool, and explore (searchable selection, exclude paired asset). - Add AssetInfo at /asset/:id with metadata and pools list; extract PoolTable for explore + asset detail; small explore header/layout and sort underline fix. - Update IAsset for emission fields; simplify add-liquidity amount flow (drop swap toggle, clear predict when the other side is empty).
…ctor - add favoriteAssets (number[]) to Redux state, persisted to localStorage - toggle favorite assets via saga (onToggleFavoriteAsset) - add star button to each asset row in AssetSearchModal - add ALL / Favorite filter dropdown in the asset selector tab bar - when Favorite filter is active, asset list and pool pair search results only show items where both assets are in favorites
… for EXPLORE page
replaces old utils Co-Authored-By: vsnation <44433026+vsnation@users.noreply.github.com>
Handle wallet cancel without forcing connector lock state, keep prediction calls returning shader results, and fix auto-mode tier probing/validation so Trade Summary and fee-tier switching stay responsive.
support AMML query formats, keep AMML-prefixed `/` searches out of POOL mode, and enforce exact fee-tier matching.
- Add fake-real asset ID mapping (imposterAssets) and surface it across trade (select + execute), explore pool open, asset info, and asset/pool search with badges and confirm/modal flows (desktop uses window.confirm, component used in web doesnt work in the desktop wallet for some reason). - Pool list and explore: apply tab filter before search; enable fav/created tabs even when empty; show contextual empty copy instead of disabling tabs or an infinite loader. - Asset search: onSelect may return false to keep the modal open during imposter handling; AssetSelectorButton supports warning state and controlled open/close.
clicking on one of the assets in the POOL INFO section of the TRADE page opens the asset in the ASSET INFO page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user enters a trade amount, all pools matching the token pair are queried sequentially (
bPredictOnly=1) and the one returning the highest buy amount is selected automatically. Adds a fee tier picker showing a "Best" badge on the winning pool with manual override and an "Auto" reset button.dapp
onFindBestPoolsaga action queries each fee tier and dispatchessetCurrentPoolwith the winner (takeLatestcancels stale searches).activePoolmemo replaced withmatchedPools+manualKind/bestKindstate so auto and manual selections are tracked independently.Input.tsxvalidates amounts using a comma-stripped copy so typing isn’t blocked; selection is restored after format so the caret doesn’t jump to the end;useValidationstrips commas in theisMaxcheck.formatPredictAmountpreserves full decimal precision (no rounding).clean: truein webpack config.MAX_SAFE_INTEGERto allow full trading in bigger pools (noticed this limitation in the TICO pool).asset amount > MAXbottom right alertutils.jswith @vsnation'sBeamDappConnectorAMML 0/7/1andAMML BEAM/BEAMX 1%, updated labels toAMML (SN(id)/SN(id) - fee%), and removed ambiguous fee-index matches.ui
Scroll / layout
tracks when not needed; optional body/html overscroll-behavior in global styles.
that forced horizontal overflow; #root block + height 100% for Scrollbars.
min-height 100vh so the shell fills the viewport behind TopNav (not only the
Window content column).
trade; TradePool embedded uses wide.
overflow-x, and grid column width (620px trade column) to avoid clip/scroll;
InlineSelect min-width 200px and flex-shrink 0 so control/menu stay readable.
Asset selector (react-select custom-filter)
by overflow ancestors.
tighter menu-list padding; styles consolidated from inline TS where possible.
StylesConfig blob; portal props kept in component.
Metadata
then N; shared assetShortLabel helper in appUtils.
Github CI build used the dev build before, now uses the correct prod build.