Nethereum / Nethereum.Playground

Compile and run Nethereum snippets on the browser
MIT License
28 stars 17 forks source link

Calling getReservesData function is throwing System.OverflowException: 'Value was either too large or too small for an Int32.' #53

Closed grantfeldman closed 7 months ago

grantfeldman commented 7 months ago

I am trying to call the getReservesData function on the AAVE UiPoolDataProviderV3 periphery contract with the following code. When I run the code a System.OverflowException is thrown - 'Value was either too large or too small for an Int32.'.

Interestingly, when I comment out the AggregatedReserveDataItems property in the ReservesData class below I am able to get hold of the BaseCurrencyInfo data.

Ref: https://docs.aave.com/developers/periphery-contracts/uipooldataproviderv3#getreservesdata

public async Task GetReservesData_UiPoolDataProviderV3()
{
    var uiPoolContractProviderAddress = "0x91c0eA31b49B69Ea18607702c5d9aC360bf3dE7d";
    var poolAddressesProviderAddress = "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e";

    var result = await Web3.Eth.GetContractQueryHandler<GetReservesDataFunction>()
        .QueryAsync<ReservesData>(
            uiPoolContractProviderAddress,
            new GetReservesDataFunction { Provider = poolAddressesProviderAddress }
        );
}
[Function("getReservesData")]
public class GetReservesDataFunction : FunctionMessage
{
    [Parameter("address", "provider", 1)]
    public string Provider { get; set; }
}
[FunctionOutput]
public class ReservesData : IFunctionOutputDTO
{
    [Parameter("tuple", "", 1)]
    public BaseCurrencyInfo BaseCurrencyInfo { get; set; }

    [Parameter("tuple[]", "", 2)]
    public List<AggregatedReserveDataItem> AggregatedReserveDataItems { get; set; }
}

public class BaseCurrencyInfo
{
    [Parameter("uint256", "marketReferenceCurrencyUnit", 1)]
    public BigInteger MarketReferenceCurrencyUnit { get; set; }

    [Parameter("int256", "marketReferenceCurrencyPriceInUsd", 2)]
    public BigInteger MarketReferenceCurrencyPriceInUsd { get; set; }

    [Parameter("int256", "networkBaseTokenPriceInUsd", 3)]
    public BigInteger NetworkBaseTokenPriceInUsd { get; set; }

    [Parameter("uint8", "networkBaseTokenPriceDecimals", 4)]
    public BigInteger NetworkBaseTokenPriceDecimals { get; set; }
}

public class AggregatedReserveDataItem
{
    [Parameter("address", "underlyingAsset", 1)]
    public string UnderlyingAsset { get; set; }

    [Parameter("string", "name", 2)]
    public string Name { get; set; }

    [Parameter("string", "symbol", 3)]
    public string Symbol { get; set; }

    [Parameter("uint256", "decimals", 4)]
    public BigInteger Decimals { get; set; }

    // Other properties remove for brevity
}