Skip to content

Commit

Permalink
feat: add liquidity snapshot (#2450)
Browse files Browse the repository at this point in the history
* feat: add liquidity snapshot

* done

* update tooltip

* get route by clientId

* update desc

* update text

* adjust ui

* using github data

* update text
  • Loading branch information
viet-nv authored Dec 15, 2023
1 parent 0bceef7 commit c6d9750
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/components/Header/groups/EarnNavGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Trans } from '@lingui/macro'
import { AlertOctagon } from 'react-feather'
import { useLocation } from 'react-router-dom'
import { useMedia } from 'react-use'
import { Flex } from 'rebass'
Expand Down Expand Up @@ -73,6 +74,13 @@ const EarnNavGroup = () => {
<Trans>My Pools</Trans>
</Flex>
</StyledNavLink>

<StyledNavLink id="my-pools-nav-link" data-testid="my-pools-nav-link" to={`${APP_PATHS.ELASTIC_SNAPSHOT}`}>
<Flex sx={{ gap: '12px' }} alignItems="center">
<AlertOctagon size={14} />
<Trans>Snapshot</Trans>
</Flex>
</StyledNavLink>
</Flex>
}
/>
Expand Down
7 changes: 4 additions & 3 deletions src/components/SwapForm/hooks/useGetRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type ArgsGetRoute = {

customChain?: ChainId
isProcessingSwap?: boolean
clientId?: string
}

export const getRouteTokenAddressParam = (currency: Currency) =>
Expand Down Expand Up @@ -76,7 +77,7 @@ export const useRouteApiDomain = () => {

const useGetRoute = (args: ArgsGetRoute) => {
const { isEnableAuthenAggregator } = useKyberswapGlobalConfig()
const { isSaveGas, parsedAmount, currencyIn, currencyOut, customChain, isProcessingSwap } = args
const { isSaveGas, parsedAmount, currencyIn, currencyOut, customChain, isProcessingSwap, clientId } = args
const { chainId: currentChain } = useActiveWeb3React()
const chainId = customChain || currentChain

Expand Down Expand Up @@ -119,15 +120,15 @@ const useGetRoute = (args: ArgsGetRoute) => {
() =>
debounce(
async (args: { url: string; params: GetRouteParams; authentication: boolean }) => {
await trigger(args)
await trigger({ ...args, clientId })
dismissSwapModalFlag.current = false
},
INPUT_DEBOUNCE_TIME,
{
leading: true,
},
),
[trigger],
[trigger, clientId],
)

const fetcher = useCallback(async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/SwapForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Trans } from '@lingui/macro'
import { rgba } from 'polished'
import { stringify } from 'querystring'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
import { useMedia } from 'react-use'
import { Box, Flex, Text } from 'rebass'
import { parseGetRouteResponse } from 'services/route/utils'
Expand Down Expand Up @@ -90,6 +90,7 @@ export type SwapFormProps = {
const SwapForm: React.FC<SwapFormProps> = props => {
const { pathname } = useLocation()
const isPartnerSwap = pathname.startsWith(APP_PATHS.PARTNER_SWAP)
const [searchParams] = useSearchParams()
const {
hidden,
currencyIn,
Expand Down Expand Up @@ -146,6 +147,7 @@ const SwapForm: React.FC<SwapFormProps> = props => {
parsedAmount,
isProcessingSwap,
customChain: chainId,
clientId: searchParams.get('clientId') || undefined,
})

const { data: getRouteRawResponse, isFetching: isGettingRoute, error: getRouteError } = result
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export const APP_PATHS = {
IAM_CONSENT: '/consent',

DEPRECATED_NOTI_CENTER: '/notification-center/overview',
ELASTIC_SNAPSHOT: '/elastic-snapshot',
} as const

export const TERM_FILES_PATH = {
Expand Down
4 changes: 4 additions & 0 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const Login = lazy(() => import('./Oauth/Login'))
const Logout = lazy(() => import('./Oauth/Logout'))
const Consent = lazy(() => import('./Oauth/Consent'))

const ElasticSnapshot = lazy(() => import('./ElasticSnapshot'))

// test page for swap only through elastic
const ElasticSwap = lazy(() => import('./ElasticSwap'))
const SwapV3 = lazy(() => import('./SwapV3'))
Expand Down Expand Up @@ -386,6 +388,8 @@ export default function App() {
<Route path={APP_PATHS.IAM_LOGOUT} element={<Logout />} />
<Route path={APP_PATHS.IAM_CONSENT} element={<Consent />} />

<Route path={APP_PATHS.ELASTIC_SNAPSHOT} element={<ElasticSnapshot />} />

<Route path="*" element={<RedirectPathToSwapV3Network />} />
</Routes>
</Web3ReactManager>
Expand Down
Loading

0 comments on commit c6d9750

Please sign in to comment.