morpho-org / morpho-utils

Repository gathering useful libraries and contracts.
GNU Affero General Public License v3.0
65 stars 1 forks source link

Add `abs` #103

Closed Rubilmax closed 1 year ago

github-actions[bot] commented 1 year ago

Changes to gas cost

Generated at commit: 27b5ad04e2455f334301888d25eecdc08838e539, compared to commit: 9fc9b2a1a40463f4fa26f547fd76458a73ac6cbb

๐Ÿงพ Summary (20% most significant diffs)

Contract Method Avg (+/-) %
MathMock contract log2 +91 โŒ +19.12%

Full diff report ๐Ÿ‘‡
| Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) | |:-|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|-:| | **MathRef contract** | 238,081 (+37,836) | _divUp_
_log2Dichotomy_
_log2Naive_
_max_
_min_
_zeroFloorSub_ | 573 (-26)
4,741 (-54)
44,490 (-538)
386 (+73)
398 (+53)
363 (-79) | **-4.34%**
**-1.13%**
**-1.19%**
**+23.32%**
**+15.36%**
**-17.87%** | 573 (-26)
4,741 (-54)
44,490 (-538)
386 (+73)
398 (+53)
363 (-79) | **-4.34%**
**-1.13%**
**-1.19%**
**+23.32%**
**+15.36%**
**-17.87%** | 573 (-26)
4,741 (-54)
44,490 (-538)
386 (+73)
398 (+53)
363 (-79) | **-4.34%**
**-1.13%**
**-1.19%**
**+23.32%**
**+15.36%**
**-17.87%** | 573 (-26)
4,741 (-54)
44,490 (-538)
386 (+73)
398 (+53)
363 (-79) | **-4.34%**
**-1.13%**
**-1.19%**
**+23.32%**
**+15.36%**
**-17.87%** | 1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0) | | **MathMock contract** | 138,183 (+34,630) | _divUp_
_log2_ | 350 (+12)
567 (+91) | **+3.55%**
**+19.12%** | 432 (+12)
567 (+91) | **+2.86%**
**+19.12%** | 453 (+12)
567 (+91) | **+2.72%**
**+19.12%** | 453 (+12)
567 (+91) | **+2.72%**
**+19.12%** | 5 (0)
2 (0) |
pakim249CAL commented 1 year ago

What does safeAbs protect from?

Rubilmax commented 1 year ago

What does safeAbs protect from?

It protects from reverting in the case we've reached the negative bound (which doesn't have an exact positive opposite) I'll add a comment about it

EDIT: it's the other way around. Instead, safeAbs does revert in the case we've reach the negative bound

Rubilmax commented 1 year ago

Nice! what's the gas imrpovement?

It is less than 10 gas lol

MerlinEgalite commented 1 year ago

Nice! what's the gas imrpovement?

It is less than 10 gas lol

lol ok thx