SlpManager
The SlpManager contract manages the Staked Liquidity Provider (SLP) token system for the Satoshi Perps protocol. It handles the minting and burning of SLP tokens in exchange for providing liquidity to the protocol.For a visual representation of the liquidity provision process, see the Protocol Flow Charts page.
Contract Overview
The SlpManager handles:- Minting SLP tokens when users add liquidity
- Burning SLP tokens when users remove liquidity
- Tracking and distributing fees to liquidity providers
- Managing the SLP token price based on underlying assets
SLP tokens represent a user’s share of the protocol’s liquidity pool and entitle holders to a portion of protocol fees.
Key Functions
Liquidity Management
AUM Calculation
Price Calculation
Fee Management
SLP Token Mechanics
The SLP token system works as follows:- Users deposit tokens into the protocol through the SlpManager
- The SlpManager mints SLP tokens representing the user’s share of the pool
- The value of SLP tokens increases as the protocol earns fees
- Users can redeem SLP tokens for the underlying assets plus earned fees
SLP tokens are subject to a cooldown period before they can be redeemed. This helps prevent flash loan attacks and provides stability to the protocol.
AUM and Price Calculation
The Assets Under Management (AUM) calculation is a critical component of SLP pricing:- The protocol earns fees, which are added to the pool
- Profits from liquidations accrue to the pool
- The value of assets in the pool increases
Integration with Vault
The SlpManager is tightly integrated with the Vault contract:- The Vault uses the liquidity provided through the SlpManager
- Fees earned by the Vault are distributed to SLP token holders
- The SlpManager helps maintain the stability of the protocol by providing liquidation reserves
Handler System and Private Mode
The SlpManager implements a handler system and private mode for controlled access:- Handlers: Addresses authorized to perform certain functions
- Private Mode: When enabled, only authorized addresses can add/remove liquidity
ShortsTracker Integration
The SlpManager integrates with the ShortsTracker contract to account for global short positions when calculating AUM:Security Considerations
The SlpManager implements several security features:- Cooldown Period: Prevents flash loan exploits
- Minimum Output Amounts: Protects users from slippage
- AUM Adjustments: Allows fine-tuning of SLP pricing
- Access Controls: Restricts sensitive functions to authorized addresses
- Private Mode: Ability to restrict liquidity operations to trusted addresses
- Handler System: Fine-grained permissions for different functions
Example Usage
1
Adding Liquidity
A user wants to provide liquidity to the protocol.
2
Checking SLP Value
The user checks the value of their SLP tokens after some time.
3
Removing Liquidity
Later, the user decides to withdraw their liquidity.
Fee Distribution
SLP token holders earn fees in several ways:- Swap fees from token exchanges in the Vault
- Borrowing fees from leveraged traders
- Liquidation fees when underwater positions are liquidated