Giter Site home page Giter Site logo

Comments (2)

DefiDebauchery avatar DefiDebauchery commented on August 18, 2024 1

You have a couple of issues in your invocation:

First, the signature is incorrect; not only are you making a tuple out of the entire return with your extra parentheses, the individual return types are not denoted as []. You can build the function signature from the ABI:

  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "poolId",
        "type": "bytes32"
      }
    ],
    "name": "getPoolTokens",
    "outputs": [
      {
        "internalType": "contract IERC20[]",
        "name": "tokens",
        "type": "address[]"
      },
      {
        "internalType": "uint256[]",
        "name": "balances",
        "type": "uint256[]"
      },
      {
        "internalType": "uint256",
        "name": "lastChangeBlock",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },

This gives us getPoolTokens(bytes32)(address[],uint256[],uint256)

Second, because this method has three return values, you should be listing three keys for the return dict (unless you really do only care about the first one, of course)

Taking the first Pool ID I found in event logs, the following call (edited for readability) yielded the same data that etherscan's UI provided:

Call(
  '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
  ['getPoolTokens(bytes32)(address[],uint256[],uint256)', HexBytes('0x8eb6c82c3081bbbd45dcac5afa631aac53478b7c000100000000000000000270')],
  [['tokens', None], ['balances', None], ['lastChangeBlock', None]],
  _w3=eth
)()

{'tokens': ('0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
  '0x798d1be841a82a273720ce31c822c61a67a601c3',
  '0xba485b556399123261a5f9c95d413b4f93107407'),
 'balances': (16480387972, 323875735362, 581643160963723873429632),
 'lastChangeBlock': 15293254}

from multicall.py.

prabhatverma286 avatar prabhatverma286 commented on August 18, 2024 1

Thanks @DefiDebauchery! I think I did not understand the way to use the library properly. Indeed, in the end, I ended up with exactly the same solution as you have written.

I remember going through the examples but couldn't find a nice one where the return types are multiple lists. Maybe this could be added to the example usages.

from multicall.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.