// SPDX-License-Identifier: UNLICENSED
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 ExampleVaultIntegration {
using SafeERC20 for IERC20;
/// @notice the iBGT vault.
InfraredVault private immutable _ibgtVault;
/// @notice iBGT token.
IERC20 private immutable _ibgtToken;
/**
* @notice Construct the ExampleVaultIntegration contract.
* @param ibgtVault address The address of the iBGT vault.
* @param ibgtToken address The address of the iBGT token.
*/
constructor(address ibgtVault, address ibgtToken) {
_ibgtVault = InfraredVault(ibgtVault);
_ibgtToken = IERC20(ibgtToken);
_ibgtToken.approve(address(_ibgtVault), type(uint256).max);
}
/**
* @notice Deposit iBGT tokens to the vault.
* @param amount uint256 The amount of iBGT tokens to deposit.
*/
function deposit(uint256 amount) external {
/// require that the user has approved the contract to spend their iBGT tokens.
_ibgtToken.safeTransferFrom(msg.sender, address(this), amount);
/// deposit the iBGT tokens to the vault.
_ibgtVault.stake(amount);
/// *** Additional logic can be added here *** ///
}
/**
* @notice Withdraw iBGT tokens from the vault.
* @param amount uint256 The amount of iBGT tokens to withdraw.
*/
function withdraw(uint256 amount) external {
/// withdraw the iBGT tokens from the vault.
_ibgtVault.withdraw(amount);
/// transfer the iBGT tokens to the user.
_ibgtToken.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.
_ibgtVault.getReward();
/// *** Additional logic can be added here *** ///
}
/**
* @notice Harvest rewards from the vault.
*/
function compoundRewards() external {
uint256 balance = _ibgtToken.balanceOf(address(this));
if (balance > 0) {
/// deposit the iBGT tokens to the vault.
_ibgtVault.stake(balance);
} else {
revert("No rewards to compound");
}
}
}