View Contracts
Last updated
Was this helpful?
Last updated
Was this helpful?
The Nexus Protocol has several view contracts to assist with querying on chain data.
Contract that returns an array of all reserve or user data for a particular market (for example, liquidity, token addresses, rate strategy), used by the Nexus Interface to display Markets and Dashboard data.
The Utilities SDK includes an interface to make calls to this contract, and functions to format the response for frontend use-cases.
The source code is available on GitHub.
Returns the list of initialised reserves in the Pool associated with the given .
Input Parameters:
provider
IPoolAddressesProvider
The given provider for the associated pool
Return Values:
address[]
The list of initialised reserves in the Pool
Input Parameters:
provider
IPoolAddressesProvider
The given provider for the associated pool
Return Values:
BaseCurrencyInfo
The base currency information
AggregatedReserveData[]
The aggregated reserve data
The BaseCurrencyInfo
struct is composed of the following fields:
marketReferenceCurrencyUnit
uint256
Reference aka base currency of the Nexus market
marketReferenceCurrencyPriceInUsd
int256
Price of reference aka base currency in USD
networkBaseTokenPriceInUsd
int256
Price of native token of the network/chain in USD
networkBaseTokenPriceDecimals
uint8
Decimals of native token of the network/chain
The AggregatedReserveData
struct is composed of the following fields:
underlyingAsset
address
The address of the underlying asset of the reserve
name
string
The name of the underlying reserve asset
symbol
string
The symbol of the underlying reserve asset
decimals
uint256
The number of decimals of the reserve
baseLTVasCollateral
uint256
The ltv of the reserve
reserveLiquidationThreshold
uint256
The liquidation threshold of the reserve
reserveLiquidationBonus
uint256
The liquidation bonus of the resurve
reserveFactor
uint256
The reserve factor of the reserve
usageAsCollateralEnabled
bool
true if the asset is enabled to be used as collateral, false otherwise
borrowingEnabled
bool
true if borrowing is enabled, false otherwise
isActive
bool
true if reserve is active, false otherwise
isFrozen
bool
true if reserve is frozen, false otherwise
BASE DATA
liquidityIndex
uint128
The liquidity index of the reserve
variableBorrowIndex
uint128
The variable borrow index of the reserve
liquidityRate
uint128
The liquidity rate of the reserve
variableBorrowRate
uint128
The variable borrow rate of the reserve
lastUpdateTimestamp
uint40
The timestamp of the last update of the reserve
zTokenAddress
address
The ZToken address of the reserve
variableDebtTokenAddress
address
The VariableDebtToken address of the reserve
interestRateStrategyAddress
address
The address of the Interest Rate strategy
availableLiquidity
uint256
The liquidity available
totalScaledVariableDebt
uint256
The total scaled variable debt
priceInMarketReferenceCurrency
uint256
Price of reference aka base currency of Nexus market
priceOracle
address
The address of the price oracle used by the associated market
variableRateSlope1
uint256
The variable rate slope
variableRateSlope2
uint256
The variable rate slope
baseVariableBorrowRate
uint256
The base variable borrow rate, expressed in ray
optimalUsageRatio
uint256
The optimal usage ratio
Input Parameters:
provider
IPoolAddressesProvider
The given provider for the associated pool
user
address
The address of the user
UserReserveData[]
The user reserve data
The UserReserveData struct is composed of the following fields:
underlyingAsset
address
The address of the underlying asset supplied/borrowed
scaledZTokenBalance
uint256
The scaled balance of the zToken. scaledBalance = balance/liquidityIndex
usageAsCollateralEnabledOnUser
bool
true if the supplied asset is enabled to be used as collateral, false otherwise
scaledVariableDebt
uint256
The scaled balance of borrow position: (current balance = scaled balance * liquidity index)
Fetches tokens balances for all underlying tokens of Nexus reserves for one user address.
This contract is not used within the Nexus Protocol. It is an accessory contract used to reduce the number of calls towards the blockchain from the Nexus backend.
For getting ETH (native chain token) balance use MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
.
The source code is available on GitHub.
Checks the token balance of a wallet in a token contract. Returns the balance of the token for user (ETH included with MOCK_ETH_ADDRESS).
Input Parameters:
user
address
The address of the user
token
address
The address of the token
Return Values:
uint256
The balance of the token for user. Returns 0 for a non-contract address
Returns balances for a list of users and tokens (ETH included with MOCK_ETH_ADDRESS).
Input Parameters:
users
address[]
The list of users
tokens
address[]
The list of tokens
Return Values:
uint256[]
A list of balances for each user
Provides balances of user wallet for all reserves available on the pool.
Input Parameters:
provider
address
The address of the provider
user
address
The address of the user
Return Values:
address[]
A list of user wallets
uint256[]
A list of balances for each user
The source code is available on GitHub.
Returns a list of the existing reserves in the pool, pairs include the symbol and tokenAddress. Handles ETH in a different way since they do not have standard symbol functions.
Return Values:
TokenData[]
The list of reserves, pairs of symbols and addresses
The TokenData struct is composed of the following fields:
symbol
string
The symbol of the underlying reserve asset
tokenAddress
address
The address of the underlying reserve asset
Returns a list of the existing ZTokens in the pool, pairs include the symbol and tokenAddress.
Return Values:
TokenData[]
The list of ZTokens, pairs of symbols and addresses
The TokenData struct is composed of the following fields:
symbol
string
The symbol of zToken of the reserve
tokenAddress
address
The address of zToken of the reserve
Returns the configuration data of the reserve as described below. Does not return borrow and supply caps, nor pause flag for compatibility.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
decimals
uint256
The number of decimals of the reserve
ltv
uint256
The ltv of the reserve
liquidationThreshold
uint256
The liquidation threshold of the reserve
liquidationBonus
uint256
The liquidation bonus of the reserve
reserveFactor
uint256
The reserve factor of the reserve
usageAsCollateralEnabled
bool
true if the usage as collateral is enabled, false otherwise
borrowingEnabled
bool
true if borrowing is enabled, false otherwise
stableBorrowRateEnabled
bool
Always false (deprecated)
isActive
bool
true if reserve is active, false otherwise
isFrozen
bool
true if reserve is frozen, false otherwise
Returns true if the pool isPaused.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
isPaused
bool
true if the pool is paused, false otherwise
Returns the protocol fee on the liquidation bonus.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
uint256
The protocol fee on liquidation
Returns the reserve data.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
unbacked
uint256
The amount of unbacked zTokens of the reserve
accruedToTreasuryScaled
uint256
The scaled amount of tokens accrued to treasury that is to be minted
totalZToken
uint256
The total supply of the zToken
totalStableDebt
uint256
The total stable debt of the reserve (deprecated)
totalVariableDebt
uint256
The total variable debt of the reserve
liquidityRate
uint256
The liquidity rate of the reserve
variableBorrowRate
uint256
The variable borrow rate of the reserve
stableBorrowRate
uint256
The stable borrow rate of the reserve (deprecated)
averageStableBorrowRate
uint256
The average stable borrow rate of the reserve (deprecated)
liquidityIndex
uint256
The liquidity index of the reserve
variableBorrowIndex
uint256
The variable borrow index of the reserve
lastUpdateTimestamp
uint40
The timestamp of the last update of the reserve
Returns the total supply of zTokens for a given asset.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
uint256
The total supply of the zToken
Returns the total debt for a given asset.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
uint256
The total borrows for an asset
Returns the following user reserve data.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
user
address
The address of the user
Return Values:
currentZTokenBalance
uint256
The current ZToken balance of the user
currentStableDebt
uint256
The current stable debt of the user (deprecated)
currentVariableDebt
uint256
The current variable debt of the user
principalStableDebt
uint256
The principal stable debt of the user (deprecated)
scaledVariableDebt
uint256
The scaled variable debt of the user
stableBorrowRate
uint256
The stable borrow rate of the user (deprecated)
liquidityRate
uint256
The liquidity rate of the reserve
stableRateLastUpdated
uint40
The timestamp of the last update of the user stable rate (deprecated)
usageAsCollateralEnabled
bool
true if the user is using the asset as collateral, else false
Returns the addresses of the ZToken, stableDebtToken and variableDebtToken of the reserve.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
zTokenAddress
address
The ZToken address of the reserve
stableDebtTokenAddress
address
The StableDebtToken address of the reserve (deprecated)
variableDebtTokenAddress
address
The VariableDebtToken address of the reserve
Returns the address of the Interest Rate strategy.
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
irStrategyAddress
address
The address of the Interest Rate strategy
Input Parameters:
asset
address
The address of the underlying asset of the reserve
Return Values:
uint256
Current reserve deficit from undercollateralized borrow positions
getDebtCeilingDecimals
Returns the debt ceiling decimals.
Return Values:
uint256
The debt ceiling decimals
This contract is a utility for fetching and pre-processing liquidation-related parameters for a given user. It aggregates data from the underlying Pool and Price Oracle to determine a user’s position, collateral, borrow details, and liquidation limits according to the protocol parameters.
The source code is available on GitHub.
Returns aggregated position information for a user including total collateral, total debt, available borrows, current liquidation threshold, loan-to-value (LTV), and health factor. All values are denominated in the base currency.
Input Parameters:
user
address
The address of the user whose position is queried
Return Values:
UserPositionFullInfo
struct
The aggregated position information of the user
The UserPositionFullInfo struct is composed of the following fields:
totalCollateralInBaseCurrency
uint256
Total collateral in base currency
totalDebtInBaseCurrency
uint256
Total debt in base currency
availableBorrowsInBaseCurrency
uint256
Available borrows in base currency
currentLiquidationThreshold
uint256
Current liquidation threshold
ltv
uint256
Loan-to-value ratio
healthFactor
uint256
Health factor of the user’s position
Returns detailed information regarding a user’s collateral for a given asset. The returned struct includes the asset’s unit (based on decimals), its current price (via the Price Oracle), the associated zToken address, the raw collateral balance, and its equivalent value in the base currency.
Input Parameters:
user
address
The address of the user
collateralAsset
address
The address of the collateral asset to fetch information for
Return Values:
CollateralFullInfo
struct
Detailed collateral information for the specified asset
The CollateralFullInfo struct is composed of the following fields:
assetUnit
uint256
The unit value of the asset (10^decimals)
price
uint256
Current price of the asset from the Price Oracle
zToken
address
Address of the zToken associated with the asset
collateralBalance
uint256
The raw collateral balance of the user
collateralBalanceInBaseCurrency
uint256
Collateral balance denominated in the base currency
Returns detailed information regarding a user’s debt for a given asset. The returned struct includes the asset’s unit, current price, the associated variable debt token address, the debt balance, and its equivalent value in the base currency.
Input Parameters:
user
address
The address of the user
debtAsset
address
The address of the debt asset to fetch information for
Return Values:
DebtFullInfo
struct
Detailed debt information for the specified asset
The DebtFullInfo struct is composed of the following fields:
assetUnit
uint256
The unit value of the asset (10^decimals)
price
uint256
Current price of the asset from the Price Oracle
variableDebtToken
address
Address of the variable debt token associated with the asset
debtBalance
uint256
The raw debt balance of the user
debtBalanceInBaseCurrency
uint256
Debt balance denominated in the base currency
A convenience function that returns liquidation parameters for a user using the maximum possible debt liquidation amount. Internally, it calls the overloaded version with debtLiquidationAmount set to the maximum (type(uint256).max).
Input Parameters:
user
address
The address of the user
collateralAsset
address
The address of the collateral asset
debtAsset
address
The address of the debt asset
Return Values:
LiquidationInfo
struct
Detailed liquidation information for the specified user and assets
The LiquidationInfo struct is composed of the following fields:
userInfo
struct
Aggregated position details of the user (UserPositionFullInfo above)
collateralInfo
struct
Detailed collateral information (CollateralFullInfo above)
debtInfo
struct
Detailed debt information (DebtFullInfo above)
maxCollateralToLiquidate
uint256
Maximum collateral that can be liquidated
maxDebtToLiquidate
uint256
Maximum debt that can be liquidated
liquidationProtocolFee
uint256
Protocol fee applied on the liquidation bonus
amountToPassToLiquidationCall
uint256
Adjusted debt amount for the liquidation call
Returns comprehensive liquidation parameters for a user given a specific collateral asset and debt asset, considering a custom maximum debt liquidation amount. The function aggregates the user’s position, collateral and debt details, checks if liquidation conditions are met, and computes the optimal amounts for liquidation—including any applicable protocol fees.
Input Parameters:
user
address
The address of the user
collateralAsset
address
The address of the collateral asset to be liquidated
debtAsset
address
The address of the debt asset to be repaid
debtLiquidationAmount
uint256
The maximum debt amount that can be liquidated (if lower than the user’s debt balance)
Return Values:
LiquidationInfo
struct
Detailed liquidation information for the specified user and assets
The LiquidationInfo struct is composed of the following fields:
userInfo
struct
Aggregated position details of the user (UserPositionFullInfo above)
collateralInfo
struct
Detailed collateral information (CollateralFullInfo above)
debtInfo
struct
Detailed debt information (DebtFullInfo above)
maxCollateralToLiquidate
uint256
Maximum collateral that can be liquidated
maxDebtToLiquidate
uint256
Maximum debt that can be liquidated
liquidationProtocolFee
uint256
Protocol fee applied on the liquidation bonus
amountToPassToLiquidationCall
uint256
Adjusted debt amount for the liquidation call
Returns BaseCurrencyInfo
of the Pool and AggregatedReserveData[]
for all the initialised reserves in the Pool associated with the given .
Returns UserReserveData[] for all user reserves in the Pool associated with the given .
The NexusProtocolDataProvider is a peripheral contract to collect and pre-process information from the . This contract contains methods for querying token addresses, reserve parameters, and user account information. The methods of the PoolDataProvider are more granular than the UiPoolDataProvider, which queries data for reserve tokens or user balances simultaneously.