Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAO vote 2: Incentives, deprecate PSMs, holding PCV deposits, agEUR redeem #922

Merged
merged 149 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
fbad5df
Add AURA locker contract
eswak Jun 2, 2022
e0befcf
add initialize function
eswak Jun 2, 2022
6f56d32
deploy AURA airdrop claimer contract
eswak Jun 6, 2022
b680a68
Merge remote-tracking branch 'origin/develop' into feat/aura-locker
eswak Jun 6, 2022
83ec87b
feat: initial commit
thomas-waite Jun 16, 2022
426df3a
feat: update standard fip template
thomas-waite Jun 16, 2022
17f9e5f
feat: withdraw TRIBE from various and send to core
thomas-waite Jun 16, 2022
b29336f
refactor: use the DAO to pull from TribalChief
thomas-waite Jun 16, 2022
61e3b82
feat: harvest staking token wrappers
thomas-waite Jun 20, 2022
89c7af1
refactor: harvest all STWs and withdraw more from votium
thomas-waite Jun 20, 2022
8914779
feat: pull from other votium, add validation
thomas-waite Jun 20, 2022
1048638
feat: change Aave incencentives controller proxy admin
thomas-waite Jun 20, 2022
a463428
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 20, 2022
1172404
feat: extract excess Rari TRIBE rewards
thomas-waite Jun 20, 2022
576ad46
feat: revoke unneeded roles and deprecate contracts
thomas-waite Jun 20, 2022
2a7e69f
refactor: minor touchups
thomas-waite Jun 20, 2022
99e8fc9
refactor: check final tribe balance
thomas-waite Jun 20, 2022
8b9c21f
refactor: keep TRIBE in timelock, already harvest
thomas-waite Jun 20, 2022
d103dbe
refactor: perform on-chain harvests, update
thomas-waite Jun 20, 2022
00fbf62
docs: update proposal description
thomas-waite Jun 20, 2022
d4a8350
Merge remote-tracking branch 'origin/develop' into feat/aura-locker
eswak Jun 21, 2022
8a1f13e
wip - need to redeploy impl & upgrade proxy
eswak Jun 21, 2022
eb91028
refactor: verify pending rewards zero, account for latest harvest
thomas-waite Jun 21, 2022
5418dcd
refactor: more conservative on pulling Fuse rewards
thomas-waite Jun 21, 2022
8eba3dc
feat: add ERC20Holding PCV Deposit contract
thomas-waite Jun 22, 2022
1f247cf
feat: add deploy script for holding deposits
thomas-waite Jun 22, 2022
3e8f219
feat: add holding pcv deposit validation
thomas-waite Jun 22, 2022
5cb431d
refactor: touchups
thomas-waite Jun 23, 2022
92d2a4d
Add proposal to redeem all agEUR
eswak Jun 23, 2022
2ca3fdb
test: add unit tests for ERC20Holding
thomas-waite Jun 23, 2022
7af96a3
test: add withdrawal tests
thomas-waite Jun 23, 2022
1423b6c
Merge branch 'feat/cleanup-cr-oracle' into feat/empty-pcv-deposits
thomas-waite Jun 23, 2022
e86046d
refactor: combine both proposals
thomas-waite Jun 23, 2022
24f912a
refactor: account for Tokemak withdrawal having occurred
thomas-waite Jun 23, 2022
c412101
feat: implement withdraw method, add events
thomas-waite Jun 23, 2022
e4e6a79
test: add integration test for Fei balance and wrapping
thomas-waite Jun 24, 2022
d1b8aa3
test: complete tests
thomas-waite Jun 24, 2022
7cfbedf
Merge branch 'develop' into feat/empty-pcv-deposits
thomas-waite Jun 27, 2022
42bd13f
test: fix all tests
thomas-waite Jun 27, 2022
573a79c
feat: break out into seperate TC action
thomas-waite Jun 27, 2022
6cc1cf9
revoke roles from psms and pause
thomas-waite Jun 27, 2022
a87c58f
test: add psm validations
thomas-waite Jun 27, 2022
c09390b
feat: transfer funds off the psm
thomas-waite Jun 27, 2022
8ff2362
feat: pause drip controllers
thomas-waite Jun 27, 2022
3257c55
Merge remote-tracking branch 'origin/develop' into feat/tip110-angle
eswak Jun 27, 2022
5d1c81a
refactor: fix validations
thomas-waite Jun 27, 2022
ce7f3ba
test: fix eth test
thomas-waite Jun 27, 2022
bcd53a2
feat: unset PSMs as safe addresses
thomas-waite Jun 27, 2022
c8752ea
additional checks
eswak Jun 27, 2022
b36d84d
feat: add new deposits to CR
thomas-waite Jun 27, 2022
16cd275
feat: remove RAI holding deposit
thomas-waite Jun 27, 2022
7b4b7fb
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 27, 2022
018673a
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 27, 2022
c06dd03
Merge branch 'deprecate-incentives' of https://github.com/fei-protoco…
thomas-waite Jun 28, 2022
efe1aa0
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 28, 2022
e4f57e7
deps: update block num, clear out config
thomas-waite Jun 28, 2022
a53546a
Merge branch 'deprecate-incentives' into feat/empty-pcv-deposits
thomas-waite Jun 28, 2022
2c246fd
feat: pause ETH PSM, update WETH transfer
thomas-waite Jun 28, 2022
7ca0882
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 28, 2022
d2865bb
Merge agEUR redeem into deprecate_incentives
eswak Jun 28, 2022
8c6b092
test: remove unneeded psm tests
thomas-waite Jun 28, 2022
2a7d274
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 28, 2022
69c2559
refactor: remove RAI from CR
thomas-waite Jun 28, 2022
554772d
feat: set new deposits as safe addresses
thomas-waite Jun 28, 2022
d774d7b
feat: deprecate skimmers
thomas-waite Jun 28, 2022
641de87
test: remove unneeded psm e2e tests
thomas-waite Jun 28, 2022
8f0784f
feat: grant DAI skimmer role and burn fei
thomas-waite Jun 28, 2022
eff85cb
rework proposal to execute in next dao vote
eswak Jun 28, 2022
0207ae4
feat: move gOHM and VOLT from DAO timelock
thomas-waite Jun 28, 2022
e658a45
build: reduce test parallelism
thomas-waite Jun 28, 2022
6602988
refactor: various tidying up - deposits and CR
thomas-waite Jun 28, 2022
772fcff
feat: disallow FEI and use wrapETH() in tests
thomas-waite Jun 29, 2022
6342473
refactor: deprecate aave eth wrapper
thomas-waite Jun 29, 2022
af42cb2
test: make tests pass, account for existing eth
thomas-waite Jun 29, 2022
37779fc
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 29, 2022
cc39769
Merge branch 'deprecate-incentives' into feat/empty-pcv-deposits
thomas-waite Jun 29, 2022
168f1d8
refactor: remove unused deposits from CR
thomas-waite Jun 29, 2022
1120e74
feat: volt deposit wrapper commit
thomas-waite Jun 29, 2022
b61b54b
docs: update proposal description
thomas-waite Jun 29, 2022
3a2d500
Merge pull request #930 from fei-protocol/feat/empty-pcv-deposits
thomas-waite Jun 29, 2022
4026cfd
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 29, 2022
a57d189
move agEUR redemption to tip_118 proposal
eswak Jun 29, 2022
a0345e6
feat: combine deprec incentives and tip_118
thomas-waite Jun 30, 2022
b2623f3
refactor: remove pause call to ethPSM
thomas-waite Jun 30, 2022
eeeae8a
feat: add pause state config
thomas-waite Jun 30, 2022
40c8c98
refactor: loosen TRIB recovery figures
thomas-waite Jun 30, 2022
1fd1d8b
test: e2e tests for pause state
thomas-waite Jun 30, 2022
6839611
docs: remove comments
thomas-waite Jun 30, 2022
dd3fa37
tom's review (1/2)
eswak Jun 30, 2022
ee43d55
test: add custom revert messages
thomas-waite Jun 30, 2022
b89ba4a
ci: increase num workers
thomas-waite Jun 30, 2022
f87074b
Merge pull request #945 from fei-protocol/pause-tests
thomas-waite Jun 30, 2022
557d829
add e2e test file for AngleEuroRedeemer
eswak Jun 30, 2022
ada90b6
add e2e tests for agEUR recovery & access control
eswak Jun 30, 2022
b9356f4
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 30, 2022
0fbcfc4
update tip_118 dai redeemed check amount
eswak Jun 30, 2022
6e25ba6
deps: add deployed mainnet addresses
thomas-waite Jun 30, 2022
3e85fcf
deps: update block number
thomas-waite Jun 30, 2022
2cc1777
Merge branch 'develop' into deprecate-incentives
thomas-waite Jun 30, 2022
e2fce1f
style: update naming to match mainnetAddresses
thomas-waite Jun 30, 2022
88d1f50
fix: correct dai holding deposit address
thomas-waite Jun 30, 2022
908e672
try to solve revert issue
eswak Jun 30, 2022
e6087a9
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 30, 2022
d05bb88
make oracles fresh in proposal setup
eswak Jun 30, 2022
fa1814e
Deploy angleEuroRedeemer
eswak Jun 30, 2022
932eac9
update block after deploy
eswak Jun 30, 2022
8060165
read pcv stats at the end of setup step
eswak Jun 30, 2022
86dade8
Merge pull request #932 from fei-protocol/feat/tip110-angle
eswak Jun 30, 2022
9da309f
Merge remote-tracking branch 'origin/deprecate-incentives' into feat/…
eswak Jun 30, 2022
0379984
make token immutable in DelegatorPCVDeposit
eswak Jun 30, 2022
98eb881
Revert "make token immutable in DelegatorPCVDeposit"
eswak Jun 30, 2022
1a83990
docs: update reward comment
thomas-waite Jun 30, 2022
651c7d4
deploy vlAuraDelegatorPCVDepositImplementation
eswak Jul 1, 2022
10aebf1
update block after deploy
eswak Jul 1, 2022
5ae93c9
Merge branch 'deprecate-incentives' into feat/aura-locker
eswak Jul 4, 2022
c42f02e
Merge pull request #873 from fei-protocol/feat/aura-locker
eswak Jul 4, 2022
2033b63
update block to be after lbp
eswak Jul 4, 2022
fd61897
fix proposal validate checks
eswak Jul 4, 2022
8a76ba8
refactor: consolidate set safe addresses, remove deposit calls
thomas-waite Jul 4, 2022
0ace7d5
docs: update text
thomas-waite Jul 4, 2022
de8bb6b
feat: unset more safe addresses, deprecate contracts
thomas-waite Jul 5, 2022
353f812
docs: update title
thomas-waite Jul 5, 2022
5ecdb51
refactor: safe address validation, re-unset rai psm
thomas-waite Jul 5, 2022
5a5b4b6
Merge branch 'develop' into deprecate-incentives
thomas-waite Jul 5, 2022
1f5713a
feat: remove more safe addresses
thomas-waite Jul 5, 2022
d78f1ed
feat: tighten DAI PSM redemption spread
thomas-waite Jul 5, 2022
9b27fb1
test: remove now deprecated e2e
thomas-waite Jul 5, 2022
4bd52bf
test: account for Fei deposits in equity check
thomas-waite Jul 5, 2022
9b576bd
refactor: update CR config and e2e tests
thomas-waite Jul 5, 2022
b72a2fc
docs: update fei burn comment
thomas-waite Jul 5, 2022
581d9f1
Merge branch 'develop' into deprecate-incentives
Jul 5, 2022
8111c05
refactor: increase unit test runners
thomas-waite Jul 6, 2022
32d7e54
Merge branch 'deprecate-incentives' of https://github.com/fei-protoco…
thomas-waite Jul 6, 2022
029ef38
deps: update block num
thomas-waite Jul 6, 2022
5f91b60
docs: add comments to constants in DAO vote
thomas-waite Jul 6, 2022
0bdc2f7
refactor: loosen DAI agEUR slippage check
thomas-waite Jul 6, 2022
32e805d
docs: add forum post and code to proposal
thomas-waite Jul 6, 2022
a3313c4
refactor: reduce check to 8M, order of magnitude
thomas-waite Jul 6, 2022
cfffff7
test: trigger CI run and log address
thomas-waite Jul 6, 2022
6100eae
refactor: remove .only
thomas-waite Jul 6, 2022
5f29a06
klob's tip-118 review
eswak Jul 6, 2022
39f76d1
Merge branch 'deprecate-incentives' of github.com:fei-protocol/fei-pr…
eswak Jul 6, 2022
f66b0f0
docs: cleanup DAO proposal
thomas-waite Jul 6, 2022
7e7e113
Merge branch 'deprecate-incentives' of https://github.com/fei-protoco…
thomas-waite Jul 6, 2022
0e1fca5
Update Angle artifact names in mainnetAddresses
eswak Jul 6, 2022
d96810b
Merge branch 'deprecate-incentives' of github.com:fei-protocol/fei-pr…
eswak Jul 6, 2022
8a1e55a
test: account for any eth already at test address
thomas-waite Jul 6, 2022
ba920bf
refactor: explicitly determine overloaded propose method
thomas-waite Jul 6, 2022
847de09
test: sort out initial eth balance
thomas-waite Jul 6, 2022
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
e2e-test:
working_directory: ~/repo
executor: nodeimage
parallelism: 19
parallelism: 17
steps:
- attach_workspace:
at: ./
Expand Down
2 changes: 1 addition & 1 deletion block.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15039959
15089978
71 changes: 71 additions & 0 deletions contracts/metagov/DelegatorPCVDeposit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../core/TribeRoles.sol";
import "../pcv/PCVDeposit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";

