-
Notifications
You must be signed in to change notification settings - Fork 215
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
Lido filter #213
Conversation
e3d7769
to
d60824c
Compare
import "./BaseFilter.sol"; | ||
|
||
contract LidoFilter is BaseFilter { | ||
bytes4 private constant DEPOSIT = bytes4(keccak256("depositBufferedEther()")); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
d60824c
to
0bcc85a
Compare
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send(address) -> submit(address) ?
a38b785
to
8448912
Compare
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
5f03470
to
66c6192
Compare
Enable ETH transfers Add tests
9b60db7
to
d9c0972
Compare
d9c0972
to
55c7672
Compare
} | ||
bytes4 methodId = getMethod(_data); | ||
if(_spender == _to) { | ||
return (methodId == EXCHANGE); |
There was a problem hiding this comment.
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).
Adds DappRegistry Filter for staking in Lido as well as selling stETH via Curve. Additionally we introduce integration testing using a mainnet fork.