Skip to content

Feat lending vault#21

Open
amalnathsathyan wants to merge 4 commits intomainfrom
feat-lending-vault
Open

Feat lending vault#21
amalnathsathyan wants to merge 4 commits intomainfrom
feat-lending-vault

Conversation

@amalnathsathyan
Copy link
Contributor

@0xRektified don't merge now, this is for you to review, withdraw_vault_lp.rs and tests are pending !!

  • supply.rs renamed to supply_vault_lp.rs
  • made changes in LendingVault, LpPosition for supporting both token_x and token_y
  • in supply.rs added logic for handling native_transfers as well as spl-transfers
  • if one of the mint = NATIVE_MINT, it will be handled accordingly with sync_native

pub sol_vault: SystemAccount<'info>,
pub token_y_vault: InterfaceAccount<'info, TokenAccount>,

// mint_x = NATIVE_MINT for WSOL
Copy link
Contributor

Choose a reason for hiding this comment

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

Then what is Y here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you said, more granular seeds like [b"token", mint.key().as_ref()] feels apt here. Will make necessary changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pub sol_vault: SystemAccount<'info>,
pub token_y_vault: InterfaceAccount<'info, TokenAccount>,

// mint_x = NATIVE_MINT for WSOL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

let rent_exempt = Rent::get()?.minimum_balance(0);
// let rent_exempt = Rent::get()?.minimum_balance(0);
//not sure whether it is safer to treat the WSOL as a token account and use token_vault.amount here
// as we have used the sync_native to sync the balances
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xRektified this needs to be resolved to move to actual withdraw fn


let accounts = Transfer{
from: self.sol_vault.to_account_info(),
from: self.token_vault.to_account_info(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xRektified This isn't complete. Confused whether I should use the transfer_checked from token_interface or normal transfer from system program,, Becasue the to transfer the WSOL back using Token program,, the user may not have the ATA,,,, wdyt ?

Copy link
Contributor

Choose a reason for hiding this comment

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

if the user send WSOL he has to have an ATA for it when withdrawing

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