/// @title Delegator PCV Deposit
/// This contract simply holds an ERC20 token, and delegate its voting power
/// to an address. The ERC20 token needs to implement a delegate(address) method.
/// @author eswak
contract DelegatorPCVDeposit is PCVDeposit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until I got to the part where the metagovernance role was used, I didn't realize this contract was for that purpose and not just a standard erc20 delegation contract. Should we change the name to reflect that this contract's purpose is to be used for metagovernance?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what should change here, a comment or the artifact name ? We use "Delegator" in the name for all contracts that call erc20vote.delegate() and other than that it's a very simple pcv deposit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Artifact name (delegating normal votes vs using for metagovernance is the confusing part)

using SafeERC20 for IERC20;

event DelegateUpdate(address indexed oldDelegate, address indexed newDelegate);

/// @notice the token that is being used for voting
ERC20Votes public token;

/// @notice the snapshot delegate for the deposit
address public delegate;

/// @notice Delegator PCV Deposit constructor
/// @param _core Fei Core for reference
/// @param _token token to custody and delegate with
/// @param _initialDelegate the initial delegate
constructor(
address _core,
address _token,
address _initialDelegate
) CoreRef(_core) {
token = ERC20Votes(_token);
if (_initialDelegate != address(0)) _delegate(_initialDelegate);
}

