BeefySonic is a liquid staking solution for Sonic tokens on the Sonic network, developed by Beefy. It allows users to stake their Sonic tokens while maintaining liquidity through a tokenized representation (beS) that earns staking rewards.
The contract is deployed at 0x871A101Dcf22fE4fE37be7B654098c801CBA1c88. The implementation contract is deployed at 0x03360fe329F44c6B0bE4d8C89D2fd4c0151b226E.
BeefySonic enables users to:
- Deposit Sonic tokens and receive beS tokens
- Earn staking rewards automatically
- Request redemption of beS tokens back to Sonic tokens
- Withdraw Sonic tokens after the redemption period
- Protection against validator slashing events
The contract implements the ERC-4626 Tokenized Vault Standard, ERC-7540 Async Redemption Extension, and ERC-7575 Share Token Interface, providing a familiar interface for integrations.
- Validator Management: Distributes deposits across multiple validators
- Automatic Harvesting: Periodically claims and distributes staking rewards
- Slashing Protection: Socializes losses when validators are slashed to protect users
- Emergency Withdrawals: Allows users to withdraw funds even during slashing events
- Fee System: Configurable fee structure for protocol sustainability
- Operator System: Allows users to authorize operators to manage their funds
The system consists of several key components:
- BeefySonic.sol: Main contract implementing the ERC-4626 vault
- BeefySonicStorageUtils.sol: Storage layout and utilities
- IBeefySonic.sol: Interface defining the contract's functions and events
- ISFC.sol: Interface for interacting with the Sonic Staking Contract
- IConstantsManager.sol: Interface for accessing network constants
BeefySonic implements several security measures:
- Multi-Validator Withdrawal Distribution: Large withdrawals are distributed across multiple validators
- Slashing Protection: Detects slashed validators and socializes losses across all users
- Zero Address Checks: Prevents critical operations with zero addresses
- Emergency Withdrawal Mode: Allows users to withdraw funds even during adverse conditions
When a validator is slashed, BeefySonic:
- Detects the slashing event during regular operations
- Marks the validator as inactive to prevent further deposits
- Calculates the recoverable amount based on the slashing refund ratio
- Initiates the withdrawal process for any recoverable funds
- Socializes the loss across all users proportionally
- Allows emergency withdrawals to ensure users can access their funds
- Foundry
- Node.js and npm/yarn
# Clone the repository
git clone https://github.com/beefyfinance/beefy-sonic.git
cd beefy-sonic
# Install dependencies
yarn install
# Build the contracts
forge build# Run all tests
forge test
# Run specific test
forge test --match-test test_DepositHarvestWithdraw -vvv
# Generate coverage report
forge coverage --report lcovThe BeefySonic contract is designed to be deployed behind a proxy for upgradeability with ownership by a timelock controller. The deployment process involves:
- Deploy the implementation contract
- Deploy a proxy pointing to the implementation
- Initialize the proxy with the required parameters
This project is licensed under MIT License - see the LICENSE file for details.
- Beefy
- Sonic
- OpenZeppelin for secure contract libraries