Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(yield): define token category by default for selection #5018

Merged
merged 111 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
01c23f9
feat(yield): setup yield widget
shoom3301 Oct 7, 2024
e8514b5
fix(yield): display correct output amount
shoom3301 Oct 7, 2024
4bde353
feat(trade-quote): support fast quote requests
shoom3301 Oct 7, 2024
cf63214
feat(yield): display trade buttons
shoom3301 Oct 7, 2024
2513c89
feat(yield): display confirm details
shoom3301 Oct 7, 2024
893859f
feat(yield): scope context to trade
shoom3301 Oct 7, 2024
89aeca4
feat(yield): do trade after confirmation
shoom3301 Oct 7, 2024
ca61cbb
feat(yield): display order progress bar
shoom3301 Oct 7, 2024
0e267a9
refactor: move useIsEoaEthFlow to trade module
shoom3301 Oct 8, 2024
2df7b69
refactor: move hooks to tradeSlippage module
shoom3301 Oct 8, 2024
4ff2db5
refactor: rename swapSlippage to tradeSlippage
shoom3301 Oct 8, 2024
f5c45e9
feat(trade-slippage): split slippage state by trade type
shoom3301 Oct 8, 2024
8b8ae26
refactor: unlink TransactionSettings from swap module
shoom3301 Oct 8, 2024
39a95c3
refactor: use reach modal in Settings component
shoom3301 Oct 8, 2024
7c3c559
refactor: move Settings component in trade module
shoom3301 Oct 8, 2024
57d4ad0
feat(yield): add settings widget
shoom3301 Oct 8, 2024
4b8a40d
feat(yield): use deadline value from settings
shoom3301 Oct 8, 2024
2c2ee88
fix(trade-quote): skip fast quote if it slower than optimal
shoom3301 Oct 8, 2024
0bbec8b
refactor: generalise TradeRateDetails from swap module
shoom3301 Oct 8, 2024
fbb9a73
refactor: move TradeRateDetails into tradeWidgetAddons module
shoom3301 Oct 8, 2024
275893e
refactor: move SettingsTab into tradeWidgetAddons module
shoom3301 Oct 8, 2024
452d107
refactor(swap): generalise useHighFeeWarning()
shoom3301 Oct 10, 2024
27407be
refactor(swap): move hooks to trade module
shoom3301 Oct 10, 2024
1073d5f
refactor: move HighFeeWarning to trade widget addons
shoom3301 Oct 10, 2024
11243ee
refactor: make HighFeeWarning independent
shoom3301 Oct 10, 2024
2548e10
feat(yield): display trade warnings
shoom3301 Oct 10, 2024
f9e3d82
refactor(trade): generalise NoImpactWarning
shoom3301 Oct 10, 2024
3c6ed69
refactor(trade): generalise ZeroApprovalWarning
shoom3301 Oct 10, 2024
8070665
refactor(trade): generalise bundle tx banners
shoom3301 Oct 10, 2024
b6d9717
refactor: extract TradeWarnings
shoom3301 Oct 10, 2024
759bc0f
chore: fix yield form displaying
shoom3301 Oct 10, 2024
f320ff7
refactor(swap): generalise trade flow
shoom3301 Oct 10, 2024
057f552
feat(yield): support safe bundle swaps
shoom3301 Oct 10, 2024
b3ac906
chore: hide yield under ff
shoom3301 Oct 10, 2024
fb10141
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 10, 2024
c780d1b
chore: remove lazy loading
shoom3301 Oct 11, 2024
fb63d4e
chore: merge develop
shoom3301 Oct 14, 2024
4c88126
chore: fix imports
shoom3301 Oct 14, 2024
0bf3ba1
fix: generalize smart slippage usage
shoom3301 Oct 14, 2024
78c0b89
fix: don't sync url params while navigating with yield
shoom3301 Oct 14, 2024
1678557
feat: open settings menu on slippage click
shoom3301 Oct 14, 2024
be2e6cc
chore: update btn text
shoom3301 Oct 14, 2024
3b769af
fix: make slippage settings through
shoom3301 Oct 14, 2024
b88e78c
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 15, 2024
b153e9e
chore: merge develop
shoom3301 Oct 15, 2024
bea304e
chore: fix yield widget
shoom3301 Oct 15, 2024
9ecaf57
chore: remove old migration
shoom3301 Oct 15, 2024
2722b3e
feat: add default lp-token lists
shoom3301 Oct 15, 2024
aa53aac
feat(tokens): display custom token selector for Yield widget
shoom3301 Oct 15, 2024
ac0a957
feat(tokens): display lp-token lists
shoom3301 Oct 15, 2024
704d003
feat: display lp-token logo
shoom3301 Oct 16, 2024
bae773d
chore: slippage label
shoom3301 Oct 16, 2024
c01f9b8
fix: fix default trade state in menu
shoom3301 Oct 16, 2024
1af6c9e
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 16, 2024
0253925
chore: fix lint
shoom3301 Oct 16, 2024
170e295
Merge branch 'feat/vampire-attack-setup' of https://github.com/cowpro…
shoom3301 Oct 16, 2024
854d685
feat: fetch lp-token balances
shoom3301 Oct 16, 2024
03da23d
feat: reuse virtual list for lp-tokens list
shoom3301 Oct 16, 2024
7228879
chore: adjust balances updater
shoom3301 Oct 16, 2024
b8b3301
chore: add yield in widget conf
shoom3301 Oct 16, 2024
6d9e416
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 16, 2024
3902abb
chore: reset balances only when account changed
shoom3301 Oct 17, 2024
6060aae
feat: cache balances into localStorage
shoom3301 Oct 17, 2024
20ba5de
feat: display cached token balances
shoom3301 Oct 17, 2024
3fe1727
feat: link to create pool
shoom3301 Oct 17, 2024
629569a
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 17, 2024
4d54103
chore: merge develop
shoom3301 Oct 17, 2024
535a046
chore: fix hooks trade state
shoom3301 Oct 17, 2024
c9df5d2
fix: fix smart slippage displaying
shoom3301 Oct 18, 2024
60c1033
chore: center slippage banner
shoom3301 Oct 18, 2024
cb3f94d
Merge branch 'feat/vampire-attack-setup' of https://github.com/cowpro…
shoom3301 Oct 18, 2024
ee11cb2
chore: condition to displayCreatePoolBanner
shoom3301 Oct 18, 2024
5d5c843
fix: poll lp-token balances only in yield widget
shoom3301 Oct 18, 2024
8e64078
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 18, 2024
9abbf85
feat(yield): persist pools info
shoom3301 Oct 21, 2024
df6f4b1
feat(yield): allow using lp-tokens in widget
shoom3301 Oct 21, 2024
c43fba1
feat(yield): display lp-token logo in widget
shoom3301 Oct 21, 2024
d95fcf1
feat(yield): display pool apy
shoom3301 Oct 21, 2024
564d0b2
chore: fix lp token logo
shoom3301 Oct 21, 2024
eeaa6bb
feat(yield): pool info page
shoom3301 Oct 21, 2024
8061fd4
Merge branch 'develop' into feat/vampire-attack-lp-tokens
fairlighteth Oct 21, 2024
13a664f
Merge branch 'feat/vampire-attack-lp-tokens' of https://github.com/co…
shoom3301 Oct 22, 2024
4488bf7
chore: fix build
shoom3301 Oct 22, 2024
de38227
chore(yield): fix balance loading state
shoom3301 Oct 22, 2024
3d31e80
chore(yield): fix pools info fetching
shoom3301 Oct 22, 2024
0cf8755
chore: fix yield menu link
shoom3301 Oct 22, 2024
36fae46
chore: format pool displayed values
shoom3301 Oct 22, 2024
f246521
chore: always use address for lp-tokens in url
shoom3301 Oct 22, 2024
4092dd7
fix: fix lp-tokens usage
shoom3301 Oct 22, 2024
788c7f7
chore: fix lint
shoom3301 Oct 22, 2024
f0c3621
feat(yield): define token category by default for selection
shoom3301 Oct 22, 2024
930253b
chore: fix lint
shoom3301 Oct 22, 2024
a0bab7b
feat: add isCoWAMM indicator to LpToken
shoom3301 Oct 22, 2024
9c5d5b5
refactor: fix lp tokens segregation
shoom3301 Oct 22, 2024
1149c36
chore: fix apr default value
shoom3301 Oct 23, 2024
e6f28c2
Merge branch 'feat/vampire-attack-pools-info' of https://github.com/c…
shoom3301 Oct 23, 2024
8048049
chore: remove lp tokens duplicates
shoom3301 Oct 23, 2024
0c6f52c
fix: set lp tokens to sell wth cowamm is set as buy
shoom3301 Oct 23, 2024
4e96783
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 23, 2024
51297d9
Merge branch 'feat/vampire-attack-lp-tokens' of https://github.com/co…
shoom3301 Oct 23, 2024
6e59eee
Merge branch 'feat/vampire-attack-pools-info' of https://github.com/c…
shoom3301 Oct 23, 2024
98597c2
feat: modify pool token list layout (#5014)
fairlighteth Oct 24, 2024
5889ea4
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 28, 2024
0350976
chore: link to create pool
shoom3301 Oct 28, 2024
f3f7eac
Merge branch 'feat/vampire-attack-lp-tokens' of https://github.com/co…
shoom3301 Oct 28, 2024
8d33d3b
chore: merge changes
shoom3301 Oct 28, 2024
265b870
chore: fix balances cache
shoom3301 Oct 28, 2024
090b239
Merge branch 'feat/vampire-attack-pools-info' of https://github.com/c…
shoom3301 Oct 28, 2024
115c017
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 29, 2024
17d2230
Merge branch 'feat/vampire-attack-pools-info' of https://github.com/c…
shoom3301 Oct 29, 2024
75e7d90
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export interface CurrencyInputPanelProps extends Partial<BuiltItProps> {
subsidyAndBalance?: BalanceAndSubsidy
onCurrencySelection: (field: Field, currency: Currency) => void
onUserInput: (field: Field, typedValue: string) => void
openTokenSelectWidget(selectedToken: string | undefined, onCurrencySelection: (currency: Currency) => void): void
openTokenSelectWidget(
selectedToken: string | undefined,
field: Field | undefined,
onCurrencySelection: (currency: Currency) => void,
): void
topLabel?: string
}

Expand Down Expand Up @@ -84,7 +88,7 @@ export function CurrencyInputPanel(props: CurrencyInputPanelProps) {
setTypedValue(typedValue)
onUserInput(field, typedValue)
},
[onUserInput, field]
[onUserInput, field],
)
const handleMaxInput = useCallback(() => {
if (!maxBalance) {
Expand Down Expand Up @@ -136,7 +140,7 @@ export function CurrencyInputPanel(props: CurrencyInputPanelProps) {
}, [_priceImpactParams, bothCurrenciesSet])

const onTokenSelectClick = useCallback(() => {
openTokenSelectWidget(selectedTokenAddress, (currency) => onCurrencySelection(field, currency))
openTokenSelectWidget(selectedTokenAddress, field, (currency) => onCurrencySelection(field, currency))
}, [openTokenSelectWidget, selectedTokenAddress, onCurrencySelection, field])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo, useRef } from 'react'

import { NATIVE_CURRENCIES } from '@cowprotocol/common-const'
import { EnrichedOrder, EthflowData, OrderClass, SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { TokensByAddress, useAllTokens } from '@cowprotocol/tokens'
import { TokensByAddress, useAllActiveTokens } from '@cowprotocol/tokens'
import { useIsSafeWallet, useWalletInfo } from '@cowprotocol/wallet'

import { Order, OrderStatus } from 'legacy/state/orders/actions'
Expand Down Expand Up @@ -32,7 +32,7 @@ const statusMapping: Record<OrderTransitionStatus, OrderStatus | undefined> = {
function _transformOrderBookOrderToStoreOrder(
order: EnrichedOrder,
chainId: ChainId,
allTokens: TokensByAddress
allTokens: TokensByAddress,
): Order | undefined {
const {
uid: id,
Expand Down Expand Up @@ -63,7 +63,7 @@ function _transformOrderBookOrderToStoreOrder(
console.warn(
`OrdersFromApiUpdater::Tokens not found for order ${id}: sellToken ${
!inputToken ? sellToken : 'found'
} - buyToken ${!outputToken ? buyToken : 'found'}`
} - buyToken ${!outputToken ? buyToken : 'found'}`,
)
return
}
Expand Down Expand Up @@ -110,7 +110,7 @@ function _getInputToken(
isEthFlow: boolean,
chainId: ChainId,
sellToken: string,
allTokens: TokensByAddress
allTokens: TokensByAddress,
): ReturnType<typeof getTokenFromMapping> {
return isEthFlow ? NATIVE_CURRENCIES[chainId] : getTokenFromMapping(sellToken, chainId, allTokens)
}
Expand Down Expand Up @@ -141,7 +141,7 @@ export function OrdersFromApiUpdater(): null {
const clearOrderStorage = useClearOrdersStorage()

const { account, chainId } = useWalletInfo()
const allTokens = useAllTokens()
const allTokens = useAllActiveTokens()
const tokensAreLoaded = useMemo(() => Object.keys(allTokens).length > 0, [allTokens])
const addOrUpdateOrders = useAddOrUpdateOrders()
const updateApiOrders = useSetAtom(apiOrdersAtom)
Expand Down Expand Up @@ -176,7 +176,7 @@ export function OrdersFromApiUpdater(): null {
console.error(`OrdersFromApiUpdater::Failed to fetch orders`, e)
}
},
[addOrUpdateOrders, ordersFromOrderBook, getTokensForOrdersList, isSafeWallet]
[addOrUpdateOrders, ordersFromOrderBook, getTokensForOrdersList, isSafeWallet],
)

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const BALANCE_UPDATE_INTERVAL = ms`5s`
const selectedCurrencyAtom = atom<Currency | undefined>(undefined)

export function RescueFundsFromProxy({ onDismiss }: { onDismiss: Command }) {
const [selectedCurrency, seSelectedCurrency] = useAtom(selectedCurrencyAtom)
const [selectedCurrency, setSelectedCurrency] = useAtom(selectedCurrencyAtom)
const [tokenBalance, setTokenBalance] = useState<CurrencyAmount<Currency> | null>(null)

const selectedTokenAddress = selectedCurrency ? getCurrencyAddress(selectedCurrency) : undefined
Expand Down Expand Up @@ -81,8 +81,8 @@ export function RescueFundsFromProxy({ onDismiss }: { onDismiss: Command }) {
}, [rescueFundsCallback, addTransaction, handleSetError])

const onCurrencySelectClick = useCallback(() => {
onSelectToken(selectedTokenAddress, seSelectedCurrency)
}, [onSelectToken, selectedTokenAddress, seSelectedCurrency])
onSelectToken(selectedTokenAddress, undefined, undefined, setSelectedCurrency)
}, [onSelectToken, selectedTokenAddress, setSelectedCurrency])

return (
<Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { ReactNode, useMemo } from 'react'

import { useTokensBalances } from '@cowprotocol/balances-and-allowances'
import { TokenWithLogo } from '@cowprotocol/common-const'
import { getTokenSearchFilter, LP_TOKEN_LIST_CATEGORIES, TokenListCategory, useAllLpTokens } from '@cowprotocol/tokens'
import {
getTokenSearchFilter,
LP_TOKEN_LIST_CATEGORIES,
LP_TOKEN_LIST_COW_AMM_ONLY,
TokenListCategory,
useAllLpTokens,
} from '@cowprotocol/tokens'
import { ProductLogo, ProductVariant, UI } from '@cowprotocol/ui'

import { usePoolsInfo } from 'modules/yield/shared'
Expand All @@ -16,6 +22,7 @@ interface LpTokenListsProps<T = TokenListCategory[] | null> {
account: string | undefined
children: ReactNode
search: string
disableErc20?: boolean
onSelectToken(token: TokenWithLogo): void
openPoolPage(poolAddress: string): void
tokenListCategoryState: [T, (category: T) => void]
Expand All @@ -35,7 +42,7 @@ const tabs = [
/>{' '}
CoW AMM only
</>
), value: [TokenListCategory.COW_AMM_LP] },
), value: LP_TOKEN_LIST_COW_AMM_ONLY },
]

export function LpTokenListsWidget({
Expand All @@ -45,6 +52,7 @@ export function LpTokenListsWidget({
onSelectToken,
openPoolPage,
tokenListCategoryState,
disableErc20,
}: LpTokenListsProps) {
const [listsCategories, setListsCategories] = tokenListCategoryState
const lpTokens = useAllLpTokens(listsCategories)
Expand All @@ -62,7 +70,7 @@ export function LpTokenListsWidget({
return (
<>
<TabsContainer>
{tabs.map((tab) => {
{(disableErc20 ? tabs.slice(1) : tabs).map((tab) => {
return (
<TabButton
key={tab.id}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { LpToken } from '@cowprotocol/common-const'
import { LP_TOKEN_LIST_CATEGORIES, LP_TOKEN_LIST_COW_AMM_ONLY, TokenListCategory } from '@cowprotocol/tokens'
import { Currency } from '@uniswap/sdk-core'

import { Field } from 'legacy/state/types'

export function getDefaultTokenListCategories(
field: Field | undefined,
oppositeToken: Currency | LpToken | undefined,
lpTokensWithBalancesCount: number,
): TokenListCategory[] | null {
const isOppositeLp = oppositeToken instanceof LpToken

// When select buy token
if (field === Field.OUTPUT) {
// If sell token is LP token
if (isOppositeLp) {
// And sell token is COW AMM LP token, propose all LP tokens by default as buy token
if (oppositeToken.isCowAmm) {
return LP_TOKEN_LIST_CATEGORIES
} else {
// And sell token is not COW AMM LP token, propose COW AMM LP tokens by default as buy token
return LP_TOKEN_LIST_COW_AMM_ONLY
}
} else {
// And sell token is not LP token, propose all LP tokens by default as buy token
return LP_TOKEN_LIST_COW_AMM_ONLY
}
}

if (isOppositeLp && oppositeToken.isCowAmm) {
return LP_TOKEN_LIST_CATEGORIES
}

// When select sell token
// If there are LP tokens with balances, propose LP tokens by default as sell token
return lpTokensWithBalancesCount > 0 ? LP_TOKEN_LIST_CATEGORIES : null
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useCallback, useState } from 'react'

import { useTokensBalances } from '@cowprotocol/balances-and-allowances'
import { TokenWithLogo } from '@cowprotocol/common-const'
import { LpToken, TokenWithLogo } from '@cowprotocol/common-const'
import { isInjectedWidget } from '@cowprotocol/common-utils'
import {
ListState,
TokenListCategory,
useAddList,
useAddUserToken,
useAllListsList,
useAllTokens,
useAllActiveTokens,
useFavoriteTokens,
useUnsupportedTokens,
useUserAddedTokens,
Expand All @@ -18,8 +18,13 @@ import { useWalletInfo } from '@cowprotocol/wallet'

import styled from 'styled-components/macro'

import { Field } from 'legacy/state/types'

import { addListAnalytics } from 'modules/analytics'
import { usePermitCompatibleTokens } from 'modules/permit'
import { useLpTokensWithBalances } from 'modules/yield/shared'

import { getDefaultTokenListCategories } from './getDefaultTokenListCategories'

import { useOnTokenListAddingError } from '../../hooks/useOnTokenListAddingError'
import { useSelectTokenWidgetState } from '../../hooks/useSelectTokenWidgetState'
Expand All @@ -44,18 +49,33 @@ interface SelectTokenWidgetProps {
}

export function SelectTokenWidget({ displayLpTokenLists }: SelectTokenWidgetProps) {
const { open, onSelectToken, tokenToImport, listToImport, selectedToken, onInputPressEnter, selectedPoolAddress } =
useSelectTokenWidgetState()
const {
open,
onSelectToken,
tokenToImport,
listToImport,
selectedToken,
onInputPressEnter,
selectedPoolAddress,
field,
oppositeToken,
} = useSelectTokenWidgetState()
const { count: lpTokensWithBalancesCount } = useLpTokensWithBalances()

const [isManageWidgetOpen, setIsManageWidgetOpen] = useState(false)
const tokenListCategoryState = useState<TokenListCategory[] | null>(null)
const isSellErc20Selected = field === Field.OUTPUT && !(oppositeToken instanceof LpToken)

const tokenListCategoryState = useState<TokenListCategory[] | null>(
getDefaultTokenListCategories(field, oppositeToken, lpTokensWithBalancesCount),
)

const updateSelectTokenWidget = useUpdateSelectTokenWidgetState()
const { account } = useWalletInfo()

const addCustomTokenLists = useAddList((source) => addListAnalytics('Success', source))
const importTokenCallback = useAddUserToken()

const allTokens = useAllTokens()
const allTokens = useAllActiveTokens()
const favoriteTokens = useFavoriteTokens()
const userAddedTokens = useUserAddedTokens()
const allTokenLists = useAllListsList()
Expand Down Expand Up @@ -181,6 +201,7 @@ export function SelectTokenWidget({ displayLpTokenLists }: SelectTokenWidgetProp
hideFavoriteTokensTooltip={isInjectedWidgetMode}
openPoolPage={openPoolPage}
tokenListCategoryState={tokenListCategoryState}
disableErc20={isSellErc20Selected}
account={account}
/>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { useCallback } from 'react'

import { LpToken, TokenWithLogo } from '@cowprotocol/common-const'
import { Currency } from '@uniswap/sdk-core'

import { Field } from 'legacy/state/types'

import { useUpdateSelectTokenWidgetState } from './useUpdateSelectTokenWidgetState'

export function useOpenTokenSelectWidget(): (
selectedToken: string | undefined,
onSelectToken: (currency: Currency) => void
field: Field | undefined,
oppositeToken: TokenWithLogo | LpToken | Currency | undefined,
onSelectToken: (currency: Currency) => void,
) => void {
const updateSelectTokenWidget = useUpdateSelectTokenWidgetState()

return useCallback(
(selectedToken, onSelectToken) => {
(selectedToken, field, oppositeToken, onSelectToken) => {
updateSelectTokenWidget({
selectedToken,
field,
oppositeToken,
open: true,
onSelectToken: (currency) => {
updateSelectTokenWidget({ open: false })
onSelectToken(currency)
},
})
},
[updateSelectTokenWidget]
[updateSelectTokenWidget],
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface SelectTokenModalProps<T = TokenListCategory[] | null> {
permitCompatibleTokens: PermitCompatibleTokens
hideFavoriteTokensTooltip?: boolean
displayLpTokenLists?: boolean
disableErc20?: boolean
account: string | undefined
tokenListCategoryState: [T, (category: T) => void]

Expand Down Expand Up @@ -60,6 +61,7 @@ export function SelectTokenModal(props: SelectTokenModalProps) {
displayLpTokenLists,
openPoolPage,
tokenListCategoryState,
disableErc20,
} = props

const [inputValue, setInputValue] = useState<string>(defaultInputValue)
Expand Down Expand Up @@ -119,6 +121,7 @@ export function SelectTokenModal(props: SelectTokenModalProps) {
search={inputValue}
onSelectToken={onSelectToken}
openPoolPage={openPoolPage}
disableErc20={disableErc20}
tokenListCategoryState={tokenListCategoryState}
>
{allListsContent}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { atom } from 'jotai'

import { TokenWithLogo } from '@cowprotocol/common-const'
import { LpToken, TokenWithLogo } from '@cowprotocol/common-const'
import { atomWithPartialUpdate } from '@cowprotocol/common-utils'
import { ListState } from '@cowprotocol/tokens'
import { Command } from '@cowprotocol/types'
import { Currency } from '@uniswap/sdk-core'

import { Field } from 'legacy/state/types'

export const { atom: selectTokenWidgetAtom, updateAtom: updateSelectTokenWidgetAtom } = atomWithPartialUpdate(
atom<{
open: boolean
field?: Field
oppositeToken?: TokenWithLogo | LpToken | Currency
selectedToken?: string
selectedPoolAddress?: string
tokenToImport?: TokenWithLogo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function tokensListSorter(balances: BalancesState['values']): (a: TokenWi
return +bBalance.sub(aBalance)
}

if (aBalance && !bBalance) {
return -1
}

return 0
}
}
Loading
Loading