Skip to content

Commit

Permalink
feat(contracts): added minimum redemption fee and send fee to feeReci…
Browse files Browse the repository at this point in the history
…pient
  • Loading branch information
0xmemorygrinder committed Dec 11, 2023
1 parent 2075e1b commit 7e95f52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions contracts/src/Pounders/abstracts/AFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ abstract contract AFees is Owned2Step {
*/
address public feeRecipient;

uint256 public redemptionFeeMin;

uint256 public redemptionFeeMax;

uint256 public protocolFee;
Expand Down
10 changes: 6 additions & 4 deletions contracts/src/Pounders/abstracts/APounder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
ILocker.LockedBalance memory lockData,
uint256 assets,
address receiver,
uint256 feeMin,
uint256 feeMax
) internal returns (uint256 feeAmount) {
if (assets == 0) revert Errors.ZeroAmount();
Expand All @@ -161,7 +162,7 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
uint256 waitTime = unlockTime - block.timestamp;

if (feeMax != 0) {
uint256 feePercent = feeMax - ((feeMax * waitTime) / MAX_REDEMPTION_TIME);
uint256 feePercent = feeMax - (((feeMax - feeMin) * waitTime) / MAX_REDEMPTION_TIME);

feeAmount = (assets * feePercent) / FEE_DENOMINATOR;
}
Expand Down Expand Up @@ -197,19 +198,20 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
ILocker.LockedBalance[] memory lockData = _lockedBalances();
uint256 totalAssets;
uint256 feeAmount;
// TODO add feeMin
uint256 feeMin = redemptionFeeMin;
uint256 feeMax = redemptionFeeMax;

for (uint256 i; i < lockLen; ++i) {
totalAssets += assets[i];
feeAmount += _initiateRedemption(lockData[lockIndexes[i]], assets[i], receiver, feeMax);
feeAmount += _initiateRedemption(lockData[lockIndexes[i]], assets[i], receiver, feeMin, feeMax);
}

// Burn pxCVX - reverts if sender balance is insufficient
_burn(msg.sender, totalAssets - feeAmount);

if (feeAmount != 0) {
// TODO Transfer fees
// Transfer the fee to the feeRecipient
SafeTransferLib.safeTransfer(address(asset), feeRecipient, feeAmount);
}
}

Expand Down

0 comments on commit 7e95f52

Please sign in to comment.