Links

Contract Reference

IEuler

Main storage contract for the Euler system

moduleIdToImplementation

Lookup the current implementation contract for a module
function moduleIdToImplementation(uint moduleId) external view returns (address);
Parameters:
  • moduleId: Fixed constant that refers to a module type (ie MODULEID__ETOKEN)
Returns:
  • An internal address specifies the module's implementation code

moduleIdToProxy

Lookup a proxy that can be used to interact with a module (only valid for single-proxy modules)
function moduleIdToProxy(uint moduleId) external view returns (address);
Parameters:
  • moduleId: Fixed constant that refers to a module type (ie MODULEID__MARKETS)
Returns:
  • An address that should be cast to the appropriate module interface, ie IEulerMarkets(moduleIdToProxy(2))

AssetConfig

Euler-related configuration for an asset
struct AssetConfig {
address eTokenAddress;
bool borrowIsolated;
uint32 collateralFactor;
uint32 borrowFactor;
uint24 twapWindow;
}

IEulerMarkets

Activating and querying markets, and maintaining entered markets lists

activateMarket

Create an Euler pool and associated EToken and DToken addresses.
function activateMarket(address underlying) external returns (address);
Parameters:
  • underlying: The address of an ERC20-compliant token. There must be an initialised uniswap3 pool for the underlying/reference asset pair.
Returns:
  • The created EToken, or the existing EToken if already activated.

activatePToken

Create a pToken and activate it on Euler. pTokens are protected wrappers around assets that prevent borrowing.
function activatePToken(address underlying) external returns (address);
Parameters:
  • underlying: The address of an ERC20-compliant token. There must already be an activated market on Euler for this underlying, and it must have a non-zero collateral factor.
Returns:
  • The created pToken, or an existing one if already activated.

underlyingToEToken

Given an underlying, lookup the associated EToken
function underlyingToEToken(address underlying) external view returns (address);
Parameters:
  • underlying: Token address
Returns:
  • EToken address, or address(0) if not activated

underlyingToDToken

Given an underlying, lookup the associated DToken
function underlyingToDToken(address underlying) external view returns (address);
Parameters:
  • underlying: Token address
Returns:
  • DToken address, or address(0) if not activated

underlyingToPToken

Given an underlying, lookup the associated PToken
function underlyingToPToken(address underlying) external view returns (address);
Parameters:
  • underlying: Token address
Returns:
  • PToken address, or address(0) if it doesn't exist

underlyingToAssetConfig

Looks up the Euler-related configuration for a token, and resolves all default-value placeholders to their currently configured values.
function underlyingToAssetConfig(address underlying) external view returns (IEuler.AssetConfig memory);
Parameters:
  • underlying: Token address
Returns:
  • Configuration struct

underlyingToAssetConfigUnresolved

Looks up the Euler-related configuration for a token, and returns it unresolved (with default-value placeholders)
function underlyingToAssetConfigUnresolved(address underlying) external view returns (IEuler.AssetConfig memory config);
Parameters:
  • underlying: Token address
Returns:
  • config: Configuration struct

eTokenToUnderlying

Given an EToken address, looks up the associated underlying
function eTokenToUnderlying(address eToken) external view returns (address underlying);
Parameters:
  • eToken: EToken address
Returns:
  • underlying: Token address

dTokenToUnderlying

Given a DToken address, looks up the associated underlying
function dTokenToUnderlying(address dToken) external view returns (address underlying);
Parameters:
  • dToken: DToken address
Returns:
  • underlying: Token address

eTokenToDToken

Given an EToken address, looks up the associated DToken
function eTokenToDToken(address eToken) external view returns (address dTokenAddr);
Parameters:
  • eToken: EToken address
Returns:
  • dTokenAddr: DToken address

interestRateModel

Looks up an asset's currently configured interest rate model
function interestRateModel(address underlying) external view returns (uint);
Parameters:
  • underlying: Token address
Returns:
  • Module ID that represents the interest rate model (IRM)

interestRate

Retrieves the current interest rate for an asset
function interestRate(address underlying) external view returns (int96);
Parameters:
  • underlying: Token address
Returns:
  • The interest rate in yield-per-second, scaled by 10**27

interestAccumulator

Retrieves the current interest rate accumulator for an asset
function interestAccumulator(address underlying) external view returns (uint);
Parameters:
  • underlying: Token address
Returns:
  • An opaque accumulator that increases as interest is accrued

reserveFee

Retrieves the reserve fee in effect for an asset
function reserveFee(address underlying) external view returns (uint32);
Parameters:
  • underlying: Token address
