@@ -719,115 +719,115 @@ contract uniswapV2SwapTest {
719
719
assert (daiAmountOut >= daiAmountMin);
720
720
}
721
721
722
- function testSwapMultiHopExactAmountIn () public {
723
- uint256 wethAmount = 1e18 ;
724
-
725
- vidWeth.deposit {value: 4 * wethAmount}();
726
- vidWeth.approve (address (vidUni), 8 * wethAmount);
727
- vidDai.mint (address (this ), 3 * wethAmount);
728
- vidDai.approve (address (vidUni), 3 * wethAmount);
729
- vidUsdc.mint (address (this ), 2 * wethAmount);
730
- vidUsdc.approve (address (vidUni), 2 * wethAmount);
731
-
732
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), wethAmount);
733
- vidDai.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), wethAmount);
734
-
735
- vidUni.router ().syncLocalPair (address (vidWeth), address (vidDai));
736
-
737
- uint256 daiAmountMin = 1 ;
738
- vidUni.swapSingleHopExactAmountIn (wethAmount, daiAmountMin);
739
-
740
- uint256 daiAmountIn = 1e18 ;
741
-
742
- vidDai.transfer (vidUni.router ().getLocalPair (address (vidDai), address (vidWeth)), daiAmountIn);
743
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidDai), address (vidWeth)), daiAmountIn);
744
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidUsdc)), daiAmountIn);
745
- vidUsdc.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidUsdc)), daiAmountIn);
746
-
747
- vidUni.router ().syncLocalPair (address (vidDai), address (vidWeth));
748
- vidUni.router ().syncLocalPair (address (vidWeth), address (vidUsdc));
749
-
750
- uint256 usdcAmountOutMin = 1 ;
751
- uint256 usdcAmountOut =
752
- vidUni.swapMultiHopExactAmountIn (daiAmountIn, usdcAmountOutMin);
753
-
754
- assert (usdcAmountOut >= usdcAmountOutMin);
755
- }
756
-
757
- function testSwapSingleHopExactAmountOut () public {
758
- uint256 wethAmount = 1e18 ;
759
- vidWeth.deposit {value: 10 * wethAmount}();
760
- vidWeth.approve (address (vidUni), 6 * wethAmount);
761
- vidDai.mint (address (this ), 10 * wethAmount);
762
- vidDai.approve (address (vidUni), 4 * wethAmount);
763
-
764
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), 4 * wethAmount);
765
- vidDai.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), 4 * wethAmount);
766
-
767
- vidUni.router ().syncLocalPair (address (vidWeth), address (vidDai));
768
-
769
- uint256 daiAmountDesired = 1e18 ;
770
- uint256 daiAmountOut =
771
- vidUni.swapSingleHopExactAmountOut (daiAmountDesired, 2 * wethAmount);
772
-
773
- assert (daiAmountOut == daiAmountDesired);
774
- }
775
-
776
- function testSwapMultiHopExactAmountOut () public {
777
- uint256 wethAmount = 1e18 ;
778
- vidWeth.deposit {value: 20 * wethAmount}();
779
- vidWeth.approve (address (vidUni), 20 * wethAmount);
780
- vidDai.mint (address (this ), 20 * wethAmount);
781
- vidDai.approve (address (vidUni), 20 * wethAmount);
782
- vidUsdc.mint (address (this ), 10 * wethAmount);
783
- vidUsdc.approve (address (vidUni), 10 * wethAmount);
784
-
785
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), 8 * wethAmount);
786
- vidDai.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidDai)), 8 * wethAmount);
787
-
788
- vidUni.router ().syncLocalPair (address (vidWeth), address (vidDai));
789
-
790
- uint256 daiAmountOut = 2 * 1e18 ;
791
- vidUni.swapSingleHopExactAmountOut (daiAmountOut, 4 * wethAmount);
792
-
793
- vidDai.transfer (vidUni.router ().getLocalPair (address (vidDai), address (vidWeth)), 2 * daiAmountOut);
794
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidDai), address (vidWeth)), 2 * daiAmountOut);
795
- vidWeth.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidUsdc)), 2 * daiAmountOut);
796
- vidUsdc.transfer (vidUni.router ().getLocalPair (address (vidWeth), address (vidUsdc)), 2 * daiAmountOut);
797
- vidUni.router ().syncLocalPair (address (vidDai), address (vidWeth));
798
- vidUni.router ().syncLocalPair (address (vidWeth), address (vidUsdc));
799
-
800
- uint256 amountOutDesired = 1e6 ;
801
- uint256 amountOut =
802
- vidUni.swapMultiHopExactAmountOut (amountOutDesired, daiAmountOut);
803
-
804
- assert (amountOut == amountOutDesired);
805
- }
806
-
807
- function testRouterAddLiquidity () public {
808
- uint256 testAmount = 131072 ; // Hex: 0x20000
809
- uint desiredA = 10000 ;
810
- uint desiredB = 10000 ;
811
- uint minA = 0 ;
812
- uint minB = 0 ;
813
-
814
- vidRouter = new uniswapV2Router02 ();
815
-
816
- vidRouter.setLocalPair (address (vidWeth), address (vidDai));
817
- vidRouter.setLocalPair (address (vidWeth), address (vidUsdc));
818
- vidRouter.setLocalPair (address (vidUsdc), address (vidDai));
819
-
820
- vidDai.mint (address (this ), testAmount);
821
- vidDai.approve (address (vidRouter), testAmount);
822
- vidUsdc.mint (address (this ), testAmount);
823
- vidUsdc.approve (address (vidRouter), testAmount);
824
-
825
- vidRouter.addLiquidity (address (vidDai), address (vidUsdc), desiredA, desiredB, minA, minB, address (this ));
826
-
827
- assert (vidDai.balanceOf (address (this )) == 121072 );
828
- assert (vidUsdc.balanceOf (address (this )) == 121072 );
829
- assert (vidDai.balanceOf (vidRouter.getLocalPair (address (vidDai), address (vidUsdc))) == 10000 );
830
- assert (vidUsdc.balanceOf (vidRouter.getLocalPair (address (vidDai), address (vidUsdc))) == 10000 );
831
- assert (uniswapV2Pair (vidRouter.getLocalPair (address (vidDai), address (vidUsdc))).balanceOf (address (this )) == 9000 );
832
- }
722
+ // function testSwapMultiHopExactAmountIn() public {
723
+ // uint256 wethAmount = 1e18;
724
+ //
725
+ // vidWeth.deposit{value: 4*wethAmount}();
726
+ // vidWeth.approve(address(vidUni), 8*wethAmount);
727
+ // vidDai.mint(address(this), 3*wethAmount);
728
+ // vidDai.approve(address(vidUni), 3*wethAmount);
729
+ // vidUsdc.mint(address(this), 2*wethAmount);
730
+ // vidUsdc.approve(address(vidUni), 2*wethAmount);
731
+ //
732
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), wethAmount);
733
+ // vidDai.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), wethAmount);
734
+ //
735
+ // vidUni.router().syncLocalPair(address(vidWeth), address(vidDai));
736
+ //
737
+ // uint256 daiAmountMin = 1;
738
+ // vidUni.swapSingleHopExactAmountIn(wethAmount, daiAmountMin);
739
+ //
740
+ // uint256 daiAmountIn = 1e18;
741
+ //
742
+ // vidDai.transfer(vidUni.router().getLocalPair(address(vidDai), address(vidWeth)), daiAmountIn);
743
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidDai), address(vidWeth)), daiAmountIn);
744
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidUsdc)), daiAmountIn);
745
+ // vidUsdc.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidUsdc)), daiAmountIn);
746
+ //
747
+ // vidUni.router().syncLocalPair(address(vidDai), address(vidWeth));
748
+ // vidUni.router().syncLocalPair(address(vidWeth), address(vidUsdc));
749
+ //
750
+ // uint256 usdcAmountOutMin = 1;
751
+ // uint256 usdcAmountOut =
752
+ // vidUni.swapMultiHopExactAmountIn(daiAmountIn, usdcAmountOutMin);
753
+ //
754
+ // assert(usdcAmountOut >= usdcAmountOutMin);
755
+ // }
756
+ //
757
+ // function testSwapSingleHopExactAmountOut() public {
758
+ // uint256 wethAmount = 1e18;
759
+ // vidWeth.deposit{value: 10*wethAmount}();
760
+ // vidWeth.approve(address(vidUni), 6*wethAmount);
761
+ // vidDai.mint(address(this), 10*wethAmount);
762
+ // vidDai.approve(address(vidUni), 4*wethAmount);
763
+ //
764
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), 4*wethAmount);
765
+ // vidDai.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), 4*wethAmount);
766
+ //
767
+ // vidUni.router().syncLocalPair(address(vidWeth), address(vidDai));
768
+ //
769
+ // uint256 daiAmountDesired = 1e18;
770
+ // uint256 daiAmountOut =
771
+ // vidUni.swapSingleHopExactAmountOut(daiAmountDesired, 2*wethAmount);
772
+ //
773
+ // assert(daiAmountOut == daiAmountDesired);
774
+ // }
775
+ //
776
+ // function testSwapMultiHopExactAmountOut() public {
777
+ // uint256 wethAmount = 1e18;
778
+ // vidWeth.deposit{value: 20*wethAmount}();
779
+ // vidWeth.approve(address(vidUni), 20*wethAmount);
780
+ // vidDai.mint(address(this), 20*wethAmount);
781
+ // vidDai.approve(address(vidUni), 20*wethAmount);
782
+ // vidUsdc.mint(address(this), 10*wethAmount);
783
+ // vidUsdc.approve(address(vidUni), 10*wethAmount);
784
+ //
785
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), 8*wethAmount);
786
+ // vidDai.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidDai)), 8*wethAmount);
787
+ //
788
+ // vidUni.router().syncLocalPair(address(vidWeth), address(vidDai));
789
+ //
790
+ // uint256 daiAmountOut = 2 * 1e18;
791
+ // vidUni.swapSingleHopExactAmountOut(daiAmountOut, 4*wethAmount);
792
+ //
793
+ // vidDai.transfer(vidUni.router().getLocalPair(address(vidDai), address(vidWeth)), 2*daiAmountOut);
794
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidDai), address(vidWeth)), 2*daiAmountOut);
795
+ // vidWeth.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidUsdc)), 2*daiAmountOut);
796
+ // vidUsdc.transfer(vidUni.router().getLocalPair(address(vidWeth), address(vidUsdc)), 2*daiAmountOut);
797
+ // vidUni.router().syncLocalPair(address(vidDai), address(vidWeth));
798
+ // vidUni.router().syncLocalPair(address(vidWeth), address(vidUsdc));
799
+ //
800
+ // uint256 amountOutDesired = 1e6;
801
+ // uint256 amountOut =
802
+ // vidUni.swapMultiHopExactAmountOut(amountOutDesired, daiAmountOut);
803
+ //
804
+ // assert(amountOut == amountOutDesired);
805
+ // }
806
+ //
807
+ // function testRouterAddLiquidity() public {
808
+ // uint256 testAmount = 131072; // Hex: 0x20000
809
+ // uint desiredA = 10000;
810
+ // uint desiredB = 10000;
811
+ // uint minA = 0;
812
+ // uint minB = 0;
813
+ //
814
+ // vidRouter = new uniswapV2Router02();
815
+ //
816
+ // vidRouter.setLocalPair(address(vidWeth), address(vidDai));
817
+ // vidRouter.setLocalPair(address(vidWeth), address(vidUsdc));
818
+ // vidRouter.setLocalPair(address(vidUsdc), address(vidDai));
819
+ //
820
+ // vidDai.mint(address(this), testAmount);
821
+ // vidDai.approve(address(vidRouter), testAmount);
822
+ // vidUsdc.mint(address(this), testAmount);
823
+ // vidUsdc.approve(address(vidRouter), testAmount);
824
+ //
825
+ // vidRouter.addLiquidity(address(vidDai), address(vidUsdc), desiredA, desiredB, minA, minB, address(this));
826
+ //
827
+ // assert(vidDai.balanceOf(address(this)) == 121072);
828
+ // assert(vidUsdc.balanceOf(address(this)) == 121072);
829
+ // assert(vidDai.balanceOf(vidRouter.getLocalPair(address(vidDai), address(vidUsdc))) == 10000);
830
+ // assert(vidUsdc.balanceOf(vidRouter.getLocalPair(address(vidDai), address(vidUsdc))) == 10000);
831
+ // assert(uniswapV2Pair(vidRouter.getLocalPair(address(vidDai), address(vidUsdc))).balanceOf(address(this)) == 9000);
832
+ // }
833
833
}
0 commit comments