From bb51be545ba17eed6242317dd98c70afb97bfc66 Mon Sep 17 00:00:00 2001
From: Tina <59578595+tinaszheng@users.noreply.github.com>
Date: Fri, 25 Aug 2023 15:00:22 -0400
Subject: [PATCH] feat: Support UniswapX exact out trades (#7225)
* add feature flag for uniswapx exact out trades
* dont route PRICE lookups through uniswapx
* add e2e test
---
cypress/e2e/swap/uniswapx.test.ts | 21 ++++++++++++++++++-
.../FeatureFlagModal/FeatureFlagModal.tsx | 7 +++++++
src/featureFlags/flags/uniswapXExactOutput.ts | 9 ++++++++
src/featureFlags/index.tsx | 1 +
.../hooks/routing/useRoutingAPIArguments.ts | 4 ++++
src/state/routing/slice.ts | 6 ++++--
src/state/routing/types.ts | 1 +
7 files changed, 46 insertions(+), 3 deletions(-)
create mode 100644 src/featureFlags/flags/uniswapXExactOutput.ts
diff --git a/cypress/e2e/swap/uniswapx.test.ts b/cypress/e2e/swap/uniswapx.test.ts
index fa78dfd988..371f0a946a 100644
--- a/cypress/e2e/swap/uniswapx.test.ts
+++ b/cypress/e2e/swap/uniswapx.test.ts
@@ -79,7 +79,7 @@ describe('UniswapX Orders', () => {
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`)
})
- it('can swap using uniswapX', () => {
+ it('can swap exact-in trades using uniswapX', () => {
// Setup a swap
cy.get('#swap-currency-input .token-amount-input').type('300')
cy.contains('Try it now').click()
@@ -98,6 +98,25 @@ describe('UniswapX Orders', () => {
cy.contains('Swapped')
})
+ it('can swap exact-out trades using uniswapX', () => {
+ // Setup a swap
+ cy.get('#swap-currency-output .token-amount-input').type('300')
+ cy.contains('Try it now').click()
+
+ // Submit uniswapx order signature
+ cy.get('#swap-button').click()
+ cy.contains('Confirm swap').click()
+ cy.wait('@eth_signTypedData_v4')
+ cy.contains('Swap submitted')
+ cy.contains('Learn more about swapping with UniswapX')
+
+ // Return filled order status from uniswapx api
+ cy.intercept(OrderStatusEndpoint, { fixture: 'uniswapx/filledStatusResponse.json' })
+
+ // Verify swap success
+ cy.contains('Swapped')
+ })
+
it('renders proper view if uniswapx order expires', () => {
// Setup a swap
cy.get('#swap-currency-input .token-amount-input').type('300')
diff --git a/src/components/FeatureFlagModal/FeatureFlagModal.tsx b/src/components/FeatureFlagModal/FeatureFlagModal.tsx
index afd4241b0a..7964d57330 100644
--- a/src/components/FeatureFlagModal/FeatureFlagModal.tsx
+++ b/src/components/FeatureFlagModal/FeatureFlagModal.tsx
@@ -6,6 +6,7 @@ import { useMultichainUXFlag } from 'featureFlags/flags/multichainUx'
import { TraceJsonRpcVariant, useTraceJsonRpcFlag } from 'featureFlags/flags/traceJsonRpc'
import { UniswapXVariant, useUniswapXFlag } from 'featureFlags/flags/uniswapx'
import { useUniswapXEthOutputFlag } from 'featureFlags/flags/uniswapXEthOutput'
+import { useUniswapXExactOutputFlag } from 'featureFlags/flags/uniswapXExactOutput'
import { useUniswapXSyntheticQuoteFlag } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
import { useUpdateAtom } from 'jotai/utils'
import { Children, PropsWithChildren, ReactElement, ReactNode, useCallback, useState } from 'react'
@@ -231,6 +232,12 @@ export default function FeatureFlagModal() {
featureFlag={FeatureFlag.uniswapXEthOutputEnabled}
label="Enable eth output for UniswapX orders"
/>
+