Use UD60x18
in the Dynamic contract
#181
Replies: 3 comments 5 replies
-
This is a great idea. I agree that this would be useful, but to keep concerns separated, we should implement this in PRBMath, rather than here. Here's a draft spec: /// @dev If y < 0, do `inv(pow(x, ud(-y)))`
/// If y >= 0, do `pow(x, ud(y))`
/// @param x The base as an UD60x18 number.
/// @param y The exponent as an SD59x18 number.
/// @return result The result as an UD60x18 number.
function pow(UD60x18 x, SD59x18 y) external returns (UD60x18 result); Let's try to see if the compiler works with |
Beta Was this translation helpful? Give feedback.
-
Found out that there is another reason for using Using Even so, I still think that would be a good idea to change the exponent type to |
Beta Was this translation helpful? Give feedback.
-
@andreivladbrg do you still want to pursue this idea, or do you concur that we can't use There is a check in the UD60x18 |
Beta Was this translation helpful? Give feedback.
-
While I was making the change from
uint256
touint128
for thetotalAmount
andwithdrawnAmount
variables,it dawned on me that the only reason we use
SD59x18
in theSablierV2LockupDynamic
contract is to allow a negative exponent.IMO it is unnecessary to use
SD59x18
because it complicates things with the all conversions we have to make.Given that we use the
pow
function only here:https://github.com/sablierhq/v2-core/blob/8bd57ebb31fddf6ef262477e5a378027db8b85d8/src/SablierV2LockupDynamic.sol#L338
Where:$elapsedTimePercentage \in R+ , \forall currentSegmentExponent => multiplier \ge 0$
My proposal is to either add a function in our contract either add in the PRBMath library called
powi
for theUD60x18
type.This may also solve this issue #178.
Beta Was this translation helpful? Give feedback.
All reactions