Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abf127c596 | ||
|
|
4d3f870b93 | ||
|
|
452f2dc3c0 | ||
|
|
b6bd59f2b1 | ||
|
|
0190b5a408 | ||
|
|
d6030dcd45 | ||
|
|
f0e2a491dc |
@@ -49,7 +49,7 @@
|
||||
"@uniswap/v2-sdk": "^1.0.9",
|
||||
"@uniswap/v3-core": "1.0.0",
|
||||
"@uniswap/v3-periphery": "1.0.0",
|
||||
"@uniswap/v3-sdk": "^1.0.3",
|
||||
"@uniswap/v3-sdk": "^1.0.8",
|
||||
"@web3-react/core": "^6.0.9",
|
||||
"@web3-react/fortmatic-connector": "^6.0.9",
|
||||
"@web3-react/injected-connector": "^6.0.7",
|
||||
|
||||
@@ -6,7 +6,7 @@ import { NavLink, Link as HistoryLink } from 'react-router-dom'
|
||||
|
||||
import { ArrowLeft } from 'react-feather'
|
||||
import { RowBetween } from '../Row'
|
||||
import Settings from '../Settings'
|
||||
import SettingsTab from '../Settings'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { AppDispatch } from 'state'
|
||||
import { resetMintState } from 'state/mint/actions'
|
||||
@@ -80,7 +80,7 @@ export function FindPoolTabs({ origin }: { origin: string }) {
|
||||
<StyledArrowLeft />
|
||||
</HistoryLink>
|
||||
<ActiveText>Import Pool</ActiveText>
|
||||
<Settings />
|
||||
<SettingsTab />
|
||||
</RowBetween>
|
||||
</Tabs>
|
||||
)
|
||||
@@ -118,7 +118,7 @@ export function AddRemoveTabs({
|
||||
<TYPE.mediumHeader fontWeight={500} fontSize={20}>
|
||||
{creating ? 'Create a pair' : adding ? 'Add Liquidity' : 'Remove Liquidity'}
|
||||
</TYPE.mediumHeader>
|
||||
<Settings />
|
||||
<SettingsTab />
|
||||
</RowBetween>
|
||||
</Tabs>
|
||||
)
|
||||
|
||||
@@ -107,9 +107,9 @@ export default function SlippageTabs({ rawSlippage, setRawSlippage, deadline, se
|
||||
let slippageError: SlippageError | undefined
|
||||
if (slippageInput !== '' && !slippageInputIsValid) {
|
||||
slippageError = SlippageError.InvalidInput
|
||||
} else if (slippageInputIsValid && rawSlippage < 50) {
|
||||
} else if (slippageInputIsValid && rawSlippage < 5) {
|
||||
slippageError = SlippageError.RiskyLow
|
||||
} else if (slippageInputIsValid && rawSlippage > 500) {
|
||||
} else if (slippageInputIsValid && rawSlippage > 100) {
|
||||
slippageError = SlippageError.RiskyHigh
|
||||
} else {
|
||||
slippageError = undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import styled from 'styled-components'
|
||||
import Settings from '../Settings'
|
||||
import SettingsTab from '../Settings'
|
||||
|
||||
import { RowBetween, RowFixed } from '../Row'
|
||||
import { TYPE } from '../../theme'
|
||||
@@ -23,7 +23,7 @@ export default function SwapHeader() {
|
||||
<RowFixed>
|
||||
{/* <TradeInfo disabled={!trade} trade={trade} /> */}
|
||||
{/* <div style={{ width: '8px' }}></div> */}
|
||||
<Settings />
|
||||
<SettingsTab />
|
||||
</RowFixed>
|
||||
</RowBetween>
|
||||
</StyledSwapHeader>
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Text } from 'rebass'
|
||||
import { AutoColumn } from '../../components/Column'
|
||||
import CurrencyLogo from '../../components/CurrencyLogo'
|
||||
import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
|
||||
import QuestionHelper from '../../components/QuestionHelper'
|
||||
import { AutoRow, RowBetween, RowFixed } from '../../components/Row'
|
||||
import { useV2LiquidityTokenPermit } from '../../hooks/useERC20Permit'
|
||||
import { useTotalSupply } from '../../hooks/useTotalSupply'
|
||||
@@ -46,6 +45,7 @@ import DoubleCurrencyLogo from 'components/DoubleLogo'
|
||||
import Badge, { BadgeVariant } from 'components/Badge'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { AppDispatch } from 'state'
|
||||
import SettingsTab from 'components/Settings'
|
||||
|
||||
const ZERO = JSBI.BigInt(0)
|
||||
|
||||
@@ -673,9 +673,7 @@ export default function MigrateV2Pair({
|
||||
<AutoRow style={{ alignItems: 'center', justifyContent: 'space-between' }} gap="8px">
|
||||
<BackArrow to="/migrate/v2" />
|
||||
<TYPE.mediumHeader>Migrate V2 Liquidity</TYPE.mediumHeader>
|
||||
<div style={{ opacity: 0 }}>
|
||||
<QuestionHelper text="Migrate your liquidity tokens from Uniswap V2 to Uniswap V3." />
|
||||
</div>
|
||||
<SettingsTab />
|
||||
</AutoRow>
|
||||
|
||||
{!account ? (
|
||||
|
||||
@@ -10,11 +10,11 @@ export function formatTokenAmount(amount: TokenAmount | undefined, sigFigs: numb
|
||||
return '0'
|
||||
}
|
||||
|
||||
if (parseFloat(amount.toFixed(sigFigs)) < 0.0001) {
|
||||
if (parseFloat(amount.toFixed(Math.min(sigFigs, amount.token.decimals))) < 0.0001) {
|
||||
return '<0.0001'
|
||||
}
|
||||
|
||||
return amount.toSignificant(sigFigs)
|
||||
return amount.toFixed(Math.min(sigFigs, amount.token.decimals))
|
||||
}
|
||||
|
||||
export function formatPrice(price: Price | undefined, sigFigs: number) {
|
||||
|
||||
@@ -28,11 +28,16 @@ describe('utils', () => {
|
||||
describe('#calculateSlippageAmount', () => {
|
||||
it('bounds are correct', () => {
|
||||
const tokenAmount = new TokenAmount(new Token(ChainId.MAINNET, AddressZero, 0), '100')
|
||||
expect(() => calculateSlippageAmount(tokenAmount, new Percent(-1, 10_000))).toThrow()
|
||||
expect(() => calculateSlippageAmount(tokenAmount, new Percent(-1, 10_000))).toThrow('Unexpected slippage')
|
||||
expect(() => calculateSlippageAmount(tokenAmount, new Percent(10_001, 10_000))).toThrow('Unexpected slippage')
|
||||
expect(calculateSlippageAmount(tokenAmount, new Percent(0, 10_000)).map((bound) => bound.toString())).toEqual([
|
||||
'100',
|
||||
'100',
|
||||
])
|
||||
expect(calculateSlippageAmount(tokenAmount, new Percent(5, 100)).map((bound) => bound.toString())).toEqual([
|
||||
'95',
|
||||
'105',
|
||||
])
|
||||
expect(calculateSlippageAmount(tokenAmount, new Percent(100, 10_000)).map((bound) => bound.toString())).toEqual([
|
||||
'99',
|
||||
'101',
|
||||
@@ -44,7 +49,6 @@ describe('utils', () => {
|
||||
expect(
|
||||
calculateSlippageAmount(tokenAmount, new Percent(10000, 10_000)).map((bound) => bound.toString())
|
||||
).toEqual(['0', '200'])
|
||||
expect(() => calculateSlippageAmount(tokenAmount, new Percent(10001, 10_000))).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getAddress } from '@ethersproject/address'
|
||||
import { AddressZero } from '@ethersproject/constants'
|
||||
import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
|
||||
import { BigNumber } from '@ethersproject/bignumber'
|
||||
import { ChainId, Percent, Token, CurrencyAmount, Currency, ETHER } from '@uniswap/sdk-core'
|
||||
import { ChainId, Percent, Token, CurrencyAmount, Currency, ETHER, Fraction } from '@uniswap/sdk-core'
|
||||
import { JSBI } from '@uniswap/v2-sdk'
|
||||
import { FeeAmount } from '@uniswap/v3-sdk/dist/'
|
||||
import { TokenAddressMap } from '../state/lists/hooks'
|
||||
@@ -63,17 +63,10 @@ export function calculateGasMargin(value: BigNumber): BigNumber {
|
||||
return value.mul(BigNumber.from(10000).add(BigNumber.from(1000))).div(BigNumber.from(10000))
|
||||
}
|
||||
|
||||
const ONE = new Fraction(1, 1)
|
||||
export function calculateSlippageAmount(value: CurrencyAmount, slippage: Percent): [JSBI, JSBI] {
|
||||
if (
|
||||
JSBI.lessThan(slippage.numerator, JSBI.BigInt(0)) ||
|
||||
JSBI.greaterThan(slippage.numerator, JSBI.BigInt(10_000)) ||
|
||||
!JSBI.equal(slippage.denominator, JSBI.BigInt(10_000))
|
||||
)
|
||||
throw new Error('Unexpected slippage')
|
||||
return [
|
||||
JSBI.divide(JSBI.multiply(value.raw, JSBI.subtract(JSBI.BigInt(10000), slippage.numerator)), JSBI.BigInt(10000)),
|
||||
JSBI.divide(JSBI.multiply(value.raw, JSBI.add(JSBI.BigInt(10000), slippage.numerator)), JSBI.BigInt(10000)),
|
||||
]
|
||||
if (slippage.lessThan(0) || slippage.greaterThan(ONE)) throw new Error('Unexpected slippage')
|
||||
return [value.multiply(ONE.subtract(slippage)).quotient, value.multiply(ONE.add(slippage)).quotient]
|
||||
}
|
||||
|
||||
// account is not optional
|
||||
|
||||
@@ -4149,10 +4149,10 @@
|
||||
"@uniswap/v3-core" "1.0.0"
|
||||
base64-sol "1.0.1"
|
||||
|
||||
"@uniswap/v3-sdk@^1.0.3":
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@uniswap/v3-sdk/-/v3-sdk-1.0.3.tgz#8f47b5f8cc8997992811a242ef202f9a8c4797cf"
|
||||
integrity sha512-izIrHTAXCeMhfye0nHntoAS0UTbpa8HyGSD++Zmy+kROeb2gSAcpXvnLHzRDIPxq0G4rOH0h05Y5fhHAxaXj5w==
|
||||
"@uniswap/v3-sdk@^1.0.8":
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@uniswap/v3-sdk/-/v3-sdk-1.0.8.tgz#c85b229ac9448d19dfb1cb4a7891478c003a72f4"
|
||||
integrity sha512-Kg0P4KZI07m6B6L5EEtkEX/Q6QOdbWnVAHiy8y1XJOxORGw4DS0vklG5IRJAVhgLsVlosbmjxELsBjVMuKtypQ==
|
||||
dependencies:
|
||||
"@ethersproject/abi" "^5.0.12"
|
||||
"@ethersproject/solidity" "^5.0.9"
|
||||
|
||||
Reference in New Issue
Block a user