From c46d880cea64b64b1fe958d3392d6f56500c2541 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 26 Oct 2023 09:24:32 +0800 Subject: [PATCH 1/2] Add setTotalSupply --- contracts/StableAsset.sol | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/StableAsset.sol b/contracts/StableAsset.sol index 5dcd87a..9926306 100644 --- a/contracts/StableAsset.sol +++ b/contracts/StableAsset.sol @@ -541,7 +541,7 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable { } totalSupply = newD; poolToken.mintShares(msg.sender, mintAmount); - if (mintFee > 0) { + if (feeAmount > 0) { poolToken.setTotalSupply(feeAmount); } @@ -799,6 +799,9 @@ 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); @@ -899,6 +902,10 @@ 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); @@ -996,6 +1003,10 @@ 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; From 076164c2776fe437a55654b1ad90dbb71da8a4d9 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 26 Oct 2023 10:24:35 +0800 Subject: [PATCH 2/2] Remove FeeCollected event --- contracts/StableAsset.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contracts/StableAsset.sol b/contracts/StableAsset.sol index 9926306..c0ad562 100644 --- a/contracts/StableAsset.sol +++ b/contracts/StableAsset.sol @@ -546,7 +546,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable { } collectFeeOrYield(true); - emit FeeCollected(feeAmount, totalSupply); emit Minted(msg.sender, mintAmount, _amounts, feeAmount); return mintAmount; } @@ -803,7 +802,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable { poolToken.setTotalSupply(feeAmount); } collectFeeOrYield(true); - emit FeeCollected(feeAmount, totalSupply); emit Redeemed(msg.sender, _amount, amounts, feeAmount); return amounts; } @@ -907,7 +905,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable { } collectFeeOrYield(true); - emit FeeCollected(feeAmount, totalSupply); emit Redeemed(msg.sender, _amount, amounts, feeAmount); return transferAmount; } @@ -1014,7 +1011,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable { } collectFeeOrYield(true); - emit FeeCollected(feeAmount, totalSupply); emit Redeemed(msg.sender, redeemAmount, amounts, feeAmount); return amounts; }