Docs
Search…
Exchange Rate
Each dToken is convertible into an ever increasing quantity of the underlying asset, as interest accrues in the market. The exchange rate between a dToken and the underlying asset is equal to:
1
exchangeRate = (getCash() + totalBorrows() - totalReserves()) / totalSupply()
Copied!

DErc20 / DEther

1
function exchangeRateCurrent() returns (uint)
Copied!
  • RETURN: The current exchange rate as an unsigned integer, scaled by 1 * 10^(18 - 8 + Underlying Token Decimals).

Solidity

1
DErc20 dToken = dToken(0x3FDA...);
2
uint exchangeRateMantissa = dToken.exchangeRateCurrent();
Copied!

Web3 1.0

1
const dToken = DEther.at(0x3FDB...);
2
const exchangeRate = (await dToken.methods.exchangeRateCurrent().call()) / 1e18;
Copied!
Tip: note the use of call vs. send to invoke the function from off-chain without incurring gas costs.