diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index cf5041b406..1fe7882778 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -163,7 +163,8 @@ library LibProposing { isProposal: true, tNow: uint64(block.timestamp), tLast: state.lastProposedAt, - tAvg: state.avgBlockTime + tAvg: state.avgBlockTime, + tCap: config.blockTimeCap }); fee = LibUtils.getSlotsAdjustedFee({ state: state, diff --git a/packages/protocol/contracts/L1/libs/LibUtils.sol b/packages/protocol/contracts/L1/libs/LibUtils.sol index cc6cc3d2c3..d6e617f76e 100644 --- a/packages/protocol/contracts/L1/libs/LibUtils.sol +++ b/packages/protocol/contracts/L1/libs/LibUtils.sol @@ -77,20 +77,19 @@ library LibUtils { bool isProposal, uint64 tNow, uint64 tLast, - uint64 tAvg + uint64 tAvg, + uint64 tCap ) internal view returns (uint256 newFeeBase, uint256 tRelBp) { if (tAvg == 0) { newFeeBase = state.feeBase; // tRelBp = 0; } else { - uint256 _tAvg = tAvg > config.proofTimeCap - ? config.proofTimeCap - : tAvg; - uint256 tGrace = (config.feeGracePeriodPctg * _tAvg) / 100; - uint256 tMax = (config.feeMaxPeriodPctg * _tAvg) / 100; - uint256 a = tLast + tGrace; - uint256 b = tNow > a ? tNow - a : 0; - tRelBp = (b.min(tMax) * 10000) / tMax; // [0 - 10000] + uint256 _tAvg = tAvg > tCap ? tCap : tAvg; + uint256 grace = (config.feeGracePeriodPctg * _tAvg) / 100; + uint256 max = (config.feeMaxPeriodPctg * _tAvg) / 100; + uint256 a = tLast + tAvg + grace; + a = tNow > a ? tNow - a : 0; + tRelBp = (a.min(max) * 10000) / max; // [0 - 10000] uint256 alpha = 10000 + ((config.rewardMultiplierPctg - 100) * tRelBp) / 100; diff --git a/packages/protocol/contracts/L1/libs/LibVerifying.sol b/packages/protocol/contracts/L1/libs/LibVerifying.sol index b5fb590ba8..4021f68afd 100644 --- a/packages/protocol/contracts/L1/libs/LibVerifying.sol +++ b/packages/protocol/contracts/L1/libs/LibVerifying.sol @@ -138,7 +138,8 @@ library LibVerifying { isProposal: false, tNow: provenAt, tLast: proposedAt, - tAvg: state.avgProofTime + tAvg: state.avgProofTime, + tCap: config.proofTimeCap }); reward = LibUtils.getSlotsAdjustedFee({ state: state,