The apporover that have the right to withdraw is not able to withdraw for the recipient
function test_WithdrawApprover()
external
whenNoDelegateCall
givenNotNull
whenAmountNotZero
whenWithdrawalAddressNotZero
whenWithdrawalAddressNotOwner
{
address boby = address(0xabc2345);
flow.approve({ to: boby, tokenId: defaultStreamId });
uint256 streamId = defaultStreamId;
address to = users.eve;
uint128 depositAmount = DEPOSIT_AMOUNT_6D;
uint128 protocolFeeAmount = 0;
uint128 withdrawAmount = WITHDRAW_AMOUNT_6D;
vars.token = flow.getToken(streamId);
vars.previousSnapshotTime = flow.getSnapshotTime(streamId);
vars.previousTotalDebt = flow.totalDebtOf(streamId);
vars.previousAggregateAmount = flow.aggregateBalance(vars.token);
vars.expectedProtocolRevenue = flow.protocolRevenue(vars.token) + protocolFeeAmount;
vm.expectEmit({ emitter: address(vars.token) });
emit IERC20.Transfer({ from: address(flow), to: to, value: withdrawAmount - protocolFeeAmount });
vm.expectEmit({ emitter: address(flow) });
emit ISablierFlow.WithdrawFromFlowStream({
streamId: streamId,
to: to,
token: vars.token,
caller: users.recipient,
protocolFeeAmount: protocolFeeAmount,
withdrawAmount: withdrawAmount - protocolFeeAmount
});
vm.expectEmit({ emitter: address(flow) });
emit IERC4906.MetadataUpdate({ _tokenId: streamId });
expectCallToTransfer({ token: vars.token, to: to, amount: withdrawAmount - protocolFeeAmount });
vars.previousTokenBalance = vars.token.balanceOf(address(flow));
(, address msgSender, address txOrigin) = vm.readCallers();
console.log("msgSender: %s", msgSender);
console.log("txOrigin: %s", txOrigin);
vm.stopPrank();
vm.prank(boby);
(vars.actualWithdrawnAmount, vars.actualProtocolFeeAmount) =
flow.withdraw({ streamId: streamId, to: to, amount: withdrawAmount });
assertEq(vars.actualProtocolFeeAmount, protocolFeeAmount, "protocol fee amount");
assertEq(vars.actualWithdrawnAmount, withdrawAmount - protocolFeeAmount, "withdrawn amount");
assertEq(flow.protocolRevenue(vars.token), vars.expectedProtocolRevenue, "protocol revenue");
vars.expectedSnapshotTime = flow.isPaused(streamId) ? vars.previousSnapshotTime : getBlockTimestamp();
assertEq(flow.getSnapshotTime(streamId), vars.expectedSnapshotTime, "snapshot time");
vars.expectedTotalDebt = vars.previousTotalDebt - withdrawAmount;
assertEq(flow.totalDebtOf(streamId), vars.expectedTotalDebt, "total debt");
vars.expectedStreamBalance = depositAmount - withdrawAmount;
assertEq(flow.getBalance(streamId), vars.expectedStreamBalance, "stream balance");
vars.expectedTokenBalance = vars.previousTokenBalance - vars.actualWithdrawnAmount;
assertEq(vars.token.balanceOf(address(flow)), vars.expectedTokenBalance, "token balance");
assertEq(
flow.aggregateBalance(vars.token),
vars.previousAggregateAmount - vars.actualWithdrawnAmount,
"aggregate amount"
);
}
we get an exception
│ ├─ [11428] USDC::transfer(eve: [0xa959355654849CbEAbBf65235f8235833b9e031D], 2500000000 [2.5e9])
│ │ ├─ emit Transfer(from: Flow: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], to: eve: [0xa959355654849CbEAbBf65235f8235833b9e031D], value: 2500000000 [2.5e9])
│ │ └─ ← [Return] true
│ ├─ emit WithdrawFromFlowStream(streamId: 1, to: eve: [0xa959355654849CbEAbBf65235f8235833b9e031D], token: USDC: [0xa0Cb889707d426A7A386870A03bc70d1b0697598], caller: 0x000000000000000000000000000000000ABc2345, withdrawAmount: 2500000000 [2.5e9], protocolFeeAmount: 0)
│ ├─ emit MetadataUpdate(_tokenId: 1)
│ └─ ← [Return] 2500000000 [2.5e9], 0
└─ ← [Revert] log != expected log