Compare commits

...

6 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
6 changed files with 44 additions and 13 deletions

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

@@ -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"