/// @notice withdraw tokens from the PCV allocation
/// @param amount of tokens withdrawn
/// @param to the address to send PCV to
function withdraw(address to, uint256 amount) external virtual override onlyPCVController {
IERC20(token).safeTransfer(to, amount);
emit Withdrawal(msg.sender, to, amount);
}

/// @notice no-op
function deposit() external override {}

/// @notice returns total balance of PCV in the Deposit
function balance() public view virtual override returns (uint256) {
return token.balanceOf(address(this));
}

/// @notice display the related token of the balance reported
function balanceReportedIn() public view override returns (address) {
return address(token);
}

/// @notice sets the snapshot delegate
/// @dev callable by governor or admin
function setDelegate(address newDelegate) external onlyTribeRole(TribeRoles.METAGOVERNANCE_VOTE_ADMIN) {
_delegate(newDelegate);
}

function _delegate(address newDelegate) internal {
address oldDelegate = delegate;
delegate = newDelegate;

token.delegate(delegate);

emit DelegateUpdate(oldDelegate, newDelegate);
}
}
140 changes: 140 additions & 0 deletions contracts/metagov/VlAuraDelegatorPCVDeposit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "../core/TribeRoles.sol";
import "./DelegatorPCVDeposit.sol";

interface IAuraLocker {
struct LockedBalance {
uint112 amount;
uint32 unlockTime;
}
struct EarnedData {
address token;
uint256 amount;
}

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

function lock(address _account, uint256 _amount) external;

function getReward(address _account, bool _stake) external;

function processExpiredLocks(bool _relock) external;

function emergencyWithdraw() external;

function delegates(address account) external view returns (address);

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

function lockedBalances(address _user)
external
view
returns (
uint256 total,
uint256 unlockable,
uint256 locked,
LockedBalance[] memory lockData
);

function claimableRewards(address _account) external view returns (EarnedData[] memory userRewards);

function notifyRewardAmount(address _rewardsToken, uint256 _reward) external;
}

