File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,13 +148,25 @@ abstract contract ZToken is IZToken, ERC20 {
148148 function _depositCollateral (uint256 _underlyingAmount ) internal {
149149 if (_underlyingAmount == 0 ) revert ZeroAmountIsNotAllowed ();
150150
151- //
151+ _transferIn (_underlyingAmount);
152+
153+ uint256 newCollateralBalance = collateralAmount[msg .sender ] + _underlyingAmount;
154+ collateralAmount[msg .sender ] = newCollateralBalance;
152155
153- emit CollateralDeposited (msg .sender , _underlyingAmount, _underlyingAmount );
156+ emit CollateralDeposited (msg .sender , _underlyingAmount, newCollateralBalance );
154157 }
155158
156159 function _redeemForCollateral (uint256 _zAmount ) internal {
157160 if (_zAmount == 0 ) revert ZeroAmountIsNotAllowed ();
161+
162+ uint256 underlyingAmount = _zAmount.mulWad (getExchangeRate ());
163+
164+ _burn (msg .sender , _zAmount);
165+
166+ uint256 newCollateralBalance = collateralAmount[msg .sender ] + underlyingAmount;
167+ collateralAmount[msg .sender ] = newCollateralBalance;
168+
169+ emit CollateralRedeemed (msg .sender , _zAmount, underlyingAmount, newCollateralBalance);
158170 }
159171
160172 function _transferIn (uint256 _amount ) internal virtual { }
You can’t perform that action at this time.
0 commit comments