From b2820c5eb3a183c870229a5b364ba426077e13ea Mon Sep 17 00:00:00 2001 From: DrZoltanFazekas Date: Tue, 8 Oct 2024 15:36:57 +0200 Subject: [PATCH] enhanced logging in DepositV3 --- src/DelegationV3.sol | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DelegationV3.sol b/src/DelegationV3.sol index 34cd344..df4a635 100644 --- a/src/DelegationV3.sol +++ b/src/DelegationV3.sol @@ -82,11 +82,18 @@ contract DelegationV3 is Initializable, PausableUpgradeable, Ownable2StepUpgrade require(success, "deposit failed"); } + event Log(uint256 _totalSupply, uint256 _msgValue, uint256 _getStake, uint256 _getReward, uint256 shares); function stake() public payable whenNotPaused { require(msg.value >= MIN_DELEGATION, "delegated amount too low"); //TODO: topup deposit by msg.value so that msg.value becomes part of getStake() Storage storage $ = _getStorage(); - uint256 shares = NonRebasingLST($.lst).totalSupply() * msg.value / (getStake() + getRewards()); + uint256 _totalSupply = NonRebasingLST($.lst).totalSupply(); + uint256 _msgValue = msg.value; + uint256 _getRewards = getRewards(); + uint256 _getStake = getStake(); + //uint256 shares = NonRebasingLST($.lst).totalSupply() * msg.value / (getStake() + getRewards()); + uint256 shares = _totalSupply * _msgValue / (_getStake + _getRewards); + emit Log(_totalSupply, _msgValue, _getStake, _getRewards, shares); NonRebasingLST($.lst).mint(msg.sender, shares); emit Staked(msg.sender, msg.value, shares); }