Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging into main #2

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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