Lens
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.
Lens Functions
getTotalSupply
function getTotalSupply()
external
view
returns (
uint256 p2pSupplyAmount,
uint256 poolSupplyAmount,
uint256 totalSupplyAmount
);
Return values:
p2pSupplyAmount
uint256
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
function getTotalBorrow()
external
view
returns (
uint256 p2pBorrowAmount,
uint256 poolBorrowAmount,
uint256 totalBorrowAmount
);
Return values:
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
function getUserUnclaimedRewards(address
external
view
returns (uint256);
Returns the unclaimed XVS rewards for the given cToken addresses.
Parameters:
_poolTokens
address[]
The cToken addresses for which to compute the rewards.
_user
address
The user to compute the rewards for.
Return values:
unclaimedRewards
uint256
The unclaimed XVS rewards for the given cToken addresses.
getAccruedSupplierXvs
function getAccruedSupplierXvs(
address _supplier,
address _poolToken
)externalviewreturns (uint256);
Returns the accrued Xvs rewards of a user since the last update.
Parameters:
_supplier
address
The user to compute the rewards for.
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
accruedSupplierXvs
uint256
The accrued XVS rewards.
getAccruedBorrowerXvs
function getAccruedBorrowerXvs(
address _supplier,
address _poolToken
)externalviewreturns (uint256);
Returns the accrued XVS rewards of a user since the last update.
Parameters:
_supplier
address
The user to compute the rewards for.
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
accruedBorrowerXvs
uint256
The accrued XVS rewards.
getCurrentXvsSupplyIndex
function getCurrentXvsSupplyIndex(address _poolToken)externalviewreturns (uint256);
Returns the updated XVS supply index.
Parameters:
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
supplyIndex
uint256
The updated XVS supply index.
getCurrentXvsBorrowIndex
function getCurrentXvsBorrowIndex(address _poolToken)externalviewreturns (uint256);
Returns the updated XVS borrow index.
Parameters:
_poolToken
address
The cToken address for which to compute the rewards.
Return values:
supplyIndex
uint256
The updated XVS borrow index.
Market Lens Functions
isMarketCreated
function isMarketCreated(address _poolToken)externalviewreturns (bool);
Checks if a market is created.
Parameters:
_poolToken
address
The address of the market to check.
Return values:
isCreated
bool
True if the market is created.
getAllMarkets
function getAllMarkets()externalviewreturns (address;
Returns the list of all markets created.
Return values:
markets
address[]
The list of all markets created.
getMainMarketData
function getMainMarketData(address _poolToken)
external
view
returns (
uint256 avgSupplyRatePerBlock,
uint256 avgBorrowRatePerBlock,
uint256 p2pSupplyAmount,
uint256 p2pBorrowAmount,
uint256 poolSupplyAmount,
uint256 poolBorrowAmount
);
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:
_poolToken
address
The address of the market to check.
Return values:
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
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
);
Returns non-updated indexes, the block at which they were last updated and the total deltas of a given market.
Parameters:
_poolToken
address
The address of the market to check.
Return values:
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
function getMarketConfiguration(address _poolToken)
external
view
returns (
address underlying,
bool isCreated,
bool isP2PDisabled,
bool isPaused,
bool isPartiallyPaused,
uint16 reserveFactor,
uint16 p2pIndexCursor,
uint256 collateralFactor
);
Returns the given market's configuration.
Parameters:
_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:
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
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);
Returns the given market's pause statuses.
Parameters:
_poolToken
address
The address of the market of which to get pause statuses.
Return values:
marketPauseStatus
MarketPauseStatus
The market status struct.
getTotalMarketSupply
function getTotalMarketSupply(address _poolToken)
external
view
returns (uint256 p2pSupplyAmount, uint256 poolSupplyAmount);
Computes and returns the total distribution of supply for a given market, using virtually updated indexes.
Parameters:
_poolToken
address
The address of the market to check.
Return values:
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
function getTotalMarketBorrow(address _poolToken)
external
view
returns (uint256 p2pBorrowAmount, uint256 poolBorrowAmount);
Computes and returns the total distribution of borrow for a given market, using virtually updated indexes.
Parameters:
_poolToken
address
The address of the market to check.
Return values:
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
function getNextUserSupplyRatePerBlock(
address _poolToken,
address _user,
uint256 _amount
)
external
view
returns (
uint256 nextSupplyRatePerBlock,
uint256 balanceInP2P,
uint256 balanceOnPool,
uint256 totalBalance
);
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:
_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:
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
function getNextUserBorrowRatePerBlock(
address _poolToken,
address _user,
uint256 _amount
)
external
view
returns (
uint256 nextBorrowRatePerBlock,
uint256 balanceInP2P,
uint256 balanceOnPool,
uint256 totalBalance
);
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:
_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:
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
function getCurrentUserSupplyRatePerBlock(address _poolToken, address _user)
external
view
returns (uint256 supplyRatePerBlock);
Returns the supply rate per block a given user is currently experiencing on a given market.
Parameters:
_poolToken
address
The address of the market.
_user
address
The user to compute the supply rate per block for.
Return values:
supplyRatePerBlock
uint256
The supply rate per block the user is currently experiencing (in wad).
getCurrentUserBorrowRatePerBlock
function getCurrentUserBorrowRatePerBlock(address _poolToken, address _user)
external
view
returns (uint256 borrowRatePerBlock);
Returns the borrow rate per block a given user is currently experiencing on a given market.
Parameters:
_poolToken
address
The address of the market.
_user
address
The user to compute the borrow rate per block for.
Return values:
borrowRatePerBlock
uint256
The borrow rate per block the user is currently experiencing (in wad).
getAverageSupplyRatePerYear
function getAverageSupplyRatePerBlock(address _poolToken)
public
view
returns (
uint256 avgSupplyRatePerBlock,
uint256 p2pSupplyAmount,
uint256 poolSupplyAmount
);
Computes and returns the current supply rate per block experienced on average on a given market.
Parameters:
_poolToken
address
The address of the market.
Return values:
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
function getAverageBorrowRatePerBlock(address _poolToken)
public
view
returns (
uint256 avgBorrowRatePerBlock,
uint256 p2pBorrowAmount,
uint256 poolBorrowAmount
);
Computes and returns the current borrow rate per block experienced on average on a given market.
Parameters:
_poolToken
address
The address of the market.
Return values:
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
function getRatesPerBlock(address _poolToken)
public
view
returns (
uint256 p2pSupplyRate,
uint256 p2pBorrowRate,
uint256 poolSupplyRate,
uint256 poolBorrowRate
);
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:
_poolToken
address
The address of the market.
Return values:
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
function getEnteredMarkets(address _user)
external
view
returns (address;
Returns all markets entered by a given user.
Parameters:
_user
address
The address of the user to check.
Return values:
enteredMarkets
address[]
The list of all markets entered by the user.
getUserMaxCapacitiesForAsset
function getUserMaxCapacitiesForAsset(address _user, address _poolToken)
external
view
returns (uint256 withdrawable, uint256 borrowable);
Returns the maximum amount available to withdraw & borrow for a given user, on a given market.
Parameters:
_user
address
The address of the user to check.
_poolToken
address
The address of the market to check.
Return values:
withdrawable
uint256
The maximum amount available to withdraw.
borrowable
uint256
The maximum amount available to borrow.
computeLiquidationRepayAmount
function computeLiquidationRepayAmount(
address _user,
address _poolTokenBorrowed,
address _poolTokenCollateral
)externalviewreturns (uint256);
Computes the maximum repayable amount for a potential liquidation.
Parameters:
_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:
repayAmount
uint256
The maximum repayable amount (in underlying).
getCurrentSupplyBalanceInOf
function getCurrentSupplyBalanceInOf(address _poolToken, address _user)
external
view
returns (
uint256 balanceInP2P,
uint256 balanceOnPool,
uint256 totalBalance
);
Returns the balance in underlying of a given user in a given market.
Parameters:
_poolToken
address
The address of the market.
_user
address
The address of the user to check.
Return values:
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
function getCurrentBorrowBalanceInOf(address _poolToken, address _user)
external
view
returns (
uint256 balanceInP2P,
uint256 balanceOnPool,
uint256 totalBalance
);
Returns the balance in underlying of a given user in a given market.
Parameters:
_poolToken
address
The address of the market.
_user
address
The address of the user to check.
Return values:
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
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);
Returns the collateral value, debt value and max debt value of a given user.
Parameters:
_user
address
The address of the user to check.
Return values:
liquidityData
LiquidityData
The liquidity data struct.
getUserHypotheticalBalanceStates
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);
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:
_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:
liquidityData
LiquidityData
The liquidity data struct.
getUserHealthFactor
function getUserHealthFactor(address _user)publicviewreturns (uint256);
Returns the health factor of a given user.
Parameters:
_user
address
The address of the user to check.
Return values:
healthFactor
uint256
The health factor of the given user.
getUserHypotheticalHealthFactor
function getUserHypotheticalHealthFactor(
address _user,
address _poolToken,
uint256 _withdrawnAmount,
uint256 _borrowedAmount
)publicviewreturns (uint256 healthFactor);
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:
_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:
healthFactor
uint256
The health factor of the given user.
isLiquidatable
function isLiquidatable(address _user)publicviewreturns (bool);
Checks if a given user is liquidatable.
Parameters:
_user
address
The address of the user to check.
Return values:
isLiquidatable
bool
True if the user is liquidatable.
Last updated