> ## Documentation Index
> Fetch the complete documentation index at: https://getequity.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Credit on Solana (Kamino Lend)

> Borrow cNGN against gNTB, or lend cNGN, through Kamino Lend on Solana.

On Solana, credit runs on [Kamino Lend](https://docs.kamino.finance) (the `klend`
program). A lending market holds one **reserve** per token: gNTB's reserve accepts it as
collateral, and cNGN's reserve is what lenders supply and borrowers draw. A borrower's
position is an **obligation** account that records its deposits and borrows.

<Warning>
  **Devnet only.** No gNTB market exists on Solana mainnet yet.
</Warning>

## The gNTB / cNGN market (devnet)

| | Address |
| - | - |
| klend program | `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD` |
| Lending market | `HMovGgLerJ4XZa1xzRLStHSEogXo77fWRtQN8AGdWW2D` |
| gNTB reserve | `5czpRfDs69uMbcytnGSrg1NLxhUMaZrzn4Nx72vsvuUz` |
| cNGN reserve | `6DDM2QqTcm5uuKtShUx5usGnH42QThos1o6v7hFJ3hCQ` |
| gNTB mint (Token-2022, 6 dp) | `55dDdsg9WN4s1WVX8u2KGDLyusWW4MchaLgtEgX96TET` |
| cNGN mint (Token-2022, 6 dp) | `HfJWS8vJHvxKn5xW3uLXkTmEy4jny3G45QnS1Eab5sg` |
| Scope price feed (prices account) | `Bt77wjkiDjwwwPZhuCX7aFRBocwgihuu336eBV6EVVrJ` |

| Reserve setting | gNTB | cNGN |
| - | - | - |
| Use | Collateral only (borrow limit 0) | Lend and borrow (not collateral) |
| Max LTV (borrow up to) | 75% | — |
| Liquidation threshold | 77% | — |
| Liquidation bonus | 7.4% | — |
| Scope price entry | 0 (gNTB in cNGN) | 1 (cNGN = 1) |
| Borrow rate curve | — | 0% → 6% at 50% → 11% at 80% → 12% at 85% → 30% at 90% → 80% at 100% |

These are read from the reserve accounts; re-read them before relying on them.

## Using the Kamino SDK

The simplest client is Kamino's TypeScript SDK,
[`@kamino-finance/klend-sdk`](https://github.com/Kamino-Finance/klend-sdk). Load the
market by its address and build actions with `KaminoAction`
(`buildDepositTxns`, `buildBorrowTxns`, `buildRepayTxns`, `buildWithdrawTxns`): the SDK
adds the refresh instructions described below for you.

<Note>
  The SDK resolves prices through Kamino's **mainnet** Scope program by default. On
  devnet, our feed lives on Kamino's devnet Scope program
  (`3Vw8Ngkh1MVJTPHthmUbmU2XKtFEkjYvJzMqrv2rh9yX`), so SDK helpers that compute prices
  client-side may not find it. Building and sending transactions is unaffected: the
  `klend` program reads the feed itself.
</Note>

## The instructions

If you build transactions yourself, klend refuses an action on stale state, so every
action is preceded **in the same transaction** by:

1. `refresh_reserve` for every reserve the obligation touches, plus the one you act on.
   Accounts: reserve, lending market, then the Pyth / Switchboard price / Switchboard
   TWAP slots (pass the klend program id for "none"), then the Scope prices account.
2. `refresh_obligation`, with the obligation's **deposit reserves, then its borrow
   reserves**, in the order the obligation lists them, as remaining accounts.

| Action | Instruction | Amount |
| - | - | - |
| First use (once per wallet) | `init_user_metadata`, then `init_obligation` (tag 0, id 0) | — |
| Post gNTB | `deposit_reserve_liquidity_and_obligation_collateral_v2` | gNTB base units |
| Borrow cNGN | `borrow_obligation_liquidity_v2` | cNGN base units |
| Repay | `repay_obligation_liquidity_v2` | cNGN base units; `u64::MAX` repays exactly what is owed |
| Withdraw gNTB | `withdraw_obligation_collateral_and_redeem_reserve_collateral_v2` | **collateral (kToken) units**, not gNTB |
| Lend cNGN | `deposit_reserve_liquidity` | cNGN base units; you receive kTokens |
| Withdraw lent cNGN | `redeem_reserve_collateral` | **kToken** units |

Posting collateral and borrowing can share one transaction: deposit, then refresh again
(the obligation now lists the gNTB deposit), then borrow.

### Accounts you derive

| Account | Seeds (klend program) |
| - | - |
| Lending market authority | `["lma", market]` |
| User metadata | `["user_meta", owner]` |
| Obligation (vanilla) | `[0u8, 0u8, owner, market, Pubkey::default, Pubkey::default]` |

Reserve vaults (liquidity supply, fee receiver, collateral mint, collateral supply) are
stored on the reserve account: read them from it. The gNTB and cNGN reserves have no
rewards farm, so the `_v2` instructions' farm accounts are the klend program id, with the
farms program `FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr`.

### kTokens

Deposits are tracked in the reserve's collateral token (kTokens). One kToken is worth
`total supply ÷ kToken supply` of the underlying, where total supply = available
liquidity + borrowed − accumulated fees. It starts at 1 and grows as interest is paid, so
convert amounts to kTokens before withdrawing (round down).

## The price feed

Each reserve reads its price from a Scope feed on Kamino's oracle program. Ours is a
`FixedPrice` entry that GetEquity updates to gNTB's accrued price in cNGN (entry 0), with
cNGN fixed at 1 (entry 1). Read an entry from the prices account at byte offset
`40 + 56 × index`: `value` (u64), `exp` (u64), then the slot and unix timestamp it was
last refreshed.

A reserve refuses a price older than its `maxAgePriceSeconds`. On devnet this is set
generously (7 days) for testing; a mainnet market would require a short age and a
running updater.

## Liquidation

When a position's borrowed value exceeds the liquidation threshold (77%) of its collateral
value, anyone may call `liquidate_obligation_and_redeem_reserve_collateral` to repay part
of the debt and receive gNTB worth the repaid amount plus the 7.4% bonus. Kamino's
liquidation rules (how much can be repaid at once) are in its
[documentation](https://docs.kamino.finance).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.