fix contract

This commit is contained in:
2026-01-12 14:33:16 +08:00
parent a18b9a42e4
commit d56f83726b
70 changed files with 1988 additions and 142 deletions

View File

@@ -20,9 +20,12 @@ contract YTLPToken is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSU
error NotMinter();
error InvalidMinter();
error InvalidPoolManager();
mapping(address => bool) public isMinter;
address public poolManager;
event MinterSet(address indexed minter, bool isActive);
/**
@@ -56,6 +59,16 @@ contract YTLPToken is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSU
emit MinterSet(_minter, _isActive);
}
/**
* @notice 设置 PoolManager 地址
* @param _poolManager PoolManager 合约地址
* @dev 用于在转账时通知 PoolManager 更新冷却时间
*/
function setPoolManager(address _poolManager) external onlyOwner {
if (_poolManager == address(0)) revert InvalidPoolManager();
poolManager = _poolManager;
}
/**
* @notice 铸造ytLP代币
* @param _to 接收地址
@@ -74,6 +87,22 @@ contract YTLPToken is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSU
_burn(_from, _amount);
}
/**
* @notice 重写 _update 函数,在转账时更新冷却时间
* @dev 当 LP 代币转账时,接收方继承发送方的冷却时间,防止绕过冷却期
*/
function _update(address from, address to, uint256 value) internal override {
super._update(from, to, value);
// 只在实际转账时触发(不包括 mint 和 burn
if (from != address(0) && to != address(0) && poolManager != address(0)) {
// 通知 PoolManager 更新接收方的冷却时间
(bool success, ) = poolManager.call(
abi.encodeWithSignature("onLPTransfer(address,address)", from, to)
);
}
}
/**
* @dev 预留存储空间,用于未来升级时添加新的状态变量
* 50个slot = 50 * 32 bytes = 1600 bytes