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

check is not a function - Error when using Uniswap quoter #6384

Closed
AlbertFiat24 opened this issue Aug 28, 2023 · 10 comments
Closed

check is not a function - Error when using Uniswap quoter #6384

AlbertFiat24 opened this issue Aug 28, 2023 · 10 comments
Labels
4.x 4.0 related Bug Addressing a bug Estimate Investigate

Comments

@AlbertFiat24
Copy link

When updating to the latest version 4.1.1 it gives me this error, when using the Uniswap Quoter (previously with web3 4.0.3 using old dependencies it used to work)

TypeError: check is not a function
    at Object.eval [as refinement] (index.mjs:693:1)
    at executeRefinement (index.mjs:3422:1)
    at ZodEffects._parse (index.mjs:3442:1)
    at eval (index.mjs:2846:1)
    at Array.map (<anonymous>)
    at ZodTuple._parse (index.mjs:2842:1)
    at ZodTuple._parseSync (index.mjs:622:1)
    at ZodTuple.safeParse (index.mjs:652:1)
    at Validator.validate (validator.js:60:1)
    at Web3Validator.validate (web3_validator.js:32:1)
    at Object.eval (contract.js:457:26)
    at eval (uniswapService.js:468:64)
    at step (tslib.es6.mjs:147:1)
    at Object.eval [as next] (tslib.es6.mjs:128:44)
    at asyncGeneratorStep (_async_to_generator.js:3:1)
    at _next (_async_to_generator.js:20:1)

In order to test this code can be used:

import SWAP_QUOTER_ABI from "@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json";

    try {
        const quoterContract = new web3.eth.Contract(SWAP_QUOTER_ABI.abi, "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6");
        // call the quoter contract to determine the amount in of a swap, given an amount out
        let quotedAmountIn = await quoterContract.methods.quoteExactOutputSingle(
            "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
            "0x22043fDdF353308B4F2e7dA2e5284E4D087449e1",
            3000,
            150000,
            0
        ).call();
    } catch (err) {
        console.log(err);
    }
@AlbertFiat24 AlbertFiat24 changed the title Error when using uniswap quoter check is not a function - Error when using Uniswap quoter Aug 28, 2023
@jdevcs jdevcs added 4.x 4.0 related Bug Addressing a bug labels Aug 28, 2023
@jdevcs
Copy link
Contributor

jdevcs commented Aug 28, 2023

Thanks for sharing details. It seems due to recently one of lib change, 4.1.1 is using zod lib. We will investigate and fix it.

@luu-alex
Copy link
Contributor

might be related to #6378

@luu-alex
Copy link
Contributor

#6376

@fullkomnun
Copy link
Contributor

This might be caused by the 'fee' parameter having a 'uint24' type which is not a power of 2 so custom validator is set to undefined during conversion to Zod.

#6434 should solve this.

@ngmachado
Copy link

I'm also getting this error using web3 v4.0.3. The method I'm getting the error is defined as

NAME : createFlow
METHOD:  {
  inputs: [
    {
      internalType: 'contract ISuperfluidToken',
      name: 'token',
      type: 'address'
    },
    { internalType: 'address', name: 'receiver', type: 'address' },
    { internalType: 'int96', name: 'flowRate', type: 'int96' },
    { internalType: 'bytes', name: 'ctx', type: 'bytes' }
  ],
  name: 'createFlow',
  outputs: [ { internalType: 'bytes', name: 'newCtx', type: 'bytes' } ],
  stateMutability: 'nonpayable',
  type: 'function',
  signature: '0x62fc305e',
  constant: false,
  payable: false
}
PARAMS:  [
  '0xbc08d67BFB5e8D1C83796EA85cdEEc3145c07Df9',
  '0x8005EF80C3FB177198C19c9fdB6CA8E6D6468706',
  '100000000000',
  '0x'
]

From what I understand from the comments is about non power of 2 uint/int. Any workaround until is fixed?

@luu-alex
Copy link
Contributor

@ngmachado hey there, gonna merge it in today and i can give you a dev branch so that theres a usuable branch fixed before release. we are planning to start the release tomorrow and should be officially out soon.

@luu-alex
Copy link
Contributor

dev branch with the fix [email protected] you can use this until release

4.1.3-dev.09f4c8b.0

@luu-alex
Copy link
Contributor

@ngmachado version 4.2.0 has been released as well so you can switch off the dev branch

@ngmachado
Copy link

ngmachado commented Oct 18, 2023

@luu-alex I'm testing now with the dev branch, will check the new release :)

Quick one:

I'm getting a error also when doing a simple transfer (other contracts interactions are ok)

    // local ganache running @ port 8545
    const httpProvider = new Web3.providers.HttpProvider("http://127.0.0.1:8545");
    const web3 = new Web3(httpProvider);
    
    // accounts array have the correct addresses, checks not included in this example
    const transaction = {
        from: accounts[0],
        to: accounts[1],
        value: web3.utils.toWei("100", "ether")
    }
    
    // fail with  "TransactionRevertInstructionError: Transaction has been reverted by the EVM"
    await web3.eth.sendTransaction(transaction);
    
    // if i ignoreGasPrice no EVM tx simulation. This works!
    await web3.eth.sendTransaction(transaction, undefined, { ignoreGasPricing: true });

If unrelated I can open a new issue.

@luu-alex
Copy link
Contributor

@ngmachado i believe this is happening due to the version update. the newest version uses transaction types 0x2, and ganache only accepts transaction types 0x0.
to fix this you can also do

 const transaction = {
        from: accounts[0],
        to: accounts[1],
        value: web3.utils.toWei("100", "ether"),
        type: '0x0'

    }

Thanks for bringing this up! if theres anything else feel free to join the discord and report it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related Bug Addressing a bug Estimate Investigate
Projects
None yet
Development

No branches or pull requests

6 participants