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

Lido filter #213

Merged
merged 14 commits into from
Mar 17, 2021
Merged

Lido filter #213

merged 14 commits into from
Mar 17, 2021

Conversation

elenadimitrova
Copy link
Contributor

@elenadimitrova elenadimitrova commented Mar 9, 2021

Adds DappRegistry Filter for staking in Lido as well as selling stETH via Curve. Additionally we introduce integration testing using a mainnet fork.

import "./BaseFilter.sol";

contract LidoFilter is BaseFilter {
bytes4 private constant DEPOSIT = bytes4(keccak256("depositBufferedEther()"));
Copy link
Contributor

Choose a reason for hiding this comment

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

The method that we want to approve is the payable submit(address) method. depositBufferedEther() is used by Lido keepers to periodically move the ETH deposited via submit to the ETH2 deposit 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.

I have added explicit calls to submit it in addition to the fallback which implicitly calls it as well.

if (_data.length == 0) {
return true;
}
if(_spender == _to) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably need to add && _data.length >= 4 here since getMethod doesn't do that check

@elenadimitrova elenadimitrova marked this pull request as ready for review March 10, 2021 11:42
bytes4 private constant SUBMIT = bytes4(keccak256("submit(address)"));

function isValid(address /*_wallet*/, address _spender, address _to, bytes calldata _data) external view override returns (bool) {
// Allow sending ETH as well as calls to send(address)
Copy link
Contributor

Choose a reason for hiding this comment

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

send(address) -> submit(address) ?

Base automatically changed from minimal-wallet/defi-filters to develop March 11, 2021 10:48
@elenadimitrova elenadimitrova force-pushed the feature/lido-filter branch 3 times, most recently from a38b785 to 8448912 Compare March 11, 2021 15:46
Copy link
Member

@juniset juniset left a comment

Choose a reason for hiding this comment

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

Shouldn't we also implement selling StETH for ETH using Curve as currently implemented in the app?

Could also be a separate PR.

return true;
}
if(_spender == _to && _data.length >= 4) {
bytes4 methodId = getMethod(_data);
Copy link
Member

Choose a reason for hiding this comment

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

Could be written as:

if(_spender == _to && _data.length >= 4) {
    return (getMethod(_data) == SUBMIT);
}

but not sure it will save anything.

@elenadimitrova elenadimitrova force-pushed the feature/lido-filter branch 2 times, most recently from 9b60db7 to d9c0972 Compare March 16, 2021 09:43
}
bytes4 methodId = getMethod(_data);
if(_spender == _to) {
return (methodId == EXCHANGE);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it is necessary, but maybe we should check that we are swapping stETH for ETH, and not the other way around. Can't imagine how it can be harmful, but our intention with this filter is to only swap stETH for ETH so we might as well enforce it in the code.

If we decide to do so (e.g. by passing the stETH address in the constructor) then we could also check that _to == stETH when the method is ERC20_APPROVE).

@elenadimitrova elenadimitrova merged commit 4bbb440 into develop Mar 17, 2021
@elenadimitrova elenadimitrova deleted the feature/lido-filter branch March 17, 2021 10:16
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.

3 participants