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:

  1. Validates all parameters using PoolValidationLib
  2. Retrieves or creates InsuredTokenInfo for both tokens
  3. Deploys new SplitRiskPool contract
  4. Stores pool information in registry
  5. Emits PoolCreated event

Token Whitelist Management

addToken(InsuredTokenInfo memory info) Adds a token to the whitelist with full metadata (governance only).

Parameters:

  • info: Complete InsuredTokenInfo struct 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: Complete InsuredTokenInfo struct 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: PoolInfo struct 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 created
    • poolAddress: Address of the created pool
    • insuredToken: Address of the insured token
    • underwriteToken: Address of the underwriter token
    • commissionRate: Commission rate
    • poolFee: Pool fee
    • colleteralRatio: Collateral ratio
    • creator: Pool creator address