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-04] Documentation Issues #28

Merged
merged 8 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
6 changes: 2 additions & 4 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, μ: 36432, ~: 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
89 changes: 41 additions & 48 deletions lcov.info
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
TN:
SF:script/Deploy.s.sol
FN:43,DeployBase_Synthetix.run
FNDA:0,DeployBase_Synthetix.run
DA:44,0
DA:45,0
DA:47,0
DA:54,0
FN:24,Setup.deploySystem
FNDA:5,Setup.deploySystem
DA:30,5
FN:62,DeployBaseGoerli_Synthetix.run
FNDA:0,DeployBaseGoerli_Synthetix.run
DA:63,0
DA:64,0
DA:66,0
DA:73,0
FN:122,DeployOptimism_Synthetix.run
FNDA:0,DeployOptimism_Synthetix.run
DA:123,0
DA:124,0
DA:126,0
DA:133,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
DA:105,0
DA:107,0
DA:114,0
FN:24,Setup.deploySystem
FNDA:5,Setup.deploySystem
DA:30,5
FN:84,DeployBaseGoerli_KwentaFork.run
FNDA:0,DeployBaseGoerli_KwentaFork.run
DA:85,0
DA:86,0
DA:88,0
DA:95,0
FN:141,DeployOptimismGoerli_Synthetix.run
FNDA:0,DeployOptimismGoerli_Synthetix.run
DA:142,0
DA:143,0
DA:145,0
DA:152,0
FN:122,DeployOptimism_Synthetix.run
FNDA:0,DeployOptimism_Synthetix.run
DA:123,0
DA:124,0
DA:126,0
DA:133,0
FNF:7
FNH:1
LF:25
Expand All @@ -62,11 +62,11 @@ DA:149,284
FN:159,Engine.depositEth
FNDA:523,Engine.depositEth
DA:162,523
BRDA:162,0,0,236
BRDA:162,0,1,287
DA:163,236
DA:166,287
DA:168,287
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 @@ -518,11 +511,6 @@ FNDA:0,BootstrapOptimism.init
DA:108,0
DA:115,0
DA:122,0
FN:134,BootstrapOptimismGoerli.init
FNDA:0,BootstrapOptimismGoerli.init
DA:138,0
DA:145,0
DA:152,0
FN:38,Bootstrap.initializeOptimismGoerli
FNDA:0,Bootstrap.initializeOptimismGoerli
DA:39,0
Expand Down Expand Up @@ -559,6 +547,11 @@ DA:91,0
DA:92,0
DA:97,0
DA:99,0
FN:134,BootstrapOptimismGoerli.init
FNDA:0,BootstrapOptimismGoerli.init
DA:138,0
DA:145,0
DA:152,0
FNF:4
FNH:0
LF:38
Expand Down Expand Up @@ -656,11 +649,11 @@ 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
FN:5,EIP7412Mock.fulfillOracleQuery
FNDA:256,EIP7412Mock.fulfillOracleQuery
FNF:3
FNH:3
LF:3
Expand Down
6 changes: 3 additions & 3 deletions src/Engine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ contract Engine is IEngine, EIP712, EIP7412 {
{
// shift _nonce to the right by 8 bits and cast to uint248
/// @dev wordPos == 0 if 0 <= _nonce <= 255, 1 if 256 <= _nonce <= 511, etc.
wordPos = uint248(_nonce >> 8);
wordPos = _nonce >> 8;

// cast the last 8 bits of _nonce to uint8
/// @dev 0 <= bitPos <= 255
Expand Down Expand Up @@ -391,7 +391,7 @@ contract Engine is IEngine, EIP712, EIP7412 {
override
returns (IPerpsMarketProxy.Data memory retOrder, uint256 fees)
{
/// @dev only the account owner can withdraw collateral
/// @dev the account owner or the delegate may commit async orders
if (_isAccountOwnerOrDelegate(_accountId, msg.sender)) {
(retOrder, fees) = _commitOrder({
_perpsMarketId: _perpsMarketId,
Expand Down Expand Up @@ -497,7 +497,7 @@ contract Engine is IEngine, EIP712, EIP7412 {
}
}

/// @dev execute the order
/// @dev commit async order
(retOrder, synthetixFees) = _commitOrder({
_perpsMarketId: _co.orderDetails.marketId,
_accountId: _co.orderDetails.accountId,
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface IEngine {
OrderDetails orderDetails;
// address of the signer of the order
address signer;
// an incrementing value indexed per order
// a means to prevent replay attacks and identify the order
uint256 nonce;
// option to require all extra conditions to be verified on-chain
bool requireVerified;
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