Commit 53d6eb09 authored by Kaylee George's avatar Kaylee George Committed by GitHub

fix: show no price impact eth to weth (#3923)

* fix: show no price impact eth to weth

Fixed the price estimate values to reflect the correct price estimates depending on whether it is a wrapped trade

* fix: show no price impact eth to weth

Fixed to display the correct price estimates depending on whether it is a wrapped trade (eth -> weth should show no price impact)

* Added ETH->wETH testing

Added a Cypress test to check wrapped value swap has no price impact

* make Cypress test cleaner
parent db0d3cf3
...@@ -48,6 +48,13 @@ describe('Swap', () => { ...@@ -48,6 +48,13 @@ describe('Swap', () => {
cy.get('#add-recipient-button').should('not.exist') cy.get('#add-recipient-button').should('not.exist')
}) })
it('ETH to wETH is same value (wrapped swaps have no price impact)', () => {
cy.get('#swap-currency-output .open-currency-select-button').click()
cy.get('.token-item-0xc778417E063141139Fce010982780140Aa0cD5Ab').click({ force: true })
cy.get('#swap-currency-input .token-amount-input').type('0.01', { force: true, delay: 100 })
cy.get('#swap-currency-output .token-amount-input').should('have.value', '0.01')
})
describe('expert mode', () => { describe('expert mode', () => {
beforeEach(() => { beforeEach(() => {
cy.window().then((win) => { cy.window().then((win) => {
......
...@@ -147,9 +147,11 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -147,9 +147,11 @@ export default function Swap({ history }: RouteComponentProps) {
() => [!trade?.swaps, TradeState.LOADING === tradeState, TradeState.SYNCING === tradeState], () => [!trade?.swaps, TradeState.LOADING === tradeState, TradeState.SYNCING === tradeState],
[trade, tradeState] [trade, tradeState]
) )
// show price estimates based on wrap trade
const fiatValueInput = useUSDCValue(trade?.inputAmount) const inputValue = showWrap ? parsedAmount : trade?.inputAmount
const fiatValueOutput = useUSDCValue(trade?.outputAmount) const outputValue = showWrap ? parsedAmount : trade?.outputAmount
const fiatValueInput = useUSDCValue(inputValue)
const fiatValueOutput = useUSDCValue(outputValue)
const priceImpact = useMemo( const priceImpact = useMemo(
() => (routeIsSyncing ? undefined : computeFiatValuePriceImpact(fiatValueInput, fiatValueOutput)), () => (routeIsSyncing ? undefined : computeFiatValuePriceImpact(fiatValueInput, fiatValueOutput)),
[fiatValueInput, fiatValueOutput, routeIsSyncing] [fiatValueInput, fiatValueOutput, routeIsSyncing]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment