LEEQUID
  • 👋 Welcome
  • Navigating LEEQUID
    • 🌱 Staking
      • The staking protocol
      • Matching stake to unstake requests
      • Potential wait times while staking
      • Deposited LYX lifecycle
      • Importing sLYX to your wallet
    • 🍇 Collecting rewards
      • Reward distribution in the LEEQUID protocol
      • Auto-compounding
      • Withdrawing rewards
      • Reward calculation in Proof of Stake
    • 🍂 Exiting the protocol
      • Option 1: swapping sLYX for LYX
      • Option 2: unstaking through the staking pool
      • Matching unstake to stake requests
      • Potential wait times while unstaking
    • 🍷 Claiming
      • Claim queued stake
      • Claim unstaked LYX
      • Claim rewards
    • 🔄 Swapping
      • LYX for sLYX: An instant alternative to staking
      • sLYX for LYX: an instant alternative to exiting
      • Providing liquidty
      • Providing Liquidity: a practical example
  • LEEQUID in depth
    • 🔐 Protocol security and risks
      • Security overview
      • Smart contract code correctness
      • Slashing and unexpected validator behaviour
      • sLYX token: economic balance
      • Validator key management
    • 📃 Smart contracts
      • Oracles
      • Merkle Distributor
      • Rewards
      • Pool
      • StakedLyxToken
      • FeesEscrow
    • 💧 The sLYX token
      • Acquiring sLYX
      • 1:1 ratio with LYX
      • Potential unpeg of sLYX from LYX
    • 💦 The liquidity pool (DEX)
      • Implementation
  • Incident Response
    • Contacts
    • Vulnerability Disclosure Policy
Powered by GitBook
On this page
  1. LEEQUID in depth
  2. 📃 Smart contracts

Rewards

0x5D48F7FC221ABcAC5386c374eF723a56AD03D4B4

Last updated 1 year ago

The Rewards contract is a key piece in the liquid staking application, providing a way to distribute rewards to protocol participants, handling protocol fees, and managing checkpoints for efficient reward calculation. This contract is also the withdrawal address of the protocol's validators: where all the rewards and unstakes from the protocol's validators get sent to.

The Rewards contract interacts with various other contracts including:

  1. : Tracks the staked tokens.

  2. : Responsible for updating the total rewards in the Rewards contract.

  3. : Distributes the rewards to the protocol's participants.

  4. : Handles the protocol's execution layer fees.

  5. : Handles incoming LYX.

Key features

The Rewards contract tracks the total rewards earned by the staking protocol and the total amount that has been cashed out. It also calculates the reward per token for user reward calculation.

Checkpointing

To optimize gas usage and enhance scalability, the contract uses a checkpoint system that keeps track of an account's rewards at a particular point in time. The reward per token is stored in each checkpoint, along with the reward value, in a single memory slot. This allows the Rewards contract to calculate the user's reward.

struct Checkpoint {
    uint128 reward;
    uint128 rewardPerToken;
}

Fee Handling

The contract calculates protocol fees and handles the distribution of these fees. It allows the protocol's admin to set the fee recipient address and fee percentage.

Oracles

An oracle system is in place that updates the total rewards in the Rewards contract.

Reward disabling

Auto-compounding

The contract stores a list of addresses who explicitly granted permission for rewards to be staked on their behalf and provides an interface to effectively re-stake these rewards. This operation can be done in batch and it will call the Pool contract's, transferring LYX to it.

The contract provides an option to disable rewards for an account. The state is toggled by calling the setRewardsDisabled function. Rewards of addresses with rewards disabled accrue in the distributor principal, the balance of the , responsible for the token distribution of rewards calculated off-chain.

StakedLyxToken
Oracles
MerkleDistributor
FeesEscrow
Pool
Merkle Distributor contract