Returns:
  • Amount of interest that is redirected to the reserves, as a fraction scaled by RESERVE_FEE_SCALE (4e9)

getPricingConfig

Retrieves the pricing config for an asset
function getPricingConfig(address underlying) external view returns (uint16 pricingType, uint32 pricingParameters, address pricingForwarded);
Parameters:
  • underlying: Token address
Returns:
  • pricingType: (1=pegged, 2=uniswap3, 3=forwarded, 4=chainlink)
  • pricingParameters: If uniswap3 pricingType then this represents the uniswap pool fee used, if chainlink pricing type this represents the fallback uniswap pool fee or 0 if none
  • pricingForwarded: If forwarded pricingType then this is the address prices are forwarded to, otherwise address(0)

getChainlinkPriceFeedConfig

Retrieves the Chainlink price feed config for an asset
function getChainlinkPriceFeedConfig(address underlying) external view returns (address chainlinkAggregator);
Parameters:
  • underlying: Token address
Returns:
  • chainlinkAggregator: Chainlink aggregator proxy address

getEnteredMarkets

Retrieves the list of entered markets for an account (assets enabled for collateral or borrowing)
function getEnteredMarkets(address account) external view returns (address[] memory);
Parameters:
  • account: User account
Returns:
  • List of underlying token addresses

enterMarket

Add an asset to the entered market list, or do nothing if already entered
function enterMarket(uint subAccountId, address newMarket) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • newMarket: Underlying token address

exitMarket

Remove an asset from the entered market list, or do nothing if not already present
function exitMarket(uint subAccountId, address oldMarket) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • oldMarket: Underlying token address

IEulerExec

Batch executions, liquidity check deferrals, and interfaces to fetch prices and account liquidity

LiquidityStatus

Liquidity status for an account, either in aggregate or for a particular asset
struct LiquidityStatus {
uint collateralValue;
uint liabilityValue;
uint numBorrows;
bool borrowIsolated;
}

AssetLiquidity

Aggregate struct for reporting detailed (per-asset) liquidity for an account
struct AssetLiquidity {
address underlying;
LiquidityStatus status;
}

EulerBatchItem

Single item in a batch request
struct EulerBatchItem {
bool allowError;
address proxyAddr;
bytes data;
}

EulerBatchItemResponse

Single item in a batch response
struct EulerBatchItemResponse {
bool success;
bytes result;
}

BatchDispatchSimulation

Error containing results of a simulated batch dispatch
error BatchDispatchSimulation(EulerBatchItemResponse[] simulation);

liquidity

Compute aggregate liquidity for an account
function liquidity(address account) external view returns (LiquidityStatus memory status);
Parameters:
  • account: User address
Returns:
  • status: Aggregate liquidity (sum of all entered assets)

detailedLiquidity

Compute detailed liquidity for an account, broken down by asset
function detailedLiquidity(address account) external view returns (AssetLiquidity[] memory assets);
Parameters:
  • account: User address
Returns:
  • assets: List of user's entered assets and each asset's corresponding liquidity

getPrice

Retrieve Euler's view of an asset's price
function getPrice(address underlying) external view returns (uint twap, uint twapPeriod);
Parameters:
  • underlying: Token address
Returns:
  • twap: Time-weighted average price
  • twapPeriod: TWAP duration, either the twapWindow value in AssetConfig, or less if that duration not available

getPriceFull

Retrieve Euler's view of an asset's price, as well as the current marginal price on uniswap
function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice);
Parameters:
  • underlying: Token address
Returns:
  • twap: Time-weighted average price
  • twapPeriod: TWAP duration, either the twapWindow value in AssetConfig, or less if that duration not available
  • currPrice: The current marginal price on uniswap3 (informational: not used anywhere in the Euler protocol)

deferLiquidityCheck

Defer liquidity checking for an account, to perform rebalancing, flash loans, etc. msg.sender must implement IDeferredLiquidityCheck
function deferLiquidityCheck(address account, bytes memory data) external;
Parameters:
  • account: The account to defer liquidity for. Usually address(this), although not always
  • data: Passed through to the onDeferredLiquidityCheck() callback, so contracts don't need to store transient data in storage

batchDispatch

Execute several operations in a single transaction
function batchDispatch(EulerBatchItem[] calldata items, address[] calldata deferLiquidityChecks) external;
Parameters:
  • items: List of operations to execute
  • deferLiquidityChecks: List of user accounts to defer liquidity checks for

