Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Use a pull model to withdraw deposit ETH balances #570

Merged
merged 14 commits into from Apr 10, 2020

Conversation

NicholasDotSol
Copy link
Contributor

@NicholasDotSol NicholasDotSol commented Apr 9, 2020

Push models introduce security and stability concerns, a pull model allows for better security, as well as more flexibility and freedom to third-party contract fallbacks given .call.value()'s gas-forwarding.

  • Accumulated Eth balance can only be withdrawn after the contract reaches an end-state.

Closes #551.

NicholasDotSol added 6 commits April 9, 2020 00:33
enableWithdrawal - Enables a given address to withdraw value
after the contract reaches an end state

withdrawFunds - Withdraw the funds a given caller is allowed.
Only callable after the contract has reached an end-state.
Use the pull model instead of
forwarding value directly.
Allow for withdrawable-allowance querry.
We use this in liquidation tests now,
it is still inherited for use where TestDepositUtils is used
@NicholasDotSol NicholasDotSol requested review from Shadowfiend and a team April 9, 2020 08:41
contact -> contract
_valueToDistribute -> valueToDistribute
}

/// @notice Get the caller's withdraw allowance.
/// @return The caller's withdrawable allowance in wei.
Copy link
Contributor

Choose a reason for hiding this comment

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

We're back-and-forthing between “withdraw allowance” and “withdrawable allowance”. I'm fine with “withdraw allowance”, but let's use it everywhere.

EDIT: And “withdrawal allowance”.

NicholasDotSol added 7 commits April 9, 2020 16:51
check `contractEthBalance > valueToDistribute + 1`
to avoid spliting a balance of 1 wei.
more consistent naming, remove awkward possessive
Check that the contract has what it owes
For better test safety make sure the initial balance is not
influences by other factors
Checking that the final balance is greated than the initial one does
not prove that the withdraw() functions correctly.
Instead, account for gas cost
and check the exact value.
Users will not be directly interacting,
therefore  @dev is more appropreate
Copy link
Contributor

@Shadowfiend Shadowfiend left a comment

Choose a reason for hiding this comment

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

Still think it would make sense to make withdrawalAllowances be withdrawAllowances, but I think we can merge this as-is and get that in the next PR that handles the redemption abort liquidation path.

@Shadowfiend Shadowfiend merged commit b2ee719 into master Apr 10, 2020
@Shadowfiend Shadowfiend deleted the eth-withdrawal-pull branch April 10, 2020 01:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secure payments from bad recipient behavior
2 participants