Interpreting Exchange Rates

The bToken Exchange Rate is scaled by the difference in decimals between the bToken and the underlying asset.

const oneBTokenInUnderlying = exchangeRateCurrent / (1 * 10 ^ (18 + underlyingDecimals - bTokenDecimals))

Here is an example of finding the value of 1 bWETH in WETH with Web3.js JavaScript.

const bTokenDecimals = 8; // all bTokens have 8 decimal places
const underlying = new web3.eth.Contract(erc20Abi, ethAddress);
const bToken = new web3.eth.Contract(bTokenAbi, bEthAddress);
const underlyingDecimals = await underlying.methods.decimals().call();
const exchangeRateCurrent = await bToken.methods.exchangeRateCurrent().call();
const mantissa = 18 + parseInt(underlyingDecimals) - bTokenDecimals;
const oneBTokenInUnderlying = exchangeRateCurrent / Math.pow(10, mantissa);
console.log('1 bWETH can be redeemed for', oneBTokenInUnderlying, 'WETH');

There is no underlying contract for SEI, so to do this with bSEI, set underlyingDecimals to 18.

To find the number of underlying tokens that can be redeemed for bTokens, multiply the number of bTokens by the above value oneBTokenInUnderlying.

const underlyingTokens = bTokenAmount * oneBTokenInUnderlying

Last updated