SlpManagerRouter
The SlpManagerRouter is a convenience contract that simplifies the process of providing liquidity to the Satoshi Perps protocol. It handles ETH wrapping/unwrapping and token routing to make liquidity provision more user-friendly.Contract Overview
The SlpManagerRouter handles:- Adding liquidity to the protocol using ETH
- Adding liquidity using ERC20 tokens
- Removing liquidity with option to receive ETH
- Routing liquidity operations to the SlpManager
The SlpManagerRouter primarily serves as a user-friendly interface on top of the SlpManager contract.
Key Functions
Adding Liquidity
Removing Liquidity
ETH Handling
The SlpManagerRouter automatically handles the conversion between ETH and WETH:-
When a user calls
addLiquidityETH()
, the router:- Receives the ETH
- Wraps it to WETH using the WETH contract’s
deposit()
function - Approves the SlpManager to use the WETH
- Calls the SlpManager’s
addLiquidity()
function
-
When a user calls
removeLiquidityETH()
, the router:- Calls the SlpManager’s
removeLiquidity()
function to get WETH - Unwraps the WETH to ETH using the WETH contract’s
withdraw()
function - Transfers the ETH to the user’s specified receiver address
- Calls the SlpManager’s
Integration with SlpManager
The SlpManagerRouter works as a thin wrapper around the SlpManager:Security Considerations
The SlpManagerRouter implements several security features:- Slippage Protection: Uses minimum output parameters to protect users
- Direct Transfers: Transfers tokens directly to the specified receiver
- Reentrancy Prevention: Follows checks-effects-interactions pattern
- Access Control: Only allows authorized operations
While the SlpManagerRouter handles ETH conversions, all the core liquidity logic remains in the SlpManager contract.
Example Usage
1
Adding Liquidity with ETH
A user wants to provide 5 ETH as liquidity to the protocol.
2
Removing Liquidity to ETH
Later, the user wants to withdraw their liquidity and receive ETH.
Benefits of Using the Router
Using the SlpManagerRouter provides several benefits over interacting directly with the SlpManager:- Simplified UX: Users can interact using native ETH without manually wrapping/unwrapping
- Gas Efficiency: Combines multiple transactions into a single operation
- Easier Integration: Frontends and dApps can provide a more streamlined experience
When using the router, be aware that the actual liquidity operations are still subject to the rules of the SlpManager, including any cooldown periods for withdrawals.