Commit 7dafb0cf authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

Remove UI (#52)

* use token0 as base in all calculations

* refactor

* fix price order

* fix existing position ticks

* remove empty space

* basic remove page
Co-authored-by: default avatarNoah Zinsmeister <noahwz@gmail.com>
parent da33ec9d
...@@ -226,6 +226,7 @@ export const ButtonText = styled(Base)` ...@@ -226,6 +226,7 @@ export const ButtonText = styled(Base)`
padding: 0; padding: 0;
width: fit-content; width: fit-content;
background: none; background: none;
text-decoration: none;
&:focus { &:focus {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
text-decoration: underline; text-decoration: underline;
......
...@@ -19,7 +19,7 @@ const StyledRangeInput = styled.input<{ size: number }>` ...@@ -19,7 +19,7 @@ const StyledRangeInput = styled.input<{ size: number }>`
-webkit-appearance: none; -webkit-appearance: none;
height: ${({ size }) => size}px; height: ${({ size }) => size}px;
width: ${({ size }) => size}px; width: ${({ size }) => size}px;
background-color: #565a69; background-color: ${({ theme }) => theme.blue1};
border-radius: 100%; border-radius: 100%;
border: none; border: none;
transform: translateY(-50%); transform: translateY(-50%);
...@@ -62,7 +62,7 @@ const StyledRangeInput = styled.input<{ size: number }>` ...@@ -62,7 +62,7 @@ const StyledRangeInput = styled.input<{ size: number }>`
} }
&::-webkit-slider-runnable-track { &::-webkit-slider-runnable-track {
background: linear-gradient(90deg, ${({ theme }) => theme.bg5}, ${({ theme }) => theme.bg3}); background: linear-gradient(90deg, ${({ theme }) => theme.blue1}, ${({ theme }) => theme.blue2});
height: 2px; height: 2px;
} }
...@@ -96,7 +96,15 @@ interface InputSliderProps { ...@@ -96,7 +96,15 @@ interface InputSliderProps {
size?: number size?: number
} }
export default function Slider({ value, onChange, min = 0, step = 1, max = 100, size = 28 }: InputSliderProps) { export default function Slider({
value,
onChange,
min = 0,
step = 1,
max = 100,
size = 28,
...rest
}: InputSliderProps) {
const changeCallback = useCallback( const changeCallback = useCallback(
(e) => { (e) => {
onChange(parseInt(e.target.value)) onChange(parseInt(e.target.value))
...@@ -107,9 +115,10 @@ export default function Slider({ value, onChange, min = 0, step = 1, max = 100, ...@@ -107,9 +115,10 @@ export default function Slider({ value, onChange, min = 0, step = 1, max = 100,
return ( return (
<StyledRangeInput <StyledRangeInput
size={size} size={size}
{...rest}
type="range" type="range"
value={value} value={value}
style={{ width: '90%', marginLeft: 15, marginRight: 15, padding: '15px 0' }} style={{ padding: '15px 0' }}
onChange={changeCallback} onChange={changeCallback}
aria-labelledby="input slider" aria-labelledby="input slider"
step={step} step={step}
......
...@@ -17,6 +17,7 @@ import useAddTokenToMetamask from 'hooks/useAddTokenToMetamask' ...@@ -17,6 +17,7 @@ import useAddTokenToMetamask from 'hooks/useAddTokenToMetamask'
const Wrapper = styled.div` const Wrapper = styled.div`
width: 100%; width: 100%;
padding: 1rem;
` `
const Section = styled(AutoColumn)<{ inline?: boolean }>` const Section = styled(AutoColumn)<{ inline?: boolean }>`
padding: ${({ inline }) => (inline ? '0' : '24px')}; padding: ${({ inline }) => (inline ? '0' : '24px')};
......
import { TransactionResponse } from '@ethersproject/providers' import { TransactionResponse } from '@ethersproject/providers'
import { Currency, TokenAmount, Percent, ETHER } from '@uniswap/sdk-core' import { Currency, TokenAmount, Percent, ETHER } from '@uniswap/sdk-core'
import React, { useCallback, useContext, useMemo, useState } from 'react' import React, { useCallback, useContext, useMemo, useState } from 'react'
import { WETH9 } from '@uniswap/sdk-core'
import { Link2, AlertTriangle } from 'react-feather' import { Link2, AlertTriangle } from 'react-feather'
import ReactGA from 'react-ga' import ReactGA from 'react-ga'
import { useV3NFTPositionManagerContract } from '../../hooks/useContract' import { useV3NFTPositionManagerContract } from '../../hooks/useContract'
...@@ -225,17 +226,8 @@ export default function AddLiquidity({ ...@@ -225,17 +226,8 @@ export default function AddLiquidity({
setAttemptingTxn(false) setAttemptingTxn(false)
addTransaction(response, { addTransaction(response, {
summary: noLiquidity summary: noLiquidity
? 'Create Pool + ' ? `Create pool and add ${currencyA?.symbol}/${currencyB?.symbol} V3 liquidity`
: '' + 'Add ' + !depositADisabled : `Add ${currencyA?.symbol}/${currencyB?.symbol} V3 liquidity`,
? parsedAmounts[Field.CURRENCY_A]?.toSignificant(3) +
' ' +
currencies[Field.CURRENCY_A]?.symbol +
!outOfRange
: ''
? ' and '
: '' + !depositBDisabled
? parsedAmounts[Field.CURRENCY_B]?.toSignificant(3) + ' ' + currencies[Field.CURRENCY_B]?.symbol
: '',
}) })
setTxHash(response.hash) setTxHash(response.hash)
ReactGA.event({ ReactGA.event({
...@@ -273,13 +265,17 @@ export default function AddLiquidity({ ...@@ -273,13 +265,17 @@ export default function AddLiquidity({
const handleCurrencyASelect = useCallback( const handleCurrencyASelect = useCallback(
(currencyA: Currency) => { (currencyA: Currency) => {
const newCurrencyIdA = currencyId(currencyA) const newCurrencyIdA = currencyId(currencyA)
//switch order if same selected
if (newCurrencyIdA === currencyIdB) { if (newCurrencyIdA === currencyIdB) {
history.push(`/add/${currencyIdB}/${currencyIdA}`) history.push(`/add/${currencyIdB}/${currencyIdA}`)
} else if (chainId && newCurrencyIdA === WETH9[chainId]?.address && currencyIdB === 'ETH') {
// prevent eth / weth
history.push(`/add/${newCurrencyIdA}`)
} else { } else {
history.push(`/add/${newCurrencyIdA}/${currencyIdB ?? 'ETH'}`) history.push(`/add/${newCurrencyIdA}/${currencyIdB ?? 'ETH'}`)
} }
}, },
[currencyIdB, history, currencyIdA] [currencyIdB, chainId, history, currencyIdA]
) )
const handleCurrencyBSelect = useCallback( const handleCurrencyBSelect = useCallback(
(currencyB: Currency) => { (currencyB: Currency) => {
...@@ -290,11 +286,14 @@ export default function AddLiquidity({ ...@@ -290,11 +286,14 @@ export default function AddLiquidity({
} else { } else {
history.push(`/add/${newCurrencyIdB}`) history.push(`/add/${newCurrencyIdB}`)
} }
} else if (chainId && newCurrencyIdB === WETH9[chainId]?.address && currencyIdA === 'ETH') {
// prevent eth / weth
history.push(`/add/${newCurrencyIdB}`)
} else { } else {
history.push(`/add/${currencyIdA ?? 'ETH'}/${newCurrencyIdB}`) history.push(`/add/${currencyIdA ?? 'ETH'}/${newCurrencyIdB}`)
} }
}, },
[currencyIdA, history, currencyIdB] [currencyIdA, chainId, currencyIdB, history]
) )
const handleFeePoolSelect = useCallback( const handleFeePoolSelect = useCallback(
......
...@@ -26,6 +26,7 @@ export const RangeBadge = styled(Card)<{ inRange?: boolean }>` ...@@ -26,6 +26,7 @@ export const RangeBadge = styled(Card)<{ inRange?: boolean }>`
font-weight: 500; font-weight: 500;
border-radius: 8px; border-radius: 8px;
padding: 4px 6px; padding: 4px 6px;
color: ${({ theme }) => theme.black};
background-color: ${({ inRange, theme }) => (inRange ? theme.green1 : theme.yellow2)}; background-color: ${({ inRange, theme }) => (inRange ? theme.green1 : theme.yellow2)};
` `
......
...@@ -48,17 +48,17 @@ const ResponsiveGrid = styled.div` ...@@ -48,17 +48,17 @@ const ResponsiveGrid = styled.div`
display: grid; display: grid;
grid-gap: 1em; grid-gap: 1em;
grid-template-columns: 1.5fr repeat(3, 1fr); grid-template-columns: 1.5fr repeat(2, 1fr);
@media screen and (max-width: 900px) { @media screen and (max-width: 900px) {
grid-template-columns: 1.5fr repeat(3, 1fr); grid-template-columns: 1.5fr repeat(2, 1fr);
& :nth-child(4) { & :nth-child(4) {
display: none; display: none;
} }
} }
@media screen and (max-width: 700px) { @media screen and (max-width: 700px) {
grid-template-columns: 20px 1.5fr repeat(3, 1fr); grid-template-columns: 20px 1.5fr repeat(2, 1fr);
& :nth-child(4) { & :nth-child(4) {
display: none; display: none;
} }
...@@ -288,9 +288,8 @@ export function PositionPage({ ...@@ -288,9 +288,8 @@ export function PositionPage({
<AutoColumn gap="lg"> <AutoColumn gap="lg">
<ResponsiveGrid> <ResponsiveGrid>
<Label>Tokens</Label> <Label>Tokens</Label>
<Label end={true}>Current</Label> <Label end={true}>Amount Deposited</Label>
<Label end={true}>Fees</Label> <Label end={true}>Fees</Label>
<Label end={true}>USD Value</Label>
</ResponsiveGrid> </ResponsiveGrid>
<ResponsiveGrid> <ResponsiveGrid>
<RowFixed> <RowFixed>
...@@ -299,7 +298,6 @@ export function PositionPage({ ...@@ -299,7 +298,6 @@ export function PositionPage({
</RowFixed> </RowFixed>
<Label end={true}>{position?.amount0.toSignificant(4)}</Label> <Label end={true}>{position?.amount0.toSignificant(4)}</Label>
<Label end={true}>{feeValue0 ? formatTokenAmount(feeValue0, 4) : '-'}</Label> <Label end={true}>{feeValue0 ? formatTokenAmount(feeValue0, 4) : '-'}</Label>
<Label end={true}>-</Label>
</ResponsiveGrid> </ResponsiveGrid>
<ResponsiveGrid> <ResponsiveGrid>
<RowFixed> <RowFixed>
...@@ -308,7 +306,6 @@ export function PositionPage({ ...@@ -308,7 +306,6 @@ export function PositionPage({
</RowFixed> </RowFixed>
<Label end={true}>{position?.amount1.toSignificant(4)}</Label> <Label end={true}>{position?.amount1.toSignificant(4)}</Label>
<Label end={true}>{feeValue1 ? formatTokenAmount(feeValue1, 4) : '-'}</Label> <Label end={true}>{feeValue1 ? formatTokenAmount(feeValue1, 4) : '-'}</Label>
<Label end={true}>-</Label>
</ResponsiveGrid> </ResponsiveGrid>
</AutoColumn> </AutoColumn>
</DarkCard> </DarkCard>
...@@ -322,13 +319,13 @@ export function PositionPage({ ...@@ -322,13 +319,13 @@ export function PositionPage({
<RowFixed> <RowFixed>
<TYPE.label>{price0Lower?.toSignificant(4)}</TYPE.label> <TYPE.label>{price0Lower?.toSignificant(4)}</TYPE.label>
<TYPE.label ml="10px"> <TYPE.label ml="10px">
{currency1?.symbol} / {currency0?.symbol} {currency0?.symbol} / {currency1?.symbol}
</TYPE.label> </TYPE.label>
</RowFixed> </RowFixed>
<RowFixed> <RowFixed>
<TYPE.label>{price1Lower?.toSignificant(4)}</TYPE.label> <TYPE.label>{price1Lower?.toSignificant(4)}</TYPE.label>
<TYPE.label ml="10px"> <TYPE.label ml="10px">
{currency0?.symbol} / {currency1?.symbol} {currency1?.symbol} / {currency0?.symbol}
</TYPE.label> </TYPE.label>
</RowFixed> </RowFixed>
<DarkBadge> <DarkBadge>
...@@ -346,13 +343,13 @@ export function PositionPage({ ...@@ -346,13 +343,13 @@ export function PositionPage({
<RowFixed> <RowFixed>
<TYPE.label>{price0Upper?.toSignificant(4)}</TYPE.label> <TYPE.label>{price0Upper?.toSignificant(4)}</TYPE.label>
<TYPE.label ml="10px"> <TYPE.label ml="10px">
{currency1?.symbol} / {currency0?.symbol} {currency0?.symbol} / {currency1?.symbol}
</TYPE.label> </TYPE.label>
</RowFixed> </RowFixed>
<RowFixed> <RowFixed>
<TYPE.label>{price1Upper?.toSignificant(4)}</TYPE.label> <TYPE.label>{price1Upper?.toSignificant(4)}</TYPE.label>
<TYPE.label ml="10px"> <TYPE.label ml="10px">
{currency0?.symbol} / {currency1?.symbol} {currency1?.symbol} / {currency0?.symbol}
</TYPE.label> </TYPE.label>
</RowFixed> </RowFixed>
<DarkBadge> <DarkBadge>
......
...@@ -138,7 +138,7 @@ export default function Pool() { ...@@ -138,7 +138,7 @@ export default function Pool() {
<AutoColumn gap="lg" style={{ width: '100%' }}> <AutoColumn gap="lg" style={{ width: '100%' }}>
<TitleRow style={{ marginTop: '1rem' }} padding={'0'}> <TitleRow style={{ marginTop: '1rem' }} padding={'0'}>
<HideSmall> <HideSmall>
<TYPE.mediumHeader>{t('Pool Overview')}</TYPE.mediumHeader> <TYPE.mediumHeader>Your Positions</TYPE.mediumHeader>
</HideSmall> </HideSmall>
<ButtonRow> <ButtonRow>
<Menu <Menu
......
This diff is collapsed.
import { MaxButton } from 'pages/Pool/styleds'
import styled from 'styled-components'
export const Wrapper = styled.div`
position: relative;
padding: 20px;
min-width: 460px;
`
export const SmallMaxButton = styled(MaxButton)`
font-size: 12px;
`
...@@ -89,14 +89,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -89,14 +89,7 @@ export default function Swap({ history }: RouteComponentProps) {
// swap state // swap state
const { independentField, typedValue, recipient } = useSwapState() const { independentField, typedValue, recipient } = useSwapState()
const { const { v2Trade, currencyBalances, parsedAmount, currencies, inputError: swapInputError } = useDerivedSwapInfo()
v2Trade,
currencyBalances,
parsedAmount,
currencies,
v3Route,
inputError: swapInputError,
} = useDerivedSwapInfo()
const { wrapType, execute: onWrap, inputError: wrapInputError } = useWrapCallback( const { wrapType, execute: onWrap, inputError: wrapInputError } = useWrapCallback(
currencies[Field.INPUT], currencies[Field.INPUT],
......
...@@ -24,6 +24,7 @@ export function useDerivedV3BurnInfo( ...@@ -24,6 +24,7 @@ export function useDerivedV3BurnInfo(
liquidityValue1?: TokenAmount liquidityValue1?: TokenAmount
feeValue0?: TokenAmount feeValue0?: TokenAmount
feeValue1?: TokenAmount feeValue1?: TokenAmount
outOfRange: boolean
error?: string error?: string
} { } {
const { account } = useActiveWeb3React() const { account } = useActiveWeb3React()
...@@ -52,6 +53,9 @@ export function useDerivedV3BurnInfo( ...@@ -52,6 +53,9 @@ export function useDerivedV3BurnInfo(
const [feeValue0, feeValue1] = useV3PositionFees(pool ?? undefined, position) const [feeValue0, feeValue1] = useV3PositionFees(pool ?? undefined, position)
const outOfRange =
pool && position ? pool.tickCurrent < position.tickLower || pool.tickCurrent > position.tickUpper : false
let error: string | undefined let error: string | undefined
if (!account) { if (!account) {
error = 'Connect Wallet' error = 'Connect Wallet'
...@@ -65,6 +69,7 @@ export function useDerivedV3BurnInfo( ...@@ -65,6 +69,7 @@ export function useDerivedV3BurnInfo(
liquidityValue1, liquidityValue1,
feeValue0, feeValue0,
feeValue1, feeValue1,
outOfRange,
error, error,
} }
} }
......
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