> For the complete documentation index, see [llms.txt](https://docs.gage.cash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gage.cash/developers/sdk-lend-generations.md).

# Lend markets with gage-sdk

Lend markets with gage-sdk: the stock tokens and stablecoins gage lends besides USDG, and new stablecoin markets found on chain.

gage lends more than USDG. Each asset it lends has its own lending generation: its own core, registry, factory and partner vaults. A generation lends a stock token, such as GLD, NVDA or HIMS, or a stablecoin. Every answer that serves amounts names their `asset`, counted in that asset's raw units.

## The markets

```ts
// Ask gage's indexer for generations found on chain now; every other read asks at most once a minute.
await gage.refreshGenerations();
const [{ lendAssets = [] }, { assets }, { vaults }] = await Promise.all([gage.capabilities(), gage.assets(), gage.earnVaults()]);
```

`capabilities().lendAssets` names each asset gage lends besides USDG: its token, symbol, decimals, whether it is a stablecoin (`stable`), its core, factory and terms, and the routers it names. Each row of `assets()` names the asset it is borrowed in, and each vault of `earnVaults()` the asset it lends.

## Borrow and earn in a lend asset

```ts
const quote = await gage.borrowQuote({ token: row.token, maxCollateral: parseUnits(amount, row.decimals).toString(), term: term.seconds, lendAsset: market.token });
```

* `borrowQuote` and `borrow` take `lendAsset`, the asset's token: the loan is paid out and repaid in that asset, so in dollars what you repay moves with its price.
* `reclaim`, `roll` and `cash_out` act in the asset of the loan's own core, and `earn_deposit` deposits in the vault's own asset. Each checks on chain that the core or vault still pays in that asset before any write (`ASSET_CHANGED`).
* Leverage and sGAGE rewards are USDG's alone. A stock token's loop router opens puts: see [Puts with gage-sdk](https://docs.gage.cash/developers/sdk-puts.md).

## Stablecoin markets, found on chain

A new stablecoin market is deployed in one batch through gage's `GenerationDeployer`, and reaches gage-sdk with no new release of the package:

* gage's indexer serves each market the deployer built, as the deployment entry it would be.
* gage-sdk proves each one on chain before it uses it: the deployer's own event names the market's factory, the deployer confirms the factory is one it built, and the market's contracts answer as the entry says. A market the chain does not bear out is left out, so nothing is prepared into a contract the index alone names.
* A market joins `capabilities().lendAssets` with `stable: true` once it is listed. It lends against the tokens its own registry admits.

Every read asks the indexer at most once a minute; `refreshGenerations()` asks now.

## Retired generations

A generation gage has retired keeps its positions: its loans can be repaid, its collateral collected and its vaults withdrawn from. Nothing rolls over on it any more: `roll` and `auto_roll` are refused (`ROLLOVER_CLOSED`), and an open loan's `note` says to repay it before it ends.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gage.cash/developers/sdk-lend-generations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
