morpho-org / morpho-utils

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

Directional rounding #68

Closed Rubilmax closed 1 year ago

Rubilmax commented 1 year ago

This is a proposal for #55. Please bear in mind that:

For this reason, I suggest to append wadMulDown & wadMulUp implementations instead

I'm expecting you to tell me if it's the correct way to go or not, so that I continue working on this, following this checklist:

github-actions[bot] commented 1 year ago

Changes to gas cost

Generated at commit: 9c9bcf283480a88d01509b122d117684001d16ae, compared to commit: d624b2e7c705c220cd4b608c7bbe81e9fc957b27

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

Contract Method Avg (+/-) %
WadRayMathRef contract rayDiv +101 โŒ +23.38%

Full diff report ๐Ÿ‘‡
| Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) | |:-|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|-:| | **WadRayMathMock contract** | 370,605 (+148,142) | _rayDiv_
_rayMul_
_rayToWad_
_rayWeightedAvg_
_wadDiv_
_wadMul_
_wadToRay_
_wadWeightedAvg_ | 415 (+95)
378 (+22)
405 (+45)
443 (+12)
408 (+22)
379 (+22)
313 (+45)
432 (-44) | **+29.69%**
**+6.18%**
**+12.50%**
**+2.78%**
**+5.70%**
**+6.16%**
**+16.79%**
**-9.24%** | 450 (+97)
429 (+25)
405 (+45)
500 (+15)
441 (+22)
427 (+22)
353 (+45)
486 (-44) | **+27.48%**
**+6.19%**
**+12.50%**
**+3.09%**
**+5.25%**
**+5.43%**
**+14.61%**
**-8.30%** | 415 (+95)
429 (+25)
405 (+45)
500 (+15)
408 (+22)
427 (+22)
353 (+45)
486 (-44) | **+29.69%**
**+6.19%**
**+12.50%**
**+3.09%**
**+5.70%**
**+5.43%**
**+14.61%**
**-8.30%** | 522 (+101)
481 (+28)
405 (+45)
557 (+18)
509 (+22)
476 (+22)
394 (+45)
540 (-44) | **+23.99%**
**+6.18%**
**+12.50%**
**+3.34%**
**+4.52%**
**+4.85%**
**+12.89%**
**-7.53%** | 3 (0)
2 (0)
1 (0)
4 (0)
3 (0)
2 (0)
2 (0)
4 (0) | | **WadRayMathRef contract** | 327,168 (+97,899) | _rayDiv_
_rayMul_
_rayToWad_
_rayWeightedAvg_
_wadDiv_
_wadMul_
_wadToRay_
_wadWeightedAvg_ | 533 (+101)
485 (+28)
432 (+45)
820 (+12)
520 (+22)
480 (+22)
405 (+45)
809 (-44) | **+23.38%**
**+6.13%**
**+11.63%**
**+1.49%**
**+4.42%**
**+4.80%**
**+12.50%**
**-5.16%** | 533 (+101)
485 (+28)
432 (+45)
820 (+12)
520 (+22)
480 (+22)
405 (+45)
809 (-44) | **+23.38%**
**+6.13%**
**+11.63%**
**+1.49%**
**+4.42%**
**+4.80%**
**+12.50%**
**-5.16%** | 533 (+101)
485 (+28)
432 (+45)
820 (+12)
520 (+22)
480 (+22)
405 (+45)
809 (-44) | **+23.38%**
**+6.13%**
**+11.63%**
**+1.49%**
**+4.42%**
**+4.80%**
**+12.50%**
**-5.16%** | 533 (+101)
485 (+28)
432 (+45)
820 (+12)
520 (+22)
480 (+22)
405 (+45)
809 (-44) | **+23.38%**
**+6.13%**
**+11.63%**
**+1.49%**
**+4.42%**
**+4.80%**
**+12.50%**
**-5.16%** | 1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0)
1 (0) | | **PercentageMathMock contract** | 193,638 (+67,067) | _percentAdd_
_percentDiv_
_percentMul_
_weightedAvg_ | 350 (-22)
387 (+67)
312 (-22)
410 (+23) | **-5.91%**
**+20.94%**
**-6.59%**
**+5.94%** | 422 (-22)
420 (+67)
360 (-22)
464 (+23) | **-4.95%**
**+18.98%**
**-5.76%**
**+5.22%** | 459 (-22)
387 (+67)
360 (-22)
464 (+23) | **-4.57%**
**+20.94%**
**-5.76%**
**+5.22%** | 459 (-22)
488 (+67)
409 (-22)
518 (+23) | **-4.57%**
**+15.91%**
**-5.10%**
**+4.65%** | 3 (0)
3 (0)
2 (0)
4 (0) | | **PercentageMathRef contract** | 187,032 (+46,449) | _percentAdd_
_percentDiv_
_percentMul_
_weightedAvg_ | 502 (-22)
499 (+67)
413 (-22)
787 (+23) | **-4.20%**
**+15.51%**
**-5.06%**
**+3.01%** | 502 (-22)
499 (+67)
413 (-22)
787 (+23) | **-4.20%**
**+15.51%**
**-5.06%**
**+3.01%** | 502 (-22)
499 (+67)
413 (-22)
787 (+23) | **-4.20%**
**+15.51%**
**-5.06%**
**+3.01%** | 502 (-22)
499 (+67)
413 (-22)
787 (+23) | **-4.20%**
**+15.51%**
**-5.06%**
**+3.01%** | 1 (0)
1 (0)
1 (0)
1 (0) |
MathisGD commented 1 year ago

Please let me the time to review it tomorrow

Edit (27/12): on it...