Skip to content

Instantly share code, notes, and snippets.

@ngmachado
Last active April 5, 2022 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngmachado/7a27014cd3ac6e66d25984164e96242a to your computer and use it in GitHub Desktop.
Save ngmachado/7a27014cd3ac6e66d25984164e96242a to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
/*
Factory that can deploy any number of TradeableCashflow using registerAppByFactory from SF protocol
*/
import "./TradeableCashflow.sol";
import {ISuperfluid, ISuperToken, SuperAppDefinitions} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
contract TCFFactory {
event NewTradeableCashflow(address indexed tcf);
uint256 immutable configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |
SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP;
address public owner;
constructor() {
owner = msg.sender;
}
function newTCF(
address lockAddress,
string memory _name,
string memory _symbol,
ISuperfluid host,
ISuperToken acceptedToken
)
external
onlyOwner
{
TradeableCashflow newTCF = new TradeableCashflow(lockAddress, _name, _symbol, host, acceptedToken);
host.registerAppByFactory(newTCF, configWord);
emit NewTradeableCashflow(address(newTCF));
}
modifier onlyOwner() {
require(owner == msg.sender, "not owner");
_;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment