diff --git a/src/tenderizer/Tenderizer.sol b/src/tenderizer/Tenderizer.sol index 4683936..31277c1 100644 --- a/src/tenderizer/Tenderizer.sol +++ b/src/tenderizer/Tenderizer.sol @@ -43,12 +43,12 @@ contract Tenderizer is TenderizerImmutableArgs, TenderizerEvents, TToken, Multic // @inheritdoc TToken function name() external view override returns (string memory) { - return string(abi.encodePacked("tender", ERC20(asset()).symbol(), " ", validator())); + return string.concat(Tenderizer(address(this)).symbol(), "-", addressToString(validator())); } // @inheritdoc TToken function symbol() external view override returns (string memory) { - return string(abi.encodePacked("t", ERC20(asset()).symbol(), "_", validator())); + return string.concat("t", ERC20(asset()).symbol()); } // @inheritdoc TToken @@ -236,3 +236,19 @@ function _staticcall(address target, bytes memory data) view returns (bytes memo return returnData; } + +function addressToString(address _addr) pure returns (string memory) { + bytes32 value = bytes32(uint256(uint160(_addr))); + bytes memory alphabet = "0123456789abcdef"; + + bytes memory str = new bytes(42); + str[0] = "0"; + str[1] = "x"; + + for (uint256 i = 0; i < 20; i++) { + str[2 + i * 2] = alphabet[uint8(value[i + 12] >> 4)]; + str[3 + i * 2] = alphabet[uint8(value[i + 12] & 0x0f)]; + } + + return string(str); +} diff --git a/src/tendertoken/TToken.sol b/src/tendertoken/TToken.sol index 5353137..e1195ba 100644 --- a/src/tendertoken/TToken.sol +++ b/src/tendertoken/TToken.sol @@ -230,7 +230,8 @@ abstract contract TToken is TTokenStorage, IERC20 { function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return keccak256( abi.encode( - keccak256("EIP712Domain(string version,uint256 chainId,address verifyingContract)"), + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256(bytes(TToken(address(this)).name())), keccak256("1"), block.chainid, address(this) diff --git a/test/helpers/StakingXYZ.sol b/test/helpers/StakingXYZ.sol index 1009d5d..5f64cb7 100644 --- a/test/helpers/StakingXYZ.sol +++ b/test/helpers/StakingXYZ.sol @@ -20,7 +20,7 @@ contract StakingXYZ { uint256 public nextRewardTimeStamp; uint256 constant rewardTime = 1 days; - uint256 constant unlockTime = 2 days; + uint256 constant unlockTime = 1 minutes; struct Unlock { uint256 amount; @@ -48,7 +48,7 @@ contract StakingXYZ { function withdraw(uint256 id) external returns (uint256) { Unlock memory unlock = unlocks[msg.sender][id]; - require(unlock.maturity < block.timestamp, "unlock time not reached"); + require(unlock.maturity <= block.timestamp, "unlock time not reached"); delete unlocks[msg.sender][id]; ERC20(token).transfer(msg.sender, unlock.amount); return unlock.amount;