interface IAuraMerkleDrop {
function claim(
bytes32[] calldata _proof,
uint256 _amount,
bool _lock
) external returns (bool);
}

/// @title Vote-locked AURA PCVDeposit
/// This contract is a derivative of the DelegatorPCVDeposit contract, that performs an
/// on-chain delegation. This contract is meant to hold AURA and vlAURA tokens, and allow
/// locking of AURA to vlAURA and renew vlAURA locks, or exit vlAURA locks to get back
/// liquid AURA. This contract can also claim vlAURA rewards.
/// The first version of this contract also allows claiming of the AURA airdrop.
/// @author eswak
contract VlAuraDelegatorPCVDeposit is DelegatorPCVDeposit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the description of this contract to provide more context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

using SafeERC20 for IERC20;

address public aura;
address public auraLocker;
address public auraMerkleDrop;

/// @notice constructor
/// @param _core Fei Core for reference
constructor(address _core)
DelegatorPCVDeposit(
_core,
address(0), // token
address(0) // initialDelegate
)
{}

// At deploy time, Aura Protocol wasn't live yet, so we need to set the
// contract addresses manually, not in the constructor.
function initialize(
address _aura,
address _auraLocker,
address _auraMerkleDrop
) external {
require(
aura == address(0) ||
auraLocker == address(0) ||
auraMerkleDrop == address(0) ||
address(token) == address(0),
"initialized"
);

aura = _aura;
auraLocker = _auraLocker;
auraMerkleDrop = _auraMerkleDrop;
token = ERC20Votes(_auraLocker);
}

