audit
This commit is contained in:
@@ -193,16 +193,13 @@ contract YTPoolManager is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrade
|
||||
|
||||
uint256 usdyAmount = _ytLPAmount * aumInUsdy / ytLPSupply;
|
||||
|
||||
// 先销毁ytLP
|
||||
IYTLPToken(ytLP).burn(_account, _ytLPAmount);
|
||||
|
||||
// 检查余额,只铸造差额部分
|
||||
uint256 usdyBalance = IERC20(usdy).balanceOf(address(this));
|
||||
if (usdyAmount > usdyBalance) {
|
||||
IUSDY(usdy).mint(address(this), usdyAmount - usdyBalance);
|
||||
}
|
||||
|
||||
// 转账USDY到Vault并换回代币
|
||||
IERC20(usdy).safeTransfer(ytVault, usdyAmount);
|
||||
uint256 amountOut = IYTVault(ytVault).sellUSDY(_tokenOut, _receiver);
|
||||
|
||||
@@ -225,7 +222,7 @@ contract YTPoolManager is Initializable, UUPSUpgradeable, ReentrancyGuardUpgrade
|
||||
function getAumInUsdy(bool _maximise) public view returns (uint256) {
|
||||
uint256 aum = IYTVault(ytVault).getPoolValue(_maximise);
|
||||
|
||||
aum += aumAddition; // aumAddition是协议额外增加的AUM,用来“预留风险缓冲 / 扣除潜在负债”
|
||||
aum += aumAddition;
|
||||
if (aum > aumDeduction) {
|
||||
aum -= aumDeduction;
|
||||
} else {
|
||||
|
||||
@@ -24,11 +24,11 @@ contract YTPriceFeed is Initializable, UUPSUpgradeable {
|
||||
|
||||
uint256 public constant PRICE_PRECISION = 10 ** 30;
|
||||
uint256 public constant BASIS_POINTS_DIVISOR = 10000;
|
||||
uint256 public constant MAX_SPREAD_BASIS_POINTS = 200; // 最大2%价差
|
||||
uint256 public constant MAX_SPREAD_BASIS_POINTS = 200;
|
||||
|
||||
address public usdcAddress;
|
||||
|
||||
uint256 public maxPriceChangeBps; // 5% 最大价格变动
|
||||
uint256 public maxPriceChangeBps;
|
||||
|
||||
AggregatorV3Interface internal usdcPriceFeed;
|
||||
|
||||
@@ -58,7 +58,7 @@ contract YTPriceFeed is Initializable, UUPSUpgradeable {
|
||||
usdcAddress = _usdcAddress;
|
||||
usdcPriceFeed = AggregatorV3Interface(_usdcPriceFeed);
|
||||
gov = msg.sender;
|
||||
maxPriceChangeBps = 500; // 5% 最大价格变动
|
||||
maxPriceChangeBps = 500;
|
||||
}
|
||||
|
||||
function setUSDCAddress(address _usdcAddress) external onlyGov {
|
||||
@@ -78,7 +78,7 @@ contract YTPriceFeed is Initializable, UUPSUpgradeable {
|
||||
}
|
||||
|
||||
function setMaxPriceChangeBps(uint256 _maxPriceChangeBps) external onlyGov {
|
||||
if (_maxPriceChangeBps > 2000) revert MaxChangeTooHigh(); // 最大20%
|
||||
if (_maxPriceChangeBps > 2000) revert MaxChangeTooHigh();
|
||||
maxPriceChangeBps = _maxPriceChangeBps;
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,6 @@ contract YTVault is Initializable, UUPSUpgradeable, ReentrancyGuardUpgradeable {
|
||||
uint256 usdyAmountAfterFees = amountAfterFees * price / PRICE_PRECISION;
|
||||
usdyAmountAfterFees = _adjustForDecimals(usdyAmountAfterFees, _token, usdy);
|
||||
|
||||
// 手续费直接留在池子中:全部代币加入poolAmount,但只铸造扣费后的USDY
|
||||
_increasePoolAmount(_token, tokenAmount);
|
||||
_increaseUsdyAmount(_token, usdyAmountAfterFees);
|
||||
|
||||
@@ -436,7 +435,6 @@ contract YTVault is Initializable, UUPSUpgradeable, ReentrancyGuardUpgradeable {
|
||||
address _tokenOut,
|
||||
uint256 _usdyAmount
|
||||
) private view returns (uint256) {
|
||||
// 稳定币交换是指两个代币都是稳定币(如 USDC <-> USDT)
|
||||
bool isStableSwap = stableTokens[_tokenIn] && stableTokens[_tokenOut];
|
||||
uint256 baseBps = isStableSwap ? stableSwapFeeBasisPoints : swapFeeBasisPoints;
|
||||
uint256 taxBps = isStableSwap ? stableTaxBasisPoints : taxBasisPoints;
|
||||
|
||||
Reference in New Issue
Block a user