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

Origination fees on borrow #239

Merged
merged 18 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ use an x86 toolchain when compiling and running the tests.

## Rust Tests

Run the full test suite with `.scripts/test-program.sh <program_to_test>`

- e.g. `.scripts/test-program.sh all --sane`
Run the full test suite with `./scripts/test-program.sh <program_to_test>`
* e.g. `./scripts/test-program.sh all --sane`

Run a single test:
`.scripts/test-program.sh <program_to_test> <name_of_test>`

- e.g. `.scripts/test-program.sh marginfi configure_bank_success --verbose`
`./scripts/test-program.sh <program_to_test> <name_of_test>`
* e.g. `./scripts/test-program.sh marginfi configure_bank_success --verbose`

## Localnet Anchor Tests

Expand Down
4 changes: 4 additions & 0 deletions clients/rust/marginfi-cli/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ pub enum BankCommand {
pf_fa: Option<f64>,
#[clap(long, help = "Protocol IR fee")]
pf_ir: Option<f64>,
#[clap(long, help = "Protocol origination fee")]
pf_or: Option<f64>,
#[clap(long, arg_enum, help = "Bank risk tier")]
risk_tier: Option<RiskTierArg>,
#[clap(long, arg_enum, help = "Bank oracle type")]
Expand Down Expand Up @@ -649,6 +651,7 @@ fn bank(subcmd: BankCommand, global_options: &GlobalOptions) -> Result<()> {
if_ir,
pf_fa,
pf_ir,
pf_or,
risk_tier,
oracle_type,
oracle_key,
Expand Down Expand Up @@ -698,6 +701,7 @@ fn bank(subcmd: BankCommand, global_options: &GlobalOptions) -> Result<()> {
insurance_ir_fee: if_ir.map(|x| I80F48::from_num(x).into()),
protocol_fixed_fee_apr: pf_fa.map(|x| I80F48::from_num(x).into()),
protocol_ir_fee: pf_ir.map(|x| I80F48::from_num(x).into()),
protocol_origination_fee: pf_or.map(|x| I80F48::from_num(x).into()),
}),
risk_tier: risk_tier.map(|x| x.into()),
total_asset_value_init_limit: usd_init_limit,
Expand Down
1 change: 1 addition & 0 deletions clients/rust/marginfi-cli/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,7 @@ pub fn marginfi_account_borrow(
&config.program_id,
)
.0,
fee_vault: find_bank_vault_pda(&bank_pk, BankVaultType::Fee, &config.program_id).0,
}
.to_account_metas(Some(true)),
data: marginfi::instruction::LendingAccountBorrow { amount }.data(),
Expand Down
128 changes: 114 additions & 14 deletions programs/marginfi/fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/marginfi/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ impl<'state> MarginfiFuzzContext<'state> {
))?,
bank_liquidity_vault_authority: ails(bank.liquidity_vault_authority.clone()),
bank_liquidity_vault: InterfaceAccount::try_from(airls(&bank.liquidity_vault))?,
fee_vault: InterfaceAccount::try_from(airls(&bank.fee_vault))?,
},
aisls(&remaining_accounts),
Default::default(),
Expand Down
3 changes: 2 additions & 1 deletion programs/marginfi/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ pub struct LendingAccountBorrowEvent {
pub header: AccountEventHeader,
pub bank: Pubkey,
pub mint: Pubkey,
pub amount: u64,
pub amount_pre_fee: u64,
jkbpvsc marked this conversation as resolved.
Show resolved Hide resolved
pub fee: u64,
}

#[event]
Expand Down
Loading
Loading