Skip to content

Commit

Permalink
updates to reference files and original router usage in addLiquidity …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
ovatman committed Sep 13, 2024
1 parent e290138 commit 76d5804
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion test/examples/swaps/UniswapV2Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ contract USDCMock {
contract UniswapV2SwapTest {

UniswapV2Swap private _uni;
UniswapV2Router02 private _router;
WETHMock private _weth;
DAIMock private _dai;
USDCMock private _usdc;
Expand Down Expand Up @@ -810,7 +811,7 @@ contract UniswapV2SwapTest {
uint minA = 0;
uint minB = 0;

UniswapV2Router02 _router = new UniswapV2Router02();
_router = new UniswapV2Router02();

_router.set_local_pair(address(_weth), address(_dai));
_router.set_local_pair(address(_weth), address(_usdc));
Expand Down
6 changes: 3 additions & 3 deletions test/regression/swaps.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@
</contract-id>
<contract-state>
_dai |-> DAIMock
_router |-> UniswapV2Router02
_uni |-> UniswapV2Swap
_usdc |-> USDCMock
_weth |-> WETHMock
Expand Down Expand Up @@ -2074,7 +2075,7 @@
false
</contract-fn-payable>
<contract-fn-body>
uint256 testAmount = 131072 ; uint256 desiredA = 10000 ; uint256 desiredB = 10000 ; uint256 minA = 0 ; uint256 minB = 0 ; _weth = new WETHMock ( .TypedVals ) ; _dai = new DAIMock ( .TypedVals ) ; _usdc = new USDCMock ( .TypedVals ) ; UniswapV2Router02 _router = new UniswapV2Router02 ( .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _usdc , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _dai . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _dai . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _router . addLiquidity ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , desiredA , desiredB , minA , minB , address ( this , .TypedVals ) , .TypedVals ) ; assert ( _dai . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _usdc . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _dai . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( _usdc . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( UniswapV2Pair ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 9000 , .TypedVals ) ; .Statements
uint256 testAmount = 131072 ; uint256 desiredA = 10000 ; uint256 desiredB = 10000 ; uint256 minA = 0 ; uint256 minB = 0 ; _weth = new WETHMock ( .TypedVals ) ; _dai = new DAIMock ( .TypedVals ) ; _usdc = new USDCMock ( .TypedVals ) ; _router = new UniswapV2Router02 ( .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _usdc , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _dai . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _dai . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _router . addLiquidity ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , desiredA , desiredB , minA , minB , address ( this , .TypedVals ) , .TypedVals ) ; assert ( _dai . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _usdc . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _dai . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( _usdc . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( UniswapV2Pair ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 9000 , .TypedVals ) ; .Statements
</contract-fn-body>
</contract-fn> <contract-fn>
<contract-fn-id>
Expand Down Expand Up @@ -2393,7 +2394,6 @@
UniswapV2SwapTest
</this-type>
<env>
_router |-> var ( 180033 , UniswapV2Router02 )
desiredA |-> var ( 180029 , uint256 )
desiredB |-> var ( 180030 , uint256 )
minA |-> var ( 180031 , uint256 )
Expand All @@ -2406,7 +2406,6 @@
180030 |-> 10000p256
180031 |-> 0p256
180032 |-> 0p256
180033 |-> 8014p160
</store>
<call-stack>
.List
Expand All @@ -2421,6 +2420,7 @@
</contract-type>
<contract-storage>
_dai |-> 8012p160
_router |-> 8014p160
_uni |-> 8006p160
_usdc |-> 8013p160
_weth |-> 8011p160
Expand Down
3 changes: 2 additions & 1 deletion test/regression/swaps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ contract USDCMock {
contract UniswapV2SwapTest {

UniswapV2Swap private _uni;
UniswapV2Router02 private _router;
WETHMock private _weth;
DAIMock private _dai;
USDCMock private _usdc;
Expand Down Expand Up @@ -738,7 +739,7 @@ contract UniswapV2SwapTest {
_dai = new DAIMock();
_usdc = new USDCMock();

UniswapV2Router02 _router = new UniswapV2Router02();
_router = new UniswapV2Router02();

_router.set_local_pair(address(_weth), address(_dai));
_router.set_local_pair(address(_weth), address(_usdc));
Expand Down
6 changes: 3 additions & 3 deletions test/transactions/swaps/UniswapV2Swap/UniswapTest.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@
</contract-id>
<contract-state>
_dai |-> DAIMock
_router |-> UniswapV2Router02
_uni |-> UniswapV2Swap
_usdc |-> USDCMock
_weth |-> WETHMock
Expand Down Expand Up @@ -2099,7 +2100,7 @@
false
</contract-fn-payable>
<contract-fn-body>
uint256 testAmount = 131072 ; uint256 desiredA = 10000 ; uint256 desiredB = 10000 ; uint256 minA = 0 ; uint256 minB = 0 ; UniswapV2Router02 _router = new UniswapV2Router02 ( .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _usdc , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _dai . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _dai . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _router . addLiquidity ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , desiredA , desiredB , minA , minB , address ( this , .TypedVals ) , .TypedVals ) ; assert ( _dai . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _usdc . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _dai . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( _usdc . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( UniswapV2Pair ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 9000 , .TypedVals ) ; .Statements
uint256 testAmount = 131072 ; uint256 desiredA = 10000 ; uint256 desiredB = 10000 ; uint256 minA = 0 ; uint256 minB = 0 ; _router = new UniswapV2Router02 ( .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _weth , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) ; _router . set_local_pair ( address ( _usdc , .TypedVals ) , address ( _dai , .TypedVals ) , .TypedVals ) ; _dai . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _dai . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . mint ( address ( this , .TypedVals ) , testAmount , .TypedVals ) ; _usdc . approve ( address ( _router , .TypedVals ) , testAmount , .TypedVals ) ; _router . addLiquidity ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , desiredA , desiredB , minA , minB , address ( this , .TypedVals ) , .TypedVals ) ; assert ( _dai . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _usdc . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 121072 , .TypedVals ) ; assert ( _dai . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( _usdc . balanceOf ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) == 10000 , .TypedVals ) ; assert ( UniswapV2Pair ( _router . get_local_pair ( address ( _dai , .TypedVals ) , address ( _usdc , .TypedVals ) , .TypedVals ) , .TypedVals ) . balanceOf ( address ( this , .TypedVals ) , .TypedVals ) == 9000 , .TypedVals ) ; .Statements
</contract-fn-body>
</contract-fn> <contract-fn>
<contract-fn-id>
Expand Down Expand Up @@ -2468,7 +2469,6 @@
UniswapV2SwapTest
</this-type>
<env>
_router |-> var ( 1300 , UniswapV2Router02 )
desiredA |-> var ( 1296 , uint256 )
desiredB |-> var ( 1297 , uint256 )
minA |-> var ( 1298 , uint256 )
Expand All @@ -2481,7 +2481,6 @@
1297 |-> 10000p256
1298 |-> 0p256
1299 |-> 0p256
1300 |-> 43p160
</store>
<call-stack>
.List
Expand All @@ -2496,6 +2495,7 @@
</contract-type>
<contract-storage>
_dai |-> 36p160
_router |-> 43p160
_uni |-> 38p160
_usdc |-> 37p160
_weth |-> 35p160
Expand Down

0 comments on commit 76d5804

Please sign in to comment.