Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integrate gage

Reading gage from your own app, lending and borrowing from your own contracts, and what to never rely on.

The contracts and their events are public. gage runs the services that read them, and what those serve can be rebuilt from the events. This page is for anyone building on top.

For an AI agent, start with AI Agents. The public API, SDK and MCP interface share a documented discovery and unsigned preparation workflow.

Reading

  • From the indexer. The API, which gage runs, serves every list and page the app shows, partner vaults included. Without it, read the events directly: what it serves can be rebuilt from them.

  • From the contracts. getLoan(id) and loanCount() on each native engine (the engines, their registries and adapters are the manifest's nativeV2.engines at https://gage.cash/api/deployment; the partner lending contracts are under intentV1 and, per lend asset, intentV1Assets); getDeal, getBid, claimableAt and the balance views on the legacy vault; earned, positionState and valueInGAGE on the liquidity rewards contract; epoch and budget views on emissions. See Contracts.

  • Links. A partner vault's page is https://gage.cash/v/<link>, its link from the name it was created with, listed by GET /intent/partners/links on the indexer; a token's Borrow page is https://gage.cash/borrow/<link>, by ticker. The first vault to claim a link keeps it, and a rename never moves one.

Writing

  • Lend from a contract. New loans live on the Intent core (intentV1.core in the manifest at https://gage.cash/api/deployment), and only partner vaults fund them: a wallet or a contract lends by depositing into a partner vault (deposit(assets, minShares), then redeem(shares, minAssets) to withdraw, or the standard ERC-4626 entry points on a current vault; see Contracts), not by funding a listing. You may end up holding the collateral instead of USDG. The earlier engines keep their own loans until they close.

  • List from a contract. Approve the collateral to the Intent core and call list; partner vaults whose rules take it fund it whole on gage's next pass, or it waits until its funding deadline. Withdrawals credit the caller; a contract that lists must be able to call withdrawUSDG and the collateral withdrawals.

  • From TypeScript. gage-sdk reads, quotes and prepares all of this, rollovers and cash-outs included, and carries it out with your own signer. In another site's page, use the hosted API: the SDK's prices come from a service that answers browsers on gage's own sites only.

  • Park your LPs' out-of-range positions. A DEX lets its liquidity providers move an out-of-range position's one token into its partner vault, and back into a new range, from their own wallet: Park out-of-range positions.

  • Register rewards (legacy vault). register(dealId) on the deal rewards contract is permissionless. The native engines carry their own rewards ledger, the rewards address of each manifest entry.

  • Checkpoint positions. checkpoint(tokenId) on the liquidity rewards contract is permissionless and keeps a position's score current.

  • Trigger a clip. DealFeeRouter.process(clipUSDG) and FeeFloor.claimAndSplit(clipETH) are permissionless subject to batch thresholds and swap checks. They pay no caller bounty. Seed-lock compounding is a separate operation restricted to its fixed treasury wallet.

Add Borrow to your site

Everything a page needs is on one host, https://mcp.gage.cash, open to any origin and with no key: add it to your connect-src. The HTTP API has every route and answer. This is the order to call them in.

  1. Read what you would otherwise hard-code. GET /v1/capabilities names the core, the rollover and cash-out routers, the fee and whether new loans are paused. gage can open a new core: read it, rather than keep its address in your code.

  2. List the markets. GET /v1/assets names each token gage takes, its minAmount, the terms a partner vault lends for now and whether it is paused. Offer those terms: capabilities.terms is what gage allows, not what a vault takes today. Keep this list on your own server, since quoting every token for every visitor runs into the ceilings of 120 requests and 30 prepares a minute per address (RATE_LIMITED, with Retry-After).

  3. Quote. GET /v1/borrow-quote answers the largest loan the partner vaults fund now for at most the pledge you name, and a prepare object to post. A refusal is a code to branch on: a token with no room now answers INSUFFICIENT_CAPACITY.

  4. Send each step. POST /v1/prepare answers the next unsigned transaction, simulated now, for the person's wallet to sign. Send it, wait for its receipt, and prepare again until next.final is true. Serve borrow, reclaim, cancel, cash_out, roll and collect the same way: there is no calldata to build, and nothing to change when gage does.

  5. Show the loans. GET /v1/portfolio/{wallet} names each loan's core (engine), token, state and repayment, the wallet's USDG waiting (usdgCredit) and the sGAGE each loan earned (sgageClaimable). Offer collect: once a vault funds a listing, the USDG waits as the wallet's credit until it is collected.

Whatever you send, however you build it:

  • Keep a repayment apart from taking the collateral back. A paused Stock Token cannot move, so withdrawCollateral reverts while reclaim still goes through. In one all-or-nothing batch, the repayment fails with it, and there is no grace: past the term's last second the lenders keep the collateral. A prepare leaves that step out while the token is paused. If you batch by yourself, batch the approval with reclaim and no more. The same goes for cancelFunding.

  • Offer a roll in a loan's last day. A roll works at any time, and gage.cash offers it only then: before it, the roll repays the loan early and pays the new loan's whole fee for little more time. Its price is signed for 30 seconds, so prepare it right before it is sent.

  • Say what a loan is. The cost is fixed, and there is no liquidation: a loan never closes early because a price moves. If it is not repaid by the end of its term, the lenders keep the collateral and nothing else is taken.

  • Show amounts in shares. Stock Token amounts are raw units. Scale them by uiMultiplier for display, and send them raw.

Tell gage you have integrated, so you hear before a new core opens.

What never to rely on

  • A price from the contracts. There is none. The vault reads no price; the in-range check reads a tick at deposit only.

  • The services being up. Nothing they hold is needed to settle a loan. Reclaim, claim, cancel, redeem and withdraw work with a wallet and the contract addresses alone. Funding a new listing does need them: gage's keeper is the only filler, on plans its rates service signs, and it also runs the rolls borrowers leave to roll by themselves.

  • Push transfers. Anything owed is credited to a balance and withdrawn by its owner. Read the balance views (cashCredit on an engine, the balance views on the legacy vault), not incoming transfers: the legacy vault emits Withdrawn, an engine's withdrawal only the token's Transfer.

  • Token-layer keys being present. The deployment record gains them when that layer is deployed, and every consumer must work without them.

Robinhood Chain specifics

  • The Universal Router on Robinhood Chain is a modified fork whose v4 swap struct carries an extra minHopPriceX36 field. Stock Uniswap SDK calldata reverts. Anything that builds swap calldata for the entry router must target that ABI.

  • Stock Token amounts are raw units on-chain. Scale by uiMultiplier() for display only.

  • Block timestamps are the clock. Block numbers on this stack are an L1 estimate.

Last updated

Was this helpful?