pymaker icon indicating copy to clipboard operation
pymaker copied to clipboard

API: Decide whether `Wad` and `Ray` can hold negative values or not

Open ghost opened this issue 8 years ago • 4 comments

I have used them to hold negative values during calculations in a few places.

This issue is to figure out whether it should stay like that or not.

ghost avatar Jun 19 '17 18:06 ghost

@dbrock

nmushegian avatar Jun 21 '17 03:06 nmushegian

I know these are always non-negative in Solidity, but it's kind of local to maker.py if we allow them to be negative. For example some arbitrage profitability calculations are performed in Wad and it's perfectly fine for profitability to be negative.

So the question is whether we want to keep Ray and Wad 100% compatible with Solidity types (in terms of sign, overflow etc.) and in that case we need another set of types for things like the aforementioned profitability calculation. Or do we relax these restrictions in the Python code (as it is currently done now).

ghost avatar Jun 21 '17 07:06 ghost

I think you can relax it in client code. Just maybe have a guard around when it goes back into the evm.

rainbreak avatar Jun 21 '17 09:06 rainbreak

I would keep Ray and Wad totally compatible and introduce signed versions that are int256 instead of uint128. Require explicit cast before it goes to the evm.

nmushegian avatar Jul 09 '17 18:07 nmushegian