Belugas Protocol
  • Belugas Protocol Documentation
  • Getting Started
    • Networks
    • Protocol Math
      • bToken and Underlying Decimals
      • Interpreting Exchange Rates
      • Calculating Accrued Interest
      • Calculating the APY Using Rate Per Block
    • Gas Costs
  • BTokens
    • Mint
    • Redeem
    • Redeem Underlying
    • Borrow
    • Repay Borrow
    • Repay Borrow Behalf
    • Transfer
    • Liquidate Borrow
    • Key Events
    • Error Codes
    • Failure Info
    • Exchange Rate
    • Get Cash
    • Total Borrow
    • Borrow Balance
    • Borrow Rate
    • Total Supply
    • Underlying Balance
    • Supply Rate
    • Total Reserves
    • Reserve Factor
  • Comptroller
    • Enter Markets
    • Exit Market
    • Get Assets In
    • Collateral Factor
    • Get Account Liquidity
    • Close Factor
    • Liquidation Incentive
    • Key Events
    • Error Codes
    • Failure Info
    • BUL Distribution Speeds
    • Claim BUL
    • Market Metadata
  • Governance
    • Delegate
    • Delegate By Signature
    • Get Current Votes
    • Get Prior Votes
    • Key Events
    • Governor Bravo
    • Quorum Votes
    • Proposal Threshold
    • Proposal Max Operations
    • Voting Delay
    • Voting Period
    • Propose
    • Queue
    • Execute
    • Cancel
    • Get Actions
    • Get Receipt
    • State
    • Cast Vote
    • Cast Vote With Reason
    • Cast Vote By Signature
    • Timelock
    • Pause Guardian
  • LP Staking
    • LP Utility
    • LP Staking Options
    • Zapping LP
    • Maintaining Eligibility Status
  • API
    • BTokenService
      • GET: /btoken
    • MarketHistoryService
      • GET: /market_history/graph
    • ProposalService
      • GET: /proposals
      • GET: /proposals/:id
      • GET: /proposals/statistics
    • VoterService
      • GET: /voters/accounts
      • GET: /voters/accounts/:address
      • GET: /voters/history/:address
      • GET: /voters/:proposalId
    • GovernanceService
      • GET: /governance/belugas
      • GET: /governance/proposals
      • GET: /governance/proposal_vote_receipts
      • GET: /governance/accounts
    • Shared Data Types
  • Belugas.js
    • Belugas Constructor
    • API Methods
      • Account
      • bToken
      • Market History
      • Governance
    • bToken Methods
      • Supply
      • Redeem
      • Borrow
      • Repay Borrow
    • BUL Methods
      • To Checksum Address
      • Get BUL Balance
      • Get BUL Accrued
      • Claim BUL
      • Delegate
      • Delegate By Sig
      • Create Delegate Signature
    • Comptroller Methods
      • Enter Markets
      • Exit Market
    • Ethereum Methods
      • Read
      • Trx
      • Get Balance
    • Governance Methods
      • Cast Vote
      • Cast Vote By Sig
      • Create Vote Signature
    • Price Feed Methods
      • Get Price
    • Utility Methods
      • Get Address
      • Get ABI
      • Get Network Name With Chain ID
  • Security
    • Formal Verification
    • Bug Bounty Program
  • Terms of Service
Powered by GitBook
On this page
  1. Getting Started
  2. Protocol Math

Interpreting Exchange Rates

PreviousbToken and Underlying DecimalsNextCalculating Accrued Interest

Last updated 1 year ago

The bToken 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
Exchange Rate