88mphapp / 88mph-contracts

GNU General Public License v3.0
83 stars 31 forks source link

change timestamps and depositID and fundingID to uint64 #19

Closed uwe closed 3 years ago

uwe commented 3 years ago

This changes both timestamps (maturationTimestamp and depositTimestamp) and fundingID and depositID from uint256 to uint64. It saves up to 7 % gas on the methods, but deployment gets up to 5 % more expensive. In practise the gas savings should be even bigger, because the lists (fundingList and deposits) in production are even longer (than in the tests).

CERC20Mock.mint:
min:  330471 ->  326733 (-1.1%)
max:  472428 ->  468690 (-0.8%)
avg:  364902 ->  361164 (-1.0%)
DInterest.deposit:
min:  552499 ->  513125 (-7.1%)
max:  738399 ->  699025 (-5.3%)
avg:  668214 ->  628839 (-5.9%)
DInterest.fund:
min:  256452 ->  256961 (0.2%)
max:  523511 ->  510793 (-2.4%)
avg:  396291 ->  385463 (-2.7%)
DInterest.payInterestToFunders:
min:  201421 ->  201695 (0.1%)
max:  358448 ->  358722 (0.1%)
avg:  257921 ->  258195 (0.1%)
DInterest.rolloverDeposit:
min:  529215 ->  488803 (-7.6%)
max:  672300 ->  631888 (-6.0%)
avg:  566370 ->  525958 (-7.1%)
DInterest.topupDeposit:
min:  261787 ->  258034 (-1.4%)
max:  403744 ->  399991 (-0.9%)
avg:  296218 ->  292465 (-1.3%)
DInterest.withdraw:
min:   78906 ->   78276 (-0.8%)
max:  382749 ->  380370 (-0.6%)
avg:  188683 ->  187520 (-0.6%)

Factory.createZeroCouponBond:
min: 1060529 ->  983322 (-7.3%)
max: 1166574 -> 1089367 (-6.6%)
avg: 1100119 -> 1022912 (-7.0%)

MPHIssuanceModel02.setPoolFunderRewardVestPeriod:
min:   26688 ->   26754 (0.2%)
max:   26700 ->   26766 (0.2%)
avg:   26699 ->   26765 (0.2%)

DInterest.DEPLOY:
avg: 4904146 -> 5143821 (4.9%)
Factory.DEPLOY:
avg: 1282064 -> 1287243 (0.4%)
MPHIssuanceModel02.DEPLOY:
avg:  824335 ->  833197 (1.1%)
MPHMinter.DEPLOY:
avg: 2403768 -> 2430977 (1.1%)
PercentageFeeModel.DEPLOY:
avg:  846664 ->  862235 (1.8%)
Vesting02.DEPLOY:
avg: 2387390 -> 2415235 (1.2%)
ZeroCouponBond.DEPLOY:
avg: 2010356 -> 2070353 (3.0%)
uwe commented 3 years ago

My fork was not up to date. I will reopen a new PR.