Skip to content

Commit aa13771

Browse files
committed
Adding admin IXs for LM reward management
1 parent 49a6c03 commit aa13771

File tree

5 files changed

+891
-1
lines changed

5 files changed

+891
-1
lines changed

token-lending/program/src/processor.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Program state processor
22
3+
mod liquidity_mining;
4+
35
use crate::state::Bonus;
46
use crate::{
57
self as solend_program,
@@ -202,6 +204,46 @@ pub fn process_instruction(
202204
msg!("Instruction: Donate To Reserve");
203205
process_donate_to_reserve(program_id, liquidity_amount, accounts)
204206
}
207+
LendingInstruction::AddPoolReward {
208+
position_kind,
209+
start_time_secs,
210+
end_time_secs,
211+
token_amount,
212+
} => {
213+
msg!("Instruction: Add Pool Reward");
214+
liquidity_mining::process_add_pool_reward(
215+
program_id,
216+
position_kind,
217+
start_time_secs,
218+
end_time_secs,
219+
token_amount,
220+
accounts,
221+
)
222+
}
223+
LendingInstruction::CancelPoolReward {
224+
position_kind,
225+
pool_reward_index,
226+
} => {
227+
msg!("Instruction: Cancel Pool Reward");
228+
liquidity_mining::process_cancel_pool_reward(
229+
program_id,
230+
position_kind,
231+
pool_reward_index,
232+
accounts,
233+
)
234+
}
235+
LendingInstruction::ClosePoolReward {
236+
position_kind,
237+
pool_reward_index,
238+
} => {
239+
msg!("Instruction: Close Pool Reward");
240+
liquidity_mining::process_close_pool_reward(
241+
program_id,
242+
position_kind,
243+
pool_reward_index,
244+
accounts,
245+
)
246+
}
205247
}
206248
}
207249

@@ -3436,6 +3478,31 @@ fn spl_token_burn(params: TokenBurnParams<'_, '_>) -> ProgramResult {
34363478
result.map_err(|_| LendingError::TokenBurnFailed.into())
34373479
}
34383480

3481+
/// Issue a spl_token `CloseAccount` instruction.
3482+
#[inline(always)]
3483+
fn spl_token_close_account(params: TokenCloseAccountParams<'_, '_>) -> ProgramResult {
3484+
let TokenCloseAccountParams {
3485+
account,
3486+
destination,
3487+
authority,
3488+
token_program,
3489+
authority_signer_seeds,
3490+
} = params;
3491+
let result = invoke_optionally_signed(
3492+
&spl_token::instruction::close_account(
3493+
token_program.key,
3494+
account.key,
3495+
destination.key,
3496+
authority.key,
3497+
&[],
3498+
)?,
3499+
&[account, destination, authority, token_program],
3500+
authority_signer_seeds,
3501+
);
3502+
3503+
result.map_err(|_| LendingError::TokenTransferFailed.into())
3504+
}
3505+
34393506
fn is_cpi_call(
34403507
program_id: &Pubkey,
34413508
current_index: usize,
@@ -3507,3 +3574,11 @@ struct TokenBurnParams<'a: 'b, 'b> {
35073574
authority_signer_seeds: &'b [&'b [u8]],
35083575
token_program: AccountInfo<'a>,
35093576
}
3577+
3578+
struct TokenCloseAccountParams<'a: 'b, 'b> {
3579+
account: AccountInfo<'a>,
3580+
destination: AccountInfo<'a>,
3581+
authority: AccountInfo<'a>,
3582+
authority_signer_seeds: &'b [&'b [u8]],
3583+
token_program: AccountInfo<'a>,
3584+
}

0 commit comments

Comments
 (0)