-
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 function to deposit reserve liquidity and collateral #8
Conversation
@@ -309,6 +309,30 @@ pub enum LendingInstruction { | |||
/// The amount that is to be borrowed - u64::MAX for up to 100% of available liquidity | |||
amount: u64, | |||
}, | |||
|
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.
TBH I'm not 100% sure what accounts I should be using here and if the ones here are correct.
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.
uhh you should be able to check this in the code side (this is just a comment)
let source_liquidity_info = next_account_info(account_info_iter)?;
let user_collateral_info = next_account_info(account_info_iter)?;
let reserve_info = next_account_info(account_info_iter)?;
let reserve_liquidity_supply_info = next_account_info(account_info_iter)?;
let reserve_collateral_mint_info = next_account_info(account_info_iter)?;
let lending_market_info = next_account_info(account_info_iter)?;
let lending_market_authority_info = next_account_info(account_info_iter)?;
let destination_collateral_info = next_account_info(account_info_iter)?;
let obligation_info = next_account_info(account_info_iter)?;
let obligation_owner_info = next_account_info(account_info_iter)?;
let user_transfer_authority_info = next_account_info(account_info_iter)?;
let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?;
let token_program_id = next_account_info(account_info_iter)?;
so it looks fine at first glance
@@ -543,6 +571,10 @@ impl LendingInstruction { | |||
buf.push(13); | |||
buf.extend_from_slice(&amount.to_le_bytes()); | |||
} | |||
Self::DepositReserveLiquidityAndObligationCollateral { liquidity_amount } => { | |||
buf.push(4); |
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.
14?
let user_transfer_authority_info = next_account_info(account_info_iter)?; | ||
let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?; | ||
let token_program_id = next_account_info(account_info_iter)?; | ||
|
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.
are there no extra checks we should do here?
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 figured no, since all it's doing is calling two existing endpoints, all which do their own checks
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.
ah yeh kk sounds fine then. the only main thing is the 4 vs 14
so lgtm
clock, | ||
token_program_id, | ||
)?; | ||
_deposit_obligation_collateral( |
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 there is a check on like collateral amount we should do?
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.
The _deposit_obligation_collateral checks for nonzero collateral amount. Anything else? I suupose we can change it to a >0 check
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.
just kidding its unsigned
f5f7eed
to
9bbc75f
Compare
9bbc75f
to
c60c518
Compare
Combines DepositReserveLiquidity and DepositObligationCollateral so that we can do it all in one transaction.
It seems to me like we can rewrite this to do fewer things, but maybe we can do that later.