The lens is a stateless contract that exposes view helpers to format data from Evoq's storage. They can be used to ease the integration on top of the protocol.
The total supplied amount matched peer-to-peer, subtracting the supply delta (in USD, 18 decimals).
poolSupplyAmount
uint256
The total supplied amount on the underlying pool, adding the supply delta (in USD, 18 decimals).
totalSupplyAmount
uint256
The total amount supplied through Evoq (in USD, 18 decimals).
getTotalBorrow
Return values:
Name
Type
Description
p2pBorrowAmount
uint256
The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in USD, 18 decimals).
poolBorrowAmount
uint256
The total borrowed amount on the underlying pool, adding the borrow delta (in USD, 18 decimals).
totalBorrowAmount
uint256
The total amount borrowed through Evoq (in USD, 18 decimals).
Rewards Lens Functions
These functions are specific to Evoq.
getUserUnclaimedRewards
Returns the unclaimed XVS rewards for the given cToken addresses.
Parameters:
Name
Type
Description
_poolTokens
address[]
The cToken addresses for which to compute the rewards.
_user
address
The user to compute the rewards for.
Return values:
Name
Type
Description
unclaimedRewards
uint256
The unclaimed XVS rewards for the given cToken addresses.
getAccruedSupplierXvs
Returns the accrued Xvs rewards of a user since the last update.
Parameters:
Name
Type
Description
_supplier
address
The user to compute the rewards for.
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
Name
Type
Description
accruedSupplierXvs
uint256
The accrued XVS rewards.
getAccruedBorrowerXvs
Returns the accrued XVS rewards of a user since the last update.
Parameters:
Name
Type
Description
_supplier
address
The user to compute the rewards for.
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
Name
Type
Description
accruedBorrowerXvs
uint256
The accrued XVS rewards.
getCurrentXvsSupplyIndex
Returns the updated XVS supply index.
Parameters:
Name
Type
Description
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
Name
Type
Description
supplyIndex
uint256
The updated XVS supply index.
getCurrentXvsBorrowIndex
Returns the updated XVS borrow index.
Parameters:
Name
Type
Description
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
Name
Type
Description
supplyIndex
uint256
The updated XVS borrow index.
Market Lens Functions
isMarketCreated
Checks if a market is created.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
isCreated
bool
True if the market is created.
getAllMarkets
Returns the list of all markets created.
Return values:
Name
Type
Description
markets
address[]
The list of all markets created.
getMainMarketData
For a given market, returns the average supply/borrow rates and amounts of underlying asset supplied and borrowed through Evoq, on the underlying pool and matched peer-to-peer.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
avgSupplyRatePerBlock
uint256
The average supply rate experienced on the given market (in wad).
avgBorrowRatePerBlock
uint256
The average borrow rate experienced on the given market (in wad).
p2pSupplyAmount
uint256
The total supplied amount matched peer-to-peer, subtracting the supply delta (in underlying).
p2pBorrowAmount
uint256
The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in underlying).
poolSupplyAmount
uint256
The total supplied amount on the underlying pool, adding the supply delta (in underlying).
poolBorrowAmount
uint256
The total borrowed amount on the underlying pool, adding the borrow delta (in underlying).
getAdvancedMarketData
Returns non-updated indexes, the block at which they were last updated and the total deltas of a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
indexes
Indexes
The indexes of the given market.
lastUpdateBlockNumber
uint32
The block at which pool indexes were last updated.
p2pSupplyDelta
uint256
The total supply delta (in underlying).
p2pBorrowDelta
uint256
The total borrow delta (in underlying).
getMarketConfiguration
Returns the given market's configuration.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market of which to get the configuration.
Return values:
The return value is a tuple containing the following values:
Name
Type
Description
underlying
address
The underlying token address.
isCreated
bool
Whether the market is created or not.
isP2PDisabled
bool
Whether the peer-to-peer market is enabled or not.
isPaused
bool
Deprecated
isPartiallyPaused
bool
Deprecated
reserveFactor
uint16
The reserve factor applied to this market.
p2pIndexCursor
uint16
The p2p index cursor applied to this market.
collateralFactor
uint256
The pool collateral factor also used by Evoq (in wad).
getMarketPauseStatus
Returns the given market's pause statuses.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market of which to get pause statuses.
Return values:
Name
Type
Description
marketPauseStatus
MarketPauseStatus
The market status struct.
getTotalMarketSupply
Computes and returns the total distribution of supply for a given market, using virtually updated indexes.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
p2pSupplyAmount
uint256
The total supplied amount matched peer-to-peer, subtracting the supply delta (in underlying).
poolSupplyAmount
uint256
The total supplied amount on the underlying pool, adding the supply delta (in underlying).
getTotalMarketBorrow
Computes and returns the total distribution of borrow for a given market, using virtually updated indexes.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
p2pBorrowAmount
uint256
The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in underlying).
poolBorrowAmount
uint256
The total borrowed amount on the underlying pool, adding the borrow delta (in underlying).
Rates Lens Functions
getNextUserSupplyRatePerBlock
Returns the supply rate per block experienced on a market after having supplied the given amount on behalf of the given user.
The returned supply rate is a low estimate: when supplying through Evoq, a supplier could be matched more than once instantly or later and thus benefit from a higher supply rate.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The address of the user on behalf of whom to supply.
_amount
uint256
The amount to supply.
Return values:
Name
Type
Description
nextSupplyRatePerBlock
uint256
An approximation of the next supply rate per block experienced after having supplied (in wad).
balanceInP2P
uint256
The total balance matched peer-to-peer after having supplied (in underlying).
balanceOnPool
uint256
The total balance supplied on pool after having supplied (in underlying).
totalBalance
uint256
The total balance supplied through Evoq (in underlying).
getNextUserBorrowRatePerYear
Returns the borrow rate per block experienced on a market after having borrowed the given amount on behalf of the given user.
the returned borrow rate is a high estimate: when borrowing through Evoq, a borrower could be matched more than once instantly or later and thus benefit from a lower borrow rate.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The address of the user on behalf of whom to borrow.
_amount
uint256
The amount to borrow.
Return values:
Name
Type
Description
nextBorrowRatePerBlock
uint256
An approximation of the next borrow rate per block experienced after having borrowed (in wad).
balanceInP2P
uint256
The total balance matched peer-to-peer after having borrowed (in underlying).
balanceOnPool
uint256
The total balance borrowed on pool after having borrowed (in underlying).
totalBalance
uint256
The total balance borrowed through Evoq (in underlying).
getCurrentUserSupplyRatePerBlock
Returns the supply rate per block a given user is currently experiencing on a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The user to compute the supply rate per block for.
Return values:
Name
Type
Description
supplyRatePerBlock
uint256
The supply rate per block the user is currently experiencing (in wad).
getCurrentUserBorrowRatePerBlock
Returns the borrow rate per block a given user is currently experiencing on a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The user to compute the borrow rate per block for.
Return values:
Name
Type
Description
borrowRatePerBlock
uint256
The borrow rate per block the user is currently experiencing (in wad).
getAverageSupplyRatePerYear
Computes and returns the current supply rate per block experienced on average on a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
Return values:
Name
Type
Description
avgSupplyRatePerBlock
uint256
The market's average supply rate per block (in wad).
p2pSupplyAmount
uint256
The total supplied amount matched peer-to-peer, subtracting the supply delta (in underlying).
poolSupplyAmount
uint256
The total supplied amount on the underlying pool, adding the supply delta (in underlying).
getAverageBorrowRatePerBlock
Computes and returns the current borrow rate per block experienced on average on a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
Return values:
Name
Type
Description
avgBorrowRatePerBlock
uint256
The market's average borrow rate per block (in wad).
p2pBorrowAmount
uint256
The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in underlying).
poolBorrowAmount
uint256
The total borrowed amount on the underlying pool, adding the borrow delta (in underlying).
getRatesPerYear
Computes and returns peer-to-peer and pool rates for a specific market.
Prefer using getAverageSupplyRatePerBlock & getAverageBorrowRatePerBlock to get the actual experienced supply/borrow rate.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
Return values:
Name
Type
Description
p2pSupplyRate
uint256
The market's peer-to-peer supply rate per block (in wad).
p2pBorrowRate
uint256
The market's peer-to-peer borrow rate per block (in wad).
poolSupplyRate
uint256
The market's pool supply rate per block (in wad).
poolBorrowRate
uint256
The market's pool borrow rate per block (in wad).
User Lens Functions
getEnteredMarkets
Returns all markets entered by a given user.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
Return values:
Name
Type
Description
enteredMarkets
address[]
The list of all markets entered by the user.
getUserMaxCapacitiesForAsset
Returns the maximum amount available to withdraw & borrow for a given user, on a given market.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
_poolToken
address
The address of the market to check.
Return values:
Name
Type
Description
withdrawable
uint256
The maximum amount available to withdraw.
borrowable
uint256
The maximum amount available to borrow.
computeLiquidationRepayAmount
Computes the maximum repayable amount for a potential liquidation.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
_poolTokenBorrowed
address
The address of the market to repay.
_poolTokenCollateral
address
The address of the market to seize.
Return values:
Name
Type
Description
repayAmount
uint256
The maximum repayable amount (in underlying).
getCurrentSupplyBalanceInOf
Returns the balance in underlying of a given user in a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The address of the user to check.
Return values:
Name
Type
Description
balanceInP2P
uint256
The total balance matched peer-to-peer (in underlying).
balanceOnPool
uint256
The total balance on the underlying pool (in underlying).
totalBalance
uint256
The total balance supplied through Evoq (in underlying).
getCurrentBorrowBalanceInOf
Returns the balance in underlying of a given user in a given market.
Parameters:
Name
Type
Description
_poolToken
address
The address of the market.
_user
address
The address of the user to check.
Return values:
Name
Type
Description
balanceInP2P
uint256
The total balance matched peer-to-peer (in underlying).
balanceOnPool
uint256
The total balance on the underlying pool (in underlying).
totalBalance
uint256
The total balance borrowed through Evoq (in underlying).
getUserBalanceStates
Returns the collateral value, debt value and max debt value of a given user.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
Return values:
Name
Type
Description
liquidityData
LiquidityData
The liquidity data struct.
getUserHypotheticalBalanceStates
Returns the aggregated position of a given user, following an hypothetical borrow/withdraw on a given market, using virtually updated pool & peer-to-peer indexes for all markets.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
_poolToken
address
The address of the market.
_withdrawnAmount
uint256
The number of tokens to hypothetically withdraw from the given market (in underlying).
_borrowedAmount
uint256
The amount of tokens to hypothetically borrow from the given market (in underlying).
Return values:
Name
Type
Description
liquidityData
LiquidityData
The liquidity data struct.
getUserHealthFactor
Returns the health factor of a given user.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
Return values:
Name
Type
Description
healthFactor
uint256
The health factor of the given user.
getUserHypotheticalHealthFactor
Returns the hypothetical health factor of a user, following an hypothetical borrow/withdraw on a given market, using virtually updated pool & peer-to-peer indexes for all markets.
Parameters:
Name
Type
Description
_user
address
The address of the user to check.
_poolToken
address
The address of the market.
_withdrawnAmount
uint256
The number of tokens to hypothetically withdraw from the given market (in underlying).
_borrowedAmount
uint256
The amount of tokens to hypothetically borrow from the given market (in underlying).
struct Indexes {
uint256 p2pSupplyIndex;// The peer-to-peer supply index (in wad), used to multiply the peer-to-peer supply scaled balance and get the peer-to-peer supply balance (in underlying).
uint256 p2pBorrowIndex;// The peer-to-peer borrow index (in wad), used to multiply the peer-to-peer borrow scaled balance and get the peer-to-peer borrow balance (in underlying).
uint256 poolSupplyIndex;// The pool supply index (in wad), used to multiply the pool supply scaled balance and get the pool supply balance (in underlying).
uint256 poolBorrowIndex;// The pool borrow index (in wad), used to multiply the pool borrow scaled balance and get the pool borrow balance (in underlying).
}
function getAdvancedMarketData(address _poolToken)
external
view
returns (
Indexesmemory indexes,
uint32 lastUpdateBlockNumber,
uint256 p2pSupplyDelta,
uint256 p2pBorrowDelta
);
struct MarketPauseStatus {
bool isSupplyPaused;// Whether the supply is paused or not.
bool isBorrowPaused;// Whether the borrow is paused or not
bool isWithdrawPaused;// Whether the withdraw is paused or not. Note that a "withdraw" is still possible using a liquidation (if not paused).
bool isRepayPaused;// Whether the repay is paused or not. Note that a "repay" is still possible using a liquidation (if not paused).
bool isLiquidateCollateralPaused;// Whether the liquidation on this market as collateral is paused or not.
bool isLiquidateBorrowPaused;// Whether the liquidatation on this market as borrow is paused or not.
bool isDeprecated;// Whether a market is deprecated or not.
}
function getMarketPauseStatus(address _poolToken)
external
view
returns (MarketPauseStatusmemory);
function getTotalMarketSupply(address _poolToken)
external
view
returns (uint256 p2pSupplyAmount, uint256 poolSupplyAmount);
function getTotalMarketBorrow(address _poolToken)
external
view
returns (uint256 p2pBorrowAmount, uint256 poolBorrowAmount);
struct LiquidityData {
uint256 collateralEth;// The collateral value (in USD, 18 decimals).
uint256 borrowableEth;// The maximum debt value allowed to borrow (in USD, 18 decimals).
uint256 maxDebtEth;// The maximum debt value allowed before being liquidatable (in USD, 18 decimals).
uint256 debtEth;// The debt value (in USD, 18 decimals).
}
function getUserBalanceStates(address _user)publicviewreturns (LiquidityDatamemory);
struct LiquidityData {
uint256 collateralEth;// The collateral value (in USD, 18 decimals).
uint256 borrowableEth;// The maximum debt value allowed to borrow (in USD, 18 decimals).
uint256 maxDebtEth;// The maximum debt value allowed before being liquidatable (in USD, 18 decimals).
uint256 debtEth;// The debt value (in USD, 18 decimals).
}
function getUserHypotheticalBalanceStates(
address _user,
address _poolToken,
uint256 _withdrawnAmount,
uint256 _borrowedAmount
)publicviewreturns (LiquidityDatamemory liquidityData);
function getUserHealthFactor(address _user)publicviewreturns (uint256);