Ion Protocol
HomeDiscordTwitter
  • Overview
    • ๐Ÿ’งWelcome to Ion Protocol
    • ๐Ÿ“šUnderstanding the Staking and Restaking Ecosystem
    • ๐Ÿ”—Official Links
    • โ”FAQ
  • Ion Protocol
    • โš™๏ธHow Ion Works
    • ๐Ÿ‘ฅReferrals
    • ๐Ÿ’ฆIon Points
  • Lending
    • ๐Ÿ’ฐHow To Lend On Ion
    • ๐ŸŒETH-on-ETH Yield
    • ๐ŸงชLending Mechanisms
      • Composable Markets
      • ZKML-Supported Risk Underwriting
  • Borrowing
    • ๐Ÿ’ธHow To Borrow On Ion
    • ๐Ÿ“ˆMultiplying Rewards
    • ๐Ÿ› ๏ธBorrowing Mechanisms
      • Flash Leverage
      • Interest Rates
      • ZK Proof-of-Reserve
  • Liquidations
    • ๐Ÿ“‰Liquidation Mechanism
    • ๐Ÿง‘โ€๐Ÿ’ปKeepers
  • Supported Collateral
    • LSTs
    • LRTs
    • Exotic ETH-Backed Assets
  • Devs
    • ๐Ÿ’ปSmart Contract Architecture
      • Home
      • Admin
        • ProxyAdmin
        • TransparentUpgradeableProxy
        • ITransparentUpgradeableProxy
      • Flash
        • LRT
          • RsEthHandler
          • EzEthHandler
          • RswEthHandler
          • WeEthHandler
        • LST
          • SwEthHandler
          • EthXHandler
          • WstEthHandler
        • BalancerFlashloanDirectMintHandler constants
        • BalancerFlashloanDirectMintHandler
        • PtHandler
        • IonHandlerBase
        • UniswapFlashloanBalancerSwapHandler
        • UniswapFlashswapDirectMintHandler
        • UniswapFlashswapDirectMintHandlerWithDust
        • UniswapFlashswapHandler
      • Join
        • GemJoin
      • Libraries
        • LRT
          • KelpDaoLibrary
          • EtherFiLibrary
          • RestakedSwellLibrary
          • RenzoLibrary
        • LST
          • StaderLibrary
          • LidoLibrary
          • SwellLibrary
        • math
          • WadRayMath constants
          • WadRayMath
        • uniswap
          • UniswapOracleLibrary
          • TickMath
      • Oracles
        • Reserve
          • LRT
            • EzEthWstEthReserveOracle
            • RsEthWstEthReserveOracle
            • RswEthWstEthReserveOracle
            • WeEthWstEthReserveOracle
          • LST
            • SwEthReserveOracle
            • EthXReserveOracle
            • WstEthReserveOracle
          • Pendle
            • EzEthPtReserveOracle
            • RsEthPtReserveOracle
            • RswEthPtReserveOracle
            • WeEthPtReserveOracle
          • ReserveOracle
          • ReserveFeed
          • ReserveOracle constants
        • Spot
          • LRT
            • EzEthWstEthSpotOracle
            • RsEthWstEthSpotOracle
            • RswEthWstEthSpotOracle
            • WeEthWstEthSpotOracle
          • LST
            • EthXSpotOracle constants
            • EthXSpotOracle
            • IRedstonePriceFeed
            • SwEthSpotOracle
            • WstEthSpotOracle
          • SpotOracle
          • PtSpotOracle
      • Periphery
        • IonInvariants
        • IonLens
        • IlkSlot0
        • IonRegistry
      • Token
        • IERC20Errors
        • RewardToken
      • Vault
        • VaultFactory
        • Vault
      • Whitelist
      • YieldOracle constants
      • YieldOracle
      • YieldOracleNull
      • YieldOraclePendle
      • Errors
      • Constants
      • Seaport Leverage and Deleverage
    • ๐Ÿ“„Deployed Contracts
  • Security
    • ๐Ÿ”Security Reviews
  • Legal
    • Terms of Use
    • Privacy Policy
  • Import
    • ProxyAdmin
