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)
| Parameter | Description | Example Value |
|---|---|---|
insuredToken | Yield bearing token that is insured | aUSDe |
underwriteToken | Yield bearing token that is used to underwriter the pool | gtUSDC |
commissionRate | % of yield shared with underwriters | 10% |
collateralRatio | Required collateral vs insured amount | 150% |
Core Functions
Deposit Functions
depositUnderwriteAsset(address asset, uint256 depositAmount)
Deposits underwriter tokens to provide collateral for the pool.
Parameters:
asset: Address of the underwriter tokendepositAmount: 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 tokendepositAmount: Amount to depositunderwriterAddress: 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 withdrawpreferredAsset: 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 withdrawpreferredAsset: 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:
- Commission Rate: Paid to underwriters from yield (immutable, set at deployment)
- Pool Fee: Paid to pool creator from yield (immutable, set at deployment)
- 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 configurationgetPoolState(): Returns current pool stategetPoolMetadata(): Returns pool metadatagetTotalValueLocked(): Returns total value lockedgetPoolBalances(): Returns token balances
User Information
getUserTokenBalances(address user): Returns user's receipt token balancesgetUnderwriterDepositInfo(address underwriter): Returns underwriter deposit detailsgetInsuredDepositInfo(address insured, uint256 index): Returns insured deposit detailsgetInsuredDepositCount(address insured): Returns number of deposits
Utility Functions
isAssetSupported(address asset): Checks if asset is supportedgetUnderwriteTokenBalance(address token): Returns underwriter token balancegetUtilizationRate(): Returns pool utilization rategetTotalLockedUnlocked(): Returns locked/unlocked amounts
Preview Functions
Preview functions allow users to simulate operations without executing them:
previewDepositUnderwriteAsset(): Preview underwriter depositpreviewDepositInsuredAsset(): Preview insured depositpreviewInsuredWithdraw(): Preview insured withdrawalpreviewUnderwriterWithdraw(): Preview underwriter withdrawal
Events
The contract emits comprehensive events for all major operations:
AssetDeposited: When assets are depositedinsuredWithdrawal: When insured assets are withdrawnColleteralWithdraw: When underwriter assets are withdrawnPoolFeePaid: When pool fees are paidProtocolFeePaid: When protocol fees are paidCommissionPaid: When commissions are paidRewardsClaimed: When rewards are claimedUnlockProcessStarted: When underwriter unlock process starts
Usage Examples
Basic Deposit Flow
- Underwriter deposits collateral tokens
- Insured user deposits yield-bearing assets
- System locks underwriter tokens as collateral
- Yield is generated and shared among stakeholders
Withdrawal Flow
- User calls withdrawal function
- System calculates fees and commissions
- Unlocks corresponding underwriter tokens
- Transfers preferred asset to user
Fee Distribution
- Yield is calculated based on time elapsed
- Fees are distributed: commission, pool fee, protocol fee
- Remaining yield stays with the pool
- Stakeholders can claim their respective fees