source
stringclasses
1 value
protocol
stringclasses
111 values
report_title
stringclasses
111 values
report_date
stringdate
2023-03-13 00:00:00
2023-04-11 00:00:00
finding_id
stringclasses
150 values
severity
stringclasses
6 values
title
stringlengths
10
284
full_content
stringlengths
103
34.2k
description
stringlengths
46
14.4k
proof_of_concept
stringclasses
438 values
impact
stringlengths
0
4.93k
recommended_mitigation
stringlengths
2
10.6k
code_block_count
int64
0
32
has_poc
bool
2 classes
has_mitigation
bool
2 classes
content_length
int64
103
34.2k
severity_normalized
stringclasses
5 values
severity_raw
stringclasses
6 values
category
stringclasses
16 values
primary_code
stringlengths
0
15k
primary_code_language
stringclasses
11 values
all_code_blocks
stringlengths
0
20.8k
all_code_blocks_count
int64
0
32
solidity_code
stringlengths
0
19.9k
has_impact
bool
2 classes
has_code_in_description
bool
2 classes
content_richness_score
float64
0
10.5
quality_estimate
stringclasses
3 values
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-01
high
Attackers can steal tokens and break the protocol's invariant
Attackers can steal tokens and break the protocol's invariant ### Description The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. The function `Well::_getIJ()` is used to get the index of the `fromToken` and `toToken` in the Well's `tokens`. But the f...
The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. The function `Well::_getIJ()` is used to get the index of the `fromToken` and `toToken` in the Well's `tokens`. But the function `Well::_getIJ` is not implemented correctly. ```solidity Well.sol 566: ...
Assume a Well with two tokens `t0, t1` is deployed with `ConstantProduct2.sol` as the Well function. 1. The protocol is in a state of `(400 ether, 100 ether)` (`reserve0, reserve1`). 2. An attacker Alice calls `swapFrom(t1, t1, 100 ether, 0)`. 3. At [L148](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb...
The protocol aims for a generalized constant function AMM (CFAMM) and the core invariant of the protocol is there are always more reserved tokens than the actual token balance (`reserves[i] >= tokens[i].balanceOf(well) for all i`). The incorrect implementation of `_getIJ()` allows attackers to break this invariant and ...
- Add a sanity check to revert if `fromToken==toToken` in the function `Well::swapFrom()` and `Well::swapTo()` . - Add a sanity check to revert if `iToken==jToken` in the function `Well::_getIJ()` assuming this internal function is not supposed to used with same tokens. - We strongly recommend adding a check in the fun...
3
true
true
6,248
high
high
token
Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.length; ++k) { 572: ...
solidity
// Code block 1 (solidity): Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.len...
3
Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.length; ++k) { 572: ...
true
true
9.6
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-02
high
Attacker can steal reserves and subsequent liquidity deposits due to lack of input token validation
Attacker can steal reserves and subsequent liquidity deposits due to lack of input token validation ### Description The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. If one of the parameters `fromToken/toToken` is not in `_tokens`, this causes simil...
The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. If one of the parameters `fromToken/toToken` is not in `_tokens`, this causes similar issues in `_getIJ` with an index `i/j` being returned as zero. It appears you can specify a garbage `fromToken` to ...
Beliw is a test case to show this exploit scenario. The attacker can deploy his own garbage token and call `Well::swapFrom(garbageToken, tokens[1])` that drains the `tokens[0]` balance of the Well. Note that the similar exploit is also possible for `Well::swapTo()`. ```solidity function test_exploitGarbageFromToken() ...
The insufficient sanity check on the input tokens of `swapFrom()`(and `swapTo()`) allows attackers to extract tokens and break the protocol's invariant. Because this exploit does not require any additional assumptions, we evaluate the severity to HIGH.
- Add a sanity check to revert if either `iToken` or `jToken` is not found in the `_tokens` array. - We also strongly recommend adding a check in the function `Well::_executeSwap()` to make sure the Well has enough reserves on every transaction.
2
true
true
4,727
high
high
input-validation
function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageToken", "GTKN", 18)); Mock...
solidity
// Code block 1 (solidity): function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageTo...
2
function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageToken", "GTKN", 18)); Mock...
true
true
7.76
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-03
high
`removeLiquidity` logic is not correct for general Well functions other than ConstantProduct
`removeLiquidity` logic is not correct for general Well functions other than ConstantProduct ### Description The protocol aims for a generalized permission-less CFAMM (constant function AMM) where various Well functions can be used. At the moment, only constant product Well function types are defined but we assume s...
The protocol aims for a generalized permission-less CFAMM (constant function AMM) where various Well functions can be used. At the moment, only constant product Well function types are defined but we assume support for more generalized Well functions are intended. The current implementation of `removeLiquidity()` and...
We wrote a test case with the quadratic Well function used by Numoen. ```solidity // QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uin...
The current `removeLiquidity()` logic assumes specific conditions on the Well function (specifically, some sort of linearity). This limits the generalization of the protocol, opposed to its original purpose. Because this will lead to loss of funds for the liquidity providers for general Well functions, we evaluate the ...
We believe that it is not possible to cover all kinds of Well functions without adding some additional functions in the interface `IWellFunction`. We recommend adding a new function in the `IWellFunction` interface, possibly in the form of `function calcWithdrawFromLp(uint lpTokenToBurn) returns (uint reserve)`. The o...
2
true
true
8,193
high
high
access-control
// QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info assume 1:1 upperbound for this...
solidity
// Code block 1 (solidity): // QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info as...
2
// QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info assume 1:1 upperbound for this...
true
true
9.35
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-04
high
Read-only reentrancy
Read-only reentrancy ### Description The current implementation is vulnerable to read-only reentrancy, especially in the function [removeLiquidity](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L296). The implementation does not conform to the [CEI pattern](https:/...
The current implementation is vulnerable to read-only reentrancy, especially in the function [removeLiquidity](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L296). The implementation does not conform to the [CEI pattern](https://fravoll.github.io/solidity-patterns/ch...
Below is a test case to show the existing read-only reentrancy. ```solidity // MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool ...
Although this is not a direct risk to the protocol itself as it is, this can lead to a critical issue in the future. We evaluate the severity to HIGH.
Implement the CEI pattern in relevant functions. For example, the function `Well::removeLiquidity` can be modified as below. ```solidity function removeLiquidity( uint lpAmountIn, uint[] calldata minTokenAmountsOut, address recipient ) external nonReentrant returns (uint[] memory tokenAmountsOut) { IER...
3
true
true
4,500
high
high
reentrancy
// MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(abi.encodeWithSignature("getR...
solidity
// Code block 1 (solidity): // MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(a...
3
// MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(abi.encodeWithSignature("getR...
true
true
9.26
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-01
medium
Insufficient support for fee-on-transfer ERC20 tokens
Insufficient support for fee-on-transfer ERC20 tokens ### Description The Well does not rely on the `balanceOf()` function from ERC20 to retrieve current reserve balances. This is a good design choice. Reserves values stored in the protocol should be equal to or less than the actual balance. The current implementati...
The Well does not rely on the `balanceOf()` function from ERC20 to retrieve current reserve balances. This is a good design choice. Reserves values stored in the protocol should be equal to or less than the actual balance. The current implementation assumes `safeTransfer()` will always increase the actual balance equa...
null
Because this vulnerability is dependent on the tokens, we evaluate the severity to MEDIUM.
- If the protocol does not intend to support these kinds of tokens, prevent them by checking the actual balance increase after calling safeTransfer. - If the protocol wants to support any kind of ERC20 tokens, use a hook method so that the caller can decide the sending amount and check the balance increase amount after...
0
false
true
1,197
medium
medium
token
0
true
false
3.83
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-02
medium
Some tokens revert on transfer of zero amount
Some tokens revert on transfer of zero amount ### Description Well protocol intends to be used with various ERC20 tokens. Some ERC20 tokens revert on transferring zero amount and it is recommended to transfer only when the amount is positive.([Ref](https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers)) ...
Well protocol intends to be used with various ERC20 tokens. Some ERC20 tokens revert on transferring zero amount and it is recommended to transfer only when the amount is positive.([Ref](https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers)) In several places, the current implementation does not check the...
null
For some ERC20 tokens, the protocol's important functions (e.g. `removeLiquidity`) would revert and this can lead to insolvency. We evaluate the severity to MEDIUM.
Check the transfer amount to be positive before calling transfer functions.
0
false
true
983
medium
medium
token
0
true
false
3.77
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-03
medium
Need to make sure the tokens are unique for ImmutableTokens
Need to make sure the tokens are unique for ImmutableTokens ### Description The current implementation does not enforce uniqueness in the `_tokens` of `ImmutableTokens`. Assuming `_tokens[0]=_tokens[1]`. An honest liquidity provider calls `addLiquidity([1 ether,1 ether], 200 ether, address)`, resulting in the reserv...
The current implementation does not enforce uniqueness in the `_tokens` of `ImmutableTokens`. Assuming `_tokens[0]=_tokens[1]`. An honest liquidity provider calls `addLiquidity([1 ether,1 ether], 200 ether, address)`, resulting in the reserves being `(1 ether, 1 ether)`. At this point, anyone can call the function `sk...
null
Assuming normal liquidity providers are smart enough to check the tokens before sending funds, the likelihood is low, hence we evaluate the severity to MEDIUM.
Enforce uniqueness of the array `_tokens` in `ImmutableTokens`. This can also be done in the function `ImmutableTokens::getTokenFromList()`.
0
false
true
874
medium
medium
token
0
true
false
3.41
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
L-01
low
Incorrect sload in LibBytes
Incorrect sload in LibBytes ### Description The function `storeUint128` in `LibBytes` intends to pack uint128 `reserves` starting at the given slot but will actually overwrite the final slot if [storing an odd number of reserves](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/sr...
The function `storeUint128` in `LibBytes` intends to pack uint128 `reserves` starting at the given slot but will actually overwrite the final slot if [storing an odd number of reserves](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibBytes.sol#L78). It is currently...
The following test case demonstrates this issue more clearly: ```solidity // NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot =...
Given that assets are not directly at risk, we evaluate the severity to LOW.
Implement the following fix to load the existing value from storage and pack in the lower bits: ```solidity sload(add(slot, mul(maxI, 32))) ``` ![Output after mitigation](Screenshot_2023-02-13_at_17.07.07.jpg)
2
true
true
3,334
low
low
token
// NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM_RESERVES_MAX - 1) / 2; ...
solidity
// Code block 1 (solidity): // NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM...
2
// NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM_RESERVES_MAX - 1) / 2; ...
true
true
8.41
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-01
informational
Non-standard storage packing
Non-standard storage packing Per the [Solidity docs](https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html), the first item in a packed storage slot is stored lower-order aligned; however, [manual packing](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/lib...
null
null
null
null
0
false
false
495
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-02
informational
EIP-1967 second pre-image best practice
EIP-1967 second pre-image best practice When calculating custom [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967) storage slots, as in [Well.sol::RESERVES_STORAGE_SLOT](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L37), it is [best practice](https://ethereum-magic...
null
null
null
null
0
false
false
493
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-03
informational
Remove experimental ABIEncoderV2 pragma
Remove experimental ABIEncoderV2 pragma ABIEncoderV2 is enabled by default in Solidity 0.8, so [two](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWellFunction.sol#L6) [instances](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe...
null
null
null
null
0
false
false
366
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-04
informational
Inconsistent use of decimal/hex notation in inline assembly
Inconsistent use of decimal/hex notation in inline assembly For readability and to prevent errors when working with inline assembly, decimal notation should be used for integer constants and hex notation for memory offsets.
null
null
null
null
0
false
false
223
informational
informational
rounding
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-05
informational
Unused variables, imports and errors
Unused variables, imports and errors In `LibBytes`, the [`temp` variable]((https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibBytes.sol#L39)) of `storeUint128` is unused and should be removed. In `LibMath`: - OpenZeppelin SafeMath is imported but not used - `PRBMath_...
null
null
null
null
0
false
false
369
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-06
informational
Inconsistency in LibMath comments
Inconsistency in LibMath comments There is inconsistent use of `x` in comments and `a` in code within the `nthRoot` and `sqrt` [functions](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L44-L147) of `LibMath`.
null
null
null
null
0
false
false
274
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-07
informational
FIXME and TODO comments
FIXME and TODO comments There are several [FIXME](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWell.sol#L268) and [TODO](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L36) comments that should be a...
null
null
null
null
0
false
false
329
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-08
informational
Use correct NatSpec tags
Use correct NatSpec tags Uses of `@dev See {IWell.fn}` should be replaced with `@inheritdoc IWell` to inherit the NatSpec documentation from the interface.
null
null
null
null
0
false
false
155
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-09
informational
Format for readability
Format for readability For readability, code should be formatted according to the [Solidity Style Guide](https://docs.soliditylang.org/en/v0.8.17/style-guide.html#other-recommendations) which includes surrounding operators with a single space on either side: e.g. [`numberOfBytes0 - 1`](https://github.com/BeanstalkFarms...
null
null
null
null
0
false
false
408
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-10
informational
Spelling errors
Spelling errors The following spelling errors were identified: - ['configurating'](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWell.sol#L110) should become 'configuration' - ['Pump'/'_pumo'](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf9...
null
null
null
null
0
false
false
383
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
G-1
gas
Simplify modulo operations
Simplify modulo operations In `LibBytes::storeUint128` and `LibBytes::readUint128`, `reserves.lenth % 2 == 1` and `i % 2 == 1` can be simplified to `reserves.length & 1 == 1` and `i & 1 == 1`.
null
null
null
null
0
false
false
192
informational
gas
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
G-2
gas
Branchless optimization
Branchless optimization The `sqrt` function in `MathLib` and [related comment](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L136-L145) should be updated to reflect changes in Solmate's `FixedPointMathLib` which now includes the [branchless optimization]...
null
null
null
null
0
false
false
485
informational
gas
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
M-01
medium
Bad signature validation, malleability & lack of zero address protection in `updateValidatorSet`
Bad signature validation, malleability & lack of zero address protection in `updateValidatorSet` ### Description The `ecrecover` built-in will return `address(0)` if it fails to recover the signer from a message digest and corresponding signature. There is no `address(0)` check in [`Signature::recoverSigner`](https:/...
The `ecrecover` built-in will return `address(0)` if it fails to recover the signer from a message digest and corresponding signature. There is no `address(0)` check in [`Signature::recoverSigner`](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L62) or [`Bridge:...
The following forge test can be seen to demonstrate these findings: ```solidity function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = Validator...
Given the vulnerability described has a low likelihood but high impact, we evaluate the severity to MEDIUM.
As mentioned above, it is recommended to correctly validate recovered signers and protect against signature malleability by using the [OpenZeppelin ECDSA library](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol). Additionally, add zero address validation to `Bri...
1
true
true
8,406
medium
medium
input-validation
function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory sigs = _getSignatures(sende...
solidity
// Code block 1 (solidity): function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory...
1
function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory sigs = _getSignatures(sende...
true
true
8.5
high
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
M-02
medium
Incorrect initialization of `powerThreshold` and lack of validation
Incorrect initialization of `powerThreshold` and lack of validation ### Description The `Bridge::powerThreshold` should be 2/3 the sum of the validator power across current validators at any point; however, the [calculation](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Br...
The `Bridge::powerThreshold` should be 2/3 the sum of the validator power across current validators at any point; however, the [calculation](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L94) in `Bridge2::constructor` is not correct and it's initialized to `(2 * _...
null
It is possible malicious actions that are lack of validation power are allowed due to wrong initialization of `powerThreshold`. Because the initializer is assumed to be called by an admin and there is also another admin function to change the `powerThreshold`, we evaluate the severity to MEDIUM.
- Initialize `powerThreshold` to the 2/3 the sum of the initial validator powers. - Add validation for the new `powerThreshold` in `Bridge::changePowerThreshold()` to allow only reasonable values (ranging from 2/3 to total of the current cumulative validation power).
0
false
true
2,686
medium
medium
access-control
0
true
false
5.5
medium
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
L-01
low
Prevent setting the new epoch to an arbitrary large value
Prevent setting the new epoch to an arbitrary large value ### Description In the function `Bridge::updateValidatorSet`, the new epoch is [checked](https://github.com/ChainAccelOrg/hyperliquid-audit/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L213) to be greater than the current epoch. However, there is n...
In the function `Bridge::updateValidatorSet`, the new epoch is [checked](https://github.com/ChainAccelOrg/hyperliquid-audit/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L213) to be greater than the current epoch. However, there is no check to prevent setting the new epoch to an arbitrary large value which c...
null
This is not likely to happen but we evaluate as LOW because it can freeze the protocol, locking funds and effectively make the whole protocol insolvent.
It is recommended to allow increase of epoch only to some limited extent, rather than any arbitrary large number.
0
false
true
1,169
low
low
other
0
true
false
3.35
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-01
informational
Make `minTotalValidatorPower` immutable
Make `minTotalValidatorPower` immutable Given that `Bridge::minTotalValidatorPower` is initialized once in the constructor and never modified thereafter, it can be made immutable. This also has the effect of reducing gas usage in functions which currently read its value from storage. ### `f045dbf` Resolution `minTot...
null
null
null
null
0
false
false
355
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-02
informational
Avoid using an initializer unless absolutely necessary
Avoid using an initializer unless absolutely necessary [This comment](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L85-L86) references the potential introduction of a separate initializer but it should be noted that bad initialization is the cause of many exploi...
null
null
null
null
0
false
false
435
informational
informational
initialization
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-03
informational
Use calldata for all function arguments that are not modified
Use calldata for all function arguments that are not modified If function arguments are not intended to be modified then it is best practice to pass them as calldata arguments rather than memory, for example in [https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#LL94C...
null
null
null
null
0
false
false
618
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-04
informational
`updateValidatorSet` block scope is not necessary
`updateValidatorSet` block scope is not necessary The block scope in `Bridge::updateValidatorSet` is not necessary as the contract successfully compiles without it and so can be removed. ### `f045dbf` Resolution The block scope has been removed.
null
null
null
null
0
false
false
248
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-05
informational
Emit events before interaction
Emit events before interaction To strictly conform to checks-effect-interactions, it is recommended to emit events prior to any [external interactions](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L122-L123). This is generally advised to ensure correct migration...
null
null
null
null
0
false
false
556
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-06
informational
Make USDC amount naming more verbose
Make USDC amount naming more verbose The naming of the USDC amount parameter in [`Bridge::deposit and Bridge::withdraw`](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L120-L152) is not clear, i.e. change `uint256 usdc` to `uin256 usdcAmount`. ### `f045dbf` Resol...
null
null
null
null
0
false
false
559
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-07
informational
Rename file to `Bridge2.sol` to match the contract name
Rename file to `Bridge2.sol` to match the contract name The `Bridge2` contract resides in `Bridge.sol`; however, it is best practice to follow the convention of one contract per file with the same name. ### `f045dbf` Resolution The client team has renamed the contract to `Bridge.sol` with the following comment: > W...
null
null
null
null
0
false
false
438
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-08
informational
Add missing NatSpec comments to document function parameters and behaviour
Add missing NatSpec comments to document function parameters and behaviour It is recommended to document all function behaviours and parameters, especially if they are public-facing. ### `f045dbf` Resolution The client team acknowledges this finding with the following comment: > Light comments were added to functio...
null
null
null
null
0
false
false
339
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-09
informational
No need to explicitly initialize variables to 0
No need to explicitly initialize variables to 0 Variables are initalized to 0 by default in Solidity, so a [number](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L169-L170) of [superfluous](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c0945070...
null
null
null
null
0
false
false
566
informational
informational
initialization
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-10
informational
Use addition assignment operator
Use addition assignment operator The addition assignment operator `+=` can be used when [checking new validator powers](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L238). ### `f045dbf` Resolution The addition assignment operator has been used.
null
null
null
null
0
false
false
304
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-11
informational
Localhost chain id can be 1337 or 31337
Localhost chain id can be 1337 or 31337 The default localhost chain id for some frameworks (e.g. HardHat) is `31337` rather than `1337`. For example, it is not possible to run signature tests using forge without changing `Signature::LOCALHOST_CHAIN_ID` to `31337`. ### `f045dbf` Resolution This has been resolved by t...
null
null
null
null
0
false
false
343
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-12
informational
Rename to DOMAIN_SEPARATOR and use `block.chainId` directly
Rename to DOMAIN_SEPARATOR and use `block.chainId` directly References to `*_DOMAIN_HASH` in `Signature` should be renamed to `*_DOMAIN_SEPARATOR` to be more consistent with the EIP and avoid confusion. Additionally, it is recommended to use `block.chainId` directly, caching on contract creation and only recomputing t...
null
null
null
null
0
false
false
782
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-13
informational
Rename to `EIP712_DOMAIN_TYPEHASH`
Rename to `EIP712_DOMAIN_TYPEHASH` Add an [additional underscore](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L19) for readability. ### `f045dbf` Resolution The constant has been renamed to `EIP712_DOMAIN_TYPEHASH`.
null
null
null
null
0
false
false
279
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-14
informational
Include `byte32 salt` in domain typehash
Include `byte32 salt` in domain typehash Per the [EIP](https://eips.ethereum.org/EIPS/eip-712), `bytes32 salt` should be added to the [domain separator](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L20) as a last-resort means to distinguish this application f...
null
null
null
null
0
false
false
934
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-15
informational
Verifying contract TODO
Verifying contract TODO Update the [verifying contract address](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L25). ### `f045dbf` Resolution The client team acknowledges this finding with the following comment: > Removed the TODO. Keeping the verifying addr...
null
null
null
null
0
false
false
431
informational
informational
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
H-01
high
Specified `minOutput` will remain locked in `LSSVMRouter::swapNFTsForSpecificNFTsThroughETH`
Specified `minOutput` will remain locked in `LSSVMRouter::swapNFTsForSpecificNFTsThroughETH` **Description:** The Cyfrin team understands that `LSSVMRouter` is slightly out of scope for this audit, given that it is intended to be deprecated and replaced by `VeryFastRouter`; however, a slightly modified version of this ...
The Cyfrin team understands that `LSSVMRouter` is slightly out of scope for this audit, given that it is intended to be deprecated and replaced by `VeryFastRouter`; however, a slightly modified version of this contract is currently deployed and [live on mainnet](https://etherscan.io/address/0x2b2e8cda09bba9660dca5cb623...
Apply the following git diff: ```diff diff --git a/src/test/interfaces/ILSSVMPairFactoryMainnet.sol b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol new file mode 100644 index 0000000..3cdea5b --- /dev/null +++ b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +prag...
This vulnerability results in the locking of user funds with high impact and likelihood. If the problematic functions were integrated into a UI, then this would be evaluated as CRITICAL, but given that the current integrations significantly reduce the likelihood, we evaluate the severity as HIGH.
Pass `minOutput` through to the internal functions to be used in refund calculations and correctly reflect the true contract balance, validating that this amount is not exceeded. This way, the [`outputAmount`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/LSSVMRouter.sol#L94) [ret...
1
true
true
11,884
high
high
integer-overflow
diff --git a/src/test/interfaces/ILSSVMPairFactoryMainnet.sol b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol new file mode 100644 index 0000000..3cdea5b --- /dev/null +++ b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {IERC721}...
diff
// Code block 1 (diff): diff --git a/src/test/interfaces/ILSSVMPairFactoryMainnet.sol b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol new file mode 100644 index 0000000..3cdea5b --- /dev/null +++ b/src/test/interfaces/ILSSVMPairFactoryMainnet.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0....
1
true
true
8.5
high
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
H-02
high
Malicious pair can re-enter `VeryFastRouter` to drain original caller's funds
Malicious pair can re-enter `VeryFastRouter` to drain original caller's funds **Description:** [`VeryFastRouter::swap`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/VeryFastRouter.sol#L266) is the main entry point for a user to perform a batch of sell and buy orders on the new Su...
[`VeryFastRouter::swap`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/VeryFastRouter.sol#L266) is the main entry point for a user to perform a batch of sell and buy orders on the new Sudoswap router, allowing partial fill conditions to be specified. Sell orders are executed first...
The following diff demonstrates a honeypot pair which re-enters the swap and drains the original caller's ETH: ```diff diff --git a/src/VeryFastRouter.sol b/src/VeryFastRouter.sol index 16047b9..2bd3797 100644 --- a/src/VeryFastRouter.sol +++ b/src/VeryFastRouter.sol @@ -85,6 +85,7 @@ contract VeryFastRouter { er...
This vulnerability results in the loss of user funds, with high impact and medium likelihood, so we evaluate the severity to HIGH.
Validate user inputs to `VeryFastRouter::swap`, in particular pairs, and consider making this function non-reentrant.
1
true
true
20,490
high
high
reentrancy
diff --git a/src/VeryFastRouter.sol b/src/VeryFastRouter.sol index 16047b9..2bd3797 100644 --- a/src/VeryFastRouter.sol +++ b/src/VeryFastRouter.sol @@ -85,6 +85,7 @@ contract VeryFastRouter { error VeryFastRouter__InvalidPair(); error VeryFastRouter__BondingCurveQuoteError(); + event vfr_log_named_uint ...
diff
// Code block 1 (diff): diff --git a/src/VeryFastRouter.sol b/src/VeryFastRouter.sol index 16047b9..2bd3797 100644 --- a/src/VeryFastRouter.sol +++ b/src/VeryFastRouter.sol @@ -85,6 +85,7 @@ contract VeryFastRouter { error VeryFastRouter__InvalidPair(); error VeryFastRouter__BondingCurveQuoteError(); + eve...
1
true
true
8.5
high
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
H-03
high
Linearity assumption on the royalty can lead to denial of service
Linearity assumption on the royalty can lead to denial of service **Description:** `VeryFastRouter::swap` relies on the internal functions [`VeryFastRouter::_findMaxFillableAmtForSell`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/VeryFastRouter.sol#L556) and [`VeryFastRouter::_f...
`VeryFastRouter::swap` relies on the internal functions [`VeryFastRouter::_findMaxFillableAmtForSell`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/VeryFastRouter.sol#L556) and [`VeryFastRouter::_findMaxFillableAmtForBuy`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d781...
null
The linearity assumption can be violated, especially in the case of external royalty info providers (possibly malicious), and this can lead to protocol failing to behave as expected, as legitimate swaps will fail. Due to these incorrect assumptions affecting the core functions, we evaluate the severity to HIGH.
While we understand the protocol team intended to reduce gas costs by using the linearity assumption, we recommend using the actual royalty amount to calculate `priceToFillAt` and `numItemsToFill`.
3
false
true
8,657
high
high
dos
VeryFastRouter.sol 576: // Perform binary search 577: while (start <= end) { 578: // We check the price to sell index + 1 579: ( 580: CurveErrorCodes.Error error, 581: /* newSpotPrice */ 582: , 583: /* newDelta */ 58...
solidity
// Code block 1 (solidity): VeryFastRouter.sol 576: // Perform binary search 577: while (start <= end) { 578: // We check the price to sell index + 1 579: ( 580: CurveErrorCodes.Error error, 581: /* newSpotPrice */ 582: , 583: ...
3
VeryFastRouter.sol 576: // Perform binary search 577: while (start <= end) { 578: // We check the price to sell index + 1 579: ( 580: CurveErrorCodes.Error error, 581: /* newSpotPrice */ 582: , 583: /* newDelta */ 58...
true
true
8.5
high
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
M-01
medium
Possible reverts due to using stricter requirements in inner swap
Possible reverts due to using stricter requirements in inner swap **Description:** `VeryFastRouter::swap` relies on the internal functions `VeryFastRouter::_findMaxFillableAmtForSell` and `VeryFastRouter::_findMaxFillableAmtForBuy` to find the maximum possible amount of tokens to be swapped. The output is supposed to b...
`VeryFastRouter::swap` relies on the internal functions `VeryFastRouter::_findMaxFillableAmtForSell` and `VeryFastRouter::_findMaxFillableAmtForBuy` to find the maximum possible amount of tokens to be swapped. The output is supposed to be the _actual_ cost of the swap, and it is used as the [`minExpectedTokenOutput`](h...
null
Although this does not lead to direct loss of funds, we are evaluating the severity of MEDIUM because it can lead to unintended protocol behavior.
We recommend using `minExpectedOutputPerNumNFTs` and `maxCostPerNumNFTs` instead of the output of `VeryFastRouter::_findMaxFillableAmtForSell` and `VeryFastRouter::_findMaxFillableAmtForBuy` as arguments to the actual swap functions.
1
false
true
5,194
medium
medium
dos
VeryFastRouter.sol 326: uint256 numItemsToFill; 327: uint256 priceToFillAt; 328: 329: { 330: // Grab royalty for calc in _findMaxFillableAmtForSell 331: (,, uint256 royaltyAmount) = order.pair.calculateRoyaltiesView( 332: ...
solidity
// Code block 1 (solidity): VeryFastRouter.sol 326: uint256 numItemsToFill; 327: uint256 priceToFillAt; 328: 329: { 330: // Grab royalty for calc in _findMaxFillableAmtForSell 331: (,, uint256 royaltyAmount) = order.pair.calculateRo...
1
VeryFastRouter.sol 326: uint256 numItemsToFill; 327: uint256 priceToFillAt; 328: 329: { 330: // Grab royalty for calc in _findMaxFillableAmtForSell 331: (,, uint256 royaltyAmount) = order.pair.calculateRoyaltiesView( 332: ...
true
true
6.5
medium
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
M-02
medium
Different rounding directions are recommended for getting buy/sell info
Different rounding directions are recommended for getting buy/sell info **Description:** This issue pertains to the need for more implementation of different rounding directions for buy and sell operations in the AMM pools. In several `ICurve` implementations (`XykCurve`, `GDACurve`), the `ICurve::getBuyInfo` and `ICur...
This issue pertains to the need for more implementation of different rounding directions for buy and sell operations in the AMM pools. In several `ICurve` implementations (`XykCurve`, `GDACurve`), the `ICurve::getBuyInfo` and `ICurve::getSellInfo` functions are implemented using the same rounding direction. This does n...
null
The issue may result in financial loss for pair creators and negatively impact the platform's overall stability, especially for tokens with fewer decimals. We, therefore, rate the severity as MEDIUM.
Ensure that the buy price and protocol/trade fees are rounded up to prevent selling items at a lower price than desired and leaking value from the system.
0
false
true
1,599
medium
medium
token
0
true
false
4.43
medium
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
M-03
medium
GDACurve does not validate new spot price
GDACurve does not validate new spot price **Description:** The new spot price calculated in `GDACurve::getBuyInfo` and `GDACurve::getSellInfo` is not currently validated against `MIN_PRICE`, meaning that the price could fall below this value. ```solidity GDACurve.sol (Line 81-91) // The new spot price is mult...
The new spot price calculated in `GDACurve::getBuyInfo` and `GDACurve::getSellInfo` is not currently validated against `MIN_PRICE`, meaning that the price could fall below this value. ```solidity GDACurve.sol (Line 81-91) // The new spot price is multiplied by alpha^n and divided by the time decay so future ...
null
null
As with an exponential bonding curve, we recommend introducing minimum price validation in `GDACurve::getBuyInfo` and `GDACurve::getSellInfo` when the spot price is updated.
2
false
true
2,440
medium
medium
integer-overflow
GDACurve.sol (Line 81-91) // The new spot price is multiplied by alpha^n and divided by the time decay so future // calculations do not need to track number of items sold or the initial time/price. This new spot price // implicitly stores the the initial price, total items sold so far, and time...
solidity
// Code block 1 (solidity): GDACurve.sol (Line 81-91) // The new spot price is multiplied by alpha^n and divided by the time decay so future // calculations do not need to track number of items sold or the initial time/price. This new spot price // implicitly stores the the initial price, total...
2
GDACurve.sol (Line 81-91) // The new spot price is multiplied by alpha^n and divided by the time decay so future // calculations do not need to track number of items sold or the initial time/price. This new spot price // implicitly stores the the initial price, total items sold so far, and time...
false
true
6.5
medium
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
M-04
medium
Binary search implementation may not always find the optimal solution
Binary search implementation may not always find the optimal solution **Description:** `VeryFastRouter::_findMaxFillableAmtForBuy` and `VeryFastRouter::_findMaxFillableAmtForSell` utilize binary search to determine the maximum trade amount. The binary search seeks a solution in a linear, sorted space based on a test fu...
`VeryFastRouter::_findMaxFillableAmtForBuy` and `VeryFastRouter::_findMaxFillableAmtForSell` utilize binary search to determine the maximum trade amount. The binary search seeks a solution in a linear, sorted space based on a test function (a criteria function used to decide the next search area). However, the current ...
Consider a situation with the following conditions: 1. A pool containing a collection of 11 NFTs with an Exponential Bonding Curve (Spot Price: 1 eth, Delta: 1.05). 2. Alice computes the maximum bids for buying a collection of NFTs using `VeryFastRouter::getNFTQuoteForBuyOrderWithPartialFill`. 3. Alice desires to acqu...
This issue does not result in an immediate financial loss. Nevertheless, users acquire fewer NFTs than they originally planned to buy. Given the significance of the core logic, the impact of this issue is considered to be MEDIUM.
null
2
true
false
10,604
medium
medium
integer-overflow
function testSwapBinarySearch_audit() public{ //START_INDEX=0, END_INDEX=10 uint256[] memory nftIds; LSSVMPair pair; uint256 numNFTsForQuote = END_INDEX + 1; //1. create an array of nft ids nftIds = _getArray(START_INDEX, END_INDEX); assertEq(nftIds.length, END_I...
solidity
// Code block 1 (solidity): function testSwapBinarySearch_audit() public{ //START_INDEX=0, END_INDEX=10 uint256[] memory nftIds; LSSVMPair pair; uint256 numNFTsForQuote = END_INDEX + 1; //1. create an array of nft ids nftIds = _getArray(START_INDEX, END_INDEX); a...
2
function testSwapBinarySearch_audit() public{ //START_INDEX=0, END_INDEX=10 uint256[] memory nftIds; LSSVMPair pair; uint256 numNFTsForQuote = END_INDEX + 1; //1. create an array of nft ids nftIds = _getArray(START_INDEX, END_INDEX); assertEq(nftIds.length, END_I...
true
true
8
high
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-01
low
Owner calling `LSSVMPair::changeSpotPrice` can cause arithmetic over/underflows on later swaps
Owner calling `LSSVMPair::changeSpotPrice` can cause arithmetic over/underflows on later swaps **Description:** Changing the spot price to a value higher than the current ERC20 (or ETH) balance of the pair can cause unintended reverts in valid swap calls later on. **Proof of Concept:** Full proof of concept [here](ht...
Changing the spot price to a value higher than the current ERC20 (or ETH) balance of the pair can cause unintended reverts in valid swap calls later on.
Full proof of concept [here](https://github.com/sudoswap/lssvm2/pull/1/files#diff-ccfdcc468a169eaf116e657d2cd2406530c2a693627167e375d78dcf8a73d87d). Snippet: ```solidity ‌// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {InvariantERC721LinearERC20} from "./InvariantERC721Lin...
`ILSSVMPair::swapNFTsForToken` reverts with a `TRANSFER_FAILED` error message despite the user obtaining a quote using `ILSSVMPair::getSellNFTQuote` in a prior call.
`ILSSVMPair::getSellNFTQuote` should return a legitimate error code if the expected output exceeds the pair's balance. This mitigates the impact on the end user trying to perform the swap. It will return a helpful error in the view function prior to the swap attempt rather than passing there, then failing on the actual...
1
true
true
2,422
low
low
integer-overflow
‌// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {InvariantERC721LinearERC20} from "./InvariantERC721LinearERC20.t.sol"; import {IERC721Mintable} from "../interfaces/IERC721Mintable.sol"; contract SwapArithmeticOverflow is InvariantERC721LinearERC20 { function setUp() p...
solidity
// Code block 1 (solidity): ‌// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {InvariantERC721LinearERC20} from "./InvariantERC721LinearERC20.t.sol"; import {IERC721Mintable} from "../interfaces/IERC721Mintable.sol"; contract SwapArithmeticOverflow is InvariantERC721LinearER...
1
‌// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "forge-std/Test.sol"; import {InvariantERC721LinearERC20} from "./InvariantERC721LinearERC20.t.sol"; import {IERC721Mintable} from "../interfaces/IERC721Mintable.sol"; contract SwapArithmeticOverflow is InvariantERC721LinearERC20 { function setUp() p...
true
true
5.8
medium
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-02
low
Partially fillable order could revert
Partially fillable order could revert **Description:** In the sell logic of `VeryFastRouter::swap`, the protocol does not check the fillable amount and executes the swap if [`pairSpotPrice == order.expectedSpotPrice`](https://github.com/sudoswap/lssvm2/blob/0967f16fb0f32b0b76f37c09e6acf35ac007225f/src/VeryFastRouter.so...
In the sell logic of `VeryFastRouter::swap`, the protocol does not check the fillable amount and executes the swap if [`pairSpotPrice == order.expectedSpotPrice`](https://github.com/sudoswap/lssvm2/blob/0967f16fb0f32b0b76f37c09e6acf35ac007225f/src/VeryFastRouter.sol#L281). But this will revert if the pair has insuffici...
null
Partially fillable orders would revert unnecessarily. While this does not affect funds, users would experience a revert for valid transactions.
Consider handling cases where the pair has insufficient balance to prevent reverting for partially fillable orders.
0
false
true
1,105
low
low
dos
0
true
false
3.46
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-03
low
Make `LSSVMPair::call` payable to allow value to be sent with external calls
Make `LSSVMPair::call` payable to allow value to be sent with external calls **Description:** Currently, [`LSSVMPair::call`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/LSSVMPair.sol#L640) simply passes a [value of zero](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813...
Currently, [`LSSVMPair::call`](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/LSSVMPair.sol#L640) simply passes a [value of zero](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/LSSVMPair.sol#L661); however, there may be instances in which non-z...
null
If the owner wishes to send ETH with the external call, they cannot do so, which may impact the external call's functionality.
Consider allowing value to be passed to external calls by making `LSSVMPair::call` payable.
0
false
true
870
low
low
dos
0
true
false
3.42
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-04
low
Incorrect/incomplete NatSpec & comments
Incorrect/incomplete NatSpec & comments The NatSpec for `LSSVMPair::getAssetRecipient` currently [reads](https://github.com/sudoswap/lssvm2/blob/0967f16fb0f32b0b76f37c09e6acf35ac007225f/src/LSSVMPair.sol#L319) "Returns the address that assets that receives assets when a swap is done with this pair" but it should be "Re...
null
null
null
null
0
false
false
2,243
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-05
low
Unreachable code path in `RoyaltyEngine::_getRoyaltyAndSpec`
Unreachable code path in `RoyaltyEngine::_getRoyaltyAndSpec` Within `RoyaltyEngine`, `int16` values have been copied over from the manifold contract for use as enum values relating to different royalty specifications with `int16 private constant NONE = -1;` and `int16 private constant NOT_CONFIGURED = 0;`. The [if case...
null
null
null
null
1
false
false
953
low
low
other
if (spec == NONE) { return (recipients, amounts, spec, royaltyAddress, addToCache); }
solidity
// Code block 1 (solidity): if (spec == NONE) { return (recipients, amounts, spec, royaltyAddress, addToCache); }
1
if (spec == NONE) { return (recipients, amounts, spec, royaltyAddress, addToCache); }
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-06
low
`vm.prank()` before nested function call in tests does not work as intended
`vm.prank()` before nested function call in tests does not work as intended Foundry's prank cheat code applies to the next external call only. [Nested](https://github.com/sudoswap/lssvm2/blob/78d38753b2042d7813132f26e5573c6699b605ef/src/test/base/VeryFastRouterAllSwapTypes.sol#L1090-L1092) [calls](https://github.com/su...
null
null
null
null
0
false
false
788
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-07
low
Event parameter names are incorrect
Event parameter names are incorrect The first parameter in each of these `LSSVMPair` events is named incorrectly: ```solidity event SwapNFTInPair(uint256 amountIn, uint256[] ids); event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); event SwapNFTOutPair(uint256 amountOut, uint256[] ids); event SwapNFTOutPair(uint25...
null
null
null
null
2
false
false
780
low
low
other
event SwapNFTInPair(uint256 amountIn, uint256[] ids); event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); event SwapNFTOutPair(uint256 amountOut, uint256[] ids); event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs);
solidity
// Code block 1 (solidity): event SwapNFTInPair(uint256 amountIn, uint256[] ids); event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); event SwapNFTOutPair(uint256 amountOut, uint256[] ids); event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs); // Code block 2 (solidity): event SwapNFTInPair(uint256 amountOut, ...
2
event SwapNFTInPair(uint256 amountIn, uint256[] ids); event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); event SwapNFTOutPair(uint256 amountOut, uint256[] ids); event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs); event SwapNFTInPair(uint256 amountOut, uint256[] ids); event SwapNFTInPair(uint256 amountOut, u...
false
true
2
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-08
low
`LSSVMPair` does not inherit `ILSSVMPair`
`LSSVMPair` does not inherit `ILSSVMPair` The interface `ILSSVMPair` is defined and used in several places, but the abstract `LSSVMPair` does not inherit from it. Consider adding `is ILSSVMPair` to the `LSSVMPair` contract declaration. **Sudoswap:** Acknowledged. **Cyfrin:** Acknowledged.
null
null
null
null
0
false
false
291
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-09
low
`MerklePropertyChecker::hasProperties` does not validate `ids.length` equals `proofList.length`
`MerklePropertyChecker::hasProperties` does not validate `ids.length` equals `proofList.length` This function loops over supplied ids and performs proof verification to ensure each id is valid. If additional proofs are supplied, the loop will terminate before these are reached and so they are never used in verification...
null
null
null
null
0
false
false
550
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-10
low
Redundant zero address check in `LSSVMPair::initialize`
Redundant zero address check in `LSSVMPair::initialize` The initializer argument `_assetRecipient` is assigned to the state variable only if it is not the zero address; however, in `LSSVMPair::getAssetRecipient`, the owner address is returned if `assetRecipient` is the zero address, and so this check is redundant. The ...
null
null
null
null
0
false
false
549
low
low
initialization
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-11
low
Redundant zero value check in `LSSVMPair::getBuyNFTQuote` and `LSSVMPair::getSellNFTQuote`
Redundant zero value check in `LSSVMPair::getBuyNFTQuote` and `LSSVMPair::getSellNFTQuote` The `numNFTs` argument to `LSSVMPair::getBuyNFTQuote` is validated to be a non-zero value; however, in `ICurve::getBuyNFTQuote`, all current implementations revert if the `numItems` parameter is zero, and so this check on the pai...
null
null
null
null
0
false
false
395
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-12
low
Simplify `LSSVMPair::_calculateBuyInfoAndUpdatePoolParams` and `LSSVMPair::_calculateSellInfoAndUpdatePoolParams` conditionals
Simplify `LSSVMPair::_calculateBuyInfoAndUpdatePoolParams` and `LSSVMPair::_calculateSellInfoAndUpdatePoolParams` conditionals Per the comment "Consolidate writes to save gas" in `LSSVMPair::_calculateBuyInfoAndUpdatePoolParams`, further optimizations can be made by reducing the logic to two if statements and storing v...
null
null
null
null
1
false
false
793
low
low
other
// Consolidate writes to save gas // Emit spot price update if it has been updated if (currentSpotPrice != newSpotPrice) { spotPrice = newSpotPrice; emit SpotPriceUpdate(newSpotPrice); } // Emit delta update if it has been updated if (currentDelta != newDelta) { delta = newDelta; emit DeltaUpdate(newDe...
solidity
// Code block 1 (solidity): // Consolidate writes to save gas // Emit spot price update if it has been updated if (currentSpotPrice != newSpotPrice) { spotPrice = newSpotPrice; emit SpotPriceUpdate(newSpotPrice); } // Emit delta update if it has been updated if (currentDelta != newDelta) { delta = newDelta...
1
// Consolidate writes to save gas // Emit spot price update if it has been updated if (currentSpotPrice != newSpotPrice) { spotPrice = newSpotPrice; emit SpotPriceUpdate(newSpotPrice); } // Emit delta update if it has been updated if (currentDelta != newDelta) { delta = newDelta; emit DeltaUpdate(newDe...
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-13
low
Cache local variable earlier in `LSSVMPairERC20::_pullTokenInputs`
Cache local variable earlier in `LSSVMPairERC20::_pullTokenInputs` Given that there are multiple instances where `token()` is called directly, the local variable `ERC20 token_ = token()` should be cached in the same manner as `_assetRecipient` at the start of the function to reduce the number of storage reads. It is a...
null
null
null
null
0
false
false
1,296
low
low
token
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-14
low
Gas Optimizations
Gas Optimizations | |Issue|Instances| |-|:-|:-:| | [GAS-1](#GAS-1) | Use `selfbalance()` instead of `address(this).balance` | 4 | | [GAS-2](#GAS-2) | Use assembly to check for `address(0)` | 10 | | [GAS-3](#GAS-3) | `array[index] += amount` is cheaper than `array[index] = array[index] + amount` (or related variants) ...
null
null
null
null
0
false
false
1,120
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-15
low
<a name="GAS-1"></a>[GAS-1] Use `selfbalance()` instead of `address(this).balance`
<a name="GAS-1"></a>[GAS-1] Use `selfbalance()` instead of `address(this).balance` Use assembly when getting a contract's balance of ETH. You can use `selfbalance()` instead of `address(this).balance` when getting your contract's balance of ETH to save gas. Additionally, you can use `balance(address)` instead of `addr...
null
null
null
null
4
false
false
873
low
low
other
File: LSSVMPairETH.sol 91: withdrawETH(address(this).balance);
solidity
// Code block 1 (solidity): File: LSSVMPairETH.sol 91: withdrawETH(address(this).balance); // Code block 2 (solidity): File: LSSVMPairFactory.sol 421: protocolFeeRecipient.safeTransferETH(address(this).balance); // Code block 3 (solidity): File: VeryFastRouter.sol 172: balance = address...
4
File: LSSVMPairETH.sol 91: withdrawETH(address(this).balance); File: LSSVMPairFactory.sol 421: protocolFeeRecipient.safeTransferETH(address(this).balance); File: VeryFastRouter.sol 172: balance = address(pair).balance; File: settings/Splitter.sol 27: uint256 ethBalance = addre...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-16
low
<a name="GAS-2"></a>[GAS-2] Use assembly to check for `address(0)`
<a name="GAS-2"></a>[GAS-2] Use assembly to check for `address(0)` *Saves 6 gas per instance* *Instances (10)*: ```solidity File: LSSVMPair.sol 139: if (owner() != address(0)) revert LSSVMPair__AlreadyInitialized(); 152: if (_assetRecipient != address(0)) { 333: if (_assetRecipient == addres...
null
null
null
null
5
false
false
1,058
low
low
other
File: LSSVMPair.sol 139: if (owner() != address(0)) revert LSSVMPair__AlreadyInitialized(); 152: if (_assetRecipient != address(0)) { 333: if (_assetRecipient == address(0)) { 346: if (_feeRecipient == address(0)) {
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 139: if (owner() != address(0)) revert LSSVMPair__AlreadyInitialized(); 152: if (_assetRecipient != address(0)) { 333: if (_assetRecipient == address(0)) { 346: if (_feeRecipient == address(0)) { // Code block 2 (solidity): File: LSSVM...
5
File: LSSVMPair.sol 139: if (owner() != address(0)) revert LSSVMPair__AlreadyInitialized(); 152: if (_assetRecipient != address(0)) { 333: if (_assetRecipient == address(0)) { 346: if (_feeRecipient == address(0)) { File: LSSVMPairFactory.sol 438: if (_protocolFeeRecipient ...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-17
low
<a name="GAS-3"></a>[GAS-3] `array[index] += amount` is cheaper than `array[index] = array[index] + amount` (or related variants)
<a name="GAS-3"></a>[GAS-3] `array[index] += amount` is cheaper than `array[index] = array[index] + amount` (or related variants) When updating a value in an array with arithmetic, using `array[index] += amount` is cheaper than `array[index] = array[index] + amount`. This is because you avoid an additonal `mload` when ...
null
null
null
null
1
false
false
919
low
low
other
File: VeryFastRouter.sol 126: prices[i] = prices[i] + (prices[i] * slippageScaling / 1e18); 218: outputAmounts[i] = outputAmounts[i] - (outputAmounts[i] * slippageScaling / 1e18);
solidity
// Code block 1 (solidity): File: VeryFastRouter.sol 126: prices[i] = prices[i] + (prices[i] * slippageScaling / 1e18); 218: outputAmounts[i] = outputAmounts[i] - (outputAmounts[i] * slippageScaling / 1e18);
1
File: VeryFastRouter.sol 126: prices[i] = prices[i] + (prices[i] * slippageScaling / 1e18); 218: outputAmounts[i] = outputAmounts[i] - (outputAmounts[i] * slippageScaling / 1e18);
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-18
low
<a name="GAS-4"></a>[GAS-4] Using bools for storage incurs overhead
<a name="GAS-4"></a>[GAS-4] Using bools for storage incurs overhead Use uint256(1) and uint256(2) for true/false to avoid a Gwarmaccess (100 gas), and to avoid Gsset (20000 gas) when changing from ‘false’ to ‘true’, after having been ‘true’ in the past. See [source](https://github.com/OpenZeppelin/openzeppelin-contract...
null
null
null
null
1
false
false
686
low
low
other
File: LSSVMPairFactory.sol 56: mapping(ICurve => bool) public bondingCurveAllowed; 57: mapping(address => bool) public override callAllowed; 60: mapping(address => mapping(address => bool)) public settingsForCollection;
solidity
// Code block 1 (solidity): File: LSSVMPairFactory.sol 56: mapping(ICurve => bool) public bondingCurveAllowed; 57: mapping(address => bool) public override callAllowed; 60: mapping(address => mapping(address => bool)) public settingsForCollection;
1
File: LSSVMPairFactory.sol 56: mapping(ICurve => bool) public bondingCurveAllowed; 57: mapping(address => bool) public override callAllowed; 60: mapping(address => mapping(address => bool)) public settingsForCollection;
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-19
low
<a name="GAS-5"></a>[GAS-5] Cache array length outside of loop
<a name="GAS-5"></a>[GAS-5] Cache array length outside of loop If not cached, the solidity compiler will always read the length of the array during each iteration. That is, if it is a storage array, this is an extra sload operation (100 additional extra gas for each iteration except for the first) and if it is a memory...
null
null
null
null
9
false
false
2,609
low
low
other
File: LSSVMPair.sol 673: for (uint256 i; i < calls.length;) {
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 673: for (uint256 i; i < calls.length;) { // Code block 2 (solidity): File: LSSVMPairERC20.sol 68: for (uint256 i; i < royaltyRecipients.length;) { 93: for (uint256 i; i < royaltyRecipients.length;) { // Code block 3 (solidity): File: ...
9
File: LSSVMPair.sol 673: for (uint256 i; i < calls.length;) { File: LSSVMPairERC20.sol 68: for (uint256 i; i < royaltyRecipients.length;) { 93: for (uint256 i; i < royaltyRecipients.length;) { File: LSSVMPairETH.sol 57: for (uint256 i; i < royaltyRecipients.length;) { File...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-20
low
<a name="GAS-6"></a>[GAS-6] Use calldata instead of memory for function arguments that do not get mutated
<a name="GAS-6"></a>[GAS-6] Use calldata instead of memory for function arguments that do not get mutated Mark data types as `calldata` instead of `memory` where possible. This makes it so that the data is not automatically loaded into memory. If the data passed into the function does not need to be changed (like updat...
null
null
null
null
3
false
false
1,008
low
low
other
File: lib/IOwnershipTransferReceiver.sol 6: function onOwnershipTransferred(address oldOwner, bytes memory data) external payable;
solidity
// Code block 1 (solidity): File: lib/IOwnershipTransferReceiver.sol 6: function onOwnershipTransferred(address oldOwner, bytes memory data) external payable; // Code block 2 (solidity): File: lib/OwnableWithTransferCallback.sol 45: function transferOwnership(address newOwner, bytes memory data) public payab...
3
File: lib/IOwnershipTransferReceiver.sol 6: function onOwnershipTransferred(address oldOwner, bytes memory data) external payable; File: lib/OwnableWithTransferCallback.sol 45: function transferOwnership(address newOwner, bytes memory data) public payable virtual onlyOwner { File: settings/StandardSettings....
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-21
low
<a name="GAS-7"></a>[GAS-7] Use Custom Errors
<a name="GAS-7"></a>[GAS-7] Use Custom Errors [Source](https://blog.soliditylang.org/2021/04/21/custom-errors/) Instead of using error strings, to reduce deployment and runtime cost, you should use Custom Errors. This would save both deployment and runtime cost. *Instances (21)*: ```solidity File: LSSVMRouter.sol 504...
null
null
null
null
3
false
false
2,002
low
low
other
File: LSSVMRouter.sol 504: require(factory.isValidPair(msg.sender), "Not pair"); 506: require(factory.getPairTokenType(msg.sender) == ILSSVMPairFactoryLike.PairTokenType.ERC20, "Not ERC20 pair"); 522: require(factory.isValidPair(msg.sender), "Not pair"); 536: require(factory.isValidP...
solidity
// Code block 1 (solidity): File: LSSVMRouter.sol 504: require(factory.isValidPair(msg.sender), "Not pair"); 506: require(factory.getPairTokenType(msg.sender) == ILSSVMPairFactoryLike.PairTokenType.ERC20, "Not ERC20 pair"); 522: require(factory.isValidPair(msg.sender), "Not pair"); 536: ...
3
File: LSSVMRouter.sol 504: require(factory.isValidPair(msg.sender), "Not pair"); 506: require(factory.getPairTokenType(msg.sender) == ILSSVMPairFactoryLike.PairTokenType.ERC20, "Not ERC20 pair"); 522: require(factory.isValidPair(msg.sender), "Not pair"); 536: require(factory.isValidP...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-22
low
<a name="GAS-8"></a>[GAS-8] Don't initialize variables with default value
<a name="GAS-8"></a>[GAS-8] Don't initialize variables with default value *Instances (10)*: ```solidity File: RoyaltyEngine.sol 35: int16 private constant NOT_CONFIGURED = 0; 81: for (uint256 i = 0; i < numTokens;) { 182: for (uint256 i = 0; i < royalties.length;) { 264: ...
null
null
null
null
3
false
false
796
low
low
initialization
File: RoyaltyEngine.sol 35: int16 private constant NOT_CONFIGURED = 0; 81: for (uint256 i = 0; i < numTokens;) { 182: for (uint256 i = 0; i < royalties.length;) { 264: for (uint256 i = 0; i < royalties.length;) { 336: for (uint256 i = 0; i < numBps;) { 349: ...
solidity
// Code block 1 (solidity): File: RoyaltyEngine.sol 35: int16 private constant NOT_CONFIGURED = 0; 81: for (uint256 i = 0; i < numTokens;) { 182: for (uint256 i = 0; i < royalties.length;) { 264: for (uint256 i = 0; i < royalties.length;) { 336: for (uint256 i = ...
3
File: RoyaltyEngine.sol 35: int16 private constant NOT_CONFIGURED = 0; 81: for (uint256 i = 0; i < numTokens;) { 182: for (uint256 i = 0; i < royalties.length;) { 264: for (uint256 i = 0; i < royalties.length;) { 336: for (uint256 i = 0; i < numBps;) { 349: ...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-23
low
<a name="GAS-9"></a>[GAS-9] Using `private` rather than `public` for constants, saves gas
<a name="GAS-9"></a>[GAS-9] Using `private` rather than `public` for constants, saves gas If needed, the values can be read from the verified contract source code, or if there are multiple values there can be a single getter function that [returns a tuple](https://github.com/code-423n4/2022-08-frax/blob/90f55a9ce4e25bc...
null
null
null
null
2
false
false
936
low
low
other
File: bonding-curves/ExponentialCurve.sol 15: uint256 public constant MIN_PRICE = 1000000 wei;
solidity
// Code block 1 (solidity): File: bonding-curves/ExponentialCurve.sol 15: uint256 public constant MIN_PRICE = 1000000 wei; // Code block 2 (solidity): File: bonding-curves/GDACurve.sol 21: uint256 public constant MIN_PRICE = 1 gwei;
2
File: bonding-curves/ExponentialCurve.sol 15: uint256 public constant MIN_PRICE = 1000000 wei; File: bonding-curves/GDACurve.sol 21: uint256 public constant MIN_PRICE = 1 gwei;
false
true
2
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-24
low
<a name="GAS-10"></a>[GAS-10] Use shift Right/Left instead of division/multiplication if possible
<a name="GAS-10"></a>[GAS-10] Use shift Right/Left instead of division/multiplication if possible Shifting left by N is like multiplying by 2^N and shifting right by N is like dividing by 2^N *Instances (13)*: ```solidity File: LSSVMPairFactory.sol 335: } ``` ```solidity File: VeryFastRouter.sol 535: ...
null
null
null
null
3
false
false
800
low
low
other
File: LSSVMPairFactory.sol 335: }
solidity
// Code block 1 (solidity): File: LSSVMPairFactory.sol 335: } // Code block 2 (solidity): File: VeryFastRouter.sol 535: ); 544: ) { 546: } 550: start = (start + end) / 2 + 1; 551: priceToFillAt = currentCost; 594: // get fee...
3
File: LSSVMPairFactory.sol 335: } File: VeryFastRouter.sol 535: ); 544: ) { 546: } 550: start = (start + end) / 2 + 1; 551: priceToFillAt = currentCost; 594: // get feeMultiplier from deltaAndFeeMultiplier 605: ...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-25
low
<a name="GAS-11"></a>[GAS-11] Use `storage` instead of `memory` for structs/arrays
<a name="GAS-11"></a>[GAS-11] Use `storage` instead of `memory` for structs/arrays Using `memory` copies the struct or array in memory. Use `storage` to save the location in storage and have cheaper reads: *Instances (29)*: ```solidity File: LSSVMPair.sol 492: ROYALTY_ENGINE.getRoyalty(nft(), assetId, sal...
null
null
null
null
10
false
false
2,482
low
low
other
File: LSSVMPair.sol 492: ROYALTY_ENGINE.getRoyalty(nft(), assetId, saleAmount); 505: ROYALTY_ENGINE.getRoyaltyView(nft(), assetId, saleAmount); 679: if (!success && revertOnFail) {
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 492: ROYALTY_ENGINE.getRoyalty(nft(), assetId, saleAmount); 505: ROYALTY_ENGINE.getRoyaltyView(nft(), assetId, saleAmount); 679: if (!success && revertOnFail) { // Code block 2 (solidity): File: LSSVMRouter.sol 299: ...
10
File: LSSVMPair.sol 492: ROYALTY_ENGINE.getRoyalty(nft(), assetId, saleAmount); 505: ROYALTY_ENGINE.getRoyaltyView(nft(), assetId, saleAmount); 679: if (!success && revertOnFail) { File: LSSVMRouter.sol 299: if (nftIds.length == 0) { File: RoyaltyEngine.sol 87:...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-26
low
<a name="GAS-12"></a>[GAS-12] Use != 0 instead of > 0 for unsigned integer comparison
<a name="GAS-12"></a>[GAS-12] Use != 0 instead of > 0 for unsigned integer comparison *Instances (3)*: ```solidity File: LSSVMRouter.sol 233: if (remainingValue > 0) { 372: if (remainingValue > 0) { 592: if (remainingValue > 0) { ```
null
null
null
null
1
false
false
266
low
low
integer-overflow
File: LSSVMRouter.sol 233: if (remainingValue > 0) { 372: if (remainingValue > 0) { 592: if (remainingValue > 0) {
solidity
// Code block 1 (solidity): File: LSSVMRouter.sol 233: if (remainingValue > 0) { 372: if (remainingValue > 0) { 592: if (remainingValue > 0) {
1
File: LSSVMRouter.sol 233: if (remainingValue > 0) { 372: if (remainingValue > 0) { 592: if (remainingValue > 0) {
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-27
low
<a name="GAS-13"></a>[GAS-13] `internal` functions not called by the contract should be removed
<a name="GAS-13"></a>[GAS-13] `internal` functions not called by the contract should be removed If the functions are required by an interface, the contract should inherit from that interface and use the `override` keyword *Instances (8)*: ```solidity File: lib/LSSVMPairCloner.sol 22: function cloneERC721ETHPair( ...
null
null
null
null
1
false
false
714
low
low
other
File: lib/LSSVMPairCloner.sol 22: function cloneERC721ETHPair( 112: function cloneERC721ERC20Pair( 204: function isERC721ETHPairClone(address factory, address implementation, address query) 238: function isERC721ERC20PairClone(address factory, address implementation, address query) 274: add...
solidity
// Code block 1 (solidity): File: lib/LSSVMPairCloner.sol 22: function cloneERC721ETHPair( 112: function cloneERC721ERC20Pair( 204: function isERC721ETHPairClone(address factory, address implementation, address query) 238: function isERC721ERC20PairClone(address factory, address implementation, addr...
1
File: lib/LSSVMPairCloner.sol 22: function cloneERC721ETHPair( 112: function cloneERC721ERC20Pair( 204: function isERC721ETHPairClone(address factory, address implementation, address query) 238: function isERC721ERC20PairClone(address factory, address implementation, address query) 274: add...
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-28
low
Non Critical Issues
Non Critical Issues | |Issue|Instances| |-|:-|:-:| | [NC-1](#NC-1) | Missing checks for `address(0)` when assigning values to address state variables | 4 | | [NC-2](#NC-2) | `require()` / `revert()` statements should have descriptive reason strings | 1 | | [NC-3](#NC-3) | Event is missing `indexed` fields | 18 | | [...
null
null
null
null
0
false
false
511
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-29
low
<a name="NC-1"></a>[NC-1] Missing checks for `address(0)` when assigning values to address state variables
<a name="NC-1"></a>[NC-1] Missing checks for `address(0)` when assigning values to address state variables *Instances (4)*: ```solidity File: LSSVMPairFactory.sol 110: _caller = _NOT_ENTERED; 349: _caller = _NOT_ENTERED; ``` ```solidity File: lib/OwnableWithTransferCallback.sol 25: _owner ...
null
null
null
null
2
false
false
372
low
low
other
File: LSSVMPairFactory.sol 110: _caller = _NOT_ENTERED; 349: _caller = _NOT_ENTERED;
solidity
// Code block 1 (solidity): File: LSSVMPairFactory.sol 110: _caller = _NOT_ENTERED; 349: _caller = _NOT_ENTERED; // Code block 2 (solidity): File: lib/OwnableWithTransferCallback.sol 25: _owner = initialOwner; 71: _owner = newOwner;
2
File: LSSVMPairFactory.sol 110: _caller = _NOT_ENTERED; 349: _caller = _NOT_ENTERED; File: lib/OwnableWithTransferCallback.sol 25: _owner = initialOwner; 71: _owner = newOwner;
false
true
2
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-30
low
<a name="NC-2"></a>[NC-2] `require()` / `revert()` statements should have descriptive reason strings
<a name="NC-2"></a>[NC-2] `require()` / `revert()` statements should have descriptive reason strings *Instances (1)*: ```solidity File: LSSVMPairETH.sol 126: require(msg.data.length == _immutableParamsLength()); ```
null
null
null
null
1
false
false
227
low
low
other
File: LSSVMPairETH.sol 126: require(msg.data.length == _immutableParamsLength());
solidity
// Code block 1 (solidity): File: LSSVMPairETH.sol 126: require(msg.data.length == _immutableParamsLength());
1
File: LSSVMPairETH.sol 126: require(msg.data.length == _immutableParamsLength());
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-31
low
<a name="NC-3"></a>[NC-3] Event is missing `indexed` fields
<a name="NC-3"></a>[NC-3] Event is missing `indexed` fields Index event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (three fields). Each event ...
null
null
null
null
2
false
false
1,773
low
low
other
File: LSSVMPair.sol 82: event SwapNFTInPair(uint256 amountIn, uint256[] ids); 83: event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); 84: event SwapNFTOutPair(uint256 amountOut, uint256[] ids); 85: event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs); 86: event SpotPriceUpdate(uint128 n...
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 82: event SwapNFTInPair(uint256 amountIn, uint256[] ids); 83: event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); 84: event SwapNFTOutPair(uint256 amountOut, uint256[] ids); 85: event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs); 86: eve...
2
File: LSSVMPair.sol 82: event SwapNFTInPair(uint256 amountIn, uint256[] ids); 83: event SwapNFTInPair(uint256 amountIn, uint256 numNFTs); 84: event SwapNFTOutPair(uint256 amountOut, uint256[] ids); 85: event SwapNFTOutPair(uint256 amountOut, uint256 numNFTs); 86: event SpotPriceUpdate(uint128 n...
false
true
2
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-32
low
<a name="NC-4"></a>[NC-4] Constants should be defined rather than using magic numbers
<a name="NC-4"></a>[NC-4] Constants should be defined rather than using magic numbers *Instances (3)*: ```solidity File: settings/Splitter.sol 23: return _getArgAddress(20); ``` ```solidity File: settings/StandardSettings.sol 70: return _getArgUint64(40); 77: return _getArgUint64(48); ```
null
null
null
null
2
false
false
320
low
low
other
File: settings/Splitter.sol 23: return _getArgAddress(20);
solidity
// Code block 1 (solidity): File: settings/Splitter.sol 23: return _getArgAddress(20); // Code block 2 (solidity): File: settings/StandardSettings.sol 70: return _getArgUint64(40); 77: return _getArgUint64(48);
2
File: settings/Splitter.sol 23: return _getArgAddress(20); File: settings/StandardSettings.sol 70: return _getArgUint64(40); 77: return _getArgUint64(48);
false
true
2
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-33
low
<a name="NC-5"></a>[NC-5] Functions not used internally could be marked external
<a name="NC-5"></a>[NC-5] Functions not used internally could be marked external *Instances (28)*: ```solidity File: LSSVMPair.sol 323: function getAssetRecipient() public view returns (address payable) { 344: function getFeeRecipient() public view returns (address payable _feeRecipient) { ``` ```solidity ...
null
null
null
null
9
false
false
2,899
low
low
other
File: LSSVMPair.sol 323: function getAssetRecipient() public view returns (address payable) { 344: function getFeeRecipient() public view returns (address payable _feeRecipient) {
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 323: function getAssetRecipient() public view returns (address payable) { 344: function getFeeRecipient() public view returns (address payable _feeRecipient) { // Code block 2 (solidity): File: LSSVMPairFactory.sol 342: function openLock() public { 347: ...
9
File: LSSVMPair.sol 323: function getAssetRecipient() public view returns (address payable) { 344: function getFeeRecipient() public view returns (address payable _feeRecipient) { File: LSSVMPairFactory.sol 342: function openLock() public { 347: function closeLock() public { 499: function getS...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-34
low
<a name="NC-6"></a>[NC-6] Typos
<a name="NC-6"></a>[NC-6] Typos *Instances (84)*: ```diff File: LSSVMPair.sol - 52: // Sudoswap Royalty Engine + 52: // @notice Sudoswap Royalty Engine - 60: // However, this should NOT be assumed, as bonding curves may use spotPrice in different ways. + 60: // @notice However, this should NOT be ass...
null
null
null
null
15
false
false
13,184
low
low
other
File: LSSVMPair.sol - 52: // Sudoswap Royalty Engine + 52: // @notice Sudoswap Royalty Engine - 60: // However, this should NOT be assumed, as bonding curves may use spotPrice in different ways. + 60: // @notice However, this should NOT be assumed, as bonding curves may use spotPrice in different ways...
diff
// Code block 1 (diff): File: LSSVMPair.sol - 52: // Sudoswap Royalty Engine + 52: // @notice Sudoswap Royalty Engine - 60: // However, this should NOT be assumed, as bonding curves may use spotPrice in different ways. + 60: // @notice However, this should NOT be assumed, as bonding curves may use spo...
15
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-35
low
Low Issues
Low Issues | |Issue|Instances| |-|:-|:-:| | [L-1](#L-1) | `abi.encodePacked()` should not be used with dynamic types when passing the result to a hash function such as `keccak256()` | 1 | | [L-2](#L-2) | Empty Function Body - Consider commenting why | 32 | | [L-3](#L-3) | Initializers could be front-run | 10 | | [L-...
null
null
null
null
0
false
false
362
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-36
low
<a name="L-1"></a>[L-1] `abi.encodePacked()` should not be used with dynamic types when passing the result to a hash function such as `keccak256()`
<a name="L-1"></a>[L-1] `abi.encodePacked()` should not be used with dynamic types when passing the result to a hash function such as `keccak256()` Use `abi.encode()` instead which will pad items to 32 bytes, which will [prevent hash collisions](https://docs.soliditylang.org/en/v0.8.13/abi-spec.html#non-standard-packe...
null
null
null
null
1
false
false
1,018
low
low
other
File: property-checking/MerklePropertyChecker.sol 25: if (!MerkleProof.verify(proof, root, keccak256(abi.encodePacked(ids[i])))) {
solidity
// Code block 1 (solidity): File: property-checking/MerklePropertyChecker.sol 25: if (!MerkleProof.verify(proof, root, keccak256(abi.encodePacked(ids[i])))) {
1
File: property-checking/MerklePropertyChecker.sol 25: if (!MerkleProof.verify(proof, root, keccak256(abi.encodePacked(ids[i])))) {
false
true
1
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-37
low
<a name="L-2"></a>[L-2] Empty Function Body - Consider commenting why
<a name="L-2"></a>[L-2] Empty Function Body - Consider commenting why *Instances (32)*: ```solidity File: LSSVMPairETH.sol 130: function _preCallCheck(address) internal pure override {} ``` ```solidity File: LSSVMPairFactory.sol 373: } catch {} 375: } catch {} 379: } catch {} ...
null
null
null
null
12
false
false
2,041
low
low
other
File: LSSVMPairETH.sol 130: function _preCallCheck(address) internal pure override {}
solidity
// Code block 1 (solidity): File: LSSVMPairETH.sol 130: function _preCallCheck(address) internal pure override {} // Code block 2 (solidity): File: LSSVMPairFactory.sol 373: } catch {} 375: } catch {} 379: } catch {} 384: } catch {} 385: } catch {} 390: ...
12
File: LSSVMPairETH.sol 130: function _preCallCheck(address) internal pure override {} File: LSSVMPairFactory.sol 373: } catch {} 375: } catch {} 379: } catch {} 384: } catch {} 385: } catch {} 390: } catch {} 391: } catch {} 398: ...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-38
low
<a name="L-3"></a>[L-3] Initializers could be front-run
<a name="L-3"></a>[L-3] Initializers could be front-run Initializers could be front-run, allowing an attacker to either set their own values, take ownership of the contract, and in the best case forcing a re-deployment *Instances (10)*: ```solidity File: LSSVMPair.sol 132: function initialize( 140: __Own...
null
null
null
null
5
false
false
1,175
low
low
front-running
File: LSSVMPair.sol 132: function initialize( 140: __Ownable_init(_owner);
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 132: function initialize( 140: __Ownable_init(_owner); // Code block 2 (solidity): File: LSSVMPairFactory.sol 568: _pair.initialize(msg.sender, _assetRecipient, _delta, _fee, _spotPrice); 596: _pair.initialize(msg.sender, _assetRecipient, ...
5
File: LSSVMPair.sol 132: function initialize( 140: __Ownable_init(_owner); File: LSSVMPairFactory.sol 568: _pair.initialize(msg.sender, _assetRecipient, _delta, _fee, _spotPrice); 596: _pair.initialize(msg.sender, _assetRecipient, _delta, _fee, _spotPrice); 625: _pair.initializ...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-39
low
<a name="L-4"></a>[L-4] Unsafe ERC20 operation(s)
<a name="L-4"></a>[L-4] Unsafe ERC20 operation(s) *Instances (7)*: ```solidity File: LSSVMPairFactory.sol 576: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 606: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 673: _nft.transferFrom(msg.sende...
null
null
null
null
4
false
false
735
low
low
token
File: LSSVMPairFactory.sol 576: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 606: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 673: _nft.transferFrom(msg.sender, recipient, ids[i]);
solidity
// Code block 1 (solidity): File: LSSVMPairFactory.sol 576: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 606: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 673: _nft.transferFrom(msg.sender, recipient, ids[i]); // Code block 2 (solidity): ...
4
File: LSSVMPairFactory.sol 576: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 606: _nft.transferFrom(msg.sender, address(_pair), _initialNFTIDs[i]); 673: _nft.transferFrom(msg.sender, recipient, ids[i]); File: LSSVMRouter.sol 525: nft.transferFrom(fro...
false
true
3
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-40
low
Medium Issues
Medium Issues | |Issue|Instances| |-|:-|:-:| | [M-1](#M-1) | Centralization Risk for trusted owners | 23 | | [M-2](#M-2) | Solmate's SafeTransferLib does not check for token contract's existence | 18 |
null
null
null
null
0
false
false
204
low
low
other
0
false
false
0
low
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-41
low
<a name="M-1"></a>[M-1] Centralization Risk for trusted owners
<a name="M-1"></a>[M-1] Centralization Risk for trusted owners **Impact:** Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds. *Instances (23)*: ```solidity File: LSSVMPair.sol 582: function changeSpotPrice(uint128 newSpotPri...
null
null
Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds. *Instances (23)*: ```solidity File: LSSVMPair.sol 582: function changeSpotPrice(uint128 newSpotPrice) external onlyOwner { 595: function changeDelta(uint128 newDelta) ex...
null
8
false
false
2,574
low
low
other
File: LSSVMPair.sol 582: function changeSpotPrice(uint128 newSpotPrice) external onlyOwner { 595: function changeDelta(uint128 newDelta) external onlyOwner { 610: function changeFee(uint96 newFee) external onlyOwner { 625: function changeAssetRecipient(address payable newRecipient) external onlyOwne...
solidity
// Code block 1 (solidity): File: LSSVMPair.sol 582: function changeSpotPrice(uint128 newSpotPrice) external onlyOwner { 595: function changeDelta(uint128 newDelta) external onlyOwner { 610: function changeFee(uint96 newFee) external onlyOwner { 625: function changeAssetRecipient(address payable new...
8
File: LSSVMPair.sol 582: function changeSpotPrice(uint128 newSpotPrice) external onlyOwner { 595: function changeDelta(uint128 newDelta) external onlyOwner { 610: function changeFee(uint96 newFee) external onlyOwner { 625: function changeAssetRecipient(address payable newRecipient) external onlyOwne...
true
true
4
medium
cyfrin
2023-06-01-sudoswap-report
2023-06-01-sudoswap-report
null
L-42
low
<a name="M-2"></a>[M-2] Solmate's SafeTransferLib does not check for token contract's existence
<a name="M-2"></a>[M-2] Solmate's SafeTransferLib does not check for token contract's existence There is a subtle difference between the implementation of solmate’s SafeTransferLib and OZ’s SafeERC20: OZ’s SafeERC20 checks if the token is a contract or not, solmate’s SafeTransferLib does not. https://github.com/transm...
null
null
null
null
6
false
false
2,212
low
low
token
File: LSSVMPairERC20.sol 90: token_.safeTransferFrom(msg.sender, _assetRecipient, inputAmountExcludingRoyalty - protocolFee); 94: token_.safeTransferFrom(msg.sender, royaltyRecipients[i], royaltyAmounts[i]); 102: token_.safeTransferFrom(msg.sender, address(factory()), prot...
solidity
// Code block 1 (solidity): File: LSSVMPairERC20.sol 90: token_.safeTransferFrom(msg.sender, _assetRecipient, inputAmountExcludingRoyalty - protocolFee); 94: token_.safeTransferFrom(msg.sender, royaltyRecipients[i], royaltyAmounts[i]); 102: token_.safeTransferFrom(msg.send...
6
File: LSSVMPairERC20.sol 90: token_.safeTransferFrom(msg.sender, _assetRecipient, inputAmountExcludingRoyalty - protocolFee); 94: token_.safeTransferFrom(msg.sender, royaltyRecipients[i], royaltyAmounts[i]); 102: token_.safeTransferFrom(msg.sender, address(factory()), prot...
false
true
3
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-01
low
Perform additional validation on Chainlink fast gas feed
Perform additional validation on Chainlink fast gas feed **Description:** When consuming data feeds provided by Chainlink, it is important to validate a number of thresholds and return values. Without this, it is possible for a consuming contract to use stale or otherwise incorrect/invalid data. `LimitOrderRegistry` c...
When consuming data feeds provided by Chainlink, it is important to validate a number of thresholds and return values. Without this, it is possible for a consuming contract to use stale or otherwise incorrect/invalid data. `LimitOrderRegistry` currently correctly validates the time since the last update against an owne...
null
`LimitOrderRegistry::performUpkeep` is reliant on this functionality within `LimitOrderRegistry::getGasPrice` which could result in DoS on fulfilling orders if not functioning correctly; however, the escape-hatch is simply having the owner set the feed address to `address(0)` which causes the owner-specified fallback v...
Consider calling `IChainlinkAggregator::latestRoundData` within a `try/catch` block and include the following additional validation: ```solidity require(signedGasPrice > 0, "Negative gas price"); require(signedGasPrice < maxGasPrice, "Upper gas price bound breached"); require(signedGasPrice > minGasPrice, "Lower gas p...
1
false
true
1,909
low
low
input-validation
require(signedGasPrice > 0, "Negative gas price"); require(signedGasPrice < maxGasPrice, "Upper gas price bound breached"); require(signedGasPrice > minGasPrice, "Lower gas price bound breached"); require(answeredInRound >= roundID, "Round incomplete");
solidity
// Code block 1 (solidity): require(signedGasPrice > 0, "Negative gas price"); require(signedGasPrice < maxGasPrice, "Upper gas price bound breached"); require(signedGasPrice > minGasPrice, "Lower gas price bound breached"); require(answeredInRound >= roundID, "Round incomplete");
1
require(signedGasPrice > 0, "Negative gas price"); require(signedGasPrice < maxGasPrice, "Upper gas price bound breached"); require(signedGasPrice > minGasPrice, "Lower gas price bound breached"); require(answeredInRound >= roundID, "Round incomplete");
true
true
4.59
medium
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-02
low
Withdrawing native assets may revert if wrapped native balance is zero
Withdrawing native assets may revert if wrapped native balance is zero **Description:** The function `LimitOrderRegistry::withdrawNative` allows the owner to withdraw native and wrapped native assets from the contract. If balances of both are zero, calls to this function revert as there is nothing to withdraw. ```sol...
The function `LimitOrderRegistry::withdrawNative` allows the owner to withdraw native and wrapped native assets from the contract. If balances of both are zero, calls to this function revert as there is nothing to withdraw. ```solidity /** * @notice Allows owner to withdraw wrapped native and native assets from this ...
null
This would temporarily prevent the withdrawal of any native token balance until the wrapped native token balance is also non-zero, although it seems none of the wrapped native tokens revert on zero transfers on current intended target chains.
Separately validate the wrapped native token balance prior to attempting the transfer.
2
false
true
2,193
low
low
access-control
/** * @notice Allows owner to withdraw wrapped native and native assets from this contract. */ function withdrawNative() external onlyOwner { uint256 wrappedNativeBalance = WRAPPED_NATIVE.balanceOf(address(this)); uint256 nativeBalance = address(this).balance; // Make sure there is something to withdraw. ...
solidity
// Code block 1 (solidity): /** * @notice Allows owner to withdraw wrapped native and native assets from this contract. */ function withdrawNative() external onlyOwner { uint256 wrappedNativeBalance = WRAPPED_NATIVE.balanceOf(address(this)); uint256 nativeBalance = address(this).balance; // Make sure ther...
2
/** * @notice Allows owner to withdraw wrapped native and native assets from this contract. */ function withdrawNative() external onlyOwner { uint256 wrappedNativeBalance = WRAPPED_NATIVE.balanceOf(address(this)); uint256 nativeBalance = address(this).balance; // Make sure there is something to withdraw. ...
true
true
6.86
medium
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-03
low
`call()` should be used instead of `transfer()` on address payable
`call()` should be used instead of `transfer()` on address payable **Description:** The `transfer()` and `send()` functions forward a fixed amount of 2300 gas. Historically, it has often been recommended to use these functions for value transfers to guard against reentrancy attacks. However, the gas cost of EVM instru...
The `transfer()` and `send()` functions forward a fixed amount of 2300 gas. Historically, it has often been recommended to use these functions for value transfers to guard against reentrancy attacks. However, the gas cost of EVM instructions may change significantly during hard forks which may break already deployed co...
null
The use of the deprecated `transfer()` function will cause transactions to fail: * If `owner` calling `LimitOrderRegistry::withdrawNative`/`sender` calling `LimitOrderRegistry::claimOrder` is a smart contract that does not implement a payable function. * If `owner` calling `LimitOrderRegistry::withdrawNative`/`sender`...
Use `call()` or solmate's `safeTransferETH` instead of `transfer()`, but be sure to respect the [Checks Effects Interactions (CEI) pattern](https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html).
0
false
true
2,452
low
low
reentrancy
0
true
false
4.74
medium
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-04
low
Fee-on-transfer/deflationary tokens will not be supported
Fee-on-transfer/deflationary tokens will not be supported **Description:** When creating a new order, `LimitOrderRegistry::newOrder` assumes that the amount of deposited tokens is equal to the function parameter plus the balance before the deposit. For tokens which take a fee on every transfer, this assumption does no...
When creating a new order, `LimitOrderRegistry::newOrder` assumes that the amount of deposited tokens is equal to the function parameter plus the balance before the deposit. For tokens which take a fee on every transfer, this assumption does not hold and so the true amount transferred is less than the specified amount....
null
It will not be possible to use fee-on-transfer/deflationary tokens within the protocol.
Avoid allowlisting such problematic tokens. If it is desired to support such tokens then it recommended to cache token balances before and after any transfers, using the difference between those two balances rather than the input amount as the amount received.
1
false
true
1,318
low
low
token
uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e18;
solidity
// Code block 1 (solidity): uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e18;
1
uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e18;
true
true
4.96
medium
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-05
low
Fulfillable ITM orders may not always be fulfilled
Fulfillable ITM orders may not always be fulfilled **Description:** Currently, orders are only fulfillable via `LimitOrderRegistry::performUpkeep` which processes them via the doubly linked list, with a limit of `maxFillsPerUpkeep` orders per call. Considering extreme and/or adversarial market conditions, there is no ...
Currently, orders are only fulfillable via `LimitOrderRegistry::performUpkeep` which processes them via the doubly linked list, with a limit of `maxFillsPerUpkeep` orders per call. Considering extreme and/or adversarial market conditions, there is no guarantee that all legitimate orders will eventually be processed. If...
null
Valid and fulfillable ITM orders may not be fulfilled even though their liquidity within the position is technically being used for the duration the pool tick exceeds their target tick price.
To guarantee that any order can be fulfilled, consider adding a public `fulfillOrder` function that can be called by any user to fulfil a specific order independently from its position in the list. The order can be simply fulfilled and removed from the list, without affecting the upkeep procedure.
0
false
true
1,863
low
low
other
0
true
false
3.97
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-06
low
Spelling errors and incorrect NatSpec
Spelling errors and incorrect NatSpec The following spelling errors and incorrect NatSpec were identified: * `cancelOrder` is [documented](https://github.com/crispymangoes/uniswap-v3-limit-orders/blob/83f5db9cb90926c11ee6ce872dc165b7f600f3d8/src/LimitOrderRegistry.sol#L657) to send all swap fees from a position to the...
null
null
null
null
0
false
false
2,654
low
low
other
0
false
false
0
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-07
low
Avoid hardcoding addresses when contract is intended to be deployed to multiple chains
Avoid hardcoding addresses when contract is intended to be deployed to multiple chains While the [`LimitOrderRegistry::fastGasFeed`](https://github.com/crispymangoes/uniswap-v3-limit-orders/blob/83f5db9cb90926c11ee6ce872dc165b7f600f3d8/src/LimitOrderRegistry.sol#L190-L193) state variable is [overwritten](https://githu...
null
null
null
null
0
false
false
1,114
low
low
other
0
false
false
0
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-08
low
Validate inputs to `onlyOwner` functions
Validate inputs to `onlyOwner` functions Whilst there is a comment that states no input validation is performed on inputs to `LimitOrderRegistry::setRegistrar` and `LimitOrderRegistry::setFastGasFeed` because it is in the owner's best interest to choose valid addresses, it is recommended that some guardrails still be ...
null
null
null
null
0
false
false
1,303
low
low
access-control
0
false
false
0
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-09
low
Limit orders can be frozen for one side of a Uniswap v3 pool if `minimumAssets` has not been set for one of the tokens
Limit orders can be frozen for one side of a Uniswap v3 pool if `minimumAssets` has not been set for one of the tokens To prevent spamming low liquidity orders, `LimitOrderRegistry::minimumAssets` must be set for a given asset before limit orders are allowed to be placed. A Uniswap v3 pool contains two assets, but `Li...
null
null
null
null
0
false
false
815
low
low
token
0
false
false
0
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-10
low
Improvements to use of ternary operator
Improvements to use of ternary operator There is currently one [instance](https://github.com/crispymangoes/uniswap-v3-limit-orders/blob/83f5db9cb90926c11ee6ce872dc165b7f600f3d8/src/LimitOrderRegistry.sol#L903) of ternary operator usage that can be simplified, with the boolean expression being evaluated directly: ```so...
null
null
null
null
4
false
false
1,152
low
low
other
bool direction = targetTick > node.tickUpper ? true : false;
solidity
// Code block 1 (solidity): bool direction = targetTick > node.tickUpper ? true : false; // Code block 2 (solidity): bool direction = targetTick > node.tickUpper; // Code block 3 (solidity): if (direction) assetIn = poolToData[pool].token0; else assetIn = poolToData[pool].token1; // Code block 4 (solidity): asse...
4
bool direction = targetTick > node.tickUpper ? true : false; bool direction = targetTick > node.tickUpper; if (direction) assetIn = poolToData[pool].token0; else assetIn = poolToData[pool].token1; assetIn = direction ? poolToData[pool].token0 : poolToData[pool].token1;
false
true
3
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-11
low
Move shared logic to internal functions called within a modifier
Move shared logic to internal functions called within a modifier ```solidity ... if (direction) data.token0.safeApprove(address(POSITION_MANAGER), amount0); else data.token1.safeApprove(address(POSITION_MANAGER), amount1); // 0.9999e18 accounts for rounding errors in the Uniswap V3 protocol. uint128 amount0Mi...
null
null
null
null
2
false
false
1,574
low
low
logic-error
... if (direction) data.token0.safeApprove(address(POSITION_MANAGER), amount0); else data.token1.safeApprove(address(POSITION_MANAGER), amount1); // 0.9999e18 accounts for rounding errors in the Uniswap V3 protocol. uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e18; uint128 amount1Min = ...
solidity
// Code block 1 (solidity): ... if (direction) data.token0.safeApprove(address(POSITION_MANAGER), amount0); else data.token1.safeApprove(address(POSITION_MANAGER), amount1); // 0.9999e18 accounts for rounding errors in the Uniswap V3 protocol. uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e1...
2
... if (direction) data.token0.safeApprove(address(POSITION_MANAGER), amount0); else data.token1.safeApprove(address(POSITION_MANAGER), amount1); // 0.9999e18 accounts for rounding errors in the Uniswap V3 protocol. uint128 amount0Min = amount0 == 0 ? 0 : (amount0 * 0.9999e18) / 1e18; uint128 amount1Min = ...
false
true
2
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-12
low
Re-entrancy in `LimitOrderRegistry::newOrder` means tokens with transfer hooks could take over execution to manipulate price to be immediately ITM, bypassing validation
Re-entrancy in `LimitOrderRegistry::newOrder` means tokens with transfer hooks could take over execution to manipulate price to be immediately ITM, bypassing validation Whilst there does not appear to be any direct benefit to an attacker, it is possible for tokens with transfer hooks to take over execution from in-fli...
null
null
null
null
0
false
false
1,323
low
low
reentrancy
0
false
false
0
low
cyfrin
uniswap-v3-limit-orders
2023-06-07-cyfrin-uniswap-v3-limit-orders
null
L-13
low
Use stack variables rather than making repeated external calls
Use stack variables rather than making repeated external calls Within `LimitOrderRegistry::withdrawNative`, calls to determine the contract balance of native/wrapped native assets are cached in [stack variables](https://github.com/crispymangoes/uniswap-v3-limit-orders/blob/83f5db9cb90926c11ee6ce872dc165b7f600f3d8/src/...
null
null
null
null
0
false
false
897
low
low
other
0
false
false
0
low