Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Type 'Token' is missing the following properties from type 'Token': isNative, isToken, wrapped on computePoolAddress #185

Open
burgossrodrigo opened this issue Aug 30, 2023 · 1 comment

Comments

@burgossrodrigo
Copy link

burgossrodrigo commented Aug 30, 2023

I have this method in a class:

    private tokenClass(chainId: number, address: string, decimals: number): Token {
        return new Token(chainId, address, decimals);
    }
    
    private async _computePoolAddress(chaindId: number, _tokenA: string, _decimalsA: number, _tokenB: string, _decimalsB: number, fee: number): Promise<any> {
        try {
            const poolAddress = computePoolAddress({
                factoryAddress: this.factoryAddress,
                tokenA: this.tokenClass(chaindId, _tokenA, _decimalsA),
                tokenB: this.tokenClass(chaindId, _tokenB, _decimalsB),
                fee: fee
            })
            return poolAddress
        } catch (error) {
            throw new Error(`${error.message}, for quoteTokenPertToken`)
        }
    }

And i'm getting errors on the properties tokenA and tokenB from that method. It's complaning that the new Token instance i'm creating and using as param is missing properties isNative, isToken, and wrapped.

How to reproduce:

Use these versions in a node project:

  "dependencies": {
    "@uniswap/sdk": "^3.0.3",
    "@uniswap/v3-sdk": "^3.10.0",
  },

Run a class like this:

import { Token } from '@uniswap/sdk';
import { computePoolAddress,  } from **'@uniswap/v3-sdk';

export class WalletService extends {
    constructor(private readonly configService: ConfigService) {
        super()
        this.factoryAddress = configService.get<string>(EnviromentVariablesEnum.POOL_FACTORY_CONTRACT_ADDRES)
    }

    private factoryAddress: string

    private tokenClass(chainId: number, address: string, decimals: number): Token {
        return new Token(chainId, address, decimals);
    }

    private async _computePoolAddress(chaindId: number, _tokenA: string, _decimalsA: number, _tokenB: string, _decimalsB: number, fee: number): Promise<any> {
        try {
            const poolAddress = computePoolAddress({
                factoryAddress: this.factoryAddress,
                tokenA: this.tokenClass(chaindId, _tokenA, _decimalsA),
                tokenB: this.tokenClass(chaindId, _tokenB, _decimalsB),
                fee: fee
            })
            return poolAddress
        } catch (error) {
            throw new Error(`${error.message}, for quoteTokenPertToken`)
        }
    }
}
@Florian-S-A-W
Copy link

Florian-S-A-W commented Sep 14, 2023

You need to use @uniswap/v2-sdk and @uniswap/sdk-core instead of @uniswap/sdk. The package you are using is an old version of the v2-sdk that was deprecated when Uniswap v3 was released.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants