我正在使用Vyper写了一个合约用来获取Uniswap的交易对信息,我可以获取到allPairsLength
的信息,但是我把从allPairsLength
获取到参数传到getAllPairs
里面时每次都是0,而不是获取到的allPairsLength
参数,我也不知道我哪里有问题,懂的大佬帮忙看一下,真的很需要帮助
# @version ^0.2
from vyper.interfaces import ERC20
interface UniswapFactory:
def allPairs(input: uint256) -> address: nonpayable
def allPairsLength() -> uint256: view
interface UniswapV2Pair:
def token0() -> address: view
def token1() -> address: view
UNISWAP_FACTORY: constant(address) = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
owner: public(address)
@external
def __init__():
self.owner = msg.sender
@internal
@view
def getPairsLength() -> uint256:
"""
@notice From Uniswap factory get last pair length
@return uint256 pair length
"""
pl: uint256 = UniswapFactory(UNISWAP_FACTORY).allPairsLength()
return pl
@external
@view
def getPairsResponse() -> Bytes[128]:
"""
@notice From Uniswap factory get new pair address
@return address pairAddress
"""
_response: Bytes[128] = raw_call(
UNISWAP_FACTORY,
concat(
method_id("allPairs(uint256)"),
convert(self.getPairsLength(), bytes32)
),
max_outsize=128,
is_static_call=True
)
return _response