# Sable skill

Sable is fixed-rate, fixed-term credit for HYPE holders on Elysium (chain 99901, gas in HYPE). Borrowers lock HYPE and
borrow USDC for 7, 30 or 90 days at a rate known on day one; lenders lend USDC at a fixed rate and receive notes (an
ERC-20 per term and maturity, one note per USDC owed at maturity). Every order joins the auction of its term that closes
at 00:00 UTC and clears at one rate.

## Read
- GET https://www.sablecredit.xyz/api/rates: last clearing rate per term, history, tonight's indicative rate (basis points per year)
- GET https://www.sablecredit.xyz/api/auctions?term=30d: tonight's aggregated book, close, maturity, indicative clearing
- GET https://www.sablecredit.xyz/api/feed: HyperCore HYPE mid, Elysium v4 pool price, Sable's guarded feed and its status (0 = usable)
- GET https://www.sablecredit.xyz/api/quote?amount=1000&term=30d&rate=6: collateral needed, fee, owed at the maximum, liquidation price
- GET https://www.sablecredit.xyz/api/loan?term=30d&id=12: one loan's debt, collateral, loan-to-value, liquidatable
- MCP (keyless, streamable HTTP, JSON): https://www.sablecredit.xyz/mcp, tools rates, auction, feed, quote_borrow, quote_lend, loan,
  offer_calldata, bid_calldata, repay_calldata, redeem_calldata, clear
- SDK: import * as Sable from "https://www.sablecredit.xyz/sdk/sable.js"

## Rules (written in the contracts)
- Rates: 0.05 % grid, 0.05 % to 50 % per year. Interest is simple, ACT/365: owed = principal x (1 + rate x days / 365).
- Clearing: over every order rate, the largest min(USDC offered at minimums <= r, USDC asked at maximums >= r) is the
  volume; the rates reaching it form [r_lo, r_hi]; the clearing rate is floor((r_lo + r_hi) / 2). Offers fill from the
  lowest minimum up, bids from the highest maximum down, the crossing level pro rata. Every fill is at the clearing rate.
- A bid posts HYPE covering amount x (1 + maxRate x days / 365) at 50 % loan-to-value.
- Origination fee 0.3 % of the principal. Repaying early pays the same fixed amount.
- Liquidation: anyone, at 70 % loan-to-value or from maturity unpaid; sells through the v4 HYPE/USDC pool within
  3 % of the guarded price; the caller gets 5 % of the HYPE sold.
- Notes redeem 1:1 from maturity while the cohort's cash covers them, else pro rata once its loans are closed.
- Orders placed during UTC day d-1 join auction d (closes d x 86400). Cancel any time before the close.

## Act (the agent signs with its own wallet; Sable holds no key)
1. Lend: approve USDC to the market, then offer(amount6, level) where level = rate_bps / 5.
2. Borrow: bid(amount6, level, 0) with the HYPE collateral as msg.value.
3. After 00:00 UTC: claim(id) (the nightly job usually does it for everyone).
4. Repay: approve USDC, repay(id, amount). Redeem notes from maturity: redeem(day, notes6).
Use the *_calldata MCP tools to get exact transactions. Gas: bid twice the base fee, priority fee 0.
