pragma solidity 0.8.22;
import {InfraredVault} from "@core/InfraredVault.sol";
import {IERC20, SafeERC20} from "@core/MultiRewards.sol";
import {IInfraredVault} from "@interfaces/IInfraredVault.sol";
contract ExampleLPVaultIntegration {
using SafeERC20 for IERC20;
/// @notice the LP token vault.
InfraredVault private immutable _lpVault;
/// @notice LP token.
IERC20 private immutable _lpToken;
/// @notice the iBGT vault.
InfraredVault private immutable _ibgtVault;
/// @notice the iBGT token.
IERC20 private immutable _ibgtToken;
/**
* @notice Construct the ExampleLPVaultIntegration contract.
* @param lpVault address The address of the LP token vault.
* @param lpToken address The address of the LP token.
* @param ibgtVault address The address of the iBGT vault.
* @param ibgtToken address The address of the iBGT token.
*/
constructor(address lpVault, address lpToken, address ibgtVault, address ibgtToken) {
_lpVault = InfraredVault(lpVault);
_lpToken = IERC20(lpToken);
_ibgtVault = InfraredVault(ibgtVault);
_ibgtToken = IERC20(ibgtToken);
_lpToken.approve(address(_lpVault), type(uint256).max);
}
/**
* @notice Deposit LP tokens to the vault.
* @param amount uint256 The amount of LP tokens to deposit.
*/
function deposit(uint256 amount) external {
/// require that the user has approved the contract to spend their LP tokens.
_lpToken.safeTransferFrom(msg.sender, address(this), amount);
/// deposit the LP tokens to the vault.
_lpVault.stake(amount);
/// *** Additional logic can be added here *** ///
}
/**
* @notice Withdraw LP tokens from the vault.
* @param amount uint256 The amount of LP tokens to withdraw.
*/
function withdraw(uint256 amount) external {
/// withdraw the LP tokens from the vault.
_lpVault.withdraw(amount);
/// transfer the LP tokens to the user.
_lpToken.safeTransfer(msg.sender, amount);
/// *** Additional logic can be added here *** ///
}
/**
* @notice Claim rewards from the vault.
*/
function claimRewards() external {
/// claim the rewards from the vault.
_lpVault.getReward();
/// claim the rewards from the iBGT vault.
_ibgtVault.getReward();
/// *** Additional logic can be added here *** ///
}
/**
* @notice stake iBGT tokens.
*/
function stakeIBGT() external {
uint256 balance = _ibgtToken.balanceOf(address(this));
if (balance > 0 ) {
/// deposit the iBGT tokens to the vault.
_ibgtVault.stake(balance);
} else revert ("No iBGT tokens to stake");
/// *** Additional logic can be added here *** ///
}
}