Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/install-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-1
sudo apt-get update
sudo apt-get install -y openssl --allow-unauthenticated
sudo apt-get install -y libssl-dev --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated
sudo apt-get install -y libudev-dev
sudo apt-get install -y binutils-dev
sudo apt-get install -y libunwind-dev
75 changes: 75 additions & 0 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Program state processor

mod liquidity_mining;

use crate::state::Bonus;
use crate::{
self as solend_program,
Expand Down Expand Up @@ -202,6 +204,46 @@ pub fn process_instruction(
msg!("Instruction: Donate To Reserve");
process_donate_to_reserve(program_id, liquidity_amount, accounts)
}
LendingInstruction::AddPoolReward {
position_kind,
start_time_secs,
end_time_secs,
token_amount,
} => {
msg!("Instruction: Add Pool Reward");
liquidity_mining::process_add_pool_reward(
program_id,
position_kind,
start_time_secs,
end_time_secs,
token_amount,
accounts,
)
}
LendingInstruction::CancelPoolReward {
position_kind,
pool_reward_index,
} => {
msg!("Instruction: Cancel Pool Reward");
liquidity_mining::process_cancel_pool_reward(
program_id,
position_kind,
pool_reward_index,
accounts,
)
}
LendingInstruction::ClosePoolReward {
position_kind,
pool_reward_index,
} => {
msg!("Instruction: Close Pool Reward");
liquidity_mining::process_close_pool_reward(
program_id,
position_kind,
pool_reward_index,
accounts,
)
}
}
}

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

/// Issue a spl_token `CloseAccount` instruction.
#[inline(always)]
fn spl_token_close_account(params: TokenCloseAccountParams<'_, '_>) -> ProgramResult {
let TokenCloseAccountParams {
account,
destination,
authority,
token_program,
authority_signer_seeds,
} = params;
let result = invoke_optionally_signed(
&spl_token::instruction::close_account(
token_program.key,
account.key,
destination.key,
authority.key,
&[],
)?,
&[account, destination, authority, token_program],
authority_signer_seeds,
);

result.map_err(|_| LendingError::TokenTransferFailed.into())
}

fn is_cpi_call(
program_id: &Pubkey,
current_index: usize,
Expand Down Expand Up @@ -3507,3 +3574,11 @@ struct TokenBurnParams<'a: 'b, 'b> {
authority_signer_seeds: &'b [&'b [u8]],
token_program: AccountInfo<'a>,
}

struct TokenCloseAccountParams<'a: 'b, 'b> {
account: AccountInfo<'a>,
destination: AccountInfo<'a>,
authority: AccountInfo<'a>,
authority_signer_seeds: &'b [&'b [u8]],
token_program: AccountInfo<'a>,
}
Loading
Loading