Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid import conflicts between v4-sdk and ethers-v6 #187

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdks/v4-sdk/src/PositionManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ether, Percent, Token } from '@uniswap/sdk-core'
import { ethers } from 'ethers'
import { _TypedDataEncoder, id } from '@ethersproject/hash'
import {
EMPTY_BYTES,
EMPTY_HOOK,
Expand Down Expand Up @@ -566,10 +566,10 @@ describe('PositionManager', () => {
})
expect(values).toEqual(permit)
// get typehash
const encodedType = ethers.utils._TypedDataEncoder.from(types).encodeType('Permit')
const encodedType = _TypedDataEncoder.from(types).encodeType('Permit')

// Compute the type hash by hashing the encoded type
const typeHash = ethers.utils.id(encodedType)
const typeHash = id(encodedType)
// ref https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/ERC721Permit.sol
expect(typeHash).toEqual('0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad')
})
Expand Down
3 changes: 2 additions & 1 deletion sdks/v4-sdk/src/entities/pool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import invariant from 'tiny-invariant'
import { defaultAbiCoder } from '@ethersproject/abi'
import { isAddress } from '@ethersproject/address'
import { keccak256 } from '@ethersproject/solidity'
import { BigintIsh, Currency, CurrencyAmount, Price } from '@uniswap/sdk-core'
import {
Expand All @@ -10,7 +12,6 @@ import {
TickListDataProvider,
TickMath,
} from '@uniswap/v3-sdk'
import { defaultAbiCoder, isAddress } from 'ethers/lib/utils'
import { sortsBefore } from '../utils/sortsBefore'
import { ADDRESS_ZERO, NEGATIVE_ONE, Q192 } from '../internalConstants'
import JSBI from 'jsbi'
Expand Down
4 changes: 2 additions & 2 deletions sdks/v4-sdk/src/internalConstants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import JSBI from 'jsbi'
import { constants } from 'ethers'
import { AddressZero } from '@ethersproject/constants'
import { encodeSqrtRatioX96 } from '@uniswap/v3-sdk'

// constants used internally but not expected to be used externally
export const ADDRESS_ZERO = constants.AddressZero
export const ADDRESS_ZERO = AddressZero
export const NEGATIVE_ONE = JSBI.BigInt(-1)
export const ZERO = JSBI.BigInt(0)
export const ONE = JSBI.BigInt(1)
Expand Down
5 changes: 3 additions & 2 deletions sdks/v4-sdk/src/utils/v4BaseActionsParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai'
import { WETH9 } from '@uniswap/sdk-core'
import { BigNumber, ethers } from 'ethers'
import { BigNumber } from '@ethersproject/bignumber'
import { parseEther } from '@ethersproject/units'
import { Route } from '../entities/route'
import { encodeRouteToPath } from './encodeRouteToPath'
import { V4BaseActionsParser, V4RouterCall } from './v4BaseActionsParser'
Expand All @@ -9,7 +10,7 @@ import { USDC_WETH, DAI_USDC, DAI, USDC } from './v4Planner.test'

const addressOne = '0x0000000000000000000000000000000000000001'
const addressTwo = '0x0000000000000000000000000000000000000002'
const amount = ethers.utils.parseEther('1')
const amount = parseEther('1')

describe('Command Parser', () => {
type ParserTest = {
Expand Down
6 changes: 3 additions & 3 deletions sdks/v4-sdk/src/utils/v4BaseActionsParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from 'ethers'
import { defaultAbiCoder } from '@ethersproject/abi'
import { PoolKey } from '../entities/pool'
import { PathKey } from './encodeRouteToPath'
import { Actions, Subparser, V4_BASE_ACTIONS_ABI_DEFINITION } from './v4Planner'
Expand Down Expand Up @@ -53,14 +53,14 @@ export type SwapExactOut = {
// Parses V4Router actions
export abstract class V4BaseActionsParser {
public static parseCalldata(calldata: string): V4RouterCall {
const [actions, inputs] = ethers.utils.defaultAbiCoder.decode(['bytes', 'bytes[]'], calldata)
const [actions, inputs] = defaultAbiCoder.decode(['bytes', 'bytes[]'], calldata)

const actionTypes = V4BaseActionsParser.getActions(actions)

return {
actions: actionTypes.map((actionType: Actions, i: number) => {
const abiDef = V4_BASE_ACTIONS_ABI_DEFINITION[actionType]
const rawParams = ethers.utils.defaultAbiCoder.decode(
const rawParams = defaultAbiCoder.decode(
abiDef.map((command) => command.type),
inputs[i]
)
Expand Down
2 changes: 1 addition & 1 deletion sdks/v4-sdk/src/utils/v4Planner.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber } from 'ethers'
import { BigNumber } from '@ethersproject/bignumber'
import JSBI from 'jsbi'
import { CurrencyAmount, Ether, Percent, TradeType, Token, WETH9 } from '@uniswap/sdk-core'
import { encodeSqrtRatioX96, nearestUsableTick, TickMath } from '@uniswap/v3-sdk'
Expand Down
4 changes: 2 additions & 2 deletions sdks/v4-sdk/src/utils/v4Planner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import invariant from 'tiny-invariant'
import { defaultAbiCoder } from 'ethers/lib/utils'
import { BigNumber } from 'ethers'
import { defaultAbiCoder } from '@ethersproject/abi'
import { BigNumber } from '@ethersproject/bignumber'
import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
import { Trade } from '../entities/trade'
import { ADDRESS_ZERO, EMPTY_BYTES } from '../internalConstants'
Expand Down
Loading