Inconsistencies on decimals type WAS, RAY, RAD

The following documentation mention RAY 27 and RAD 45:

However, it is mentionned to the link below that RAY is 36, and WAS 18.

What are the correct expected values ?

Disclaimer: I am not a maker dev

Single source of truth principle. And that is the code (contracts in solidity)

There are 2 repos:

I don’t have time for detailed “investigation” atm, but quick search in
and you get:

uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;

I was assuming this code gets used, but after checking vat code, i am not sure anymore :expressionless:

1 Like

Thanks lot @jernejml it’s already a strong hint.
But I am always happy to have multiple confirmations when there are inconsistencies. It may hidding other inconsistencies elsewhere.

Dai has three different numerical units: wad , ray and rad

  • wad : fixed point decimal with 18 decimals (for basic quantities, e.g. balances)
  • ray : fixed point decimal with 27 decimals (for precise quantites, e.g. ratios)
  • rad : fixed point decimal with 45 decimals (result of integer multiplication with a wad and a ray )

wad and ray units will be familiar from SCD. rad is a new unit and exists to prevent precision loss in the core CDP engine.


Purple paper is an old specification. You can find [draft; 2018-02-06] line in the beginning. Actual documentation in DSS repo from Github or MCD Docs.

WAD is 18 decimals, for example USDC Gem use type coercion from 6 to 18 decimals:
uint wad18 = mul(wad, 10 ** (18 - dec));
Vat test contract has type coercion for checking RAY and RAD decimals:
function ray(uint wad) internal pure returns (uint) { return wad * 10 ** 9; }
function rad(uint wad) internal pure returns (uint) { return wad * 10 ** 27; }