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 function to deposit reserve liquidity and collateral #8

Merged
merged 1 commit into from
Jun 28, 2021

Conversation

DaSichuan
Copy link

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.

@@ -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,
},

Copy link
Author

@DaSichuan DaSichuan Jun 25, 2021

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.

Copy link
Member

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);
Copy link
Member

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)?;

Copy link
Member

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?

Copy link
Author

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

Copy link
Member

@nope-finance nope-finance Jun 28, 2021

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(
Copy link
Member

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?

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

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

just kidding its unsigned

@DaSichuan DaSichuan force-pushed the add_combined_fn branch 4 times, most recently from f5f7eed to 9bbc75f Compare June 28, 2021 19:48
@DaSichuan DaSichuan merged commit 2ca5dfa into master Jun 28, 2021
@DaSichuan DaSichuan deleted the add_combined_fn branch June 28, 2021 23:43
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.

2 participants