/// @notice noop, vlAURA can't be transferred.
/// wait for lock expiry, and call withdrawERC20 on AURA.
function withdraw(address, uint256) external override {}

/// @notice returns the balance of locked + unlocked
function balance() public view virtual override returns (uint256) {
return IERC20(aura).balanceOf(address(this)) + IERC20(auraLocker).balanceOf(address(this));
}

/// @notice claim AURA airdrop and vote-lock it for 16 weeks
/// this function is not access controlled & can be called by anyone.
function claimAirdropAndLock(bytes32[] calldata _proof, uint256 _amount) external returns (bool) {
return IAuraMerkleDrop(auraMerkleDrop).claim(_proof, _amount, true);
}

/// @notice lock AURA held on this contract to vlAURA
function lock() external whenNotPaused onlyTribeRole(TribeRoles.METAGOVERNANCE_TOKEN_STAKING) {
uint256 amount = IERC20(aura).balanceOf(address(this));
IERC20(aura).safeApprove(auraLocker, amount);
IAuraLocker(auraLocker).lock(address(this), amount);
}

/// @notice refresh lock after it has expired
function relock() external whenNotPaused onlyTribeRole(TribeRoles.METAGOVERNANCE_TOKEN_STAKING) {
IAuraLocker(auraLocker).processExpiredLocks(true);
}

