Skip to content

Add Yield Farming & Rewards to Lending Contract #508

@ONEONUORA

Description

@ONEONUORA

Component: Contracts (Lending) | Effort: 5-7 days | Priority: MEDIUM

Current State

Depositors earn interest but no additional rewards or yield farming.

Missing Functions

Yield farming functions:

  • stake_lp_tokens() - Stake LP tokens for rewards
  • unstake_lp_tokens() - Unstake LP tokens
  • claim_rewards() - Claim accumulated rewards
  • get_pending_rewards() - View pending rewards
  • set_reward_rate() - Set reward emission rate (admin)
  • get_staked_balance() - Get user's staked balance

Why This Matters

  • Incentives: Attract more liquidity with rewards
  • Competitive: Other protocols offer yield farming
  • Growth: Rewards drive TVL growth
  • Token utility: Use protocol token for rewards

Tasks

  • Add RewardPool struct (total_staked, reward_rate, last_update)
  • Add UserStake struct (amount, reward_debt, pending_rewards)
  • Implement stake_lp_tokens() function
  • Add unstake_lp_tokens() function
  • Implement reward calculation logic
  • Add claim_rewards() function
  • Implement get_pending_rewards() view
  • Add set_reward_rate() (admin only)
  • Track total rewards distributed
  • Add Staked, Unstaked, RewardsClaimed events
  • Add tests for yield farming
  • Document rewards mechanism

Acceptance Criteria

  • Users can stake LP tokens
  • Rewards calculated correctly over time
  • Rewards claimable
  • Reward rate adjustable by admin
  • Tests cover reward scenarios
  • Documentation explains yield farming

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions