Borrow
Borrows tokens from the pool’s reserves against deposited collateral.
Accounts
user_position
Account<UserPosition>
required
The user’s position account.
token_vault
InterfaceAccount<TokenAccount>
required
The pair vault for the debt token (the token being borrowed).
user_token_account
InterfaceAccount<TokenAccount>
required
User’s token account for the debt token. Will receive borrowed tokens.
The user borrowing. Must be a signer.
Arguments
Amount to borrow. Use u64::MAX to borrow maximum available. Must be greater than 0 otherwise.
use anchor_lang::prelude::*;
use omnipair::program::Omnipair;
// Borrow specific amount
let borrow_args = AdjustPositionArgs {
amount: 500 * 10u64.pow(debt_token_decimals),
};
// Or borrow maximum available
let max_borrow_args = AdjustPositionArgs {
amount: u64::MAX,
};
let accounts = CommonAdjustPosition {
pair: pair_pda,
user_position: user_position_pda,
token_vault: debt_token_vault,
user_token_account: user_debt_token_account,
user: user.key(),
// ... other accounts
};
let ctx = CpiContext::new(program_id, accounts);
omnipair::cpi::borrow(ctx, borrow_args)?;
{
"signature": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmG5Rk88jH2k9f4w3JHFf7Pjsk3bWqeXrC",
"slot": 123456789
}