Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contracts/pcv/compound/CErc20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity =0.8.13;

interface CErc20 {
function mint(uint256 amount) external returns (uint256);

function underlying() external returns (address);
}
13 changes: 13 additions & 0 deletions contracts/pcv/compound/CToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma solidity =0.8.13;

interface CToken {
function redeemUnderlying(uint256 redeemAmount) external returns (uint256);

function exchangeRateStored() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);

function isCToken() external view returns (bool);

function isCEther() external view returns (bool);
}
26 changes: 7 additions & 19 deletions contracts/pcv/compound/CompoundPCVDepositBase.sol
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
pragma solidity =0.8.13;

import "../PCVDeposit.sol";
import "../../refs/CoreRef.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

interface CToken {
function redeemUnderlying(uint256 redeemAmount) external returns (uint256);

function exchangeRateStored() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);

function isCToken() external view returns (bool);

function isCEther() external view returns (bool);
}
import {PCVDeposit} from "../PCVDeposit.sol";
import {CoreRef} from "../../refs/CoreRef.sol";
import {CToken} from "./CToken.sol";

/// @title base class for a Compound PCV Deposit
/// @author Fei Protocol
abstract contract CompoundPCVDepositBase is PCVDeposit {
CToken public cToken;
CToken public immutable cToken;

uint256 private constant EXCHANGE_RATE_SCALE = 1e18;

/// @notice Compound PCV Deposit constructor
/// @param _core Fei Core for reference
/// @param _core Volt Core for reference
/// @param _cToken Compound cToken to deposit
constructor(address _core, address _cToken) CoreRef(_core) {
cToken = CToken(_cToken);
Expand All @@ -49,7 +37,7 @@ abstract contract CompoundPCVDepositBase is PCVDeposit {
emit Withdrawal(msg.sender, to, amountUnderlying);
}

/// @notice returns total balance of PCV in the Deposit excluding the FEI
/// @notice returns total balance of PCV in the Deposit excluding the VOLT
/// @dev returns stale values from Compound if the market hasn't been updated
function balance() public view override returns (uint256) {
uint256 exchangeRate = cToken.exchangeRateStored();
Expand Down
15 changes: 6 additions & 9 deletions contracts/pcv/compound/ERC20CompoundPCVDeposit.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "./CompoundPCVDepositBase.sol";

interface CErc20 {
function mint(uint256 amount) external returns (uint256);

function underlying() external returns (address);
}
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CompoundPCVDepositBase} from "./CompoundPCVDepositBase.sol";
import {CErc20} from "./CErc20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title ERC-20 implementation for a Compound PCV Deposit
/// @author Fei Protocol
contract ERC20CompoundPCVDeposit is CompoundPCVDepositBase {
/// @notice the token underlying the cToken
IERC20 public token;
IERC20 public immutable token;

/// @notice Compound ERC20 PCV Deposit constructor
/// @param _core Fei Core for reference
/// @param _core Volt Core for reference
/// @param _cToken Compound cToken to deposit
constructor(address _core, address _cToken)
CompoundPCVDepositBase(_core, _cToken)
Expand Down