-
Notifications
You must be signed in to change notification settings - Fork 71
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
Conversation
fcc8b89
to
0c2f4ec
Compare
token-lending/cli/src/main.rs
Outdated
@@ -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 { |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
0c2f4ec
to
ded7622
Compare
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Adds a flag to disable reserve borrows
Also updates the command line tool to be able to change it this