Skip to content

Commit

Permalink
merging into main (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DrZoltanFazekas authored Oct 8, 2024
1 parent 4712ae1 commit 5bcd747
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion script/upgrade_Delegation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/DelegationV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5bcd747

Please sign in to comment.