Skip to content

Commit

Permalink
chore: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
garethfuller committed Dec 20, 2023
1 parent f9fefcd commit 7aee56a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
8 changes: 1 addition & 7 deletions lib/modules/pool/actions/add-liquidity/AddLiquidityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ export function AddLiquidityForm() {
return amountIn ? amountIn.humanAmount : ''
}

function submit() {
if (!isDisabled) {
previewDisclosure.onOpen()
}
}

return (
<TokenBalancesProvider tokens={validTokens}>
<Center h="full" w="full" maxW="lg" mx="auto">
Expand Down Expand Up @@ -122,7 +116,7 @@ export function AddLiquidityForm() {
w="full"
size="lg"
isDisabled={isDisabled}
onClick={submit}
onClick={() => !isDisabled && previewDisclosure.onOpen()}
>
Next
</Button>
Expand Down
9 changes: 5 additions & 4 deletions lib/modules/swap/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { fNum } from '@/lib/shared/utils/numbers'
import { PROJECT_CONFIG } from '@/lib/config/getProjectConfig'
import { isSameAddress } from '@/lib/shared/utils/addresses'
import { CgArrowsExchangeV } from 'react-icons/cg'
import { SwapFlowButton } from './SwapFlowButton'
import { Address } from 'viem'
import { SwapPreviewModal } from './SwapPreviewModal'

Expand All @@ -37,6 +36,8 @@ export function SwapForm() {
tokenOut,
selectedChain,
tokenSelectKey,
isDisabled,
disabledReason,
setSelectedChain,
setTokenInAmount,
setTokenOutAmount,
Expand Down Expand Up @@ -139,14 +140,14 @@ export function SwapForm() {
</HStack>
</VStack>

<Tooltip label={isAddLiquidityDisabled ? addLiquidityDisabledReason : ''}>
<Tooltip label={isDisabled ? disabledReason : ''}>
<Button
ref={nextBtn}
variant="secondary"
w="full"
size="lg"
isDisabled={isAddLiquidityDisabled}
onClick={submit}
isDisabled={isDisabled}
onClick={() => !isDisabled && previewDisclosure.onOpen()}
>
Next
</Button>
Expand Down
8 changes: 3 additions & 5 deletions lib/modules/swap/SwapPreviewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from '@chakra-ui/react'
import { RefObject, useRef } from 'react'
import { Address } from 'wagmi'
import { usePool } from '../pool/usePool'
import { useSwap } from './useSwap'
import { SwapFlowButton } from './SwapFlowButton'

Expand All @@ -39,11 +38,11 @@ type Props = {
}

function TokenAmountRow({ address, amount }: { address: Address; amount: string }) {
const { pool } = usePool()
const { selectedChain } = useSwap()
const { getToken, usdValueForToken } = useTokens()
const { toCurrency } = useCurrency()

const token = getToken(address, pool.chain)
const token = getToken(address, selectedChain)
const usdValue = token ? usdValueForToken(token, amount) : undefined

return (
Expand All @@ -70,10 +69,9 @@ export function SwapPreviewModal({
...rest
}: Props & Omit<ModalProps, 'children'>) {
const initialFocusRef = useRef(null)
const { pool } = usePool()
const spenderAddress = useContractAddress('balancer.vaultV2')
const { userAddress } = useUserAccount()
const { tokenIn, tokenOut, swapType } = useSwap()
const { tokenIn, tokenOut } = useSwap()

return (
<Modal
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/swap/useSwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export function _useSwap() {
const isLoading = loading

const { isDisabled, disabledReason } = useIsDisabledWithReason(
[isConnected, LABELS.walletNotConnected],
[!isConnected, LABELS.walletNotConnected],
[isLoading, 'Swap is loading'],
[!swapOutput, 'Swap output is undefined'],
[swapOutput?.swaps.length === 0, 'Swap output is empty']
Expand Down

0 comments on commit 7aee56a

Please sign in to comment.