-
Notifications
You must be signed in to change notification settings - Fork 413
Numerical Ranges
As a consequence of using finite-precision arithmetic, the contracts in this repository will only work well if the magnitudes of various values are within reasonable bounds. This document defines what these boundaries are intended to be; i.e. any contract that performs incorrectly (for example, reverting due to an overflow or arriving at an inaccurate result due to round-off error) for input values that are all within the ranges given here should be considered flawed. These values are subject to revision and may be overly-conservative (i.e. the system may in fact function correctly even when some values stray from these ranges).
Ranges are given in the form:
Lower_Bound <= Quantity <= Upper_Bound
Rarely, strict inequality (<
instead of <=
) may apply to one or both of the bounds.
Some ranges will depend wholly or partially on the upper and/or lower bounds of other quantities. The notation L(Quantity)
will denote the lower bound of Quantity
, and the notation U(Quantity)
will denote the upper bound of Quantity
.
Constants:
WAD = 10^18
RAY = 10^27
RAD = 10^45
These are quantities that would exist regardless of the implementation of the system, and are expressed 18 decimal fixed-point notation for convenience.
10^16 <= Total_DAI_MC_Dollars <= 10^32
10^12 <= PerToken_Collateral_Price_Dollars <= 10^30
This is the actual price DAI trades at on the open market, and determines the value reported by any oracle
5 * 10^17 <= DAI_Price_Dollars <= 2 * 10^18
WAD * L(Total_DAI_MC_Dollars) / U(DAI_Price_Dollars) <= Total_DAI_Supply <= WAD * U(Total_DAI_MC_Dollars) / L(DAI_Price_Dollars)
Substituting values, we obtain:
5 * 10^15 <= Total_DAI_Supply <= 2 * 10^32
0 < ERC20_totalSupply <= 10^20 * WAD == 10^38
10^16 <= MKR_Price_DAI <= 10^24
These are quantities defined in the specific smart contracts found in this repository. Most of the bounds are at least partially derived from the system-independent values, and all non-integer expressions should be assumed to be truncated to the nearest integer.
Currently, we are not interested in considering values of Spotter.par
that deviate from unity (in fixed-point representation).
10^27 <= Spotter.par <= 10^27
10^27 <= Spotter.Ilk.mat <= 10^31
L(Total_DAI_Supply) * RAY <= Vat.debt <= U(Total_DAI_Supply) * RAY
Substituting values, we obtain:
5 * 10^42 <= Vat.debt <= 2 * 10^59
0 <= Vat.vice <= U(Vat.debt)
Substituting:
0 <= Vat.vice <= 2 * 10^59
0 <= Vat.Line <= 2^256 - 1
Upper bound derived by assuming a 50% APY for 50 years.
10^27 <= Vat.Ilk.rate <= 64 * 10^34
0 <= Vat.Ilk.Art <= U(Vat.debt) / L(Vat.Ilk.rate)
Substituting values, we obtain:
0 <= Vat.Ilk.Art <= 2 * 10^42
( RAY * RAY * 10^9 * L(PerToken_Collateral_Price_Dollars) ) / ( U(Spotter.par) * U(Spotter.Ilk.mat) )
<=
Vat.Ilk.spot
<=
( RAY * RAY * 10^9 * U(PerToken_Collateral_Price_Dollars) ) / ( L(Spotter.par) * L(Spotter.Ilk.mat) )
Substituting values:
10^17 <= Vat.Ilk.spot <= 10^39
0 <= Vat.Ilk.line <= 2^256 - 1
Strict inequality on lower bound is intentional.
0 < Vat.Ilk.dust <= 10^5 / L(DAI_Price_Dollars)
Substituting values:
0 < Vat.Ilk.dust <= 2 * 10^5
0 <= Vat.Urn.ink <= ERC20_totalSupply
Substituting:
0 <= Vat.Urn.ink <= 10^38
0 <= Vat.Urn.art <= U(Vat.Ilk.Art)
Substituting:
0 <= Vat.Urn.art <= 2 * 10^42
0 <= Vat.gem[u] <= U(ERC20_totalSupply)
Substituting:
0 <= Vat.gem[u] <= 10^38
0 <= Vat.dai[u] <= U(Vat.debt)
Substituting:
0 <= Vat.dai[u] <= 2 * 10^59
0 <= Vat.sin[u] <= U(Vat.vice)
Substituting:
0 <= Vat.sin[u] <= 2 * 10^59
UB is 100% APY
10^27 <= duty <= 1000000022535216018065179047
From MCD launch to 50 years in the future.
1574092804 <= Jug.Ilk.rho <= 3151972804
Upper bound derived by assuming a 50% APY for 50 years.
10^27 <= Vat.Ilk.rate <= 64 * 10^34
0 <= Pot.Pie <= U(Vat.debt) / L(Pot.chi)
Substituting:
0 <= Pot.Pie <= 2 * 10^32
0 <= Pot.pie[u] <= U(Pot.Pie)
Substituting:
0 <= Pot.pie[u] <= 2 * 10^32
UB is 100% APY
RAY <= Pot.dsr <= 1000000022535216018065179047
From MCD launch to 50 years in the future.
1574092804 <= Pot.rho <= 3151972804
0 <= Vow.sin[t] <= U(Vat.vice)
Substituting:
0 <= Vow.sin[t] <= 2 * 10^59
0 <= Vow.Sin <= U(Vat.vice)
Substituting:
0 <= Vow.Sin <= 2 * 10^59
0 <= Vow.Ash <= U(Vat.vice)
Substituting:
0 <= Vow.Ash <= 2 * 10^59
Between 1 hour and 28 days.
3600 <= Vow.wait <= 2419200
10^46 <= Vow.sump <= 10^51
L(Vow.sump) / U(MKR_Price_DAI) / 10^9 <= Vow.dump <= U(Vow.sump) / L(MKR_Price_DAI) / 10^9
Substituting:
10^13 <= Vow.dump <= 10^34
10^46 <= Vow.bump <= 10^51
0 <= Vow.hump <= RAY * U(Total_DAI_Supply) / 100
Substituting:
0 <= Vow.hump <= 2 * 10^57
If you have any questions regarding the Maker Protocol, please reach out to us on the #dev channel in chat.makerdao.com.