-
-
Notifications
You must be signed in to change notification settings - Fork 883
Description
Simple Summary
Make it easy to use numeric values that are allowed to be only within given ranges (and optionally only certain discrete values).
Motivation
When doing math, values may converge and/or have needed properties only for some range (e.g. 10**12 .. 10**36). For example, the Balancer incident wouldn’t be feasible if one restricted Wei swaps. Currently this can be achieved through additional asserts on values, though it makes it hard to follow all inputs/outputs and makes the code clumsy. Adding defined ranges/conditions for values may improve explicitness.
Specification
Basic usage is defining acceptable ranges for values, e.g. 10**12 .. 10**36 for amounts and 10**5 .. 10**10 for fees, with similar ranges for other parameters. Amount values might also need to accept 0. Open question: how to deal with values like 10**18 + 1—in some cases it might be helpful to fully ignore wei values (if it doesn’t break EIP requirements).
Illustrative syntax (suggested by AI):
amount: uint256[10**12:10**36]
fee: uint256[10**5:10**10]
amount18: uint256[10**12:10**36, step=10**10]Backwards Compatibility
Compatible.
Dependencies
References
- Balancer incident: https://rekt.news/balancer-rekt2
- ERC4626 Virtual shares could be also solved by limiting deposit values as in YB