Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion contracts/lending_pool/src/flash_loan_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait FlashLoanReceiver {
/// # Arguments
/// * `env` - Soroban environment
/// * `amount` - Borrowed amount (must repay fully)
/// * `fee` - Flash loan fee (0.08% = 8 bps)
/// * `fee` - Flash loan fee (0.05% = 5 bps)
/// * `params` - Caller-provided params (user data)
///
/// # Panics
Expand Down
8 changes: 4 additions & 4 deletions contracts/lending_pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use soroban_sdk::{contract, contracterror, contractimpl, contracttype, token, Ad
pub mod flash_loan_receiver;
pub use flash_loan_receiver::FlashLoanReceiver;

/// Flash loan fee in basis points (8 bps = 0.08%)
/// Flash loan fee in basis points (5 bps = 0.05%)
/// This fee compensates Liquidity Providers for temporary risk exposure
/// while generating additional protocol revenue.
const FLASH_LOAN_FEE_BPS: i128 = 8;
const FLASH_LOAN_FEE_BPS: i128 = 5;

#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
Expand Down Expand Up @@ -431,7 +431,7 @@ impl LendingPool {
if amount < 0 {
panic_with_error!(&env, Error::MathOverflow);
}
// amount * 8 / 10000
// amount * 5 / 10000
amount
.checked_mul(FLASH_LOAN_FEE_BPS)
.and_then(|v| v.checked_div(10_000))
Expand All @@ -442,7 +442,7 @@ impl LendingPool {
/// `amount + calculate_flash_fee(amount)` to be returned before callback returns.
///
/// # Flash Loan Fee & LP Share Value
/// A fee of 0.08% (8 bps) is charged. Fees stay in pool reserves, increasing LP share value.
/// A fee of 0.05% (5 bps) is charged. Fees stay in pool reserves, increasing LP share value.
///
/// # Callback Interface
/// Receiver must implement [`FlashLoanReceiver`] trait:
Expand Down
14 changes: 7 additions & 7 deletions contracts/lending_pool/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,21 @@ use crate::mock_flash_receiver::MockFlashReceiverClient;
let contract_id = env.register(crate::LendingPool, ());
let client = LendingPoolClient::new(&env, &contract_id);

// 10000 * 8 / 10000 = 8
assert_eq!(client.calculate_flash_fee(&10000), 8);
// 10000 * 5 / 10000 = 5
assert_eq!(client.calculate_flash_fee(&10000), 5);

// 5000 * 8 / 10000 = 4
assert_eq!(client.calculate_flash_fee(&5000), 4);
// 5000 * 5 / 10000 = 2
assert_eq!(client.calculate_flash_fee(&5000), 2);

// Zero amount
assert_eq!(client.calculate_flash_fee(&0), 0);

// Large amount: 1_000_000 * 8 / 10000 = 800
assert_eq!(client.calculate_flash_fee(&1_000_000), 800);
// Large amount: 1_000_000 * 5 / 10000 = 500
assert_eq!(client.calculate_flash_fee(&1_000_000), 500);

// Max limit consideration: using i128, large amounts won't overflow
let large_amount: i128 = 1_000_000_000_000_000;
assert_eq!(client.calculate_flash_fee(&large_amount), 800_000_000_000);
assert_eq!(client.calculate_flash_fee(&large_amount), 500_000_000_000);
}

#[test]
Expand Down
Loading