Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rewards in redeem #23

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions contracts/StableAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,11 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
}
totalSupply = newD;
poolToken.mintShares(msg.sender, mintAmount);
if (mintFee > 0) {
if (feeAmount > 0) {
poolToken.setTotalSupply(feeAmount);
}

collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Minted(msg.sender, mintAmount, _amounts, feeAmount);
return mintAmount;
}
Expand Down Expand Up @@ -799,8 +798,10 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
totalSupply = D - _amount;
// After reducing the redeem fee, the remaining pool tokens are burned!
poolToken.burnSharesFrom(msg.sender, _amount);
if (feeAmount > 0) {
poolToken.setTotalSupply(feeAmount);
}
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return amounts;
}
Expand Down Expand Up @@ -899,8 +900,11 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
IERC20Upgradeable(tokens[_i]).safeTransfer(msg.sender, transferAmount);
totalSupply = D - _amount;
poolToken.burnSharesFrom(msg.sender, _amount);
if (feeAmount > 0) {
poolToken.setTotalSupply(feeAmount);
}

collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return transferAmount;
}
Expand Down Expand Up @@ -996,14 +1000,17 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
balances = _balances;
totalSupply = oldD - redeemAmount;
poolToken.burnSharesFrom(msg.sender, redeemAmount);
if (feeAmount > 0) {
poolToken.setTotalSupply(feeAmount);
}

uint256[] memory amounts = _amounts;
for (i = 0; i < _balances.length; i++) {
if (_amounts[i] == 0) continue;
IERC20Upgradeable(tokens[i]).safeTransfer(msg.sender, _amounts[i]);
}

collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, redeemAmount, amounts, feeAmount);
return amounts;
}
Expand Down
Loading