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

Compound Filter #209

Merged
merged 7 commits into from
Mar 5, 2021
Merged

Compound Filter #209

merged 7 commits into from
Mar 5, 2021

Conversation

juniset
Copy link
Member

@juniset juniset commented Mar 4, 2021

This PR adds support for lending with Compound by:

  • adding the CompoundFilter
  • adding tests to confirm minting and redeeming cTokens


import "./IFilter.sol";

contract CompoundFilter is IFilter {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that the only method that needs to be forbidden is repayBorrowBehalf. Everything else is safe to allow (note that ERC20 methods of cToken will be caught in recoverSpender and do not need to be forbidden here). In particular why not allow borrow, repayBorrow, redeemUnderlying?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed for the CToken methods, we should only block reapyBorrowBehalf.

However I believe ERC20 token methods where the spender is the cToken (i.e. the ones which will end up in the filter) must be blocked because you want to prevent e.g. a transfer of DAI to cBAT. So dai.transfer(cBAT, 1000) must be blocked. The only one we should accept is an approve on the underlying to allow minting, i.e. dai.approve(cDAI,1000) .


function isValid(address _wallet, address _spender, address _to, bytes calldata _data) external view override returns (bool) {
// disable ETH transfer
if (_data.length < 4) {
Copy link
Contributor

@olivdb olivdb Mar 4, 2021

Choose a reason for hiding this comment

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

We could create the filter with a constructor parameter indicating whether this is a cErc20 or a cEther. For a cEther filter, it would be nice to enable ETH transfers (which invoke cEther's fallback) to enable deposits via simple ETH transfers.

Base automatically changed from experiment/minimal-wallet to develop March 4, 2021 16:13
@juniset juniset merged commit 8cacec9 into develop Mar 5, 2021
@elenadimitrova elenadimitrova deleted the minimal-wallet/compound branch March 19, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants