Submitted by rbserver, also found by imare and Lambda
When calling the swap function below, the following _swapCallback function is further called for calling the algebraSwapCallback function in the callee contract, which is msg.sender; such contract could be implemented by a third party especially for non-technical users. There is no guarantee that such contract will not send more input token amount than required to the pool. When this happens, the output token amount corresponding to the extra input token amount will not be transferred from the pool to the recipient after the swap. As a result, the user sends extra input token amount to the pool but does not receive any output token amount corresponding to the extra input token amount. Disputes between the user and protocol can occur because of this.
AlgebraPool.sol#L580-L586
AlgebraPool.sol#L589-L623
First, in src\core\contracts\test\, please add the following test callee contract.
Then, please add the following test in the AlgebraPool describe block in src\core\test\AlgebraPool.spec.ts. This test will pass to demonstrate the described scenario.
VSCode
AlgebraPool.sol#L608 can be updated to the following code.
Also, AlgebraPool.sol#L614 can be updated to the following code.
debych (Quickswap & Stellaswap) confirmed
0xean (judge) commented:
