FEYAutoPoolProductFactory
Inherits: FEYFactoryConfigurator, IFEYFactory
Author: Struct Finance
Factory contract that is used to create Fixed and Enhanced Yield AutoPool Products
State Variables
latestSpTokenId
Keeps track of the latest SP token ID
uint256 public latestSpTokenId;
spTokenAddress
Address of the StructSP Token
ISPToken public spTokenAddress;
wAVAX
Address of the Native token
IERC20Metadata public immutable wAVAX;
isProductActive
Active products
mapping(address => uint256) public isProductActive;
isPoolActive
Active pairs
mapping(address => mapping(address => uint256)) public isPoolActive;
autoPoolVaults
Vaults mapping for reverse loopup
mapping(address => mapping(address => address)) public autoPoolVaults;
productTokenId
TokenID => Product
mapping(uint256 => address) public productTokenId;
allProducts
List of addresses of all the FEYProducts created
address[] public allProducts;
yieldSources
AutoPoool vault => YieldSource
mapping(address => IAutoPoolYieldSource) public yieldSources;
Functions
constructor
Initializes the Factory based on the given parameter
constructor(
ISPToken _spTokenAddress,
address _feyProductImpl,
IGAC _globalAccessControl,
IStructPriceOracle _priceOracle,
IERC20Metadata _wAVAX,
IDistributionManager _distributionManager
);
Parameters
Name | Type | Description |
---|---|---|
_spTokenAddress | ISPToken | Address of the Struct SP Token |
_feyProductImpl | address | Address for FEYProduct implementation |
_globalAccessControl | IGAC | Address of the StructGAC contract |
_priceOracle | IStructPriceOracle | The address of the struct price oracle |
_wAVAX | IERC20Metadata | wAVAX address |
_distributionManager | IDistributionManager | Address of the distribution manager contract |
totalProducts
Returns the total number of products created
function totalProducts() external view returns (uint256);
createProduct
Creates new FEY Products based on the given specifications
If the caller is not WHITELISTED
, an initial deposit should be made.
The contract should not be in the PAUSED
state
function createProduct(
DataTypes.TrancheConfig memory _configTrancheSr,
DataTypes.TrancheConfig memory _configTrancheJr,
DataTypes.ProductConfigUserInput memory _productConfigUserInput,
DataTypes.Tranche _tranche,
uint256 _initialDepositAmount
) external payable gacPausable;
Parameters
Name | Type | Description |
---|---|---|
_configTrancheSr | DataTypes.TrancheConfig | Configuration of the senior tranche |
_configTrancheJr | DataTypes.TrancheConfig | Configuration of the junior tranche |
_productConfigUserInput | DataTypes.ProductConfigUserInput | User-set configuration of the Product |
_tranche | DataTypes.Tranche | The tranche into which the creater makes the initial deposit |
_initialDepositAmount | uint256 | The initial deposit amount |
setPoolStatus
Used to update the status of pair
Validate if the initial deposit value is >= the minimumInitialDeposit
If not, then the product creator should be whitelisted.
function setPoolStatus(address _autoPoolVault, uint256 _status) external onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_autoPoolVault | address | The addresss of the autopool vault contract |
_status | uint256 | The status of the pair |
setYieldSource
Sets yield-source contract address for the AutoPool vault
function setYieldSource(address _autoPoolVault, address _yieldSource) external onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_autoPoolVault | address | Address of the AutoPool Vault contract |
_yieldSource | address | Address of the yield source contract |
isMintActive
Checks if spToken can still be minted for the given product.
SPTokens should be minted only for the products with OPEN
state
function isMintActive(uint256 _spTokenId) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spTokenId | uint256 | The SPTokenId associated with the product (senior/junior tranche) |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A flag indicating if SPTokens can be minted |
isTransferEnabled
Checks if the SPToken with the given ID can be transferred.
function isTransferEnabled(uint256 _spTokenId, address _user) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spTokenId | uint256 | The SPToken Id |
_user | address | Address of the SPToken holder |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A flag indicating if transfers are allowed or not |
_deployProduct
Restrict transfer when the product state is OPEN
Deploys the FEY Product based on the given config
function _deployProduct(
DataTypes.TrancheConfig memory _configTrancheSr,
DataTypes.TrancheConfig memory _configTrancheJr,
DataTypes.ProductConfig memory _productConfig
) private returns (address);
Parameters
Name | Type | Description |
---|---|---|
_configTrancheSr | DataTypes.TrancheConfig | - The configuration for the Senior Tranche |
_configTrancheJr | DataTypes.TrancheConfig | - The configuration for the Junior Tranche |
_productConfig | DataTypes.ProductConfig | - The configuration for the new product |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the new product |
_makeInitialDeposit
Used to increase allowance and deposit on behalf of the product creator
function _makeInitialDeposit(
DataTypes.Tranche _tranche,
uint256 _amount,
IERC20Metadata _trancheToken,
IFEYProduct _productAddress
) private;
Parameters
Name | Type | Description |
---|---|---|
_tranche | DataTypes.Tranche | Tranche id to make the initial deposit |
_amount | uint256 | Amount of tokens to be deposited |
_trancheToken | IERC20Metadata | Tranche token address |
_productAddress | IFEYProduct | FEYProduct address that's recently deployed |
_validateProductConfig
Validates the Product configuration
function _validateProductConfig(DataTypes.ProductConfig memory _productConfig) private view;
Parameters
Name | Type | Description |
---|---|---|
_productConfig | DataTypes.ProductConfig | Product configuration |
_validatePool
Validates if pool exists for the given set of tokens and the autopool vault is not paused.
function _validatePool(address _token0, address _token1) private view;
Parameters
Name | Type | Description |
---|---|---|
_token0 | address | Address for token0 |
_token1 | address | Address for token1 |
_getTrancheCapacityValues
Returns the tranche capacity values in USD.
function _getTrancheCapacityValues(address _trancheTokenSenior, address _trancheTokenJunior)
private
view
returns (uint256 _trancheCapacityValueSenior, uint256 _trancheCapacityValueJunior);
Parameters
Name | Type | Description |
---|---|---|
_trancheTokenSenior | address | Senior tranche token address |
_trancheTokenJunior | address | Junior tranche token address |
Returns
Name | Type | Description |
---|---|---|
_trancheCapacityValueSenior | uint256 | Value of Senior tranche capacity in USD |
_trancheCapacityValueJunior | uint256 | Value of Junior tranche capacity in USD |
_getInitialDepositValueUSD
Returns the initial deposit amount value in USD
function _getInitialDepositValueUSD(
DataTypes.Tranche _tranche,
uint256 _amount,
address _trancheTokenSenior,
address _trancheTokenJunior
) private view returns (uint256 _valueUSD, address _trancheToken);
Parameters
Name | Type | Description |
---|---|---|
_tranche | DataTypes.Tranche | Tranche for initial deposit |
_amount | uint256 | The initial deposit amount |
_trancheTokenSenior | address | Senior tranche token address |
_trancheTokenJunior | address | Junior tranche token address |
Returns
Name | Type | Description |
---|---|---|
_valueUSD | uint256 | Value of initial deposit amount in USD |
_trancheToken | address | Address of the tranche token |