How sherlock-audit/2025-05-layeredge works
Project type and purpose
• This is a Solidity-based, EVM-compatible staking protocol (LayerEdgeStaking) intended for deployment on Ethereum and the LayerEdge L1 Cosmos chain.
• It provides a tiered staking system (20%/30%/50%) with a Fenwick Tree for efficient user ranking, supports ERC-20 token (EDGEN) and wrapped native token (WETH9), and is UUPS upgradeable via OpenZeppelin.
File structure
• Top‐level “edgen-staking” folder contains:
• src/ – Solidity contracts
– stake/LayerEdgeStaking.sol (core logic)
– library/FenwickTree.sol (ranking DS)
– WETH9.sol (wrapped native)
– interfaces/ and library/ folders
• lib/ – vendored dependencies (OpenZeppelin, Solady, forge-std)
• script/ – deployment/test scripts (Foundry)
• test/ – unit tests organized by contract area
• foundry.toml, remappings.txt, Makefile – build & config
• No frontend; purely smart-contract and off-chain tooling (tests/scripts).
Key insights from the README
• UUPSUpgradeable pattern (EIP-1822/1967).
• ERC-20 & WETH9 interfaces.
• Fenwick Tree for O(log n) tier boundary management.
• On‐chain invariants (tier distribution, FCFS ordering, interest correctness, reentrancy protection).
• Dual‐chain deployment: Ethereum & LayerEdge L1.
Detailed capture of all essential elements
• Proxy forwarding to the implementation, which loads the FenwickTree library.
• UUPS upgrade path: implementation ← upgradeTo() ← ProxyAdmin.
• Off-chain scripts/tests at the bottom, pointing to deployment and unit test targets in contracts.