-
Notifications
You must be signed in to change notification settings - Fork 74
/
Strategy.sol
46 lines (39 loc) · 2.28 KB
/
Strategy.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
import {ERC20} from "solmate/tokens/ERC20.sol";
/// @notice Minimal interface for Vault compatible strategies.
/// @dev Designed for out of the box compatibility with Fuse cTokens.
/// @dev Like cTokens, strategies must be transferrable ERC20s.
abstract contract Strategy is ERC20 {
/// @notice Returns whether the strategy accepts ETH or an ERC20.
/// @return True if the strategy accepts ETH, false otherwise.
/// @dev Only present in Fuse cTokens, not Compound cTokens.
function isCEther() external view virtual returns (bool);
/// @notice Withdraws a specific amount of underlying tokens from the strategy.
/// @param amount The amount of underlying tokens to withdraw.
/// @return An error code, or 0 if the withdrawal was successful.
function redeemUnderlying(uint256 amount) external virtual returns (uint256);
/// @notice Returns a user's strategy balance in underlying tokens.
/// @param user The user to get the underlying balance of.
/// @return The user's strategy balance in underlying tokens.
/// @dev May mutate the state of the strategy by accruing interest.
function balanceOfUnderlying(address user) external virtual returns (uint256);
}
/// @notice Minimal interface for Vault strategies that accept ERC20s.
/// @dev Designed for out of the box compatibility with Fuse cERC20s.
abstract contract ERC20Strategy is Strategy {
/// @notice Returns the underlying ERC20 token the strategy accepts.
/// @return The underlying ERC20 token the strategy accepts.
function underlying() external view virtual returns (ERC20);
/// @notice Deposit a specific amount of underlying tokens into the strategy.
/// @param amount The amount of underlying tokens to deposit.
/// @return An error code, or 0 if the deposit was successful.
function mint(uint256 amount) external virtual returns (uint256);
}
/// @notice Minimal interface for Vault strategies that accept ETH.
/// @dev Designed for out of the box compatibility with Fuse cEther.
abstract contract ETHStrategy is Strategy {
/// @notice Deposit a specific amount of ETH into the strategy.
/// @dev The amount of ETH is specified via msg.value. Reverts on error.
function mint() external payable virtual;
}