Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,13 @@ SafeTransferLibTest:testTransferWithReturnsTooMuch() (gas: 37118)
SafeTransferLibTest:testTransferWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 36942, ~: 37955)
SafeTransferLibTest:testTransferWithStandardERC20() (gas: 36702)
SafeTransferLibTest:testTransferWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 36592, ~: 37605)
SignedWadMathTest:testFailWadDivOverflow(int256,int256) (runs: 256, μ: 347, ~: 329)
SignedWadMathTest:testFailWadDivZeroDenominator(int256) (runs: 256, μ: 296, ~: 296)
SignedWadMathTest:testFailWadDivOverflow(int256,int256) (runs: 256, μ: 349, ~: 329)
SignedWadMathTest:testFailWadDivZeroDenominator(int256) (runs: 256, μ: 319, ~: 319)
SignedWadMathTest:testFailWadMulEdgeCase() (gas: 286)
SignedWadMathTest:testFailWadMulEdgeCase2() (gas: 309)
SignedWadMathTest:testFailWadMulOverflow(int256,int256) (runs: 256, μ: 354, ~: 319)
SignedWadMathTest:testFailWadMulOverflow(int256,int256) (runs: 256, μ: 356, ~: 319)
SignedWadMathTest:testWadDiv(uint256,uint256,bool,bool) (runs: 256, μ: 5712, ~: 5714)
SignedWadMathTest:testWadExpZeroPoint() (gas: 771)
SignedWadMathTest:testWadMul(uint256,uint256,bool,bool) (runs: 256, μ: 5760, ~: 5762)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 3840, reverts: 1776)
WETHTest:testDeposit() (gas: 63535)
Expand Down
6 changes: 2 additions & 4 deletions src/test/CREATE3.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ contract CREATE3Test is DSTestPlus {
bytes32 salt = keccak256(bytes("A salt!"));
Factory factory = new Factory();

MockERC20 deployed = MockERC20(
factory.deploy(salt)
);

MockERC20 deployed = MockERC20(factory.deploy(salt));

assertEq(address(deployed), CREATE3.getDeployed(salt, address(factory)));
assertTrue(address(deployed) != CREATE3.getDeployed(salt));

Expand Down
7 changes: 6 additions & 1 deletion src/test/SignedWadMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.0;

import {DSTestPlus} from "./utils/DSTestPlus.sol";

import {wadMul, wadDiv} from "../utils/SignedWadMath.sol";
import {wadMul, wadDiv, wadExp} from "../utils/SignedWadMath.sol";

contract SignedWadMathTest is DSTestPlus {
function testWadMul(
Expand All @@ -21,6 +21,11 @@ contract SignedWadMathTest is DSTestPlus {
assertEq(wadMul(xPrime, yPrime), (xPrime * yPrime) / 1e18);
}

function testWadExpZeroPoint() public {
assertEq(wadExp(-41446531673892822312), 1);
assertEq(wadExp(-41446531673892822313), 0);
}

function testFailWadMulEdgeCase() public pure {
int256 x = -1;
int256 y = type(int256).min;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/SignedWadMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function wadExp(int256 x) pure returns (int256 r) {
unchecked {
// When the result is < 0.5 we return zero. This happens when
// x <= floor(log(0.5e18) * 1e18) ~ -42e18
if (x <= -42139678854452767551) return 0;
if (x <= -41446531673892822313) return 0;

// When the result is > (2**255 - 1) / 1e18 we can not represent it as an
// int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
Expand Down