LayerCover

IYieldAdapter

Interface for integrating new yield sources (e.g., Aave, Compound).

View deployed contract addresses in the Contract Addresses section.

The IYieldAdapter is the standard interface for connecting external yield protocols to the LayerCover system. Developers can implement this interface to create new strategies for the CapitalPool.

Interface

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IYieldAdapter {
    /**
     * @notice Returns the underlying ERC20 asset that this adapter primarily manages.
     */
    function asset() external view returns (IERC20);

    /**
     * @notice Deposits a specified amount of the underlying asset from the caller (e.g., CoverPool)
     * into the yield strategy.
     * @dev Caller must have approved this adapter contract to spend its tokens.
     */
    function deposit(uint256 _amountToDeposit) external;

    /**
     * @notice Withdraws a specified value of the underlying asset from the strategy to a recipient.
     * @dev Caller is typically the CoverPool contract.
     * @return actuallyWithdrawn The amount of underlying asset actually withdrawn.
     */
    function withdraw(uint256 _targetAmountOfUnderlyingToWithdraw, address _to) external returns (uint256 actuallyWithdrawn);

    /**
     * @notice Returns the current total market value of the underlying asset managed by this adapter
     * specifically for the caller (e.g., CoverPool contract, which is msg.sender).
     */
    function getCurrentValueHeld() external view returns (uint256 currentValue);

    /**
     * @notice Emergency function to transfer assets out of the adapter
     * @dev Only callable by authorized admin in emergency situations
     * @param recipient Address to receive the transferred assets
     * @param amount Amount of underlying asset to transfer
     * @return The actual amount transferred
     */
    function emergencyTransfer(address recipient, uint256 amount) external returns (uint256);

}```

## Interface

```solidity
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title IYieldAdapter
 * @notice Interface for yield strategy adapters used by the protocol capital layer.
 */
interface IYieldAdapter {
    /**
     * @notice Returns the underlying ERC20 asset that this adapter primarily manages.
     */
    function asset() external view returns (IERC20);

    /**
     * @notice Deposits a specified amount of the underlying asset from the caller (e.g., CoverPool)
     * into the yield strategy.
     * @dev Caller must have approved this adapter contract to spend its tokens.
     */
    function deposit(uint256 _amountToDeposit) external;

    /**
     * @notice Withdraws a specified value of the underlying asset from the strategy to a recipient.
     * @dev Caller is typically the CoverPool contract.
     * @return actuallyWithdrawn The amount of underlying asset actually withdrawn.
     */
    function withdraw(uint256 _targetAmountOfUnderlyingToWithdraw, address _to) external returns (uint256 actuallyWithdrawn);


    /**
     * @notice Returns the current total market value of the underlying asset managed by this adapter
     * specifically for the caller (e.g., CoverPool contract, which is msg.sender).
     */
    function getCurrentValueHeld() external view returns (uint256 currentValue);

    function emergencyTransfer(address recipient, uint256 amount) external returns (uint256);

}