batchDispatchSimulate

Call batch dispatch, but instruct it to revert with the responses, before the liquidity checks.
function batchDispatchSimulate(EulerBatchItem[] calldata items, address[] calldata deferLiquidityChecks) external;
Parameters:
  • items: List of operations to execute
  • deferLiquidityChecks: List of user accounts to defer liquidity checks for

trackAverageLiquidity

Enable average liquidity tracking for your account. Operations will cost more gas, but you may get additional benefits when performing liquidations
function trackAverageLiquidity(uint subAccountId, address delegate, bool onlyDelegate) external;
Parameters:
  • subAccountId: subAccountId 0 for primary, 1-255 for a sub-account.
  • delegate: An address of another account that you would allow to use the benefits of your account's average liquidity (use the null address if you don't care about this). The other address must also reciprocally delegate to your account.
  • onlyDelegate: Set this flag to skip tracking average liquidity and only set the delegate.

unTrackAverageLiquidity

Disable average liquidity tracking for your account and remove delegate
function unTrackAverageLiquidity(uint subAccountId) external;
Parameters:
  • subAccountId: subAccountId 0 for primary, 1-255 for a sub-account

getAverageLiquidity

Retrieve the average liquidity for an account
function getAverageLiquidity(address account) external returns (uint);
Parameters:
  • account: User account (xor in subAccountId, if applicable)
Returns:
  • The average liquidity, in terms of the reference asset, and post risk-adjustment

getAverageLiquidityWithDelegate

Retrieve the average liquidity for an account or a delegate account, if set
function getAverageLiquidityWithDelegate(address account) external returns (uint);
Parameters:
  • account: User account (xor in subAccountId, if applicable)
Returns:
  • The average liquidity, in terms of the reference asset, and post risk-adjustment

getAverageLiquidityDelegateAccount

Retrieve the account which delegates average liquidity for an account, if set
function getAverageLiquidityDelegateAccount(address account) external view returns (address);
Parameters:
  • account: User account (xor in subAccountId, if applicable)
Returns:
  • The average liquidity delegate account

pTokenWrap

Transfer underlying tokens from sender's wallet into the pToken wrapper. Allowance should be set for the euler address.
function pTokenWrap(address underlying, uint amount) external;
Parameters:
  • underlying: Token address
  • amount: The amount to wrap in underlying units

pTokenUnWrap

Transfer underlying tokens from the pToken wrapper to the sender's wallet.
function pTokenUnWrap(address underlying, uint amount) external;
Parameters:
  • underlying: Token address
  • amount: The amount to unwrap in underlying units

usePermit

Apply EIP2612 signed permit on a target token from sender to euler contract
function usePermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
Parameters:
  • token: Token address
  • value: Allowance value
  • deadline: Permit expiry timestamp
  • v: secp256k1 signature v
  • r: secp256k1 signature r
  • s: secp256k1 signature s

usePermitAllowed

