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.
A user wants to provide liquidity to the protocol.
Copy
// Amount of WETH to provide as liquidityconst liquidityAmount = ethers.utils.parseEther("10");// Approve SlpManager to use WETHawait weth.approve(slpManagerAddress, liquidityAmount);// Add liquidityawait slpManager.addLiquidity( wethAddress, // Token to provide liquidityAmount, // Amount to provide ethers.utils.parseEther("9.5"), // Minimum USDG to receive ethers.utils.parseEther("9.5") // Minimum SLP to receive (5% slippage));
2
Checking SLP Value
The user checks the value of their SLP tokens after some time.
Copy
// Get SLP priceconst slpPrice = await slpManager.getPrice(true);// Get user's SLP balanceconst slpBalance = await slpToken.balanceOf(userAddress);// Calculate value in USDconst valueInUsd = slpPrice.mul(slpBalance).div(ethers.utils.parseEther("1"));
3
Removing Liquidity
Later, the user decides to withdraw their liquidity.
Copy
// Amount of SLP tokens to redeemconst slpAmount = await slpToken.balanceOf(userAddress);// Remove liquidityawait slpManager.removeLiquidity( wethAddress, // Token to receive slpAmount, // SLP amount to burn ethers.utils.parseEther("9.5"), // Minimum WETH to receive (5% slippage) userAddress // Receiver address);