diff --git a/token-lending/program/tests/liquidate_obligation.rs b/token-lending/program/tests/liquidate_obligation.rs index 21f1aa5883a..57776f71dab 100644 --- a/token-lending/program/tests/liquidate_obligation.rs +++ b/token-lending/program/tests/liquidate_obligation.rs @@ -12,7 +12,7 @@ use solana_sdk::{ use solend_program::{ instruction::{liquidate_obligation, refresh_obligation}, processor::process_instruction, - state::INITIAL_COLLATERAL_RATIO, + state::{INITIAL_COLLATERAL_RATIO, LIQUIDATION_CLOSE_FACTOR}, }; use spl_token::instruction::approve; @@ -32,10 +32,10 @@ async fn test_success() { // 100 SOL * 80% LTV -> 80 SOL * 20 USDC -> 1600 USDC borrow const USDC_BORROW_AMOUNT_FRACTIONAL: u64 = 1_600 * FRACTIONAL_TO_USDC; // 1600 USDC * 20% -> 320 USDC liquidation - const USDC_LIQUIDATION_AMOUNT_FRACTIONAL: u64 = USDC_BORROW_AMOUNT_FRACTIONAL / 5; + const USDC_LIQUIDATION_AMOUNT_FRACTIONAL: u64 = USDC_BORROW_AMOUNT_FRACTIONAL * (LIQUIDATION_CLOSE_FACTOR as u64) / 100 ; // 320 USDC / 20 USDC per SOL -> 16 SOL + 10% bonus -> 17.6 SOL (88/5) const SOL_LIQUIDATION_AMOUNT_LAMPORTS: u64 = - LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO * 88 / 5; + LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO * 88 * (LIQUIDATION_CLOSE_FACTOR as u64) / 100; const SOL_RESERVE_COLLATERAL_LAMPORTS: u64 = 2 * SOL_DEPOSIT_AMOUNT_LAMPORTS; const USDC_RESERVE_LIQUIDITY_FRACTIONAL: u64 = 2 * USDC_BORROW_AMOUNT_FRACTIONAL; diff --git a/token-lending/program/tests/liquidate_obligation_and_redeem_collateral.rs b/token-lending/program/tests/liquidate_obligation_and_redeem_collateral.rs index a4e50db96dc..69a6342c31a 100644 --- a/token-lending/program/tests/liquidate_obligation_and_redeem_collateral.rs +++ b/token-lending/program/tests/liquidate_obligation_and_redeem_collateral.rs @@ -12,7 +12,7 @@ use solana_sdk::{ use solend_program::{ instruction::{liquidate_obligation_and_redeem_reserve_collateral, refresh_obligation}, processor::process_instruction, - state::INITIAL_COLLATERAL_RATIO, + state::{INITIAL_COLLATERAL_RATIO, LIQUIDATION_CLOSE_FACTOR}, }; use std::cmp::max; @@ -32,10 +32,10 @@ async fn test_success() { // 100 SOL * 80% LTV -> 80 SOL * 20 USDC -> 1600 USDC borrow const USDC_BORROW_AMOUNT_FRACTIONAL: u64 = 1_600 * FRACTIONAL_TO_USDC; // 1600 USDC * 20% -> 320 USDC liquidation - const USDC_LIQUIDATION_AMOUNT_FRACTIONAL: u64 = USDC_BORROW_AMOUNT_FRACTIONAL / 5; + const USDC_LIQUIDATION_AMOUNT_FRACTIONAL: u64 = USDC_BORROW_AMOUNT_FRACTIONAL * (LIQUIDATION_CLOSE_FACTOR as u64) / 100; // 320 USDC / 20 USDC per SOL -> 16 SOL + 10% bonus -> 17.6 SOL (88/5) const SOL_LIQUIDATION_AMOUNT_LAMPORTS: u64 = - LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO * 88 / 5; + LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO * 88 * (LIQUIDATION_CLOSE_FACTOR as u64) / 100; const SOL_RESERVE_COLLATERAL_LAMPORTS: u64 = 2 * SOL_DEPOSIT_AMOUNT_LAMPORTS; const USDC_RESERVE_LIQUIDITY_FRACTIONAL: u64 = 2 * USDC_BORROW_AMOUNT_FRACTIONAL;