Skip to content

Onchain Liquidity Mining #169

Description

@0xripleys

Instructions

New Instructions

AddLiquidityMiningRewards

arguments

  • reserve: Pubkey
  • RewardType: Deposit | Borrow
  • token address: Pubkey
  • token amount: u64
  • duration_in_slots: u64

behavior

  • transfer rewards to a token account owned by program

ClaimRewards

arguments

  • reserve: Pubkey
  • reward_id: u64

Modifying existing instructions

Deposit, Repay, Borrow, WIthdraw, Liquidate now all affect rewards calculations, so reward variables have to be "refreshed" at the start of each instruction now.

I think easiest way is to modify _refresh_reserve_interest to also refresh the rewards

State

RewardInfo

struct ReserveRewardInfo {
  id: u8,
  token_account: Pubkey,
  mint: Pubkey,
  accumulated_reward_rate: Decimal,
  last_updated_slot: u64,
  rewards_attributed: Decimal,
  total_rewards: u64
}

struct ObligationRewardInfo {
  id: u8,
  old_accumulator: Decimal,
  claimed_rewards: Decimal,
  unclaimed_rewards: Decimal
}

Other considerations:

  • how to handle cases when the lm reward duration is finished? rewards can't accumulate forever. maybe best to have a cancelRewards function so the owner can withdraw
  • should we have a way to permissionlessly crank LM rewards? in case reward refreshing causes compute issues. Compute issues are scary because they can break liquidations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions