From 97bb79b7fe5b15cb460285bb17423887f1a8e5f6 Mon Sep 17 00:00:00 2001 From: DaniiRix Date: Wed, 8 Oct 2025 02:08:55 +0530 Subject: [PATCH] enhanced swap ui --- .../Aggregator/adapters/odos/index.ts | 5 ++- src/components/Aggregator/index.tsx | 4 +- src/components/RefreshIcon/index.tsx | 2 +- src/components/SwapRoute/index.tsx | 39 ++++++++++++------- src/queries/useGetRoutes.tsx | 2 + src/utils/index.tsx | 4 +- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/components/Aggregator/adapters/odos/index.ts b/src/components/Aggregator/adapters/odos/index.ts index a373c36d..3dec8943 100644 --- a/src/components/Aggregator/adapters/odos/index.ts +++ b/src/components/Aggregator/adapters/odos/index.ts @@ -93,7 +93,8 @@ export async function getQuote(chain: string, from: string, to: string, amount: amountReturned: swapData.outputTokens[0].amount, estimatedGas: swapData.transaction.gas <= 0 ? swapData.gasEstimate : swapData.transaction.gas, rawQuote: swapData, - tokenApprovalAddress: routers[chain] + tokenApprovalAddress: routers[chain], + logo: 'https://icons.llamao.fi/icons/protocols/odos?w=48&q=75' }; } @@ -120,4 +121,4 @@ export const getTx = ({ rawQuote }) => ({ to: rawQuote.transaction.to, data: rawQuote.transaction.data, value: rawQuote.transaction.value -}); \ No newline at end of file +}); diff --git a/src/components/Aggregator/index.tsx b/src/components/Aggregator/index.tsx index e31b8f4e..10c59f2a 100644 --- a/src/components/Aggregator/index.tsx +++ b/src/components/Aggregator/index.tsx @@ -974,7 +974,7 @@ export function AggregatorContainer() { signatureForSwapMutation.reset(); }, onError: (err: { reason: string; code: string }, variables) => { - console.log(err) + console.log(err); if (err.code !== 'ACTION_REJECTED' || err.code.toString() === '-32603') { toast(formatErrorToast(err, false)); @@ -1051,7 +1051,7 @@ export function AggregatorContainer() { approvalData: gaslessApprovalMutation?.data ?? {}, eip5792: isEip5792 ? { shouldRemoveApproval: shouldRemoveApproval ? true : false, isTokenApproved } : null, signature: signatureForSwapMutation?.data, - isSmartContractWallet: (bytecode && bytecode !== '0x') ? true : false + isSmartContractWallet: bytecode && bytecode !== '0x' ? true : false }); } }; diff --git a/src/components/RefreshIcon/index.tsx b/src/components/RefreshIcon/index.tsx index e5cd8ebb..83929dcc 100644 --- a/src/components/RefreshIcon/index.tsx +++ b/src/components/RefreshIcon/index.tsx @@ -9,7 +9,7 @@ export const RefreshIcon = ({ refetch, lastFetched }: { refetch: () => void; las return ( {inputAmount ? ( @@ -115,10 +118,10 @@ const Route = ({ )} - {index === 0 ? ( - + {best ? ( + BEST - + ) : Number.isFinite(lossPercent) ? ( -{Math.abs(100 - lossPercent * 100).toFixed(2)}% @@ -187,12 +190,10 @@ const Route = ({ )} via - {isApproved ? ( - - - - ) : ( - ' ' + {logo && ( +
+ {name} +
)} {name} {price.isMEVSafe === true ? ( @@ -200,6 +201,13 @@ const Route = ({ ) : null} + {isApproved ? ( + + + + ) : ( + ' ' + )}
@@ -233,6 +241,11 @@ const RouteWrapper = styled.div<{ selected?: boolean; best?: boolean }>` background-color: rgb(3 11 23); } + &.is-best { + border-color: rgb(56 189 248); + background-color: rgb(4 17 32); + } + background-color: ${({ selected }) => (selected ? ' #161616;' : '#2d3039;')}; border: 1px solid #373944; padding: 7px 15px 9px; diff --git a/src/queries/useGetRoutes.tsx b/src/queries/useGetRoutes.tsx index e2b55229..b02c659c 100644 --- a/src/queries/useGetRoutes.tsx +++ b/src/queries/useGetRoutes.tsx @@ -56,6 +56,7 @@ export const REFETCH_INTERVAL = 25_000; const defaultRouteResponse = ({ adapter, amount }) => ({ price: null, name: adapter.name, + logo: '', airdrop: !adapter.token, fromAmount: amount, txData: '', @@ -109,6 +110,7 @@ export async function getAdapterRoutes({ adapter, chain, from, to, amount, extra txData, tx: adapter?.getTx?.(price), name: adapter.name, + logo: price.logo, airdrop: !adapter.token, fromAmount: amountIn, isOutputAvailable: adapter.isOutputAvailable, diff --git a/src/utils/index.tsx b/src/utils/index.tsx index 9c6c5c0e..22420f8b 100644 --- a/src/utils/index.tsx +++ b/src/utils/index.tsx @@ -2,7 +2,7 @@ export const capitalizeFirstLetter = (word) => word.charAt(0).toUpperCase() + wo const ICONS_CDN = 'https://icons.llamao.fi/icons'; -export function protoclIconUrl(protocol) { +export function protocolIconUrl(protocol) { return `${ICONS_CDN}/protocols/${protocol}?w=48&h=48`; } @@ -26,7 +26,7 @@ export const formattedNum = (number, symbol = false, acceptNegatives = false) => currencySymbol = symbol; } if (!number || number === '' || Number.isNaN(Number(number))) { - return symbol ? `${currencySymbol}0` : 0; + return symbol ? `${currencySymbol}0` : '0'; } let formattedNum = String(); let num = parseFloat(number);