Repay Debt
Repay borrowed assets to improve your position health.1
Import Dependencies
Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.2
Load Signer and Initialize Market
Load your keypair from a file and initialize RPC connections and the Kamino market.Replace
/path/to/your/keypair.json with the actual path to your keypair file. The KaminoMarket.load() method fetches the current market state including all reserve data.3
Fetch Obligation and Build Repay Instructions
Fetch the existing obligation and generate repay instructions for the specified token and amount.The
buildRepayTxns method creates instructions to repay your borrowed assets. Repaying reduces your debt and improves your loan-to-value ratio.4
Build and Sign Transaction
Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.5
Send and Confirm Transaction
Send the repay transaction and wait for confirmation.Once the repay transaction is confirmed, your debt is reduced and your loan-to-value ratio improves. You stop paying interest on the repaid amount.
Withdraw Collateral
Withdraw collateral from your obligation.1
Import Dependencies
Import the required packages for Solana RPC communication, Kamino SDK operations, and Kit transaction building.2
Load Signer and Initialize Market
Load your keypair from a file and initialize RPC connections and the Kamino market.Replace
/path/to/your/keypair.json with the actual path to your keypair file. The KaminoMarket.load() method fetches the current market state including all reserve data.3
Build Withdraw Collateral Instructions
Generate withdraw instructions for the specified collateral token and amount.The
buildWithdrawTxns method creates instructions to withdraw your collateral. You can only withdraw collateral if your position remains healthy after the withdrawal.4
Build and Sign Transaction
Use Kit’s functional pipe pattern to build and sign the transaction with a fresh blockhash.5
Send and Confirm Transaction
Send the withdraw transaction and wait for confirmation.Once the withdraw transaction is confirmed, your collateral is returned to your wallet. Your borrowing capacity decreases and your loan-to-value ratio may increase.