|
1 | 1 | //! Program state processor
|
2 | 2 |
|
| 3 | +mod liquidity_mining; |
| 4 | + |
3 | 5 | use crate::state::Bonus;
|
4 | 6 | use crate::{
|
5 | 7 | self as solend_program,
|
@@ -202,6 +204,46 @@ pub fn process_instruction(
|
202 | 204 | msg!("Instruction: Donate To Reserve");
|
203 | 205 | process_donate_to_reserve(program_id, liquidity_amount, accounts)
|
204 | 206 | }
|
| 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 | + } |
205 | 247 | }
|
206 | 248 | }
|
207 | 249 |
|
@@ -3436,6 +3478,31 @@ fn spl_token_burn(params: TokenBurnParams<'_, '_>) -> ProgramResult {
|
3436 | 3478 | result.map_err(|_| LendingError::TokenBurnFailed.into())
|
3437 | 3479 | }
|
3438 | 3480 |
|
| 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 | + |
3439 | 3506 | fn is_cpi_call(
|
3440 | 3507 | program_id: &Pubkey,
|
3441 | 3508 | current_index: usize,
|
@@ -3507,3 +3574,11 @@ struct TokenBurnParams<'a: 'b, 'b> {
|
3507 | 3574 | authority_signer_seeds: &'b [&'b [u8]],
|
3508 | 3575 | token_program: AccountInfo<'a>,
|
3509 | 3576 | }
|
| 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