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

WIP Sonic Staking #2335

Draft
wants to merge 319 commits into
base: master
Choose a base branch
from
Draft

WIP Sonic Staking #2335

wants to merge 319 commits into from

Conversation

naddison36
Copy link
Collaborator

@naddison36 naddison36 commented Dec 30, 2024

Dependencies

Contracts

sonicContracts

Tests

Sonic Unit Tests

The Sonic unit tests are in contracts/test/vault/os-vault.sonic.js.

yarn test:sonic

Sonic Fork Tests

The Sonic fork tests are in:

  • contracts/test/strategies/sonicStaking.sonic.fork-test.js
  • contracts/test/zapper/osonic-zapper.sonic.fork-test.js
# start a local Sonic forked node
yarn run node:sonic

# In another terminal, run the Sonic fork tests
yarn test:sonic-fork

Deployment

The first Sonic mainnet deployment file is contracts/deploy/sonic/001_origin_sonic.js

yarn run deploy:sonic

Code Change Checklist

To be completed before internal review begins:

  • The contract code is complete
  • Executable deployment file
  • Fork tests that test after the deployment file runs
  • Unit tests *if needed
  • The owner has done a full checklist review of the code + tests

Internal review:

  • Two approvals by internal reviewers

sparrowDom and others added 30 commits May 13, 2024 10:45
Added Natspec
* add withdrawal events to the tests

* add WETH accounting

* add better documentation

* add sending WETH to the Vault back to fix manual accounting function

* actually wrap the ETH to WETH before sending it to the Vault when manually fixing accounting

* add withdrawal event to manually fix accounting

* fix bugs and add tests with WETH accounting

* add test to verify correct deposits

* Gas changes to Native Staking's depositAll

---------

Co-authored-by: Nicholas Addison <[email protected]>
* Deployed new NativeStakingSSVStrategy

* Generated latest Native Staking Strategy diagrams
* deploy native staking proxy and add auxiliary functions to transfer its governance

* Shortened error message in InitializeGovernedUpgradeabilityProxy.initialize

---------

Co-authored-by: Nicholas Addison <[email protected]>
* deploy native staking proxy and add auxiliary functions to transfer its governance

* Setup basic defender action

* update defender-sdk version

* add defender client as an external export

* configuration update

---------

Co-authored-by: Nicholas Addison <[email protected]>
claimWithdrawal collects from Dripper and adds any unallocated WETH to the withdrawal queue if not enough liquidity available
depositToStrategy only deposits WETH not allocated to the withdrawal queue
swapCollateral restricted to only swap to WETH
swapCollateral adds to withdrawal queue after swap
}
}

// TODO use Deposit event or something else?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a bool flag isRestake to Deposit event indicating whether it is a normal deposit or restaking of the rewards

*/
receive() external payable {
require(
msg.sender == sfc || msg.sender == wrappedSonic,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice check, but there is this little devil lurking around :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that donating S to the contract would throw off the math:

  • We do the address(this).balance only in the withdrawFromTheSFC and we are looking at the increment that the withdrawal has caused... ignoring previous amount
  • Also the checkBalance does ignore the S balance on the contract.

The only complaint I have that the check might give a false sense of security, since anyone can call withdrawTo and send S to the contract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants