GEB Docs
  • Introduction to GEB
  • Community Resources
  • FLX Mechanics
  • FAQ
  • RAI
    • RAI Use-Cases
    • Multi-chain RAI
    • RAI Integrations
  • The Money God League
    • Intro to The League
  • Ungovernance
    • Governance Minimization Guide
  • Risk
    • GEB Risks
    • PID Failure Modes & Responses
  • Incentives
    • RAI Uniswap V2 Mint + LP Incentives Program
    • RAI Uniswap V3 Mint + LP Incentives Program (Inactive)
    • FLX Staking
    • RAI / ETH Uniswap V3 Oracle LP Incentives Program
  • Contract Variables Translation
    • Core Contracts Naming Transition
    • Governance Contracts Naming Transition
    • SAFE Management Contract Naming Transition
  • System Contracts
    • Core Module
      • SAFE Engine
      • Liquidation Engine
      • Accounting Engine
    • Auction Module
      • English Collateral Auction House
      • Fixed Discount Collateral Auction House
      • Increasing Discount Collateral Auction House
      • Debt Auction House
      • Surplus Auction House
    • Oracle Module
      • Oracle Relayer
      • Medianizer
        • DSValue
        • Governance Led Median
        • Chainlink Median
        • Uniswap V2 Median
      • FSM
        • Oracle Security Module
        • Dampened Security Module
        • FSM Governance Interface
    • Token Module
      • Token Adapters
      • System Coin
      • Protocol Token
      • Protocol Token Authority
      • Protocol Token Printing Permissions
    • Money Market Module
      • Tax Collector
    • Sustainability Module
      • Stability Fee Treasury
      • FSM Wrapper
      • Increasing Treasury Reimbursement
      • Mandatory Fixed Treasury Reimbursement
      • Increasing Reward Relayer
    • Automation Module
      • Collateral Auction Throttler
      • Single Spot Debt Ceiling Setter
      • ESM Threshold Setter
    • Governance Module
      • DSPause
    • Shutdown Module
      • Global Settlement
      • ESM
  • Proxy Infrastructure
    • DSProxy
    • Proxy Registry
  • Helper Contracts
    • SAFE Manager
  • GEB.js
    • Getting Started
    • Global Settlement Guide
    • API Reference
      • Geb
      • Safe
      • Proxy Actions
      • Geb Admin
  • APIs
    • API Endpoints
  • Pyflex
    • Getting Started
      • Configuration
      • GEB Basics
    • SAFE Management
      • Opening a SAFE
      • Closing a SAFE
    • Numerics
  • Keepers
    • Keeper Overview
    • Collateral Auction Keeper
      • Running in Docker
      • Running on a Host
      • Liquidations & Collateral Auctions
      • Collateral Auction Flash Swaps
    • Debt Auction Keeper
      • Running in Docker
      • Running on a Host
    • Staked Token Auction Keeper
      • Running in Docker
      • Running on a Host
    • Surplus Auction Keeper
      • Running in Docker
      • Running on a Host
    • Bidding Models
  • Liquidation Protection
    • SAFE Protection
    • Liquidation Protection Guide
    • Uni-V2 RAI/ETH Savior Details
    • Curve V1 Savior Details
Powered by GitBook
On this page
  • Operations: Addition, Subtraction, Division
  • Operations: Multiplication
  • Conversion

Was this helpful?

  1. Pyflex

Numerics

GEB uses different numbers representing various levels of precision.

Type

Precision

Wad

1E-18

Ray

1E-27

Rad

1E-45

You can import them from pyflex:

>>> from pyflex.numeric import Wad, Ray, Rad

Converting Wad, Ray, Rad to a str shows the numbers in a friendly format:

>>> Wad.from_number(1.2)
Wad(1200000000000000000)
>>> str(Wad.from_number(1.2))
'1.200000000000000000'

Constructors will add a specific precision to a number eg. Wad(1) is not equal to 1 but to 10^18.

>>> Wad(10) == Wad.from_number(10)
False
>>> Wad(10) == Wad.from_number(10 * 1E-18)
True

Operations: Addition, Subtraction, Division

Wad, Ray, and Rad can only perform addition, subtraction and division with another Wad, Ray, or Rad

>>> Rad(10) + Wad(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/georgekellerman/reflexer/pyflex/lib/python3.8/site-packages/pyflex/numeric.py", line 320, in __add__
    raise ArithmeticError
ArithmeticError
>>> Ray(10) - Ray(5)
Ray(5)
>>> Rad(10) / Rad.from_number(2)
Rad(5)
>>> 

Operations: Multiplication

Wad, Ray, and Rad can be multiplied by any Wad, Ray, and Rad and int.

The result is the type of the first number:

>>> x = Wad.from_number(1.2) * Rad.from_number(1)
>>> type(x)
<class 'pyflex.numeric.Wad'>
>>> y = Rad.from_number(1) * Wad.from_number(1.2)
>>> type(y)
<class 'pyflex.numeric.Rad'>

Conversion

Wad, Ray, and Rad all accept Wad, Ray, and Rad in the constructors. This is the canonical way to convert numbers:

>>> Rad(Wad(10))
Rad(10000000000000000000000000000)

During conversion (Rad to Ray/Wad or Ray to Wad) you may lose precision!

>>> Wad(Rad(10))
Wad(0)
>>> Ray(Rad(20))
Ray(0)

PreviousClosing a SAFENextKeeper Overview

Last updated 4 years ago

Was this helpful?