Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added liquidate and redeem (with protocol fee) #75

Merged
merged 7 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
setting fee to 0 for initial deploy
  • Loading branch information
nope-finance committed Mar 15, 2022
commit 409a022326842f3218a32dd65bb379adc61129bd
2 changes: 1 addition & 1 deletion token-lending/program/src/state/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl Reserve {

// After deploying must update all reserves to set liquidation fee then redeploy with this line instead of hardcode
// let protocol_fee = max(bonus.try_mul(Rate::from_percent(self.config.protocol_liquidation_fee))?.try_ceil_u64()?, 1);
let protocol_fee = std::cmp::max(bonus.try_mul(Rate::from_percent(30))?.try_ceil_u64()?, 1);
let protocol_fee = std::cmp::max(bonus.try_mul(Rate::from_percent(0))?.try_ceil_u64()?, 1);
Ok(protocol_fee)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use spl_token_lending::{
processor::process_instruction,
state::INITIAL_COLLATERAL_RATIO,
};
use std::cmp::max;

#[tokio::test]
async fn test_success() {
Expand Down Expand Up @@ -175,7 +176,9 @@ async fn test_success() {

assert_eq!(
// 30% of the bonus
SOL_LIQUIDATION_AMOUNT_LAMPORTS * 3 / 10 / 11,
// SOL_LIQUIDATION_AMOUNT_LAMPORTS * 3 / 10 / 11,
// 0 % min 1 for now
max(SOL_LIQUIDATION_AMOUNT_LAMPORTS * 0 / 10 / 11, 1),
(fee_reciever_withdraw_liquidity_balance - initial_fee_reciever_withdraw_liquidity_balance)
);

Expand Down