Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔎 [N-09] Unused Code #30

Merged
merged 3 commits into from
Dec 7, 2023
Merged
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
8 changes: 3 additions & 5 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
67 changes: 30 additions & 37 deletions lcov.info
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions src/libraries/MathLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions test/MathLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading