Guides

Borrow from a seat

This guide opens a position at Kamino from your private balance: deposit collateral, borrow against it, repay, withdraw the collateral and close. The position is owned by a seat, an address no wallet controls, and you command it with a note. Seats explains the object. This page is the task.

You need a private balance holding the asset you will use as collateral. The examples deposit SOL and borrow USDC.

The four hooks

HookWhat it doesAsset inAsset out
kamino.collateral.depositPuts collateral into the seat's position. The first one opens the seat.The collateralNone
kamino.borrowBorrows against the collateral.NoneThe borrowed asset
kamino.repayPays the debt down.The borrowed assetNone
kamino.collateral.withdrawTakes collateral out.NoneThe collateral

Assets going into a seat come from your notes. Assets coming out become new notes in your private balance.

In the app

  1. Deposit collateral

    On Balance, under Run a hook, press Deposit collateral. Under Seat, leave Open a new seat selected. Pick the collateral asset, type the amount and press Run.

    The first stage reads Opening a seat, then Making the proofs, Relayed and Confirmed. Two transactions go out, both submitted by the relayer: one opens the seat and its position at Kamino, the next makes the deposit.

  2. Look at the seat

    Open Seats. The seat is listed with what it Holds and what it Owes, its Health, its address and its position at Kamino.

  3. Borrow

    Press Borrow on the seat, or open kamino.borrow from Run a hook and choose the seat under Seat. Pick the asset to borrow, type the amount and press Run. The borrowed asset arrives as a note in your private balance.

  4. Repay

    Open kamino.repay on the same seat. The asset in is the one you borrowed. Type the amount and press Run. To clear the debt, repay a little more than the seat shows as owed, about 0.1% more: interest accrues every moment, Kamino takes only what is owed, and the rest returns to your private balance as a note in the same run.

  5. Withdraw the collateral

    Open kamino.collateral.withdraw on the seat, type the amount and press Run. The collateral returns as a note.

  6. Close the seat

    Once the seat holds nothing and owes nothing, Seats offers Close this seat. Closing returns the seat's rent to the relayer that opened it. A close sent while collateral or debt remains is refused with SEAT_NOT_EMPTY.

With the SDK

Every step is a pook.run. A seat hook takes the seat's address as seat. Leave it out on the first deposit and the SDK opens a seat first.

TypeScript
const SOL = 'So11111111111111111111111111111111111111112'
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'

// 1. Deposit 0.1 SOL as collateral. No seat named, so one is opened first.
const deposit = await pook.run('kamino.collateral.deposit', {
  in: SOL,
  amount: '100000000',
  onStage: (stage) => console.log(stage), // opening_seat, quoting, proving, relayed, confirmed
})
const seat = deposit.seat

// 2. Borrow 1 USDC against it.
await pook.run('kamino.borrow', { out: USDC, amount: '1000000', seat })

// 3. Read the position.
const [position] = (await pook.seats()).filter((s) => s.seatAddress === seat)
position.collateral   // [{ mint, symbol, decimals, amount, usdValue }]
position.debt         // the same shape
position.healthFactor

// 4. Repay the debt plus 0.1%, rounded up, to cover interest accrued since the read.
//    Kamino takes what is owed and the rest returns to you as a note.
const debt = BigInt(position.debt[0].amount)
const owed = debt + (debt + 999n) / 1000n
await pook.run('kamino.repay', { in: USDC, amount: owed, seat })

// 5. Withdraw all the collateral.
await pook.run('kamino.collateral.withdraw', {
  out: SOL,
  amount: '18446744073709551615',
  seat,
  args: { withdrawAll: 'true' },
})

// 6. Close the seat.
await pook.closeSeat(seat)

deposit.openSeatSignature is the transaction that opened the seat, and deposit.signature is the deposit.

For kamino.borrow and kamino.collateral.withdraw, amount is what you ask the protocol for, since nothing leaves your notes. Passing withdrawAll with the largest 64-bit amount withdraws every unit of collateral and lets Kamino close the position.

What happens when a seat opens

Opening a seat is its own transaction, the instruction open_seat. In it the program records the seat, your first seat note is created, and Kamino's accounts for the seat are created with the seat as their owner. The relayer puts up the rent for all of it, about 0.034 SOL for a Kamino seat, and gets it back when the seat is closed. Opening and closing carry no relayer's fee.

To Kamino the seat is an ordinary borrower. Its obligation shows the collateral and the debt like anyone's.

Fees on seat runs

A run that returns an asset, the borrow and the collateral withdrawal, pays the run fee and the relayer's fee out of that asset. A run that returns nothing, the deposit and the repayment, pays neither.

Keeping the position healthy

Kamino's rules apply to a seat exactly as they apply to a wallet. If the debt grows too large against the collateral, Kamino can liquidate the position. Seats shows each seat's Health as Kamino computes it, and pook.seats() returns it as healthFactor, which is null when nothing is owed. Repay or add collateral to raise it.

What the chain shows

The seat's address, its position at Kamino and every run on it are public. What links the seat to you is the seat note, which is encrypted. No wallet appears in the seat's address, in the transaction that opened it or in any run on it. What the chain shows has the full table.