Replies: 3 comments 2 replies
-
Hello @JJScar, So below is the function you are talking about, and it specifies that it // SPDX-License-Identifier: GNU General Public License v3.0
pragma solidity 0.8.20;
....
function swapExactInput(
IERC20 inputToken,
uint256 inputAmount,
IERC20 outputToken,
uint256 minOutputAmount,
uint64 deadline
)
public
revertIfZero(inputAmount)
revertIfDeadlinePassed(deadline)
//@reported: you never returned this value [Low]
returns (uint256 output)
{
uint256 inputReserves = inputToken.balanceOf(address(this));
uint256 outputReserves = outputToken.balanceOf(address(this));
uint256 outputAmount = getOutputAmountBasedOnInput(
inputAmount,
inputReserves,
outputReserves
);
if (outputAmount < minOutputAmount) {
revert TSwapPool__OutputTooLow(outputAmount, minOutputAmount);
}
_swap(inputToken, inputAmount, outputToken, outputAmount);
} |
Beta Was this translation helpful? Give feedback.
-
You can |
Beta Was this translation helpful? Give feedback.
-
For anyone who stumbled upon the same issue, it took my some time, but I got there (lol). Here is the test the passed: function testSwapExactInputAlwaysReturnsZero() public {
vm.startPrank(liquidityProvider);
weth.approve(address(pool), type(uint256).max);
poolToken.approve(address(pool), type(uint256).max);
pool.deposit(STARTING_Y, STARTING_Y, STARTING_Y, uint64(block.timestamp));
vm.stopPrank();
uint256 newAmount = 1e18;
poolToken.mint(user, newAmount);
vm.startPrank(user);
poolToken.approve(address(pool), type(uint256).max);
uint256 returned = pool.swapExactInput(poolToken, newAmount, weth, 0, uint64(block.timestamp));
vm.stopPrank();
assertEq(returned, 0);
} |
Beta Was this translation helpful? Give feedback.
-
Hello all!
I am trying to write the test to prove that the swapExactInput function will return zero as they did not use the return variable in the function. This is what i have so far, however I cannot get my head around what i am doing wrong:
Beta Was this translation helpful? Give feedback.
All reactions