STP
Contract Reference
Factory Ref

STPV2Factory

Git Source (opens in a new tab)

Inherits: AccessControlled, Multicallable

Author: Fabric Inc.

A factory which leverages Clones to deploy Fabric Subscription Token Contracts

State Variables

IMPLEMENTATION

The STP contract implementation address

address private immutable IMPLEMENTATION;

_protocolFeeRecipient

The protocol fee recipient

address private _protocolFeeRecipient;

_deployFee

The deploy fee (how much to charge for deployment)

uint256 private _deployFee;

Functions

constructor

Construct a new Factory contract

constructor(address stpImplementation, address protocolFeeRecipient);

Parameters

NameTypeDescription
stpImplementationaddressthe STPV2 implementation address
protocolFeeRecipientaddress

deploySubscription

Deploy a new Clone of a STPV2 contract

function deploySubscription(DeployParams memory params) public payable returns (address);

Parameters

NameTypeDescription
paramsDeployParamsthe initialization parameters for the contract (@see DeloyParams)

_transferDeployFee

Transfer the deploy fee to the collector (if configured)

function _transferDeployFee() internal;

setProtocolFeeRecipient

Set the protocol recipient for deployed contracts

function setProtocolFeeRecipient(address recipient) external;

Parameters

NameTypeDescription
recipientaddressthe new recipient

setDeployFee

Set the deploy fee (wei)

function setDeployFee(uint256 deployFeeWei) external;

Parameters

NameTypeDescription
deployFeeWeiuint256the new deploy fee

feeSchedule

Get the current fee schedule

function feeSchedule() external view returns (FeeScheduleView memory schedule);

Returns

NameTypeDescription
scheduleFeeScheduleViewthe fee schedule

updateClientFeeRecipient

Update the client fee recipient for a list of deployments

requires the sender to be the current recipient

function updateClientFeeRecipient(address payable deployment, address recipient) external;

Parameters

NameTypeDescription
deploymentaddress payablethe deployment to update
recipientaddressthe new recipient

updateProtocolFeeRecipient

Update the protocol fee recipient for a list of deployments

requires the sender to be the current recipient

function updateProtocolFeeRecipient(address payable deployment, address recipient) external;

Parameters

NameTypeDescription
deploymentaddress payablethe deployment to update
recipientaddressthe new recipient

Events

Deployment

Emitted upon a successful subscription contract deployment

event Deployment(address indexed deployment, bytes deployKey);

DeployFeeTransfer

Emitted when the deploy fees are collected by the owner

event DeployFeeTransfer(address indexed recipient, uint256 amount);

DeployFeeChange

Emitted when a deploy fee is set

event DeployFeeChange(uint256 amount);

ProtocolFeeRecipientChange

Emitted when the protocol fee recipient is set

event ProtocolFeeRecipientChange(address account);

Errors

InvalidImplementation

Error when the implementation address is invalid

error InvalidImplementation();

InvalidFeeRecipient

Error when a fee collector is invalid (0 address)

error InvalidFeeRecipient();

FeeInvalid

Error when the fee paid for deployment is insufficient

error FeeInvalid();