FEYGMXProductFactory
Inherits: IFEYFactory, FEYFactoryConfigurator
Author: Struct Finance
Factory contract that is used to create Fixed and Enhanced Yield 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;
GMX_VAULT
GMX vault address
IGMXVault public constant GMX_VAULT = IGMXVault(0x9ab2De34A33fB459b538c43f251eB825645e8595);
productTokenId
TokenID => Product
mapping(uint256 => address) public productTokenId;
allProducts
List of addresses of all the FEYProducts created
address[] public allProducts;
yieldSource
GLP YieldSource contract
IGMXYieldSource public yieldSource;
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 |
isMintActive
Checks if spToken can still be minted for the given product.
Validate if the initial deposit value is >= the minimumInitialDeposit
If not, then the product creator should be whitelisted.
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 |
setYieldSource
Sets yield-source contract address for the GMX pool
function setYieldSource(address _yieldSource) external onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_yieldSource | address | Address of the yield source contract |
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 |
setTokenStatus
Restrict transfer when the product state is OPEN
Used to update a token status (active/inactive)
function setTokenStatus(address _token, uint256 _status) external override onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_token | address | The token address |
_status | uint256 | The status of the token |
setPoolStatus
Used to update the status of pair
function setPoolStatus(address _token0, address _token1, uint256 _status) external onlyRole(GOVERNANCE);
Parameters
Name | Type | Description |
---|---|---|
_token0 | address | The first token address |
_token1 | address | The second token address |
_status | uint256 | The status of the pair |
_deployProduct
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.
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 |