The void function is used to stop a stream. However, if a stream is voided, it can not be restarted meaning the stream is of no value. This is a problem because the stream can still be transferred. This is a concern as voided stream id can of sablier can be transferred, while it is of no consequence to the spender or recipient because either can refund, withdraw respectively. However, the stream id can still be transferred to other users to mislead them about the status and value of the stream.
pragma solidity ^0.8.13;
import { Test,console2 } from "forge-std/src/Test.sol";
import "src/SablierFlow.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ERC20Mock } from "tests/mocks/ERC20Mock.sol";
import "src/abstracts/SablierFlowBase.sol";
import "src/FlowNFTDescriptor.sol";
contract SablierFlowWithdrawTest is Test {
UD60x18 internal constant PROTOCOL_FEE = UD60x18.wrap(0.01e18);
SablierFlow sablierFlow;
ERC20Mock testToken;
FlowNFTDescriptor flowDescriptor;
address john = address(0x1111);
address sarah = address(0x2222);
address bob = address(0x3333);
uint256 streamId;
function setUp() public {
sablierFlow = new SablierFlow(address(this), IFlowNFTDescriptor(flowDescriptor));
testToken = new ERC20Mock("Test Token", "TT", 18);
testToken.mint(john, 100e18);
testToken.mint(address(this), 2e18);
testToken.approve(address(sablierFlow), type(uint256).max);
vm.startPrank(john);
testToken.approve(address(sablierFlow), type(uint256).max);
streamId = sablierFlow.create(
john,
sarah,
UD21x18.wrap(1e18),
testToken,
true
);
vm.stopPrank();
streamId = sablierFlow.create(john, sarah, UD21x18.wrap(1e18), testToken, false);
console2.log(streamId);
}
function testCanTransferVoidId() public {
vm.prank(address(this));
sablierFlow.setProtocolFee(testToken, PROTOCOL_FEE);
uint128 streamBalanceBefore = sablierFlow.getStream(1).balance;
console2.log(streamBalanceBefore);
vm.warp(20 seconds);
vm.prank(john);
sablierFlow.deposit(1, 100e18, john, sarah);
vm.startPrank(john);
sablierFlow.void(1);
sablierFlow.refund(1, 81e18);
vm.stopPrank();
vm.startPrank(sarah)
sablierFlow.withdraw(1, sarah, 19e18);
sablierFlow.safeTransferFrom(sarah, bob, 1, "");
sablierFlow.getStream(1);
}
}