Powered by GitBook
On this page
  • Functions
  • Errors
  1. Devs
  2. Smart Contract Architecture
  3. Libraries
  4. math

WadRayMath

PreviousWadRayMath constantsNextuniswap

This library provides mul/div[up/down] functionality for WAD, RAY and RAD with phantom overflow protection as well as scale[up/down] functionality for WAD, RAY and RAD.

Functions

wadMulDown

Multiplies two WAD numbers and returns the result as a WAD rounding the result down.

function wadMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand.

b

uint256

Multiplier.

wadMulUp

Multiplies two WAD numbers and returns the result as a WAD rounding the result up.

function wadMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand.

b

uint256

Multiplier.

wadDivDown

Divides two WAD numbers and returns the result as a WAD rounding the result down.

function wadDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend.

b

uint256

Divisor.

wadDivUp

Divides two WAD numbers and returns the result as a WAD rounding the result up.

function wadDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend.

b

uint256

Divisor.

rayMulDown

Multiplies two RAY numbers and returns the result as a RAY rounding the result down.

function rayMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand

b

uint256

Multiplier

rayMulUp

Multiplies two RAY numbers and returns the result as a RAY rounding the result up.

function rayMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand

b

uint256

Multiplier

rayDivDown

Divides two RAY numbers and returns the result as a RAY rounding the result down.

function rayDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend

b

uint256

Divisor

rayDivUp

Divides two RAY numbers and returns the result as a RAY rounding the result up.

function rayDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend

b

uint256

Divisor

radMulDown

Multiplies two RAD numbers and returns the result as a RAD rounding the result down.

function radMulDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand

b

uint256

Multiplier

radMulUp

Multiplies two RAD numbers and returns the result as a RAD rounding the result up.

function radMulUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Multiplicand

b

uint256

Multiplier

radDivDown

Divides two RAD numbers and returns the result as a RAD rounding the result down.

function radDivDown(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend

b

uint256

Divisor

radDivUp

Divides two RAD numbers and returns the result as a RAD rounding the result up.

function radDivUp(uint256 a, uint256 b) internal pure returns (uint256);

Parameters

Name
Type
Description

a

uint256

Dividend

b

uint256

Divisor

scaleUpToWad

Scales a value up from WAD. NOTE: The scale value must be less than 18.

function scaleUpToWad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale up.

scale

uint256

of the returned value.

scaleUpToRay

Scales a value up from RAY. NOTE: The scale value must be less than 27.

function scaleUpToRay(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale up.

scale

uint256

of the returned value.

scaleUpToRad

Scales a value up from RAD. NOTE: The scale value must be less than 45.

function scaleUpToRad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale up.

scale

uint256

of the returned value.

scaleDownToWad

Scales a value down to WAD. NOTE: The scale value must be greater than 18.

function scaleDownToWad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale down.

scale

uint256

of the returned value.

scaleDownToRay

Scales a value down to RAY. NOTE: The scale value must be greater than 27.

function scaleDownToRay(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale down.

scale

uint256

of the returned value.

scaleDownToRad

Scales a value down to RAD. NOTE: The scale value must be greater than 45.

function scaleDownToRad(uint256 value, uint256 scale) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale down.

scale

uint256

of the returned value.

scaleUp

Scales a value up from one fixed-point precision to another.

function scaleUp(uint256 value, uint256 from, uint256 to) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale up.

from

uint256

Precision to scale from.

to

uint256

Precision to scale to.

scaleDown

Scales a value down from one fixed-point precision to another.

function scaleDown(uint256 value, uint256 from, uint256 to) internal pure returns (uint256);

Parameters

Name
Type
Description

value

uint256

to scale down.

from

uint256

Precision to scale from.

to

uint256

Precision to scale to.

Errors

NotScalingUp

error NotScalingUp(uint256 from, uint256 to);

NotScalingDown

error NotScalingDown(uint256 from, uint256 to);

๐Ÿ’ป
Git Source