SplitRiskPool

Splits the risk into two different tranches

Overview

SplitRiskPool.sol is the main contract of the protocol. It has two deploy and withdraw functions for underwriter as well as users that are looking for insured tokens. It also let's you define gates which are external smart contracts that provide access control and compliance mechanisms for pool operations. This let's pool operaters for example set up KYC requirements.

Key Features

  • Dual Token System: Supports both insured tokens (yield-bearing assets) and underwriter tokens (collateral)
  • Yield Sharing: Underwriters earn commissions from the yield generated by insured deposits
  • Flexible Withdrawals: Users can withdraw in either insured tokens or underwriter tokens
  • Governance Integration: Configurable parameters controlled by governance timelock
  • Fee Distribution: Automatic distribution of pool fees, protocol fees, and commissions

Constructor

constructor(
    address _insuredToken, 
    address _underwriteToken,
    uint256 _commissionInPercent,
    uint256 _collateralRatio)
ParameterDescriptionExample Value
insuredTokenYield bearing token that is insuredaUSDe
underwriteTokenYield bearing token that is used to underwriter the poolgtUSDC
commissionRate% of yield shared with underwriters10%
collateralRatioRequired collateral vs insured amount150%

Core Functions

Deposit Functions

depositUnderwriteAsset(address asset, uint256 depositAmount) Deposits underwriter tokens to provide collateral for the pool.

Parameters:

  • asset: Address of the underwriter token
  • depositAmount: Amount to deposit

Requirements:

  • Amount must be between min and max deposit limits
  • Asset must be the supported underwriter token
  • TVL limit must not be exceeded

depositInsuredAsset(address asset, uint256 depositAmount, address underwriterAddress) Deposits insured tokens to receive insurance coverage.

Parameters:

  • asset: Address of the insured token
  • depositAmount: Amount to deposit
  • underwriterAddress: Address of the underwriter to lock tokens

Requirements:

  • Sufficient underwriter tokens must be available for collateral
  • Collateral ratio must be maintained
  • Asset must be the supported insured token

Withdrawal Functions

insuredWithdraw(uint256 withdrawIndex, address preferredAsset) Withdraws insured deposits with choice of asset type.

Parameters:

  • withdrawIndex: Index of the deposit to withdraw
  • preferredAsset: Asset to receive (insured token or underwriter token)

Features:

  • Calculates and distributes fees automatically
  • Supports cross-asset withdrawals
  • Unlocks corresponding underwriter tokens

underwriterWithdraw(uint256 totalTokensToWithdraw, address preferredAsset) Withdraws underwriter tokens from the pool.

Parameters:

  • totalTokensToWithdraw: Amount to withdraw
  • preferredAsset: Asset to receive

Requirements:

  • Sufficient unlocked tokens available
  • Must be the supported underwriter token

Fee Management

payPoolFee() Pays out accumulated pool fees to the pool creator.

payProtocolFee() Pays out accumulated protocol fees to the protocol recipient.

payCommission() Pays out accumulated commissions to the caller (underwriter).

claimRewards(uint256 index, address insuredAddress) Claims yield rewards for a specific insured deposit.

Fee Structure

The protocol implements a three-tier fee system:

  1. Commission Rate: Paid to underwriters from yield (immutable, set at deployment)
  2. Pool Fee: Paid to pool creator from yield (immutable, set at deployment)
  3. Protocol Fee: Paid to protocol from yield (governance-controlled)

All fees are calculated in basis points (1 basis point = 0.01%).

View Functions

Pool Information

  • getPoolConfig(): Returns pool configuration
  • getPoolState(): Returns current pool state
  • getPoolMetadata(): Returns pool metadata
  • getTotalValueLocked(): Returns total value locked
  • getPoolBalances(): Returns token balances

User Information

  • getUserTokenBalances(address user): Returns user's receipt token balances
  • getUnderwriterDepositInfo(address underwriter): Returns underwriter deposit details
  • getInsuredDepositInfo(address insured, uint256 index): Returns insured deposit details
  • getInsuredDepositCount(address insured): Returns number of deposits

Utility Functions

  • isAssetSupported(address asset): Checks if asset is supported
  • getUnderwriteTokenBalance(address token): Returns underwriter token balance
  • getUtilizationRate(): Returns pool utilization rate
  • getTotalLockedUnlocked(): Returns locked/unlocked amounts

Preview Functions

Preview functions allow users to simulate operations without executing them:

  • previewDepositUnderwriteAsset(): Preview underwriter deposit
  • previewDepositInsuredAsset(): Preview insured deposit
  • previewInsuredWithdraw(): Preview insured withdrawal
  • previewUnderwriterWithdraw(): Preview underwriter withdrawal

Events

The contract emits comprehensive events for all major operations:

  • AssetDeposited: When assets are deposited
  • insuredWithdrawal: When insured assets are withdrawn
  • ColleteralWithdraw: When underwriter assets are withdrawn
  • PoolFeePaid: When pool fees are paid
  • ProtocolFeePaid: When protocol fees are paid
  • CommissionPaid: When commissions are paid
  • RewardsClaimed: When rewards are claimed
  • UnlockProcessStarted: When underwriter unlock process starts

Usage Examples

Basic Deposit Flow

  1. Underwriter deposits collateral tokens
  2. Insured user deposits yield-bearing assets
  3. System locks underwriter tokens as collateral
  4. Yield is generated and shared among stakeholders

Withdrawal Flow

  1. User calls withdrawal function
  2. System calculates fees and commissions
  3. Unlocks corresponding underwriter tokens
  4. Transfers preferred asset to user

Fee Distribution

  1. Yield is calculated based on time elapsed
  2. Fees are distributed: commission, pool fee, protocol fee
  3. Remaining yield stays with the pool
  4. Stakeholders can claim their respective fees