> 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-lp-lane.md).

# LP loans with gage-sdk

LP loans with gage-sdk: fixed-cost USDG loans against Uniswap, SushiSwap, Ouro, Ramses and Fables liquidity positions, LP vaults and curators.

gage lends USDG at a fixed cost against a liquidity position: an ETH/USDG or stock/USDG position on Uniswap v3 or v4, SushiSwap v3, Ouro v3, Ramses or Fables, in a pool the LP lane lists (`capabilities().lpLane`). There is no liquidation: the loan is never closed early because a price moves, and a loan not repaid by its end is settled by unwinding the position for its lenders, nothing else taken. Lending to the lane is a deposit into an LP vault. See [Borrow against LP positions](https://docs.gage.cash/borrow/lp-lane.md).

## Borrow against a position

```ts
const [{ lpLane }, positions, { vaults }] = await Promise.all([gage.capabilities(), gage.lpPositions(wallet), gage.lpVaults()]);
```

`lpPositions(wallet)` lists the wallet's positions in a pool the lane lends against, with each one's range, amounts and worth in USDG, and whether the lane takes it now (`borrowable`, else `refusal`). Uniswap v4 positions are found through gage's index and checked on chain. Fables receipts not wrapped into a position yet are under `fablesReceipts`.

```ts
// Signed for this wallet for five minutes at most: borrow soon after quoting.
const quote = await gage.lpQuote({ adapter: position.adapter, tokenId: position.tokenId, wallet: signer.address, term });
const { action: _, ...loan } = quote.prepare;
const borrowed = await gage.run({ action: "lp_borrow", ...loan }, signer);
```

`lp_borrow` approves the position to the lane's core on its own position manager, borrows on the quote, and sends the USDG the loan pays out, less its fee, to the wallet. Sent with under a minute of its quote left, it is quoted again and refused above `maxCostBps`. A Uniswap v4 position leaves any subscription it has as it moves into the loan's escrow. A stock LP is priced on weekends and holidays too, on a smaller loan, and a report inside its term is priced in. With `rangeId` instead of `tokenId`, Fables receipts are wrapped into a position first, and the borrow follows once the wrap is mined.

## The fourteen actions

| Action                 | Does                                                                                                   |
| ---------------------- | ------------------------------------------------------------------------------------------------------ |
| `lp_borrow`            | Borrows against a position, or Fables receipts not wrapped yet.                                        |
| `lp_repay`             | Repays an LP loan in full before its end and takes the position back.                                  |
| `lp_return_position`   | Takes back the position of an LP loan repaid before its end.                                           |
| `lp_roll`              | Rolls a running LP loan into a new loan on the same position; only the difference moves.               |
| `lp_collect`           | Collects a running loan's trading fees, and a Ramses position's rewards; the liquidity stays in place. |
| `lp_withdraw`          | Withdraws what the lane credits the wallet.                                                            |
| `lp_deposit`           | Deposits USDG into an LP vault.                                                                        |
| `lp_redeem`            | Withdraws from an LP vault, every share its free cash pays when `shares` is omitted.                   |
| `lp_claim_bonus`       | Claims an LP vault's bonus for a defaulted loan.                                                       |
| `lp_wrap`              | Wraps every Fables receipt of one range into one position NFT the lane lends against.                  |
| `lp_unwrap`            | Gives a wrapped Fables position back as its receipts.                                                  |
| `lp_create_vault`      | Opens an LP vault, for a wallet the LP registry lets open one.                                         |
| `lp_vault_add_pool`    | Adds a pool to the mandate of an LP vault you curate; it funds there three hours later.                |
| `lp_vault_remove_pool` | Drops a pool from the mandate of an LP vault you curate, at once; open loans run on.                   |

```ts
export const repayLpLoan = (gage: Gage, signer: Signer, loanId: string) => gage.run({ action: "lp_repay", loanId }, signer);
```

## Lend to the lane

```ts
const { vaults } = await gage.lpVaults();
const vault = vaults.find((v) => v.vault.toLowerCase() === chosen.toLowerCase());
if (!vault?.takesDeposits) throw new Error("That LP vault takes no deposits now");
return gage.run({ action: "lp_deposit", vault: vault.vault, amount }, signer);
```

`chosen` is the address of the LP vault you chose: curators open their own, so choose by the curator and the pools it funds, not by its place in the list.

`lpVaults()` lists the LP vaults: size, free cash, loans out, share value, fee, curator, the pools each funds, and whether it takes deposits and pays out now. An LP vault's shares (`gLP`) move between wallets, counted in the vault's own `shareDecimals`. A vault takes no deposit and pays nothing out while a loan past its end is not settled (`VAULT_IMPAIRED`). A defaulted loan's sale that brings more than its book value pays its lenders a bonus (`lp_claim_bonus`).

## Curators

A wallet the LP registry lets open a vault opens one with `lp_create_vault`: its name, its performance fee (500 to 1,500 basis points of each loan's fixed cost, fixed for good), its largest loan and the pools it funds. Its curator changes the pools with `lp_vault_add_pool` and `lp_vault_remove_pool`, and never touches its lenders' money.


---

# 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-lp-lane.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.
