From 410ca57f55968570a54f2d4ba7cfbee63dccd292 Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Thu, 21 Nov 2019 18:35:02 -0500 Subject: [PATCH] make clear that this is still just a mock --- contracts/libraries/UQ104x104.sol | 11 +++++------ contracts/test/GenericERC20.sol | 12 ------------ 2 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 contracts/test/GenericERC20.sol diff --git a/contracts/libraries/UQ104x104.sol b/contracts/libraries/UQ104x104.sol index 0df0926..26d0e8b 100644 --- a/contracts/libraries/UQ104x104.sol +++ b/contracts/libraries/UQ104x104.sol @@ -1,17 +1,16 @@ pragma solidity 0.5.12; -// TODO this whole library is basically just a mock at the moment +// TODO this library is broken at the moment, and is meant only to serve as a mock library UQ104x104 { uint208 constant Q104 = uint104(-1); function encode(uint128 y) internal pure returns (uint208 z) { - // require(y <= Q104, "encode-overflow"); + require(y <= Q104, "encode-overflow"); z = y * Q104; } - function qmul(uint208 x, uint208 y) internal pure returns (uint208 z) { - z = x * y / Q104; - } function qdiv(uint208 x, uint208 y) internal pure returns (uint208 z) { - z = x / y; + uint256 quotient = uint256(x) / uint256(y); + require(quotient <= Q104, "div-overflow"); + z = uint208(quotient * Q104); } } diff --git a/contracts/test/GenericERC20.sol b/contracts/test/GenericERC20.sol deleted file mode 100644 index 8981525..0000000 --- a/contracts/test/GenericERC20.sol +++ /dev/null @@ -1,12 +0,0 @@ -pragma solidity 0.5.12; - -import "../token/ERC20.sol"; - -contract GenericERC20 is ERC20 { - constructor( - string memory _name, - string memory _symbol, - uint8 _decimals, - uint256 _totalSupply - ) ERC20(_name, _symbol, _decimals, _totalSupply) public {} -}