Skip to content

Commit

Permalink
fix: sort by cost (metadata)
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Nov 15, 2024
1 parent cd4e423 commit e987faa
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui/ducks/bridge/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const initialState: BridgeState = {
fromTokenExchangeRate: null,
toNativeExchangeRate: null,
toTokenExchangeRate: null,
sortOrder: SortOrder.ADJUSTED_RETURN_DESC,
sortOrder: SortOrder.COST_ASC,
selectedQuote: null,
};

Expand Down
2 changes: 1 addition & 1 deletion ui/ducks/bridge/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ describe('Bridge selectors', () => {

it('should recommend 2nd cheapest quote if ETA exceeds 1 hour', () => {
const state = createBridgeMockStore({
bridgeSliceOverrides: { sortOrder: SortOrder.ADJUSTED_RETURN_DESC },
bridgeSliceOverrides: { sortOrder: SortOrder.COST_ASC },
bridgeStateOverrides: {
quotes: [
mockBridgeQuotesNativeErc20[1],
Expand Down
8 changes: 2 additions & 6 deletions ui/ducks/bridge/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,9 @@ const _getSortedQuotesWithMetadata = createDeepEqualSelector(
(quote) => quote.estimatedProcessingTimeInSeconds,
'asc',
);
case SortOrder.ADJUSTED_RETURN_DESC:
case SortOrder.COST_ASC:
default:
return orderBy(
quotesWithMetadata,
({ adjustedReturn }) => adjustedReturn.fiat,
'desc',
);
return orderBy(quotesWithMetadata, ({ cost }) => cost.fiat, 'asc');
}
},
);
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/quotes/bridge-quotes-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const BridgeQuotesModal = ({
{/* HEADERS */}
<Row padding={[4, 3]} paddingBottom={1}>
{[
[SortOrder.ADJUSTED_RETURN_DESC, t('bridgeNetCost')],
[SortOrder.COST_ASC, t('bridgeNetCost')],
[SortOrder.ETA_ASC, t('time')],
].map(([sortOrderOption, label]) => (
<ButtonLink
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/bridge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type QuoteMetadata = {

// Sort order set by the user
export enum SortOrder {
ADJUSTED_RETURN_DESC,
COST_ASC,
ETA_ASC,
}

Expand Down

0 comments on commit e987faa

Please sign in to comment.