Skip to content

edgelessNetwork/contracts

Repository files navigation

Edgeless Contracts

For Auditors

Documentation is below the Getting Started section

  • SLOC: 378 Lines (yarn sloc)
  • In Scope:
    • src/EdgelessDeposit.sol
    • src/StakingManager.sol
    • src/WrappedToken.sol
    • src/Constants.sol
    • src/strategies/*
  • Out of Scope:
    • src/interfaces/* - just interfaces
    • src/upgrade-tests/* - just testing files
    • Centralization concerns
  • Copied files
  • Coverage: Over 90% on in scope files https://app.warp.dev/block/ijNP6MzDaIxBrWuhZgYFgb

Getting Started

npm i --force
forge test

Overview

Background

The yield generating contracts on Ethereum for Edgeless Network.

Overview: The high level vision of Edgeless is to lower or remove the transaction fees that dApps currently charge and monetize via bridged TVL. Blast and Manta are focused on creating generalizable L2s where the native token is yield bearing and passed through to the initial user. While this is a step in the right direction the ultimate vision should be to remove transaction fees altogether, which is what we are setting out to do. Like Roblox and Epic, Edgeless is able to pool together the revenue that is generated across the ecosystem and redistribute it to app developers based on the value they bring to the ecosystem.

Use Cases: There are many use cases where charging no transaction fee naturally makes sense, social gaming is one of the most exciting, and is one of the key focuses for Edgeless to begin with (think games that Zynga would make: poker, blackjack, slot machines, and Gacha games). For the first time ever you could offer EV neutral or even EV positive games using the infrastructure that Edgeless offers. Game creators do not need to have a house rake or fee on every spin / turn since they can monetize off of the yield (ETH / stables). Other gaming related use cases include daily fantasy sports, season long survivor brackets and PvP games. Second to gaming, there are several DeFi and consumer applications that we believe would be great apps for our ecosystem including perps exchanges and NFT marketplaces.

System Design

Deposit Flow

image

Withdrawal Flow

image

Contract Design

Contract Structure

  • The contracts are organized into four distinct groups of contracts. Additionally, there is an integration with a standard bridge designed for Layer 1 (L1).

Edgeless Managed Contracts

  • Edgeless Deposit Contract: This contract is UUPS Upgradeable by the owner.
  • Edgeless Wrapped Ether: An ERC20 representing ETH balance on the L2 with minting exposed to a minter (Edgeless Deposit Contract).

Staking Contracts

  • Lido Contract: This contract is focused on managing the staking of Ethereum, a key component of the marketplace's asset management strategy.

Deposit Flows

  • Eth: Involves minting Wrapped Ether, optional auto-staking through Lido, and bridging the Wrapped Ether to the Edgeless Layer 2

Withdrawal Flows

  • Lido (Eth): This flow allows the designated staker to request Lido to withdraw a specific balance of Eth, followed by claiming rewards after the withdrawal is finalized.

Staking Information

  • Staker Responsibilities: The staker is responsible for setting the AutoStake value, staking Dai and Eth in the bridge, and managing withdrawals from Lido.
  • AutoStake Feature: This functionality allows for the automatic staking of deposits to respective platforms.
  • Owner's Role in Setting Staker: The owner of the contract has the authority to designate the staker.

Owner Information

  • Owner Responsibilities: The owner is tasked with authorizing upgrades to the contract, setting the Layer 1 Bridge, designating the staker, pausing direct bridge deposits, and minting new Wrapped tokens in line with yield or staking rewards.

Invariants

The following invariants should always be maintained within the contract:

  • The balance of Wrapped Eth should always be less than or equal to the total Steth balance combined with the Eth balance.
  • If autostaking is not enabled, only the designated staker has the authority to stake Eth and Dai.
  • Toggling the AutoStake feature can only be done by the staker.
  • Setting the staker, L1Bridge, bridgePause, authorizing upgrades, and minting tokens can only be performed by the owner of the contract.
  • If the bridge is paused, users are unable to bridge to L1.
  • The mint and burn functions can only be called by the Edgeless Deposit contract.

Usage

This is a list of the most frequently needed commands.

Clean

Delete the build artifacts and cache directories:

$ forge clean

Compile

Compile the contracts:

$ forge build

Coverage

Get a test coverage report:

$ forge coverage

Format

Format the contracts:

$ forge fmt

Gas Usage

Get a gas report:

$ forge test --gas-report

Lint

Lint the contracts:

$ npm run lint

Test

Run the tests:

$ forge test

Generate test coverage and output result to the terminal:

$ npm run test:coverage

Generate test coverage with lcov report (you'll have to open the ./coverage/index.html file in your browser, to do so simply copy paste the path):

$ npm run test:coverage:report