Example: USDC to streaming 1 IbAlluo per second
This example will walk through how to start with USDC and end up streaming 1 IbAlluo per second to a certain address directly through the IbAlluo contract without ever interacting with the StIbAlluo contract.
Polygon + Ethers + Hardhat
1
// First we will deposit 1000 USDC into the IbAlluo contract and
2
// receive IbAlluos.
3
let yourAddress= "";
4
let recipientAddress="";
5
let ibAlluoUSD = await ethers.getContractAt("IbAlluo", "0xC2DbaAEA2EfA47EBda3E572aa0e55B742E408BF6");
6
const usdc = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
7
let amount = parseEther(1000);
8
await ibAlluoUSD.deposit(usdc, amount);
9
10
// Now grant permissions to the IbAlluo contract to create streams on your behalf
11
// You only need to do this once for each IbAlluo contract when you first make a stream.
12
let encodeData = await ibAlluoCurrent.formatPermissions();
13
let superhost = await ethers.getContractAt("Superfluid", "0x3E14dC1b13c488a8d5D310918780c983bD5982E7");
14
await superhost.connect(signers[1]).callAgreement(
15
"0x6EeE6060f715257b970700bc2656De21dEdF074C",
16
encodeData,
17
"0x"
18
)
19
20
// Now create the actual flow for 1 IbAlluo per second. The last parameter is the
21
// amount of IbAlluos you want to wrap into StIbAlluos. We recommend wrapping
22
// your entire balance.
23
let currentBalance = await ibAlluoUSD.combinedBalanceOf(yourAddress);
24
// If you only want to wrap 800 IbAlluos.
25
await ibAlluoUSD.createFlow(recipientAddress, parseEther("1"), parseEther("800"))
26
// Or if you want to wrap your entire balance
27
await ibAlluoUSD.createFlow(recipientAddress, parseEther("1"), currentBalance)
... and you're finished! You will now have a stream for 1 IbAlluo/ second to the recipient address.