/// @notice exit lock after it has expired
function unlock() external whenNotPaused onlyTribeRole(TribeRoles.METAGOVERNANCE_TOKEN_STAKING) {
IAuraLocker(auraLocker).processExpiredLocks(false);
}

/// @notice emergency withdraw if system is shut down
function emergencyWithdraw() external whenNotPaused onlyTribeRole(TribeRoles.METAGOVERNANCE_TOKEN_STAKING) {
IAuraLocker(auraLocker).emergencyWithdraw();
}

/// @notice get rewards & stake them (rewards claiming is permissionless)
function getReward() external {
IAuraLocker(auraLocker).getReward(address(this), true);
}
}
66 changes: 66 additions & 0 deletions contracts/pcv/ERC20HoldingPCVDeposit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {PCVDeposit} from "./PCVDeposit.sol";
import {CoreRef} from "../refs/CoreRef.sol";
import {Constants} from "../Constants.sol";

/// @title ERC20HoldingPCVDeposit
/// @notice PCVDeposit that is used to hold ERC20 tokens as a safe harbour. Deposit is a no-op
contract ERC20HoldingPCVDeposit is PCVDeposit {
using SafeERC20 for IERC20;

/// @notice Token which the balance is reported in
IERC20 immutable token;

/// @notice Fei ERC20 token address
address private constant FEI = 0x956F47F50A910163D8BF957Cf5846D573E7f87CA;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer that we not inline this and use CoreRef instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was approved and deployed in this PR: #930

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to use CoreRef, but don't think it warrants making a change now and redeploying


constructor(address _core, IERC20 _token) CoreRef(_core) {
require(address(_token) != FEI, "FEI not supported");
token = _token;
}

/// @notice Empty receive function to receive ETH
receive() external payable {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add fallback as well to catch all use cases of sending eth to this contract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What use case of sending eth to this contract would a receive() function not handle, but a fallback would?

Copy link
Contributor

@kryptoklob kryptoklob Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallback handles contract calls that don't match any function, receive() only handles transfers


/////// READ-ONLY Methods /////////////

/// @notice returns total balance of PCV in the deposit
function balance() public view override returns (uint256) {
return token.balanceOf(address(this));
}

/// @notice returns the resistant balance and FEI in the deposit
function resistantBalanceAndFei() public view override returns (uint256, uint256) {
return (balance(), 0);
}

/// @notice display the related token of the balance reported
function balanceReportedIn() public view override returns (address) {
return address(token);
}

/// @notice No-op deposit
function deposit() external override whenNotPaused {
emit Deposit(msg.sender, balance());
}

/// @notice Withdraw underlying
/// @param amountUnderlying of tokens withdrawn
/// @param to the address to send PCV to
function withdraw(address to, uint256 amountUnderlying) external override onlyPCVController whenNotPaused {
token.safeTransfer(to, amountUnderlying);
emit Withdrawal(msg.sender, to, amountUnderlying);
}

/// @notice Wraps all ETH held by the contract to WETH. Permissionless, anyone can call it
function wrapETH() public {
uint256 ethBalance = address(this).balance;
if (ethBalance != 0) {
Constants.WETH.deposit{value: ethBalance}();
}
}
}
Loading