Skip to content

Commit

Permalink
add deployment address and code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ukby1234 committed Oct 17, 2023
1 parent 39f325a commit ac4dee2
Show file tree
Hide file tree
Showing 12 changed files with 1,461 additions and 420 deletions.
755 changes: 755 additions & 0 deletions .openzeppelin/goerli.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ npx hardhat run scripts/deploy.ts
Goerli Testnet Address:
```
constant: 0x07e70721C1737a9D410bcd038BA7e82e8BC19e2a
rETHRate: 0xf2dD62922B5f0cb2a72dAeda711018d6F56EEb17
rETHRate: 0xC24783cC76Faa4AE12b1fedb989E301De543a289
poolToken: 0xA33a79c5Efadac7c07693c3ce32Acf9a1Fc5A387
wrapped poolToken: 0x7a254de1Ef64c1E37C8B80eA8C0877B37BD69743
stETHSwap: 0x52543FE4597230ef59fC8C38D3a682Fa2F0fc026
rETHSwap: 0x8589F6Dedae785634f47132193680149d43cfaF3
stETHSwap: 0x774a36e77876eC9e887a07b2E53f81479d178532
rETHSwap: 0x169804a3060E4d07c46B1a39eA776eCDADDa2614
application: 0x019270711FF6774a14732F850f9A15008F15c05f
application: 0x1aEfABbE56dB3c47f0824f4af3d74845e4BCD117
wETHAddress: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6'
stETHAddress: '0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F'
Expand Down
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 @@ -572,6 +544,7 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
poolToken.mintShares(msg.sender, _sharesAmount);

collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Minted(msg.sender, mintAmount, _amounts, feeAmount);
return mintAmount;
}
Expand Down Expand Up @@ -716,13 +689,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 {
uint256 _sharesAmount = poolToken.getPooledEthByShares(_amount);
poolToken.burnSharesFrom(msg.sender, _sharesAmount);

feeAmount = collectFeeOrYield(true);
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return amounts;
}
Expand Down Expand Up @@ -926,7 +900,8 @@ contract StableAsset is Initializable, ReentrancyGuardUpgradeable {
totalSupply = D - _amount;
uint256 _sharesAmount = poolToken.getPooledEthByShares(_amount);
poolToken.burnSharesFrom(msg.sender, _sharesAmount);
feeAmount = collectFeeOrYield(true);
collectFeeOrYield(true);
emit FeeCollected(feeAmount, totalSupply);
emit Redeemed(msg.sender, _amount, amounts, feeAmount);
return transferAmount;
}
Expand Down Expand Up @@ -1029,7 +1004,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 @@ -1106,10 +1082,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 @@ -1172,28 +1146,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
20 changes: 3 additions & 17 deletions contracts/TapETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ contract TapETH is Initializable, ITapETH {
uint256 private totalShares;
uint256 private _totalSupply;
uint256 private totalRewards;
uint256 public buffer;
address public governance;
address public pendingGovernance;
mapping(address => uint256) private shares;
Expand All @@ -52,11 +51,9 @@ contract TapETH is Initializable, ITapETH {
event GovernanceProposed(address indexed governance);
event PoolAdded(address indexed pool);
event PoolRemoved(address indexed pool);
event SetBuffer(uint256);

function initialize(address _governance) public initializer {
require(_governance != address(0), "TapETH: zero address");
governance = _governance;
function initialize() public initializer {
governance = msg.sender;
}

function proposeGovernance(address _governance) public {
Expand Down Expand Up @@ -262,26 +259,15 @@ contract TapETH is Initializable, ITapETH {
return totalShares;
}

/**
* @notice This function is called by the governance to set the buffer.
*/
function setBuffer(uint256 _amount) external {
require(msg.sender == governance, "TapETH: no governance");
buffer = _amount;
emit SetBuffer(_amount);
}

/**
* @notice This function is called only by a stableSwap pool to increase
* the total supply of TapETH by the staking rewards and the swap fee.
*/
function setTotalSupply(uint256 _amount) external {
require(pools[msg.sender], "TapETH: no pool");
require(_amount != 0, "TapETH: no pool");
uint256 _deltaBuffer = Math.min(buffer, _amount);
_totalSupply += _amount - _deltaBuffer;
_totalSupply += _amount;
totalRewards += _amount;
buffer -= _deltaBuffer;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/WtapETH.sol → contracts/WTapETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "./interfaces/ITapETH.sol";
*
*/

contract WtapETH is ERC20PermitUpgradeable {
contract WTapETH is ERC20PermitUpgradeable {
ITapETH public tapETH;

function initialize(
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/ITapETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ interface ITapETH is IERC20 {

function setTotalSupply(uint256 _amount) external;

function setBuffer(uint256 _amount) external;

function getPooledEthByShares(
uint256 _sharesAmount
) external view returns (uint256);
Expand Down
Loading

0 comments on commit ac4dee2

Please sign in to comment.