Skip to content

Commit

Permalink
StETH: Add share-related math to transfer #3 #28
Browse files Browse the repository at this point in the history
* Change transfer math to share-based
* Additional checks in _transfer
  • Loading branch information
ongrid committed Oct 22, 2020
1 parent 1d758db commit 31788c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contracts/0.4.24/StETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ contract StETH is ISTETH, Pausable, AragonApp {
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(value <= _shares[from]);
require(value != 0);
require(to != address(0));

_shares[from] = _shares[from].sub(value);
_shares[to] = _shares[to].add(value);
uint256 sharesToTransfer = getSharesByPooledEth(value);
require(sharesToTransfer <= _shares[from]);
_shares[from] = _shares[from].sub(sharesToTransfer);
_shares[to] = _shares[to].add(sharesToTransfer);
emit Transfer(from, to, value);
}

Expand Down

0 comments on commit 31788c8

Please sign in to comment.