Compare commits

...

4 Commits

Author SHA1 Message Date
Moody Salem
021aab6547 fix(wallet): workaround the ethers bug to fix other wallets 2021-05-06 11:10:45 -04:00
Noah Zinsmeister
81af31eec1 estimate gas in migrate v2 2021-05-06 10:40:19 -04:00
Moody Salem
d3898cf900 fix(wallet): workaround for coinbase wallet / fortmatic 2021-05-06 10:09:41 -04:00
Moody Salem
b8f61d5f90 fix(positions list): base/currency ordering 2021-05-06 09:57:12 -04:00
3 changed files with 31 additions and 19 deletions

View File

@@ -202,8 +202,8 @@ export default function PositionListItem({ positionDetails }: PositionListItemPr
// prices
let { priceLower, priceUpper, base, quote } = getPriceOrderingFromPositionForUI(position)
const inverted = token1 ? base?.equals(token1) : undefined
const currencyQuote = inverted ? currency0 : currency1
const currencyBase = inverted ? currency1 : currency0
const currencyQuote = inverted ? currency1 : currency0
const currencyBase = inverted ? currency0 : currency1
// check if price is within range
const outOfRange: boolean = pool ? pool.tickCurrent < tickLower || pool.tickCurrent >= tickUpper : false

View File

@@ -16,7 +16,7 @@ import { usePairContract, useV2MigratorContract } from '../../hooks/useContract'
import { NEVER_RELOAD, useSingleCallResult } from '../../state/multicall/hooks'
import { useTokenBalance } from '../../state/wallet/hooks'
import { BackArrow, ExternalLink, TYPE } from '../../theme'
import { getEtherscanLink, isAddress } from '../../utils'
import { calculateGasMargin, getEtherscanLink, isAddress } from '../../utils'
import { BodyWrapper } from '../AppBody'
import { V3_MIGRATOR_ADDRESSES } from 'constants/v3'
import { PoolState, usePool } from 'hooks/usePools'
@@ -274,7 +274,7 @@ function V2PairMigration({
const deadlineToUse = signatureData?.deadline ?? deadline
const data = []
const data: string[] = []
// permit if necessary
if (signatureData) {
@@ -324,19 +324,24 @@ function V2PairMigration({
)
setConfirmingMigration(true)
migrator
.multicall(data)
.then((response: TransactionResponse) => {
ReactGA.event({
category: 'Migrate',
action: `${isNotUniswap ? 'SushiSwap' : 'V2'}->V3`,
label: `${currency0.symbol}/${currency1.symbol}`,
})
addTransaction(response, {
summary: `Migrate ${currency0.symbol}/${currency1.symbol} liquidity to V3`,
})
setPendingMigrationHash(response.hash)
migrator.estimateGas
.multicall(data)
.then((gasEstimate) => {
return migrator
.multicall(data, { gasLimit: calculateGasMargin(gasEstimate) })
.then((response: TransactionResponse) => {
ReactGA.event({
category: 'Migrate',
action: `${isNotUniswap ? 'SushiSwap' : 'V2'}->V3`,
label: `${currency0.symbol}/${currency1.symbol}`,
})
addTransaction(response, {
summary: `Migrate ${currency0.symbol}/${currency1.symbol} liquidity to V3`,
})
setPendingMigrationHash(response.hash)
})
})
.catch(() => {
setConfirmingMigration(false)

View File

@@ -1,8 +1,15 @@
import { Web3Provider } from '@ethersproject/providers'
import { Web3Provider, Network } from '@ethersproject/providers'
class WorkaroundWeb3Provider extends Web3Provider {
private _detectNetworkResult: Promise<Network> | null = null
async detectNetwork(): Promise<Network> {
return this._detectNetworkResult ?? (this._detectNetworkResult = this._uncachedDetectNetwork())
}
}
export default function getLibrary(provider: any): Web3Provider {
// latest ethers version tries to detect the network which fails
const library = new Web3Provider(
const library = new WorkaroundWeb3Provider(
provider,
typeof provider.chainId === 'number'
? provider.chainId