Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onchain Liquidity Mining #169

Open
0xripleys opened this issue Oct 11, 2023 · 0 comments
Open

Onchain Liquidity Mining #169

0xripleys opened this issue Oct 11, 2023 · 0 comments

Comments

@0xripleys
Copy link

0xripleys commented Oct 11, 2023

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant