-
Notifications
You must be signed in to change notification settings - Fork 239
About Agreement Forwarders
Agreement forwarders are contracts providing a simple and intuitive API for an agreement's functionality.
They aren't part of the core protocol, but have privileged access through the Trusted Forwarder mechanism.
The agreement forwarder contracts are:
- CFAv1Forwarder
- IDAv1Forwarder (not yet deployed - note that IDA may become superseded by GDA)
- GDAv1Forwarder (the GDA is not yet finalized and deployed)
This is what creating a flow looks like without the forwarder contract, using ethers.js:
const cfaV1Type = ethers.utils.keccak256(
ethers.utils.toUtf8Bytes("org.superfluid-finance.agreements.ConstantFlowAgreement.v1")
);
const cfaV1Addr = await host.getAgreementClass(cfaV1Type);
const res = await host.callAgreement(
cfaV1Addr,
cfaV1.interface.encodeFunctionData(
"createFlow", [tokenAddr, receiverAddr, flowRate, "0x"],
),
"0x"
);
With the CFAv1Forwarder, this could become:
const res = await cfaFwd.setFlowrate(superTokenAddr, receiverAddr, flowrate);
An added benefit of using agreement forwarders is improved transaction readability in Explorers.
If the initial contract invoked by a transaction is verified, explorers usually show the method invoked and the arguments provided in the transaction detail page. Example tx:
After clicking "Decode Input Data", this becomes:
The API provided by agreement forwarders can also be considered a preview of a future Token Centric API, where all functionality is made available by the token contract itself, similar to how ERC20 contracts expose transfer
for moving tokens.
The forwarder contracts can't fully approximate such an API, instead they take the token address as first argument.
If you're using the Solidity API from other Solidity contracts, you can instead use SuperTokenV1Library, this allows you to use the API as if it were part of the SuperToken interface itself (thanks to Solidity's using for feature).
You can find up to date agreement forwarder addresses for supported networks in metadata/networks.json.
- Governance Overview
- For Contributors
- Development Process
- Protocol EVMv1 Operations
- Protocol EVMv1 Technical Notes
- Protocol EVMv1 Core Subgraph