forked from Uniswap/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from uniswapfoundation/feat/release-sdk-versio…
…n-update Feat/release sdk version update
- Loading branch information
Showing
41 changed files
with
359 additions
and
1,200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
"@types/node": "^16.7.13", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0", | ||
"@uniswap/sdk-core": "^3.1.0", | ||
"@uniswap/v3-sdk": "^3.9.0", | ||
"@uniswap/sdk-core": "npm:@koraykoska/uniswap-sdk-core@^6.0.9", | ||
"@uniswap/v3-sdk": "npm:@florian-s-a-w/[email protected]", | ||
"ethers": "^5.7.2", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
|
@@ -19,7 +19,7 @@ | |
"build": "react-scripts build", | ||
"lint": "yarn eslint .", | ||
"install:chain": "curl -L https://foundry.paradigm.xyz | bash && clear && echo $0 | exec && foundryup", | ||
"start:chain": "anvil --chain-id 1337 --fork-url" | ||
"start:chain": "anvil --chain-id 1 --fork-url" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,17 @@ | ||
import { ethers } from 'ethers' | ||
import { CurrentConfig } from '../config' | ||
import IUniswapV3PoolABI from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json' | ||
import { POOL_FACTORY_CONTRACT_ADDRESS } from './constants' | ||
import { getProvider } from './providers' | ||
import { computePoolAddress } from '@uniswap/v3-sdk' | ||
import { getProvider } from '../libs/providers' | ||
import { Pool } from '@uniswap/v3-sdk' | ||
|
||
interface PoolInfo { | ||
token0: string | ||
token1: string | ||
fee: number | ||
tickSpacing: number | ||
sqrtPriceX96: ethers.BigNumber | ||
liquidity: ethers.BigNumber | ||
tick: number | ||
} | ||
|
||
export async function getPoolInfo(): Promise<PoolInfo> { | ||
export async function getPool(): Promise<Pool> { | ||
const provider = getProvider() | ||
if (!provider) { | ||
throw new Error('No provider') | ||
} | ||
|
||
const currentPoolAddress = computePoolAddress({ | ||
factoryAddress: POOL_FACTORY_CONTRACT_ADDRESS, | ||
return Pool.initFromChain({ | ||
provider, | ||
tokenA: CurrentConfig.tokens.token0, | ||
tokenB: CurrentConfig.tokens.token1, | ||
fee: CurrentConfig.tokens.poolFee, | ||
}) | ||
|
||
const poolContract = new ethers.Contract( | ||
currentPoolAddress, | ||
IUniswapV3PoolABI.abi, | ||
provider | ||
) | ||
|
||
const [token0, token1, fee, tickSpacing, liquidity, slot0] = | ||
await Promise.all([ | ||
poolContract.token0(), | ||
poolContract.token1(), | ||
poolContract.fee(), | ||
poolContract.tickSpacing(), | ||
poolContract.liquidity(), | ||
poolContract.slot0(), | ||
]) | ||
|
||
return { | ||
token0, | ||
token1, | ||
fee, | ||
tickSpacing, | ||
liquidity, | ||
sqrtPriceX96: slot0[0], | ||
tick: slot0[1], | ||
} | ||
} |
Oops, something went wrong.