Flashloans
Flashloans allows any smart contract to execute any arbitrary code after borrowing as long as the funds are returned to the lending protocol within the scope of the same transaction.
In Fuji's case, we have integrated three different Flashloan providers:
Provider
% Charged per Tx
Aave
0.09%
DyDx
no fee*
Cream Finance
0.03%
DyDx flashloans are free of charge but more complex to implement, you cannot use it while having collateral and debt on the protocol itself.
Fuji uses flashloans very often to save users money by choosing the lowest-interest protocol in the market. When the Controller identifies (off-chain) that an interest is lower in another protocol i.e. Aave vs Compound, then the Controller will call the flasher and execute a switch by taking all the collateral and debt from one protocol to the next.

Flasher

Fuji's Flasher.sol is a smart contract that uses SafeMath and UniERC20 (audited contracts by Open Zeppelin) to handle all the parameters that are going to be needed to execute the protocol switch.
contract Flasher is DyDxFlashloanBase, IFlashLoanReceiver, ICFlashloanReceiver, ICallee, Ownable {
using SafeMath for uint256;
using UniERC20 for IERC20;
When the flasher is called by the Controller, it will contain the parameter (0, 1, 2) to identify which flashloan to use.
function initiateFlashloan(FlashLoan.Info calldata info, uint8 _flashnum) public isAuthorized {
if (_flashnum == 0) {
_initiateAaveFlashLoan(info);
} else if (_flashnum == 1) {
_initiateDyDxFlashLoan(info);
} else if (_flashnum == 2) {
_initiateCreamFlashLoan(info);
After the Flasher borrows the needed amount to pay for all debt and withdraw the collateral, it will then deposit it in the right protocol that is offering the lowest-interest rate. To keep count of all the tokens flowing through Fuji we have Fuji1155.
Copy link