Using the IbAlluo contract directly to create streams
Creating a stream directly through the IbAlluo contract allows you to bypass manually wrapping and approving the StIbAlluo contract.
1. Grant Permissions first!
To do so, you must grant permissions to the IbAlluo contract as a stream operator for your account. One way you can do this is through hardhat by instantiating an IbAlluo contract, using formatPermissions to get the callData and then calling the Superfluid Host contract with the following parameters. This only needs to be done once for each IbAlluo contract when initially making a stream.
/// @notice Formats permissios so users can approve the ibAlluo contract as an operator of streams
/// @dev This can be removed once the frontend hardcodes the function call / does it inside ethers.js.
function formatPermissions() public view returns (bytes memory) {
return abi.encodeCall(
cfaV1Lib.cfa.authorizeFlowOperatorWithFullControl,
(
ISuperfluidToken(superToken),
address(this),
new bytes(0)
)
);
}
let encodeData = await ibAlluoCurrent.formatPermissions();
let superhost = await ethers.getContractAt("Superfluid", "0x3E14dC1b13c488a8d5D310918780c983bD5982E7");
await superhost.callAgreement(
"0x6EeE6060f715257b970700bc2656De21dEdF074C",
encodeData,
"0x"
)
2. Once permissions are granted, now call the createFlow function
/// @notice Wraps and creates flow
/// @dev Forces transfer of ibAlluo to the StIbAlluo contract then mints StIbAlluos to circumvent having to sign multiple transactions to create streams
/// @param receiver The recipient of the streamed flow
/// @param flowRate The amount of ibAlluos per second to be streamed (decimals 10**18)
/// @param toWrap The amount of ibAlluos to automatically wrap (recommend wrapping entire ibALluo balance initially)
function createFlow(address receiver, int96 flowRate, uint256 toWrap) external {
_transfer(msg.sender, address(this), toWrap);
_approve(address(this), superToken, toWrap);
IAlluoSuperToken(superToken).upgradeTo(msg.sender, toWrap, "");
cfaV1Lib.createFlowByOperator( msg.sender, receiver, ISuperfluidToken(superToken), flowRate);
ISuperfluidResolver(superfluidResolver).addToChecker(msg.sender, receiver);
emit CreateFlow(msg.sender, receiver, flowRate);
}
function stopFlowWhenCritical(address sender, address receiver) external onlyRole(DEFAULT_ADMIN_ROLE) {
cfaV1Lib.deleteFlowByOperator(sender, receiver, ISuperfluidToken(superToken));
emit DeletedFlow(sender, receiver);
}
function forceWrap(address sender) external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 balance = balanceOf(address(sender));
_transfer(sender, address(this), balance);
_approve(address(this), superToken, balance);
IAlluoSuperToken(superToken).upgradeTo(sender, balance, "");
}
Calling createFlow will force transfer IbAlluos and then the IbAlluo contract will upgrade on your behalf and mint you StIbAlluos. Then, a flow will be created with the parameters you specified.
PreviousA closer look at the integration between IbAlluo and StIbAlluoNextLiquidity Handler and adapters
Last updated