Skip to content
Request an audit

‹ All findings

BaseFlasher transfers tokens and then calls xBundle(...), so the sent tokens can't be returned due to the balance check

MediumFuji Finance·Three Sigma · Lending aggregator · 6th May, 20233S-FUJI-M04

Description

The BaseRouter checks if the balances of the assets remain the same after the xBundle(...) execution. The BaseFlasher, _requestorExecution(...) is implemented in the following way

solidity
IERC20(asset).safeTransfer(requestor, amount);
requestor.functionCall(requestorCalldata);
// approve flashloan source address to spend to repay flashloan
IERC20(asset).safeApprove(getFlashloanSourceAddr(asset), amount + fee);

Thus, when xBundle(...) is called in requestor.functionCall(requestorCalldata);, the initial balance of the BaseRouter will take into account the received funds from the flashloan, such that it will be impossible to return the funds at the end of the call.

Recommendation

Similarly to xReceive(...) of the ConnextRouter, the BaseRouter could implement a similar function. In this case, the caller of, let's say, flashloanReceive(...), could be whitelisted to one of the flashers.

POC

https://github.com/threesigmaxyz/fuji-issues-external/blob/master/test/POC/POCCantUseFlashloanFunds.t.sol#L97

Status

Addressed here: Fujicracy/fuji-v2#622