Skip to content

Commit

Permalink
Merge pull request #14 from code-423n4/truco/bug/decayTime
Browse files Browse the repository at this point in the history
Fix fee decay in 3piecewise
  • Loading branch information
kingyetifinance committed Jan 11, 2022
2 parents 881b0a4 + 5260d76 commit 622bf41
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -145,10 +145,12 @@ contract ThreePieceWiseLinearPriceCurve is IPriceCurve, Ownable {

function calculateDecayedFee() public override view returns (uint256 fee) {
uint256 decay = block.timestamp.sub(lastFeeTime);
if (decay > 0 && decay < decayTime) {
// Decay within bounds of decay time, then decay the fee.
if (decay <= decayTime) {
fee = lastFeePercent.sub(lastFeePercent.mul(decay).div(decayTime));
} else {
fee = lastFeePercent;
// If it has been longer than decay time, then reset fee to 0.
fee = 0;
}
return fee;
}
Expand Down

0 comments on commit 622bf41

Please sign in to comment.