Issue in exercise 2, #15
Unanswered
farman1094
asked this question in
Q&A
Replies: 1 comment 10 replies
-
This works fine for me. Ran 1 test for test/UniswapV2SwapTest.t.sol:UniswapV2SwapTest
[PASS] test_swapTokensForExactTokens() (gas: 164757)
Logs:
WETH 94124367944473348
DAI 337407440607281150345
MKR 100000000000000000
Traces:
[62118] UniswapV2SwapTest::setUp()
├─ [0] VM::deal(0x0000000000000000000000000000000000000064, 100000000000000000000 [1e20])
│ └─ ← [Return]
├─ [0] VM::startPrank(0x0000000000000000000000000000000000000064)
│ └─ ← [Return]
├─ [23974] 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2::deposit{value: 100000000000000000000}()
│ ├─ emit Deposit(param0: 0x0000000000000000000000000000000000000064, param1: 100000000000000000000 [1e20])
│ └─ ← [Stop]
├─ [24420] 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2::approve(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77])
│ ├─ emit Approval(owner: 0x0000000000000000000000000000000000000064, spender: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, value: 115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77])
│ └─ ← [Return] true
├─ [0] VM::stopPrank()
│ └─ ← [Return]
└─ ← [Stop]
[170357] UniswapV2SwapTest::test_swapTokensForExactTokens()
├─ [0] VM::prank(0x0000000000000000000000000000000000000064)
│ └─ ← [Return]
├─ [156224] 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D::swapTokensForExactTokens(100000000000000000 [1e17], 1000000000000000000 [1e18], [0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 0x6B175474E89094C44Da98b954EedeAC495271d0F, 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2], 0x0000000000000000000000000000000000000064, 1732802447 [1.732e9])
│ ├─ [2504] 0x517F9dD285e75b599234F7221227339478d0FcC8::getReserves() [staticcall]
│ │ └─ ← [Return] 375666095063796494027 [3.756e20], 211674029428388778 [2.116e17], 1732785371 [1.732e9]
│ ├─ [2504] 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11::getReserves() [staticcall]
│ │ └─ ← [Return] 6552852397611689605386392 [6.552e24], 1822428920933467739475 [1.822e21], 1732802243 [1.732e9]
│ ├─ [15025] 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2::transferFrom(0x0000000000000000000000000000000000000064, 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11, 94124367944473348 [9.412e16])
│ │ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000064, to: 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11, value: 94124367944473348 [9.412e16])
│ │ └─ ← [Return] true
│ ├─ [48033] 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11::swap(337407440607281150345 [3.374e20], 0, 0x517F9dD285e75b599234F7221227339478d0FcC8, 0x)
│ │ ├─ [13074] 0x6B175474E89094C44Da98b954EedeAC495271d0F::transfer(0x517F9dD285e75b599234F7221227339478d0FcC8, 337407440607281150345 [3.374e20])
│ │ │ ├─ emit Transfer(from: 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11, to: 0x517F9dD285e75b599234F7221227339478d0FcC8, value: 337407440607281150345 [3.374e20])
│ │ │ └─ ← [Return] true
│ │ ├─ [602] 0x6B175474E89094C44Da98b954EedeAC495271d0F::balanceOf(0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11) [staticcall]
│ │ │ └─ ← [Return] 6552514990171082324236047 [6.552e24]
│ │ ├─ [534] 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2::balanceOf(0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11) [staticcall]
│ │ │ └─ ← [Return] 1822523045301412212823 [1.822e21]
│ │ ├─ emit Sync(reserve0: 6552514990171082324236047 [6.552e24], reserve1: 1822523045301412212823 [1.822e21])
│ │ ├─ emit Swap(sender: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, amount0In: 0, amount1In: 94124367944473348 [9.412e16], amount0Out: 337407440607281150345 [3.374e20], amount1Out: 0, to: 0x517F9dD285e75b599234F7221227339478d0FcC8)
│ │ └─ ← [Stop]
│ ├─ [67846] 0x517F9dD285e75b599234F7221227339478d0FcC8::swap(0, 100000000000000000 [1e17], 0x0000000000000000000000000000000000000064, 0x)
│ │ ├─ [32706] 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2::transfer(0x0000000000000000000000000000000000000064, 100000000000000000 [1e17])
│ │ │ ├─ emit Transfer(from: 0x517F9dD285e75b599234F7221227339478d0FcC8, to: 0x0000000000000000000000000000000000000064, value: 100000000000000000 [1e17])
│ │ │ └─ ← [Return] true
│ │ ├─ [602] 0x6B175474E89094C44Da98b954EedeAC495271d0F::balanceOf(0x517F9dD285e75b599234F7221227339478d0FcC8) [staticcall]
│ │ │ └─ ← [Return] 713073535671077644372 [7.13e20]
│ │ ├─ [715] 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2::balanceOf(0x517F9dD285e75b599234F7221227339478d0FcC8) [staticcall]
│ │ │ └─ ← [Return] 111674029428388778 [1.116e17]
│ │ ├─ emit Sync(reserve0: 713073535671077644372 [7.13e20], reserve1: 111674029428388778 [1.116e17])
│ │ ├─ emit Swap(sender: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, amount0In: 337407440607281150345 [3.374e20], amount1In: 0, amount0Out: 0, amount1Out: 100000000000000000 [1e17], to: 0x0000000000000000000000000000000000000064)
│ │ └─ ← [Stop]
│ └─ ← [Return] [94124367944473348 [9.412e16], 337407440607281150345 [3.374e20], 100000000000000000 [1e17]]
├─ [0] console::log("WETH", 94124367944473348 [9.412e16]) [staticcall]
│ └─ ← [Stop]
├─ [0] console::log("DAI", 337407440607281150345 [3.374e20]) [staticcall]
│ └─ ← [Stop]
├─ [0] console::log("MKR", 100000000000000000 [1e17]) [staticcall]
│ └─ ← [Stop]
├─ [715] 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2::balanceOf(0x0000000000000000000000000000000000000064) [staticcall]
│ └─ ← [Return] 100000000000000000 [1e17]
├─ [0] VM::assertEq(100000000000000000 [1e17], 100000000000000000 [1e17], "MKR balance of user") [staticcall]
│ └─ ← [Return]
└─ ← [Stop]
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 12.52s (8.42s CPU time) |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am facing this issue of exercise 2
I am also trying the same thing in other test file which is available here link that is working absolutely fine, I have also tried changing the order of
swapExactTokensForTokens
andswapTokensForExactTokens
function. By calling the functionswapTokensForExactTokens
first. that also work. But only this specific order is not working down below. Maybe I am missing something important.Repo Link: https://github.com/farman1094/UniswapV2Practice
code
Beta Was this translation helpful? Give feedback.
All reactions