Apply DAI like (allowed) signed permit on a target token from sender to euler contract
function usePermitAllowed(address token, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external;
Parameters:
  • token: Token address
  • nonce: Sender nonce
  • expiry: Permit expiry timestamp
  • allowed: If true, set unlimited allowance, otherwise set zero allowance
  • v: secp256k1 signature v
  • r: secp256k1 signature r
  • s: secp256k1 signature s

usePermitPacked

Apply allowance to tokens expecting the signature packed in a single bytes param
function usePermitPacked(address token, uint256 value, uint256 deadline, bytes calldata signature) external;
Parameters:
  • token: Token address
  • value: Allowance value
  • deadline: Permit expiry timestamp
  • signature: secp256k1 signature encoded as rsv

doStaticCall

Execute a staticcall to an arbitrary address with an arbitrary payload.
function doStaticCall(address contractAddress, bytes memory payload) external view returns (bytes memory);
Parameters:
  • contractAddress: Address of the contract to call
  • payload: Encoded call payload
Returns:
  • result: Encoded return data

IEulerEToken

Tokenised representation of assets

name

Pool name, ie "Euler Pool: DAI"
function name() external view returns (string memory);

symbol

Pool symbol, ie "eDAI"
function symbol() external view returns (string memory);

decimals

Decimals, always normalised to 18.
function decimals() external pure returns (uint8);

underlyingAsset

Address of underlying asset
function underlyingAsset() external view returns (address);

totalSupply

Sum of all balances, in internal book-keeping units (non-increasing)
function totalSupply() external view returns (uint);

totalSupplyUnderlying

Sum of all balances, in underlying units (increases as interest is earned)
function totalSupplyUnderlying() external view returns (uint);

balanceOf

Balance of a particular account, in internal book-keeping units (non-increasing)
function balanceOf(address account) external view returns (uint);

balanceOfUnderlying

Balance of a particular account, in underlying units (increases as interest is earned)
function balanceOfUnderlying(address account) external view returns (uint);

reserveBalance

Balance of the reserves, in internal book-keeping units (non-increasing)
function reserveBalance() external view returns (uint);

reserveBalanceUnderlying

Balance of the reserves, in underlying units (increases as interest is earned)
function reserveBalanceUnderlying() external view returns (uint);

convertBalanceToUnderlying

Convert an eToken balance to an underlying amount, taking into account current exchange rate
function convertBalanceToUnderlying(uint balance) external view returns (uint);
Parameters:
  • balance: eToken balance, in internal book-keeping units (18 decimals)
Returns:
  • Amount in underlying units, (same decimals as underlying token)

convertUnderlyingToBalance

Convert an underlying amount to an eToken balance, taking into account current exchange rate
function convertUnderlyingToBalance(uint underlyingAmount) external view returns (uint);
Parameters:
  • underlyingAmount: Amount in underlying units (same decimals as underlying token)
Returns:
  • eToken: balance, in internal book-keeping units (18 decimals)

touch

Updates interest accumulator and totalBorrows, credits reserves, re-targets interest rate, and logs asset status
function touch() external;

deposit

Transfer underlying tokens from sender to the Euler pool, and increase account's eTokens
function deposit(uint subAccountId, uint amount) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • amount: In underlying units (use max uint256 for full underlying token balance)

withdraw

Transfer underlying tokens from Euler pool to sender, and decrease account's eTokens
function withdraw(uint subAccountId, uint amount) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • amount: In underlying units (use max uint256 for full pool balance)

mint

Mint eTokens and a corresponding amount of dTokens ("self-borrow")
function mint(uint subAccountId, uint amount) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • amount: In underlying units

burn

Pay off dToken liability with eTokens ("self-repay")
function burn(uint subAccountId, uint amount) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • amount: In underlying units (use max uint256 to repay the debt in full or up to the available underlying balance)

approve

Allow spender to access an amount of your eTokens in sub-account 0
function approve(address spender, uint amount) external returns (bool);
Parameters:
  • spender: Trusted address
  • amount: Use max uint256 for "infinite" allowance

approveSubAccount

Allow spender to access an amount of your eTokens in a particular sub-account
function approveSubAccount(uint subAccountId, address spender, uint amount) external returns (bool);
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • spender: Trusted address
  • amount: Use max uint256 for "infinite" allowance

allowance

Retrieve the current allowance
function allowance(address holder, address spender) external view returns (uint);
Parameters:
  • holder: Xor with the desired sub-account ID (if applicable)
  • spender: Trusted address

transfer

Transfer eTokens to another address (from sub-account 0)
function transfer(address to, uint amount) external returns (bool);
Parameters:
  • to: Xor with the desired sub-account ID (if applicable)
  • amount: In internal book-keeping units (as returned from balanceOf).

transferFromMax

Transfer the full eToken balance of an address to another
function transferFromMax(address from, address to) external returns (bool);
Parameters:
  • from: This address must've approved the to address, or be a sub-account of msg.sender
  • to: Xor with the desired sub-account ID (if applicable)

transferFrom

Transfer eTokens from one address to another
function transferFrom(address from, address to, uint amount) external returns (bool);
Parameters:
  • from: This address must've approved the to address, or be a sub-account of msg.sender
  • to: Xor with the desired sub-account ID (if applicable)
  • amount: In internal book-keeping units (as returned from balanceOf).

donateToReserves

Donate eTokens to the reserves
function donateToReserves(uint subAccountId, uint amount) external;
Parameters:
  • subAccountId: 0 for primary, 1-255 for a sub-account
  • amount: In internal book-keeping units (as returned from balanceOf).

IEulerDToken

Tokenised representation of debts

name

Debt token name, ie "Euler Debt: DAI"
function name() external view returns (string memory);

symbol

Debt token symbol, ie "dDAI"
function symbol() external view returns (string memory);

decimals

Decimals of underlying
function decimals() external view returns (uint8);

underlyingAsset

Address of underlying asset
function underlyingAsset() external view returns (address);

totalSupply

Sum of all outstanding debts, in underlying units (increases as interest is accrued)
function totalSupply() external view returns (uint);