Skip to content

Commit

Permalink
fix(price-impact): show price impact exact %
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed Feb 5, 2025
1 parent b9d55a3 commit 3d999bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { useConfirmationRequest } from 'common/hooks/useConfirmationRequest'

function getDescription(priceImpactWithoutFee: Percent) {
if (!priceImpactWithoutFee.lessThan(PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN)) {
return `This swap has a price impact of at least ${PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN.toFixed(0)}%.`
return `This swap has a price impact of at least ${priceImpactWithoutFee.toFixed(0)}%.`
}

if (!priceImpactWithoutFee.lessThan(ALLOWED_PRICE_IMPACT_HIGH)) {
return `This swap has a price impact of at least ${ALLOWED_PRICE_IMPACT_HIGH.toFixed(0)}%.`
return `This swap has a price impact of at least ${priceImpactWithoutFee.toFixed(0)}%.`
}

return undefined
Expand Down Expand Up @@ -57,14 +57,14 @@ export function useConfirmPriceImpactWithoutFee() {
return true
}
},
[triggerConfirmation]
[triggerConfirmation],
)

return useMemo(
() => ({
confirmPriceImpactWithoutFee,
isConfirmed,
}),
[confirmPriceImpactWithoutFee, isConfirmed]
[confirmPriceImpactWithoutFee, isConfirmed],
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export default function confirmPriceImpactWithoutFee(priceImpactWithoutFee: Perc
if (!priceImpactWithoutFee.lessThan(PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN)) {
return (
window.prompt(
`This swap has a price impact of at least ${PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN.toFixed(
0
)}%. Please type the word "confirm" to continue with this swap.`
`This swap has a price impact of at least ${priceImpactWithoutFee.toFixed(
0,
)}%. Please type the word "confirm" to continue with this swap.`,
) === 'confirm'
)
} else if (!priceImpactWithoutFee.lessThan(ALLOWED_PRICE_IMPACT_HIGH)) {
return window.confirm(
`This swap has a price impact of at least ${ALLOWED_PRICE_IMPACT_HIGH.toFixed(
0
)}%. Please confirm that you would like to continue with this swap.`
`This swap has a price impact of at least ${priceImpactWithoutFee.toFixed(
0,
)}%. Please confirm that you would like to continue with this swap.`,
)
}
return true
Expand Down

0 comments on commit 3d999bb

Please sign in to comment.