Compare commits

...

9 Commits

Author SHA1 Message Date
Ian Lapham
cccf149568 fix: update tick parsing to handle min/max prices (#1613)
* update tick parsing to handle min/max prices

* remove fee tier step
2021-05-17 20:19:15 -04:00
Justin Domingue
604ea49567 Revert "lazy load uncommon routes to reduce initial bundle size (#1597)" (#1611)
This reverts commit 4c0c6dfde6.
2021-05-17 11:24:31 -07:00
Justin Domingue
4c0c6dfde6 lazy load uncommon routes to reduce initial bundle size (#1597) 2021-05-17 11:03:49 -07:00
Noah Zinsmeister
a160bb8f02 Merge remote-tracking branch 'refs/remotes/origin/main' 2021-05-17 11:54:17 -04:00
Noah Zinsmeister
e86946b104 bump to sdk version that fixes mint slippage bug
closes #1573
2021-05-17 11:54:06 -04:00
Moody Salem
03108b981e update README.md 2021-05-17 10:14:35 -05:00
Moody Salem
ae27e245b4 replace the message when we fail to parse an error 2021-05-14 14:13:13 -05:00
Moody Salem
897f354202 chore: bump mathieudutour/github-tag-action to latest release version to fix generated changelogs
https://github.com/Uniswap/uniswap-interface/issues/1572
2021-05-14 10:56:57 -05:00
Moody Salem
4745052f0e fix: break words in swap error messages (fixes https://github.com/Uniswap/uniswap-interface/issues/1462) 2021-05-14 10:50:55 -05:00
10 changed files with 59 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ jobs:
- name: Bump version and push tag
id: github_tag_action
uses: mathieudutour/github-tag-action@v4.5
uses: mathieudutour/github-tag-action@331898d5052eedac9b15fec867b5ba66ebf9b692
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: .*

View File

@@ -41,8 +41,17 @@ yarn start
**Please open all pull requests against the `main` branch.**
CI checks will run against all PRs.
## Accessing Uniswap Interface V1
## Accessing Uniswap V2
The Uniswap Interface supports swapping against, and migrating or removing liquidity from Uniswap V1. However,
if you would like to use Uniswap V1, the Uniswap V1 interface for mainnet and testnets is accessible via IPFS gateways
The Uniswap Interface supports swapping, adding liquidity, removing liquidity and migrating liquidity for
Uniswap protocol V2.
- Swap on Uniswap V2: https://app.uniswap.org/#/swap?use=v2
- View V2 liquidity: https://app.uniswap.org/#/pool/v2
- Add V2 liquidity: https://app.uniswap.org/#/add/v2
- Migrate V2 liquidity to V3: https://app.uniswap.org/#/migrate/v2
## Accessing Uniswap V1
The Uniswap V1 interface for mainnet and testnets is accessible via IPFS gateways
linked from the [v1.0.0 release](https://github.com/Uniswap/uniswap-interface/releases/tag/v1.0.0).

View File

@@ -51,7 +51,7 @@
"@uniswap/v2-sdk": "^3.0.0-alpha.0",
"@uniswap/v3-core": "1.0.0",
"@uniswap/v3-periphery": "1.0.0",
"@uniswap/v3-sdk": "^3.0.0-alpha.4",
"@uniswap/v3-sdk": "^3.0.0-alpha.5",
"@web3-react/core": "^6.0.9",
"@web3-react/fortmatic-connector": "^6.0.9",
"@web3-react/injected-connector": "^6.0.7",

View File

@@ -184,7 +184,12 @@ export function TransactionErrorContent({ message, onDismiss }: { message: strin
</RowBetween>
<AutoColumn style={{ marginTop: 20, padding: '2rem 0' }} gap="24px" justify="center">
<AlertTriangle color={theme.red1} style={{ strokeWidth: 1.5 }} size={64} />
<Text fontWeight={500} fontSize={16} color={theme.red1} style={{ textAlign: 'center', width: '85%' }}>
<Text
fontWeight={500}
fontSize={16}
color={theme.red1}
style={{ textAlign: 'center', width: '85%', wordBreak: 'break-word' }}
>
{message}
</Text>
</AutoColumn>

View File

@@ -171,7 +171,7 @@ export function SwapCallbackError({ error }: { error: string }) {
<SwapCallbackErrorInnerAlertTriangle>
<AlertTriangle size={24} />
</SwapCallbackErrorInnerAlertTriangle>
<p>{error}</p>
<p style={{ wordBreak: 'break-word' }}>{error}</p>
</SwapCallbackErrorInner>
)
}

View File

@@ -166,7 +166,13 @@ export function swapErrorToUserReadableMessage(error: any): string {
case 'TF':
return 'The output token cannot be transferred. There may be an issue with the output token. Note fee on transfer and rebase tokens are incompatible with Uniswap V3.'
default:
return `Unknown error${reason ? `: "${reason}"` : ''}. Please join the Discord to get help.`
if (reason?.indexOf('undefined is not an object') !== -1) {
console.error(error, reason)
return 'An error occurred when trying to execute this swap. You may need to increase your slippage tolerance. If that does not work, there may be an incompatibility with the token you are trading. Note fee on transfer and rebase tokens are incompatible with Uniswap V3.'
}
return `Unknown error${
reason ? `: "${reason}"` : ''
}. Try increasing your slippage tolerance. Note fee on transfer and rebase tokens are incompatible with Uniswap V3.`
}
}

View File

@@ -208,6 +208,7 @@ function V2PairMigration({
tickUpper,
amount0: token0Value.quotient,
amount1: token1Value.quotient,
useFullPrecision: false, // we don't want full precision as this is used to calculate slippage amounts
})
: undefined

View File

@@ -286,6 +286,7 @@ export function useV3DerivedMintInfo(
tickLower,
tickUpper,
amount0: independentAmount.quotient,
useFullPrecision: true, // we want full precision for the theoretical position
})
: Position.fromAmount1({
pool: poolForPosition,
@@ -356,7 +357,7 @@ export function useV3DerivedMintInfo(
return undefined
}
// mark as 0 if disbaled because out of range
// mark as 0 if disabled because out of range
const amount0 = !deposit0Disabled
? parsedAmounts?.[tokenA.equals(poolForPosition.token0) ? Field.CURRENCY_A : Field.CURRENCY_B]?.quotient
: BIG_INT_ZERO
@@ -371,6 +372,7 @@ export function useV3DerivedMintInfo(
tickUpper,
amount0,
amount1,
useFullPrecision: true, // we want full precision for the theoretical position
})
} else {
return undefined

View File

@@ -1,6 +1,14 @@
import { priceToClosestTick, nearestUsableTick, FeeAmount, TICK_SPACINGS } from '@uniswap/v3-sdk/dist/'
import {
priceToClosestTick,
nearestUsableTick,
FeeAmount,
TICK_SPACINGS,
encodeSqrtRatioX96,
TickMath,
} from '@uniswap/v3-sdk/dist/'
import { Price, Token } from '@uniswap/sdk-core'
import { tryParseAmount } from 'state/swap/hooks'
import JSBI from 'jsbi'
export function tryParseTick(
baseToken?: Token,
@@ -12,8 +20,8 @@ export function tryParseTick(
return undefined
}
// base token fixed at 1 unit, quote token amount based on typed input
const amount = tryParseAmount(value, quoteToken)
const amountOne = tryParseAmount('1', baseToken)
if (!amount || !amountOne) return undefined
@@ -21,8 +29,19 @@ export function tryParseTick(
// parse the typed value into a price
const price = new Price(baseToken, quoteToken, amountOne.quotient, amount.quotient)
// this function is agnostic to the base, will always return the correct tick
const tick = priceToClosestTick(price)
let tick: number
// check price is within min/max bounds, if outside return min/max
const sqrtRatioX96 = encodeSqrtRatioX96(price.numerator, price.denominator)
if (JSBI.greaterThanOrEqual(sqrtRatioX96, TickMath.MAX_SQRT_RATIO)) {
tick = TickMath.MAX_TICK
} else if (JSBI.lessThanOrEqual(sqrtRatioX96, TickMath.MIN_SQRT_RATIO)) {
tick = TickMath.MIN_TICK
} else {
// this function is agnostic to the base, will always return the correct tick
tick = priceToClosestTick(price)
}
return nearestUsableTick(tick, TICK_SPACINGS[feeAmount])
}

View File

@@ -4478,10 +4478,10 @@
"@uniswap/v3-core" "1.0.0"
base64-sol "1.0.1"
"@uniswap/v3-sdk@^3.0.0-alpha.4":
version "3.0.0-alpha.4"
resolved "https://registry.yarnpkg.com/@uniswap/v3-sdk/-/v3-sdk-3.0.0-alpha.4.tgz#e8bf26291fd74e36a5a3d9b88f1809a7aceb7d3a"
integrity sha512-BcEH8eHt+b6eaaiLDlzbFox2NquP1H7KgrgmNjAlU/et+vC4azdfNN6SsRlTFzhioPOwHlAKAAZJLq+yzboDOQ==
"@uniswap/v3-sdk@^3.0.0-alpha.5":
version "3.0.0-alpha.5"
resolved "https://registry.yarnpkg.com/@uniswap/v3-sdk/-/v3-sdk-3.0.0-alpha.5.tgz#b583bd2399abee1b329debb930f903d0d87ccc7c"
integrity sha512-swuEzbQAzNw9ZA//EZN/qT3g6V3X5kTnB8FK8xRHAn3WE4mCMHMxut4Wt6iV24VlTHuVzx9EIoHS53rXHwjv4Q==
dependencies:
"@ethersproject/abi" "^5.0.12"
"@ethersproject/solidity" "^5.0.9"