audit
This commit is contained in:
@@ -10,11 +10,6 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import "../../interfaces/IYTPoolManager.sol";
|
||||
import "../../interfaces/IYTVault.sol";
|
||||
|
||||
/**
|
||||
* @title YTRewardRouter
|
||||
* @notice 用户交互入口
|
||||
* @dev UUPS可升级合约
|
||||
*/
|
||||
contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
@@ -48,13 +43,6 @@ contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrad
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 初始化合约
|
||||
* @param _usdy USDY代币地址
|
||||
* @param _ytLP ytLP代币地址
|
||||
* @param _ytPoolManager YTPoolManager地址
|
||||
* @param _ytVault YTVault地址
|
||||
*/
|
||||
function initialize(
|
||||
address _usdy,
|
||||
address _ytLP,
|
||||
@@ -78,35 +66,16 @@ contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrad
|
||||
ytVault = _ytVault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 授权升级(仅gov可调用)
|
||||
* @param newImplementation 新实现合约地址
|
||||
*/
|
||||
function _authorizeUpgrade(address newImplementation) internal override onlyGov {}
|
||||
|
||||
/**
|
||||
* @notice 暂停合约(仅gov可调用)
|
||||
* @dev 暂停后,所有资金流动操作将被禁止
|
||||
*/
|
||||
function pause() external onlyGov {
|
||||
_pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 恢复合约(仅gov可调用)
|
||||
*/
|
||||
function unpause() external onlyGov {
|
||||
_unpause();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 添加流动性
|
||||
* @param _token YT代币或USDC地址
|
||||
* @param _amount 代币数量
|
||||
* @param _minUsdy 最小USDY数量
|
||||
* @param _minYtLP 最小ytLP数量
|
||||
* @return ytLPAmount 获得的ytLP数量
|
||||
*/
|
||||
function addLiquidity(
|
||||
address _token,
|
||||
uint256 _amount,
|
||||
@@ -132,14 +101,6 @@ contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrad
|
||||
return ytLPAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 移除流动性
|
||||
* @param _tokenOut 输出代币地址
|
||||
* @param _ytLPAmount ytLP数量
|
||||
* @param _minOut 最小输出数量
|
||||
* @param _receiver 接收地址
|
||||
* @return amountOut 获得的代币数量
|
||||
*/
|
||||
function removeLiquidity(
|
||||
address _tokenOut,
|
||||
uint256 _ytLPAmount,
|
||||
@@ -161,15 +122,6 @@ contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrad
|
||||
return amountOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice YT代币互换
|
||||
* @param _tokenIn 输入代币地址
|
||||
* @param _tokenOut 输出代币地址
|
||||
* @param _amountIn 输入数量
|
||||
* @param _minOut 最小输出数量
|
||||
* @param _receiver 接收地址
|
||||
* @return amountOut 获得的代币数量
|
||||
*/
|
||||
function swapYT(
|
||||
address _tokenIn,
|
||||
address _tokenOut,
|
||||
@@ -192,29 +144,15 @@ contract YTRewardRouter is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrad
|
||||
return amountOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 获取ytLP价格
|
||||
* @return ytLP价格(18位精度)
|
||||
*/
|
||||
function getYtLPPrice() external view returns (uint256) {
|
||||
return IYTPoolManager(ytPoolManager).getPrice(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 获取账户价值
|
||||
* @param _account 账户地址
|
||||
* @return 账户持有的ytLP价值(USDY计价)
|
||||
*/
|
||||
function getAccountValue(address _account) external view returns (uint256) {
|
||||
uint256 ytLPBalance = IERC20(ytLP).balanceOf(_account);
|
||||
uint256 ytLPPrice = IYTPoolManager(ytPoolManager).getPrice(true);
|
||||
return ytLPBalance * ytLPPrice / (10 ** 18);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev 预留存储空间,用于未来升级时添加新的状态变量
|
||||
* 50个slot = 50 * 32 bytes = 1600 bytes
|
||||
*/
|
||||
uint256[50] private __gap;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user