From e1ad372187869ef44bc074244152c23a8d30345c Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Wed, 6 Dec 2023 01:43:25 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20lib=20func?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libraries/MathLib.sol | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/libraries/MathLib.sol b/src/libraries/MathLib.sol index fb634509..3a67ee2b 100644 --- a/src/libraries/MathLib.sol +++ b/src/libraries/MathLib.sol @@ -45,17 +45,6 @@ library MathLib { } } - /// @notice cast uint256 to uint128 - /// @dev asserts that input is not greater than uint128 max - /// @param x unsigned 256-bit number - /// @return downcasted uint128 from uint256 - function castU128(uint256 x) internal pure returns (uint128) { - if (x > type(uint128).max) { - revert OverflowU128(); - } - return uint128(x); - } - /// @notice determines if input numbers have the same sign /// @dev asserts that both numbers are not zero /// @param x signed number From c28c24babbe5a83d1931ace0b825b20f1fa9f90d Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Wed, 6 Dec 2023 01:43:36 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/MathLib.t.sol | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/test/MathLib.t.sol b/test/MathLib.t.sol index 92cec7b8..14e2f8cc 100644 --- a/test/MathLib.t.sol +++ b/test/MathLib.t.sol @@ -78,21 +78,6 @@ contract MathLibTest is Test { } } - function test_castU128() public { - uint256 x = 1 ether; - uint128 z = x.castU128(); - assertEq(z, 1 ether); - } - - function test_castU128_overflow() public { - uint256 x = type(uint128).max; - x++; - - vm.expectRevert(abi.encodeWithSelector(MathLib.OverflowU128.selector)); - - x.castU128(); - } - function test_isSameSign() public { int128 x = -1; int128 y = -1; From d58bba20c85acca040bb1192e25ff8032652c552 Mon Sep 17 00:00:00 2001 From: JaredBorders Date: Wed, 6 Dec 2023 01:44:20 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=B8=20Update=20gas-snapshot/lcov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 8 +++--- lcov.info | 67 +++++++++++++++++++++++---------------------------- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 3d2a8da9..da42540a 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -32,7 +32,7 @@ DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 42915) Deposit:test_depositEth() (gas: 55221) Deposit:test_depositEth_Account_Doesnt_Exist() (gas: 34292) Deposit:test_depositEth_event() (gas: 56837) -Deposit:test_depositEth_fuzz(uint256,uint128) (runs: 256, μ: 36528, ~: 34844) +Deposit:test_depositEth_fuzz(uint256,uint128) (runs: 256, μ: 36624, ~: 34844) DepositCollateral:test_depositCollateral() (gas: 258418) DepositCollateral:test_depositCollateral_availableMargin() (gas: 265986) DepositCollateral:test_depositCollateral_collateralAmount() (gas: 258994) @@ -49,10 +49,8 @@ Execute:test_execute_order_committed() (gas: 430886) Fee:test_fee_exceeds_account_credit() (gas: 67971) Fee:test_fee_exceeds_maxExecutorFee() (gas: 67506) Fee:test_fee_imposed() (gas: 469073) -MathLibTest:test_abs128() (gas: 448) +MathLibTest:test_abs128() (gas: 425) MathLibTest:test_abs256() (gas: 480) -MathLibTest:test_castU128() (gas: 350) -MathLibTest:test_castU128_overflow() (gas: 3509) MathLibTest:test_fuzz_abs128(int128) (runs: 256, μ: 577, ~: 603) MathLibTest:test_fuzz_abs256(int256) (runs: 256, μ: 472, ~: 458) MathLibTest:test_isSameSign() (gas: 999) @@ -80,7 +78,7 @@ Withdraw:test_withdrawEth_EthTransferFailed() (gas: 92992) Withdraw:test_withdrawEth_InsufficientEthBalance() (gas: 59659) Withdraw:test_withdrawEth_Unauthorized() (gas: 59409) Withdraw:test_withdrawEth_event() (gas: 51728) -Withdraw:test_withdrawEth_fuzz(uint256) (runs: 256, μ: 70863, ~: 71387) +Withdraw:test_withdrawEth_fuzz(uint256) (runs: 256, μ: 70837, ~: 71387) WithdrawCollateral:test_withdrawCollateral() (gas: 353084) WithdrawCollateral:test_withdrawCollateral_availableMargin() (gas: 354602) WithdrawCollateral:test_withdrawCollateral_collateralAmount() (gas: 353594) diff --git a/lcov.info b/lcov.info index cf1c3a24..f52b2671 100644 --- a/lcov.info +++ b/lcov.info @@ -1,26 +1,26 @@ TN: SF:script/Deploy.s.sol -FN:141,DeployOptimismGoerli_Synthetix.run -FNDA:0,DeployOptimismGoerli_Synthetix.run -DA:142,0 -DA:143,0 -DA:145,0 -DA:152,0 FN:24,Setup.deploySystem FNDA:5,Setup.deploySystem DA:30,5 -FN:43,DeployBase_Synthetix.run -FNDA:0,DeployBase_Synthetix.run -DA:44,0 -DA:45,0 -DA:47,0 -DA:54,0 FN:62,DeployBaseGoerli_Synthetix.run FNDA:0,DeployBaseGoerli_Synthetix.run DA:63,0 DA:64,0 DA:66,0 DA:73,0 +FN:43,DeployBase_Synthetix.run +FNDA:0,DeployBase_Synthetix.run +DA:44,0 +DA:45,0 +DA:47,0 +DA:54,0 +FN:141,DeployOptimismGoerli_Synthetix.run +FNDA:0,DeployOptimismGoerli_Synthetix.run +DA:142,0 +DA:143,0 +DA:145,0 +DA:152,0 FN:103,DeployBaseGoerli_Andromeda.run FNDA:0,DeployBaseGoerli_Andromeda.run DA:104,0 @@ -62,11 +62,11 @@ DA:149,284 FN:159,Engine.depositEth FNDA:523,Engine.depositEth DA:162,523 -BRDA:162,0,0,239 -BRDA:162,0,1,284 -DA:163,239 -DA:166,284 -DA:168,284 +BRDA:162,0,0,232 +BRDA:162,0,1,291 +DA:163,232 +DA:166,291 +DA:168,291 FN:172,Engine.withdrawEth FNDA:261,Engine.withdrawEth DA:176,261 @@ -295,24 +295,17 @@ DA:23,0 FN:30,MathLib.abs256 FNDA:0,MathLib.abs256 DA:44,0 -FN:52,MathLib.castU128 -FNDA:0,MathLib.castU128 -DA:53,0 -BRDA:53,0,0,- -BRDA:53,0,1,- -DA:54,0 -DA:56,0 -FN:64,MathLib.isSameSign +FN:53,MathLib.isSameSign FNDA:0,MathLib.isSameSign -DA:65,0 -BRDA:65,1,0,- -BRDA:65,1,1,- -DA:66,0 -FNF:4 +DA:54,0 +BRDA:54,0,0,- +BRDA:54,0,1,- +DA:55,0 +FNF:3 FNH:0 -LF:7 +LF:4 LH:0 -BRF:4 +BRF:2 BRH:0 end_of_record TN: @@ -650,17 +643,17 @@ BRH:0 end_of_record TN: SF:test/utils/mocks/EIP7412Mock.sol -FN:16,EIP7412MockRevert.fulfillOracleQuery -FNDA:256,EIP7412MockRevert.fulfillOracleQuery -DA:17,256 -FN:5,EIP7412Mock.fulfillOracleQuery -FNDA:256,EIP7412Mock.fulfillOracleQuery FN:9,EIP7412MockRefund.fulfillOracleQuery FNDA:256,EIP7412MockRefund.fulfillOracleQuery DA:10,256 DA:11,256 BRDA:11,0,0,256 BRDA:11,0,1,- +FN:5,EIP7412Mock.fulfillOracleQuery +FNDA:256,EIP7412Mock.fulfillOracleQuery +FN:16,EIP7412MockRevert.fulfillOracleQuery +FNDA:256,EIP7412MockRevert.fulfillOracleQuery +DA:17,256 FNF:3 FNH:3 LF:3