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

Add flag on reserve config to disable borrows #19

Merged
merged 1 commit into from
Jul 23, 2021
Merged

Conversation

DaSichuan
Copy link

Adds a flag to disable reserve borrows
Also updates the command line tool to be able to change it this

@DaSichuan DaSichuan force-pushed the WM_borrow_limit branch 2 times, most recently from fcc8b89 to 0c2f4ec Compare July 22, 2021 20:30
@@ -612,6 +625,14 @@ fn main() {
let flash_loan_fee = value_of::<f64>(arg_matches, "flash_loan_fee");
let host_fee_percentage = value_of(arg_matches, "host_fee_percentage");
let deposit_limit = value_of(arg_matches, "deposit_limit");
let borrows_disabled_option = value_of(arg_matches, "borrows_disabled");
let borrows_disabled = match borrows_disabled_option {
Some(v) => match v {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't just do like unwrap_or(true)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. A missing value is different from false. I made the CLI so that you don't have to specify every value every time you update the reserve config, you only specify the ones that you want to change. That makes it so that None, is different from False.

@@ -562,6 +566,32 @@ impl LendingInstruction {
Ok((pk, rest))
}

fn unpack_bool(input: &[u8]) -> Result<(bool, &[u8]), ProgramError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this gonna work to store up to 8 boolean configs if we want to add later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe lets implement this as borrow limit instead (and we can set it to 0)

@DaSichuan DaSichuan merged commit 30571d1 into staging Jul 23, 2021
@@ -1339,6 +1339,14 @@ fn process_borrow_obligation_liquidity(
msg!("Borrow reserve is stale and must be refreshed in the current slot");
return Err(LendingError::ReserveStale.into());
}
if Decimal::from(liquidity_amount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a case for when borrow_limit == u64::MAX that just passes through. This is more of a nit since the token program stores amounts as u64 anyway, but it's good practice to have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talked about this offline, same reason we didn't (the token program u64 cap)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We'd save a tiny bit of computation right?

Guess it's not too important either way.

Copy link
Member

@nope-finance nope-finance Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saving computation sometimes doesn't really matter right? worst case is all that matters so better to keep consistent compute so we dont accidentally introduce bugs that aren't caught cause edge case overcompute

@nope-finance nope-finance deleted the WM_borrow_limit branch January 11, 2022 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants