STP
V1 Docs
Contract Reference
Factory Ref

SubscriptionTokenV1Factory

Git Source (opens in a new tab)

Inherits: Ownable2Step

Author: Fabric Inc.

A factory which leverages Clones to deploy Fabric Subscription Token Contracts

State Variables

_MAX_FEE_BIPS

The maximum fee that can be charged for a subscription contract

uint16 private constant _MAX_FEE_BIPS = 1250;

_DEFAULT_REWARD_HALVINGS

The number of reward halvings

uint8 private constant _DEFAULT_REWARD_HALVINGS = 6;

_implementation

The campaign contract implementation address

address immutable _implementation;

_feeConfigs

Configured fee ids and their config

mapping(uint256 => FeeConfig) private _feeConfigs;

_feeDeployMin

Fee to collect upon deployment

uint256 private _feeDeployMin;

Functions

feeRequired

Guard to ensure the deploy fee is met

modifier feeRequired();

constructor

constructor(address implementation) Ownable2Step;

Parameters

NameTypeDescription
implementationaddressthe SubscriptionTokenV1 implementation address

deploySubscription

Deploy a new Clone of a SubscriptionTokenV1 contract

function deploySubscription(
    string memory name,
    string memory symbol,
    string memory contractURI,
    string memory tokenURI,
    uint256 tokensPerSecond,
    uint256 minimumPurchaseSeconds,
    uint16 rewardBps,
    address erc20TokenAddr,
    uint256 feeConfigId
) public payable feeRequired returns (address);

Parameters

NameTypeDescription
namestringthe name of the collection
symbolstringthe symbol of the collection
contractURIstringthe metadata URI for the collection
tokenURIstringthe metadata URI for the tokens
tokensPerSeconduint256the number of base tokens required for a single second of time
minimumPurchaseSecondsuint256the minimum number of seconds an account can purchase
rewardBpsuint16the basis points for reward allocations
erc20TokenAddraddressthe address of the ERC20 token used for purchases, or the 0x0 for native
feeConfigIduint256the fee configuration id to use for this deployment (if the id is invalid, the default fee is used)

transferDeployFees

Owner Only: Transfer accumulated fees

function transferDeployFees(address recipient) external onlyOwner;

Parameters

NameTypeDescription
recipientaddressthe address to transfer the fees to

createFee

Create a fee for future deployments using that fee id

function createFee(uint256 id, address collector, uint16 bips) external onlyOwner;

Parameters

NameTypeDescription
iduint256the id of the fee for future deployments
collectoraddressthe address of the fee collector
bipsuint16the fee in basis points, allocated during withdraw

destroyFee

Destroy a fee schedule

function destroyFee(uint256 id) external onlyOwner;

Parameters

NameTypeDescription
iduint256the id of the fee to destroy

updateMinimumDeployFee

Update the deploy fee (wei)

function updateMinimumDeployFee(uint256 minFeeAmount) external onlyOwner;

Parameters

NameTypeDescription
minFeeAmountuint256the amount of wei required to deploy a campaign

feeInfo

Fetch the fee schedule for a given fee id

function feeInfo(uint256 feeId) external view returns (address collector, uint16 bips, uint256 deployFeeWei);

Returns

NameTypeDescription
collectoraddressthe address of the fee collector, or the 0 address if no fees are collected
bipsuint16the fee in basis points, allocated during withdraw
deployFeeWeiuint256the amount of wei required to deploy a campaign

Events

Deployment

Emitted upon a successful contract deployment

event Deployment(address indexed deployment, uint256 feeId);

FeeCreated

Emitted when a new fee is created

event FeeCreated(uint256 indexed id, address collector, uint16 bips);

FeeDestroyed

Emitted when a fee is destroyed

event FeeDestroyed(uint256 indexed id);

DeployFeeChange

Emitted when the deployment fee changes

event DeployFeeChange(uint256 amount);

DeployFeeTransfer

Emitted when the deploy fees are collected by the owner

event DeployFeeTransfer(address indexed recipient, uint256 amount);

Structs

FeeConfig

Fee configuration for agreements and revshare

struct FeeConfig {
    address collector;
    uint16 basisPoints;
}