-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Confusion of sdk and v2-sdk #62
Comments
Also: I don't find the Fetcher source code (is it not part of the v2-sdk anymore?) |
I'm here trying to figure out the same questions @tennox ! |
@tennox It looks like they redid the versioning and renamed this repository about a month back. You can see the old naming here with the v3.0.3, the name is https://github.com/Uniswap/uniswap-v2-sdk/tree/a88048e9c4198a5bdaea00883ca00c8c8e582605 About a month back, the name changed to So it seems that the answer is yes, we should be using |
Having same issue. The module I have managed to follow some of their docs by importing dependencies such as |
This is the best I could do using as much
Someone can spot what may be wrong? |
In the end, I let go of the Fetcher and called the pair contract directly for the reserves. See gist: |
@uniswa/sdk is v1 |
The npm package @uniswap/sdk works for what is in the Uniswap v2 SDK documentation. But I'm not really sure what source is used for that. |
Well since the Fetcher class isn't exported anymore, here's a function to get const getChainProvider = () => {
return (new ethers.providers.JsonRpcProvider(process.env.RPC));
}
const getPair = async (tokenA: Token, tokenB: Token) => {
const pairAddress = Pair.getAddress(tokenA, tokenB)
const contract = new ethers.Contract(pairAddress, [
'function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast)',
'function token0() external view returns (address)',
'function token1() external view returns (address)'
], getChainProvider());
const reserves = await contract.getReserves()
const token0Address = await contract.token0()
const token1Address = await contract.token1()
const token0 = [tokenA, tokenB].find(token => token.address === token0Address)
const token1 = [tokenA, tokenB].find(token => token.address === token1Address)
const pair = new Pair(
CurrencyAmount.fromRawAmount(token0, reserves.reserve0.toString()),
CurrencyAmount.fromRawAmount(token1, reserves.reserve1.toString())
)
return pair;
} Source: https://gist.github.com/monokh/5dc494b9fb7887ac02d6898b6458648c |
Improve type inference speed
Installing
@uniswap/sdk
returns a package from "https://github.com/Uniswap/uniswap-sdk.git" - but that URL forwards to this repository, which holds a v1.0.7 version. (not 3.0.3)Is it now recommended to install
@uniswap/v2-sdk
?Then the docs on uniswap.org (which are also linked in the Readme of this repository) still talk about the old version and should be updated.
The text was updated successfully, but these errors were encountered: