Skip to content

This repository contains the ABI interfaces to fetch data from the ETHLend smart contracts and the Aave API endpoints.

Notifications You must be signed in to change notification settings

ETHLend/statistics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

statistics

This repository contains the ABI interfaces to fetch data from the ETHLend smart contracts and the Aave API endpoints.

Fetching data through the smart contract interfaces

The ETHLend smart contract infrastructure references one specific contract, called the Loan Data Controller, that acts as a container for all the data regarding the onchain activity of the users. In the contract all the information of the loans created on the platform is stored, and from that it's possible to calculate interesting statistics like the users activity, amount of assets locked and so on. The following document describes how to fetch data from the Loan Data Controller and to perform proper conversion. We also provide information about the API endpoints for statistics that do the heavy lifting for integrators and allows to fetch data quickly and easily.

Loan Data Controller methods

Address of the Loan Data Controller

Mainnet:

0x551325450cc75a0122ad6d156823d05090151d0c

Kovan testnet:

0xec21584a997e5ff90becba025a467770e706bda2

Description of the methods of the Loan Data Controller

getLoanRequests() returns(address[])

returns the list of all the loan requests created on the platform

getLoanOffers() returns(address[])

returns the list of all the loan offers created on the platform

getLoanData(address loan) returns(LoanData)

Fetches the basic data of either loan requests or loan offers. Receives the address of the loan as input parameter.

Returns an object defined as follows:

      {
          "name": "mediumAmount", //amount of the loan in wei, or if it's an ETHUSD loan, in USDcents
          "type": "uint256"
        },
        {
          "name": "premiumAmount", //amount of the total premium in wei, or if it's an ETHUSD loan, in USDcents
          "type": "uint256"
        },
        {
          "name": "collateralAmount", //amount of the collateral in wei
          "type": "uint256"
        },
        {
          "name": "fundedCapital", //actual amount funded: equal to mediumAmount if the loan is ETH/ERC20, or if it's pegged the equivalent amount in ETH of the                             //pegged loan at the instant of funding
          "type": "uint256"
        },
        {
          "name": "collateralToken", //address of the collateral token in the corresponding network
          "type": "address"
        },
        {
          "name": "mediumOfExchangeToken", //address of the medium of exchange (loan currency) in the corresponding network
          "type": "address"
        },
        {
          "name": "mediumOfExchange", //Type of the loan currency, check the MediumOfExchange enum below
          "type": "uint8"
        },
        {
          "name": "collateralType", //Type of the collateral, check the CollateralType enum below
          "type": "uint8"
        },
        {
          "name": "currentState", //state of the loan (look for the State enum below)
          "type": "uint8"
        },
        {
          "name": "installments_count",
          "type": "uint8"
        }
}

getLoanOfferInitialData(address loan) returns(LoanData)

Fetches the initial configuration of the loan offer specified by the input parameters.

Returns an object defined as follows:

       {
          "name": "minimumMediumAmount", //maximum amount of the offer
          "type": "uint256"
        },
        {
          "name": "maximumMediumAmount", //minimum amount of the offer, if supported
          "type": "uint256"
        },
        {
          "name": "minimumLoanDuration",
          "type": "uint256"
        },
        {
          "name": "maximumLoanDuration",
          "type": "uint256"
        },
        {
          "name": "acceptedCollaterals", //bytes32 packing all the data for the supported collaterals
          "type": "bytes32[5]"
        },
        {
          "name": "creationTime",
          "type": "uint256"
        }

The following Enumeratives are used in the getLoanData() and getLoanOfferInitialData() return values:

enum State {
    Init = 0,
    WaitingForCollateral = 1,
    Funding = 2,
    Funded = 3,
    WaitingForPayback = 4,
    Finished = 5,
    Cancelled = 6,
    Defaulted = 7,
    TokenPriceIsBad = 8,
    Timeout = 9,
    CollateralCalled = 10,
    WaitingForFunds = 11,
    WaitingForBorrower = 12,
    OfferTaken = 13
}

enum MediumOfExchange {
    ETH = 0,
    ERC20 = 1,
    BTC = 2
}

enum CollateralType {
    ERC20 = 0,
    ETH = 1,
    BTC = 2
}

Code example: fetch the data of loan offers and loan requests

TBD

Fetch the data using the Aave API

Given the fairly complex structure of the ETHLend marketplace, fetching and processing the data needed to analyze the usage the platform can be problematic. To ease the job of integrators and devs, we developed an API server that will provide the information in a simply and human readable way.

Description of the endpoints

https://api.aave.com/request

returns an array containing the address of all the loan requests on the platform. Equivalent of the getLoanRequests() method in the Loan Data Controller

https://api.aave.com/request/getone/:address

returns the data related to a specific loan request (defined by the :address parameter). Data is already parsed to be human readable (amounts in the proper unit of currency - currency addresses converted to the equivalent token symbol - durations converted to days). Equivalent of the getLoanData() method in the Loan Data Controller

https://api.aave.com/offer

returns an array containing the address of all the loan offers on the platform. Equivalent of the getLoanOffers() method in the Loan Data Controller

https://api.aave.com/offer/getone/:address

returns the data related to a specific loan offer (defined by the :address parameter). Data is already parsed to be human readable (amounts in the proper unit of currency - currency addresses converted to the equivalent token symbol - durations converted to days). Merges the information of the getLoanData() method and the getLoanOfferInitialData() in the Loan Data Controller.

Fetch statistics using the Aave API

https://api.aave.com/stats/locked

returns the total amount in USD of the assets locked as collateral/loan currency (for the offers) within the ETHLend smart contracts.

How is the statistic calculated

The total worth in USD of all the collaterals stored on the platform, for all the loans that are in the states State.Funding and State.WaitingForPayback, is calculated, plus the loan pricipal that are stored in the loan offers in state State.WaitingForBorrower.

https://api.aave.com/stats/totalborrows

returns the total amount in USD of the assets that have been borrowed within the ETHLend smart contracts.

How is the statistic calculated

The total worth in USD of all the loan principals, for all the loans that are in the states State.WaitingForPayback is calculated.

https://api.aave.com/stats/activeloans

How is the statistic calculated

Count of all the loans that are in State.WaitingForBorrower, State.Funding, or State.WaitingForPayback.

About

This repository contains the ABI interfaces to fetch data from the ETHLend smart contracts and the Aave API endpoints.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published