-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from 0xDmtri/fix/div-zero
Fix/div zero
- Loading branch information
Showing
6 changed files
with
176 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[profile.default] | ||
optimizer = false | ||
evm_version = "cancun" | ||
|
||
remappings = [ | ||
"forge-std=lib/forge-std/src/", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
import "../src/GetWethValueInPoolBatchRequest.sol"; | ||
|
||
contract GetWethValueInPoolBatchRequestTest is Test { | ||
address constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; | ||
uint256 constant wethInPoolThreshold = 0.01 ether; | ||
|
||
function setUp() public {} | ||
|
||
function testUniV3GoodLiquidity() public { | ||
address[] memory pools = new address[](1); | ||
pools[0] = address(0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640); | ||
|
||
address[] memory dexes = new address[](1); | ||
dexes[0] = address(0x1F98431c8aD98523631AE4a59f267346ea31F984); | ||
|
||
bool[] memory dexIsUniV3 = new bool[](1); | ||
dexIsUniV3[0] = true; | ||
|
||
GetWethValueInPoolBatchRequest data = | ||
new GetWethValueInPoolBatchRequest(pools, dexes, dexIsUniV3, weth, wethInPoolThreshold); | ||
|
||
uint256[] memory weth_values = abi.decode(address(data).code, (uint256[])); | ||
|
||
// expecting weth value to be non 0 | ||
assert(weth_values[0] != 0); | ||
} | ||
|
||
function testUniV3VerySmallLiquidity() public { | ||
address[] memory pools = new address[](1); | ||
pools[0] = address(0x697C1CcA83174363e9B6758B8CD616474487C192); | ||
|
||
address[] memory dexes = new address[](1); | ||
dexes[0] = address(0x1F98431c8aD98523631AE4a59f267346ea31F984); | ||
|
||
bool[] memory dexIsUniV3 = new bool[](1); | ||
dexIsUniV3[0] = true; | ||
|
||
GetWethValueInPoolBatchRequest data = | ||
new GetWethValueInPoolBatchRequest(pools, dexes, dexIsUniV3, weth, wethInPoolThreshold); | ||
|
||
uint256[] memory weth_values = abi.decode(address(data).code, (uint256[])); | ||
|
||
// expecting weth value to be 0 | ||
assert(weth_values[0] == 0); | ||
} | ||
|
||
function testUniV3ZeroLiquidity() public { | ||
address[] memory pools = new address[](1); | ||
pools[0] = address(0xc53489F27F4d8A1cdceD3BFe397CAF628e8aBC13); | ||
|
||
address[] memory dexes = new address[](1); | ||
dexes[0] = address(0x1F98431c8aD98523631AE4a59f267346ea31F984); | ||
|
||
bool[] memory dexIsUniV3 = new bool[](1); | ||
dexIsUniV3[0] = true; | ||
|
||
GetWethValueInPoolBatchRequest data = | ||
new GetWethValueInPoolBatchRequest(pools, dexes, dexIsUniV3, weth, wethInPoolThreshold); | ||
|
||
uint256[] memory weth_values = abi.decode(address(data).code, (uint256[])); | ||
|
||
// expecting weth value to be non 0 | ||
assert(weth_values[0] == 0); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters