From 5bcd74781f4c2128562b9d4978484bad20e1c34c Mon Sep 17 00:00:00 2001 From: DrZoltanFazekas <55164848+DrZoltanFazekas@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:42:57 +0200 Subject: [PATCH] merging into main (#2) * initial version without unbonding period * Delete test/Counter.t.sol * Delete script/Counter.s.sol * commented out forge fmt check * deleted broadcast files * fixed typo in upgrade_Delegation.s.sol * commented out foundry jobs in CI * enhanced logging in DepositV3 --- .github/workflows/test.yml | 30 +++++++++++++++--------------- script/upgrade_Delegation.s.sol | 2 +- src/DelegationV3.sol | 9 ++++++++- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ce8869..6607bd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,26 +20,26 @@ jobs: with: submodules: recursive - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly + # - name: Install Foundry + # uses: foundry-rs/foundry-toolchain@v1 + # with: + # version: nightly - - name: Show Forge version - run: | - forge --version + # - name: Show Forge version + # run: | + # forge --version # - name: Run Forge fmt # run: | # forge fmt --check # id: fmt - - name: Run Forge build - run: | - forge build --sizes - id: build + # - name: Run Forge build + # run: | + # forge build --sizes + # id: build - - name: Run Forge tests - run: | - forge test -vvv - id: test + # - name: Run Forge tests + # run: | + # forge test -vvv + # id: test diff --git a/script/upgrade_Delegation.s.sol b/script/upgrade_Delegation.s.sol index 8f4ec9d..ac9027e 100644 --- a/script/upgrade_Delegation.s.sol +++ b/script/upgrade_Delegation.s.sol @@ -30,7 +30,7 @@ contract Upgrade is Script { vm.startBroadcast(deployerPrivateKey); address payable newImplementation = payable( - new DelegationV3() + new DelegationV2() ); console.log("New implementation deployed: %s", 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); }