Euler Finance
  • Welcome
  • Getting Started
    • Introduction
    • White Paper
    • Quick Links
  • App
    • Getting Started
      • Common Errors
    • How To
      • Connect a Wallet
      • Deposit
      • Withdraw
      • Borrow
      • Repay
      • Mint
      • Burn
      • Sub-Accounts
      • Transfer
      • Swap
      • Short/Long
      • Protected Collateral
      • Transaction Builder
      • Wrap
      • Activate
      • Allowances
      • Retrieve Browser Errors
      • Lending and Borrowing
    • FAQ
  • Euler Protocol
    • Getting Started
      • Risk Methodology
        • Asset Tiers
        • Collateral and Borrow Factor
        • Ranking Assets
        • Oracle Rating
      • Simulation Environment
    • Addresses
    • Parameters
      • Interest Rates
      • Risk Factors
  • Euler Governance
    • Getting Started
      • Phases
    • How To
      • Delegate Voting Power
      • Write a Proposal
      • Create a Tally (On-Chain) Proposal
        • Create a Snapshot (Off-Chain) Proposal
      • Vote on Tally (On-Chain)
      • Vote on Snapshot (Off-Chain)
      • Join the Forum
    • Treasury
    • Grants
    • Addresses
    • Parameters
  • EUL
    • About
    • Distribution
    • Epochs
    • Gauges
    • Staking
  • Developers
    • Getting Started
      • Contract Integration Guide
      • Contract Reference
      • Architecture
    • Proxy Protocol
    • Numeric Limits
    • SDK
    • Subgraph
  • Security
    • Audits
    • Bug Bounty
    • Insurance
  • Languages
    • White Paper (ENG-CHN)
    • Community Translations
  • Legal
    • Terms and Conditions
    • Privacy Policy
Powered by GitBook
On this page
  • amounts
  • small amounts
  • debt amounts
  • prices
  • interestRate
  • interestAccumulator
  • moduleId
  • collateralFactor/borrowFactor

Was this helpful?

Export as PDF
  1. Developers

Numeric Limits

amounts

uint112

  • Maximum sane amount (result of balanceOf) for external tokens

  • Uniswap2 limits token amounts to this

  • Spec: For an 18 decimal token, more than a million billion tokens (1e15)

small amounts

uint96

  • For holding amounts that we don't expect to get quite as large, in particular reserve balances

  • Can pack together with an address in a single slot

  • Spec: For an 18 decimal token, more than a billion tokens (1e9)

debt amounts

uint144

  • Maximum sane amount for debts

  • Packs together with an amount in a single storage slot

  • Spec: Should hold the maximum possible amount (uint112) but scaled by another 9 decimal places (for the internal debt precision)

    • Actual: 2e16

prices

  • Minimum supported price:

    • Fraction: 1e3 / 1e18 = 1e-15

    • Tick: -345405

    • sqrtPriceX96: 2505418623681149822473

  • Maximum supported price:

    • Fraction: 1e33 / 1e18 = 1e15

    • Tick: 345405

    • sqrtPriceX96: 2505410343826649584586222772852783278

The supported price range was chosen for the following reason:

  • The maximum price squared fits in a uint256: 6e73 < 1e77

    • Not necessary to use FullMath library

  • The maximum supported price times the maximum supported amount fits within a uint256: 5e66 < 1e77

    • Also holds with debt and its extra 9 digits of precision: 5e75 < 1e77

interestRate

int96

  • "Second Percent Yield"

  • Fraction scaled by 1e27

    • Example: 10% APR = 1e27 * 0.1 / (86400*365) = 1e27 * 0.000000003170979198376458650 = 3170979198376458650

  • Spec: 1 billion % APR, positive or negative

interestAccumulator

uint256

  • Starts at 1e27, multiplied by (1e27 + interestRate) every second

  • Spec: 100% APR for 100 years

    -> 2^256
    ~= 1.1579208923e+77
    -> 10^27 * (1 + (100/100 / (86400*365)))^(86400*365*100)
    ~= 2.6881128798e+70

moduleId

uint32

  • One per module, so this is way more than needed

  • Divided into 3 sections

    • <500_000: Public single-proxy

    • =500_000 and <1_000_000: Public multi-proxy

    • =1_000_000: Internal

  • Spec: A dozen or so modules, with room to grow in all sections

collateralFactor/borrowFactor

uint32

  • Fraction between 0 and 1, scaled by 2^32 - 1

  • Spec: At least 3 decimal places (overkill)

PreviousProxy ProtocolNextSDK

Last updated 2 years ago

Was this helpful?