Factory
Contract designed to deploy and manage multiple instances of `SplitRiskPool`
Overview
The SplitRiskPoolFactory is a factory contract designed to deploy and manage multiple instances of SplitRiskPool contracts.
It provides a standardized way to create insurance pools while maintaining a registry of all deployed pools for easy discovery and management.
Key Features
- Pool Creation: Deploy new SplitRiskPool instances with validated parameters
- Token Whitelisting: Governance-controlled whitelist for supported tokens
- Pool Registry: Central registry of all created pools with metadata
- Token Pair Management: Track pools by insured/underwriter token pairs
- Governance Integration: Configurable parameters controlled by governance timelock
Core Functions
Pool Creation
createPool(address _insuredToken, string _insuredTokenSymbol, address _underwriteToken, string _underwriteTokenSymbol, uint256 _commissionRate, uint256 _poolFee, uint256 _colleteralRatio)
Creates a new SplitRiskPool instance with validated parameters.
Parameters:
_insuredToken: Address of the insured yield-bearing token_insuredTokenSymbol: Symbol for the insured token_underwriteToken: Address of the underwriter yield-bearing token_underwriteTokenSymbol: Symbol for the underwriter token_commissionRate: Commission rate in basis points (100-5000)_poolFee: Pool creator fee in basis points (0-2000)_colleteralRatio: Collateral ratio in basis points (10000-50000)
Returns:
poolAddress: Address of the newly created pool
Validation:
- Both tokens must be whitelisted (if whitelist is active)
- Parameters must be within valid ranges
- Tokens must be different addresses
- Symbol lengths must be valid
Process:
- Validates all parameters using
PoolValidationLib - Retrieves or creates
InsuredTokenInfofor both tokens - Deploys new
SplitRiskPoolcontract - Stores pool information in registry
- Emits
PoolCreatedevent
Token Whitelist Management
addToken(InsuredTokenInfo memory info)
Adds a token to the whitelist with full metadata (governance only).
Parameters:
info: CompleteInsuredTokenInfostruct with token details
Requirements:
- Caller must be governance timelock
- Token must not already be whitelisted
- Token address must not be zero
addTokenInitial(InsuredTokenInfo memory info)
Adds a token to the whitelist during initial deployment (owner only).
Parameters:
info: CompleteInsuredTokenInfostruct with token details
Requirements:
- Caller must be contract owner
- Used for initial token setup
removeToken(address token)
Removes a token from the whitelist (governance only).
Parameters:
token: Address of the token to remove
Requirements:
- Caller must be governance timelock
- Token must be currently whitelisted
View Functions
getPoolCount()
Returns the total number of pools created.
Returns:
count: Total number of pools
getPoolInfo(address _poolAddress)
Returns detailed information about a specific pool.
Parameters:
_poolAddress: Address of the pool to query
Returns:
info:PoolInfostruct containing pool metadata
Requirements:
- Pool must exist
getPoolsByTokenPair(address _insuredToken, address _underwriteToken)
Returns all pools for a specific token pair.
Parameters:
_insuredToken: Address of the insured token_underwriteToken: Address of the underwriter token
Returns:
- Array of pool addresses for the token pair
getAllPools()
Returns all created pools.
Returns:
- Array of all pool addresses
getWhitelistedTokens()
Returns all whitelisted tokens.
Returns:
- Array of whitelisted token addresses
Governance Functions
setGovernanceTimelock(address newGovernanceTimelock)
Updates the governance timelock address (owner only).
Parameters:
newGovernanceTimelock: New governance timelock address
Requirements:
- Caller must be contract owner
- Address must not be zero
Events
Pool Creation
PoolCreated: Emitted when a new pool is createdpoolAddress: Address of the created poolinsuredToken: Address of the insured tokenunderwriteToken: Address of the underwriter tokencommissionRate: Commission ratepoolFee: Pool feecolleteralRatio: Collateral ratiocreator: Pool creator address