Skip to content

redacted-cartel/pirex-eth-contracts

Repository files navigation

Pirex-ETH

Setup

From inside the project directory:

  1. forge i to install contract dependencies
  2. forge build to compile contracts

(Forge version: 0.2.0)

Overview

[Contract Contents]

Pirex provides ETH holders to take advantage of Ethereum staking rewards through pooling.

As a user of Pirex, you can benefit in the following ways:

  • Yield as a resulting of block validation, block attestation and MEV.
  • Efficient, autonomous compounding of rewards into pxETH

And more. We're continuously improving our products and adding value to our users, and will make announcements as additional utility is available for our tokens. Please follow us on Twitter (@redactedcartel) to stay in the loop ❤️.

How Does It Work?

pxETH: The Pirex-wrapped version of ETH, handled in a way to attain benefit from MEV, Execution layer and Consensus layer rewards to the user. pxETH token holders can earn yield by staking in AutoPxETH. pxETH token holders can redeem pxETH for ETH

Architecture Diagram

Below are visualizations of how Dinero-Pirex-Eth contracts interact with one another as well as with external contracts (e.g. beacon chain deposit) as a result of different user interactions. Please note that the diagrams do not cover some details to keep the diagram easy for understanding on token flow (for e.g. the setFee call for configuring deposit, redemption and `instantRedemption`` fees, adding initialized validators).

Pirex ETH Smart Contract Architecture

Pirex ETH Smart Contract Architecture

Core Contract Overview

PirexEthValidators.sol

  • This contract manages validators and deposits for the Eth2.0 (Beacon chain) deposit contract.
    • It allows governance to set contract addresses, manage validator queues, trigger deposits, manage rewards, handle slashing and top-up operations, and more.
    • Validators are managed through various queues and can be added, swapped, popped, removed, or cleared.
    • Validators can be slashed, dissolved, and topped up based on different conditions.
    • Validators can be redeemed and rewarded with upxEth tokens.
  • Handles the MEV, Execution layer and Consensus layer rewards.
  • Keeps the status of validators in sync via that on consensus layer.
  • GOVERNANCE_ROLE - manages validator queue, set fee params, pausing deposits to beacon chain deposit contract
  • KEEPER_ROLE - harvest rewards. Update status when a validator is slashed , top up the validator stake when active balance goes below effective balance
  • DEFAULT_ADMIN_ROLE - set the external contract addresses

PirexEth.sol

  • Main contract for handling interactions with pxETH
  • The contract allows depositing ETH to receive pxETH tokens and staking them in the autocompounding vault on behalf of the user.
  • It allows pxETH holders to redeem pxETH for ETH or upxETH
  • It manages fees for deposit ETH , redemption and instant redemption of pxEth.

ERC1155Solmate.sol

  • Modified ERC1155 Solmate mint, mintBatch , burn and burnBatch by making it permissioned.

OracleAdapter.sol

  • The contract acts as an intermediary between different contract components, facilitates setting contract addresses, managing access control roles, and handling interactions related to validator exits and dissolution.
  • It has permission to interact with PirexEth for notifying validator to voluntary exit.
  • It has permission to interact with PirexEth when validator is dissolved.
  • ORACLE_ROLE - permission to update the state of the validator when it is dissolved.

PirexFees.sol

  • The contract handles the distribution of fees generated by the protocol
  • It allows its owner, a Redacted multisig, to configure fee recipient addresses and treasury fee percentages
    • When fees are distributed, the specified token amount is split between the treasury and contributors according to the configured percentages.

DineroERC20.sol

  • This contract extends the ERC20 standard by adding permissioned minting and burning capabilities
  • It implements access control mechanisms to restrict who can perform these actions.
  • It defines the MINTER_ROLE and BURNER_ROLE roles, and only accounts with these roles are allowed to mint and burn tokens, respectively.
  • The access control mechanisms are facilitated through the use of OpenZeppelin's AccessControlDefaultAdminRules contract.

PxEth.sol

  • This contract represents the main token for the PirexEth system within the Dinero ecosystem.
    • Is a derivative of the DineroERC20 contract
  • The contract introduces an OPERATOR_ROLE that allows certain addresses to perform specific actions - approve allowances between specified accounts.

AutoPxEth.sol

  • Autocompounding vault for (staked) pxETH, adapted from pxCVX vault system
  • The contract provides a mechanism for users to stake and unstake pxETH tokens.
    • Accepts pxETH deposits, and issues share tokens (apxEth) against them
  • It compounds pxEth rewards into more pxEth by harvesting ETH rewards (MEV, Consensus layer and Execution layer).
    • Rewards are streamed over time based on a set rewards rate and duration.
    • Harvesting of rewards is done by the contract, and a platform fee is deducted before rewards are compounded.
  • Provides a series of permissioned methods that enables the Pirex multisig to configure platform(vault's fees recipient), PirexEth contract, withdraw penalty and platformFee.
  • Modifies transfer and transferFrom method to initiateRedemption if apxEth are transferred to PirexEth.

RewardRecipient.sol

  • This contract is responsible for harvesting validators rewards, dissolving and slashing validators and setting protocol’s contracts addresses (OracleAdapter, PirexEth)
  • The governance and keeper roles are responsible for managing various operations related to validators and their rewards.