Skip to content

Commit

Permalink
remove fee/yield recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
ukby1234 committed Oct 19, 2023
1 parent d2f2373 commit 652bd31
Showing 1 changed file with 9 additions and 57 deletions.
66 changes: 9 additions & 57 deletions contracts/StableAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
*/
event RedeemFeeModified(uint256 redeemFee);

/**
* @dev This event is emitted when the fee recipient is modified.
* @param recipient is the new value of the recipient.
*/
event FeeRecipientModified(address recipient);

/**
* @dev This event is emitted when the yield recipient is modified.
* @param recipient is the new value of the recipient.
*/
event YieldRecipientModified(address recipient);

/**
* @dev This event is emitted when the governance is modified.
* @param governance is the new value of the governance.
Expand Down Expand Up @@ -201,14 +189,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
* redeemFee = redeemFee * FEE_DENOMINATOR
*/
uint256 public redeemFee;
/**
* @dev This is the account which receives transaction fees collected by the StableAsset contract.
*/
address public feeRecipient;
/**
* @dev This is the account which receives yield generated by the StableAsset contract.
*/
address public yieldRecipient;
/**
* @dev This is the address of the ERC20 token contract that represents the StableAsset pool token.
*/
Expand Down Expand Up @@ -281,17 +261,13 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
* @param _tokens The tokens in the pool.
* @param _precisions The precisions of each token (10 ** (18 - token decimals)).
* @param _fees The fees for minting, swapping, and redeeming.
* @param _feeRecipient The address that collects the fees.
* @param _yieldRecipient The address that receives yield farming rewards.
* @param _poolToken The address of the pool token.
* @param _A The initial value of the amplification coefficient A for the pool.
*/
function initialize(
address[] memory _tokens,
uint256[] memory _precisions,
uint256[] memory _fees,
address _feeRecipient,
address _yieldRecipient,
ITapETH _poolToken,
uint256 _A,
IExchangeRateProvider _exchangeRateProvider,
Expand All @@ -316,8 +292,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
require(_precisions[i] != 0, "precision not set");
balances.push(0);
}
require(_feeRecipient != address(0x0), "fee recipient not set");
require(_yieldRecipient != address(0x0), "yield recipient not set");
require(address(_poolToken) != address(0x0), "pool token not set");
require(_A > 0 && _A < MAX_A, "A not set");
require(
Expand All @@ -331,8 +305,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
__ReentrancyGuard_init();

governance = msg.sender;
feeRecipient = _feeRecipient;
yieldRecipient = _yieldRecipient;
tokens = _tokens;
precisions = _precisions;
mintFee = _fees[0];
Expand Down Expand Up @@ -574,6 +546,7 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
}

collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Minted(msg.sender, mintAmount, _amounts, feeAmount);
return mintAmount;
}
Expand Down Expand Up @@ -718,13 +691,13 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
amountPositive[_i] = false;
amountPositive[_j] = true;

feeAmount = collectFeeOrYield(true);
uint256 feeAmountActual = collectFeeOrYield(true);
emit TokenSwapped(
msg.sender,
transferAmountJ,
amounts,
amountPositive,
feeAmount
feeAmountActual
);
return transferAmountJ;
}
Expand Down Expand Up @@ -826,7 +799,8 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
totalSupply = D - _amount;
// After reducing the redeem fee, the remaining pool tokens are burned!
poolToken.burnSharesFrom(msg.sender, _amount);
feeAmount = collectFeeOrYield(true);
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return amounts;
}
Expand Down Expand Up @@ -925,7 +899,8 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
IERC20Upgradeable(tokens[_i]).safeTransfer(msg.sender, transferAmount);
totalSupply = D - _amount;
poolToken.burnSharesFrom(msg.sender, _amount);
feeAmount = collectFeeOrYield(true);
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return transferAmount;
}
Expand Down Expand Up @@ -1027,7 +1002,8 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
IERC20Upgradeable(tokens[i]).safeTransfer(msg.sender, _amounts[i]);
}

feeAmount = collectFeeOrYield(true);
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, redeemAmount, amounts, feeAmount);
return amounts;
}
Expand Down Expand Up @@ -1104,10 +1080,8 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
poolToken.setTotalSupply(feeAmount);

if (isFee) {
//address recipient = feeRecipient;
emit FeeCollected(feeAmount, totalSupply);
} else {
//address recipient = yieldRecipient;
uint256[] memory amounts = new uint256[](_balances.length);
for (uint256 i = 0; i < _balances.length; i++) {
amounts[i] = _balances[i] - oldBalances[i];
Expand Down Expand Up @@ -1170,28 +1144,6 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
emit RedeemFeeModified(_redeemFee);
}

/**
* @dev Updates the recipient of mint/swap/redeem fees.
* @param _feeRecipient The new recipient of mint/swap/redeem fees.
*/
function setFeeRecipient(address _feeRecipient) external {
require(msg.sender == governance, "not governance");
require(_feeRecipient != address(0x0), "fee recipient not set");
feeRecipient = _feeRecipient;
emit FeeRecipientModified(_feeRecipient);
}

/**
* @dev Updates the recipient of yield.
* @param _yieldRecipient The new recipient of yield.
*/
function setYieldRecipient(address _yieldRecipient) external {
require(msg.sender == governance, "not governance");
require(_yieldRecipient != address(0x0), "fee recipient not set");
yieldRecipient = _yieldRecipient;
emit YieldRecipientModified(_yieldRecipient);
}

/**
* @dev Pause mint/swap/redeem actions. Can unpause later.
*/
Expand Down

0 comments on commit 652bd31

Please sign in to comment.