Repay
Repays borrowed debt, reducing the user’s debt position.
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 repaid).
user_token_account
InterfaceAccount<TokenAccount>
required
User’s token account for the debt token. Must have sufficient balance.
The user repaying. Must be a signer.
Arguments
Amount to repay. Use u64::MAX to repay all debt. Must be greater than 0 otherwise.
use anchor_lang::prelude::*;
use omnipair::program::Omnipair;
// Repay specific amount
let repay_args = AdjustPositionArgs {
amount: 300 * 10u64.pow(debt_token_decimals),
};
// Or repay all debt
let repay_all_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::repay(ctx, repay_args)?;
{
"signature": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmG5Rk88jH2k9f4w3JHFf7Pjsk3bWqeXrC",
"slot": 123456789
}