# Tapehouse > Portfolio margin for Stock Tokens on Robinhood Chain: a price band that keeps updating while the market is closed, margin accounts that treat a portfolio as one position, and SDKs, an API and an MCP server to read and build on them. Testnet only, not audited. Every page is also served as Markdown at its own address with `.md` appended, and the whole documentation as one file at /llms-full.txt. ## Get started - [Introduction](https://docs.tapehouse.xyz/md/index): Tapehouse is portfolio margin for Stock Tokens on Robinhood Chain. This is where you read its prices, borrow against a portfolio and build on it. - [Quickstart](https://docs.tapehouse.xyz/md/quickstart): Read a Stock Token's band and the price at which a position would be liquidated, against Robinhood Chain's testnet. - [Networks](https://docs.tapehouse.xyz/md/networks): The chains Tapehouse has a registry for, their chain IDs and RPC endpoints, what is deployed on each, and how to get test funds on the testnet. ## Concepts - [The band](https://docs.tapehouse.xyz/md/concepts/band): How Tapehouse prices a Stock Token while the equity market is closed, what the band's state and width mean, and what stops it from answering. - [The session](https://docs.tapehouse.xyz/md/concepts/session): How the band knows whether the market is open, and what changes for a loan across the week, from the margin ramp to the reopening auction. - [Portfolio margin](https://docs.tapehouse.xyz/md/concepts/portfolio-margin): How the margin engine turns a whole portfolio of Stock Tokens into one requirement, and how that requirement changes with the session. - [Liquidation](https://docs.tapehouse.xyz/md/concepts/liquidation): When a position is sold, how the Dutch auction and the sealed-bid reopening auction work, and who bears a loss in what order. - [Weekend gap cover](https://docs.tapehouse.xyz/md/concepts/weekend-gap-cover): Buy cover against a Stock Token's fall over a market closure, paid in USDG, and see how it is priced and settled from public inputs. - [Trust and limits](https://docs.tapehouse.xyz/md/concepts/trust): What each input to Tapehouse is signed by, what you can check yourself, who can pause what, and what is not live or not covered. ## Guides - [Read a price](https://docs.tapehouse.xyz/md/guides/read-a-price): Read a Stock Token's band, the market session and any trading halt from the chain, and tell a price from no price. - [Open an account](https://docs.tapehouse.xyz/md/guides/open-an-account): Create a smart account that Tapehouse sponsors the first operations of, and deposit Stock Tokens into a margin position. - [Borrow](https://docs.tapehouse.xyz/md/guides/borrow): Read your position's liquidation price with the loan counted in, borrow USDG against it, and repay. - [Earn](https://docs.tapehouse.xyz/md/guides/earn): Supply USDG to the vault, join the gap backstop, or lend a Stock Token, and know what each earns, how you leave and what you bear. - [Short and baskets](https://docs.tapehouse.xyz/md/guides/short-and-baskets): Short a Stock Token on its own USDG margin, and mint, hold and redeem an index basket of Stock Tokens. - [Price a Morpho market with the band](https://docs.tapehouse.xyz/md/guides/morpho-oracle): Read a Stock Token's Morpho oracle, deploy one, create a Morpho Blue market on it, and liquidate against it. - [Bid in the reopening auction](https://docs.tapehouse.xyz/md/guides/auction): Commit, reveal and claim a sealed bid for the collateral of positions that fell short over a weekend, or run the reference bidder that does it for you. ## Operate - [Run the indexer](https://docs.tapehouse.xyz/md/operate/indexer): Run the Tapehouse indexer, its public API and its x402 facilitator yourself, with every environment variable, the tiers and the health check. - [Run the keepers](https://docs.tapehouse.xyz/md/operate/keepers): Run the keeper service that sends every permissionless call keeping Tapehouse on time, with its jobs, environment variables and key handling. - [Run the sponsor](https://docs.tapehouse.xyz/md/operate/sponsor): Run the sponsor service that signs ERC-4337 paymaster data, with its environment variables, limits, keys and the dev-node setup. - [Run the reference bidder](https://docs.tapehouse.xyz/md/operate/bidder): Run the reference bot that bids in the reopening auction and buys in liquidation auctions, with its pricing rule, state file and environment variables. - [Run the alerts service](https://docs.tapehouse.xyz/md/operate/alerts): Run the service that warns margin holders by email or Telegram before a weekend and before a liquidation, with its API, environment variables and what it stores. ## SDKs - [SDKs](https://docs.tapehouse.xyz/md/sdks/overview): Three SDKs, in TypeScript, Go and Rust, read Tapehouse's contracts and build their transactions from one registry of addresses. - [TypeScript SDK](https://docs.tapehouse.xyz/md/sdks/typescript): Read the band, margin accounts, shorts, baskets and gap cover and build their transactions with @tapehouse/sdk on viem. - [Go SDK](https://docs.tapehouse.xyz/md/sdks/go): Read the band, margin accounts, shorts, baskets, auction and gap cover from Go and pack their transactions, over go-ethereum bindings. - [Rust SDK](https://docs.tapehouse.xyz/md/sdks/rust): Read the band, margin accounts, shorts, baskets and gap cover and build their transactions with the tapehouse-sdk crate on alloy. - [Errors](https://docs.tapehouse.xyz/md/sdks/errors): Decode a revert from any Tapehouse contract into a named error with arguments, and look up what each custom error means and how to fix it. ## Agents - [Agents](https://docs.tapehouse.xyz/md/agents/overview): How an AI agent reads Tapehouse, prepares transactions for a wallet to sign, borrows within a mandate and pays for API reads. - [MCP server](https://docs.tapehouse.xyz/md/agents/mcp): Run @tapehouse/mcp so an AI agent can read the band, margin accounts, shorts and gap cover, and prepare unsigned transactions. - [Claude Code plugin](https://docs.tapehouse.xyz/md/agents/claude-code): Install the Tapehouse plugin in Claude Code to read the band and margin positions and prepare transactions for a wallet to sign. - [Mandates](https://docs.tapehouse.xyz/md/agents/mandates): Give an agent a bounded authority over a margin account: a time, a debt limit and a leverage limit, with loans and withdrawals sent only to the account. - [Paying per request over x402](https://docs.tapehouse.xyz/md/agents/x402): Read Tapehouse's API beyond the public allowance by paying 0.001 USDG a request over x402, with no API key. ## Indexer API - [Indexer API overview](https://docs.tapehouse.xyz/md/api/overview): Every event and view of Tapehouse's contracts over REST and a WebSocket, with the limits of each tier and how to pay per request. ## Contracts - [Contracts overview](https://docs.tapehouse.xyz/md/contracts/overview): How the Tapehouse contracts fit together, which are Solidity and which are Stylus, where the source lives and how to build, test and verify it. - [Addresses](https://docs.tapehouse.xyz/md/contracts/addresses): Every contract Tapehouse deployed on Robinhood Chain's testnet, read from the registry the SDKs use. ## Pricing - [Band](https://docs.tapehouse.xyz/md/contracts/band): The Stylus program that prices each Stock Token as a band, with its functions, events, roles and the SDK calls that read it. - [Band feeds](https://docs.tapehouse.xyz/md/contracts/band-feeds): One Chainlink-compatible feed per asset that serves one side of the band, with the whole band, the token's market and a seal before each reopen. - [Margin engine](https://docs.tapehouse.xyz/md/contracts/margin-engine): The Stylus program that returns the margin a portfolio of Stock Tokens needs, with its inputs, outputs, parameters, roles and SDK calls. - [Morpho oracle](https://docs.tapehouse.xyz/md/contracts/morpho-oracle): The Morpho Blue oracle that prices a Stock Token at the low edge of its band, with its functions, owner powers, failure modes and SDK calls. ## Lending - [Supply vault](https://docs.tapehouse.xyz/md/contracts/supply-vault): The ERC-4626 vault where lenders deposit USDG and earn the interest the margin accounts pay, with its functions, rates, roles and SDK calls. - [Margin accounts](https://docs.tapehouse.xyz/md/contracts/margin-accounts): The contract where you hold collateral and borrow USDG against a portfolio of Stock Tokens, with every external function, its events, roles and SDK calls. - [Liquidator](https://docs.tapehouse.xyz/md/contracts/liquidator): The contract that sells the collateral of a margin position that falls short, in a Dutch auction that follows the market, with its functions, events and rules. - [Gap backstop](https://docs.tapehouse.xyz/md/contracts/gap-backstop): The junior ERC-4626 tranche behind the supply vault's lenders, with its functions, events, limits and SDK calls. - [Reopening auction](https://docs.tapehouse.xyz/md/contracts/reopening-auction): The sealed-bid, uniform-price batch that sells positions which fell short over a closure, with its phases, functions, events and SDK calls. - [Stock lending](https://docs.tapehouse.xyz/md/contracts/stock-lending): The per-token vault that lends Stock Tokens to short sellers for a fee, with its recall queue, functions, events and SDK reads. ## Products - [Short positions](https://docs.tapehouse.xyz/md/contracts/short-positions): The contract that shorts a Stock Token against USDG margin, with its functions, rules, events and SDK calls. - [Baskets](https://docs.tapehouse.xyz/md/contracts/baskets): The ERC-20 index share over a fixed set of Stock Tokens, minted and redeemed in kind, with its functions, target rules, events and SDK calls. - [Gap cover](https://docs.tapehouse.xyz/md/contracts/gap-cover): Cover against a Stock Token's fall over a market closure, paid in USDG, with its functions, pricing inputs, settlement rules, events and SDK calls. - [Sponsor paymaster](https://docs.tapehouse.xyz/md/contracts/sponsor-paymaster): The ERC-4337 paymaster that pays gas for a new smart account's first operations, with its functions, limits, events and SDK helpers. ## Resources - [Backtest](https://docs.tapehouse.xyz/md/resources/backtest): What Tapehouse's weekend parameters were tested against, every closure of the market since 2010, with each figure's method and the command that repeats the run. - [Calibration](https://docs.tapehouse.xyz/md/resources/calibration): How the margin engine's parameters are proposed from history, stepped within bounds, gated by the backtest and applied. - [Stylus versus Solidity](https://docs.tapehouse.xyz/md/resources/stylus-vs-solidity): The margin engine's gas in Stylus and in a bit-exact Solidity reference, and the command that checks both live on the testnet. - [Verification](https://docs.tapehouse.xyz/md/resources/verification): How to check Tapehouse's claims yourself, from the deployed bytecode and the registry to the tests, the gas snapshots and static analysis. - [Glossary](https://docs.tapehouse.xyz/md/resources/glossary): The terms Tapehouse's contracts, SDKs and documentation use, each defined as the repository uses it, with a link to the page that explains it. ## Indexer API endpoints - [Get status](https://docs.tapehouse.xyz/md/api/get-status): The chain, the block indexing started at, the index's head and the chain's finalized block. - [List contracts](https://docs.tapehouse.xyz/md/api/list-contracts): Every contract of the registry, its binding and the events the index keeps of it. - [List events](https://docs.tapehouse.xyz/md/api/list-events): Indexed events, in the order they were emitted, a page at a time. - [Call view](https://docs.tapehouse.xyz/md/api/call-view): A view of a contract, at the index's head or at a named block. - [List debts](https://docs.tapehouse.xyz/md/api/list-debts): Each position of the margin accounts with debt, its debt and its health, at the index's head. - [List shorts](https://docs.tapehouse.xyz/md/api/list-shorts): Each open short, its position and its health, at the index's head. - [List halts](https://docs.tapehouse.xyz/md/api/list-halts): The band's halt of each asset, and the halt signer it accepts. - [List morpho oracles](https://docs.tapehouse.xyz/md/api/list-morpho-oracles): Each Morpho oracle on the band, and whether it prices. - [List morpho markets](https://docs.tapehouse.xyz/md/api/list-morpho-markets): Each Morpho Blue market the registry records, by id, with its parameters and its state. - [Get gap cover series](https://docs.tapehouse.xyz/md/api/get-gap-cover-series): A series of the weekend gap cover, with what rebuilds its pricing and its settlement. - [Get RedStone payload](https://docs.tapehouse.xyz/md/api/get-red-stone-payload): RedStone's latest signed packages, as the payload the band's writePrices verifies. - [Stream](https://docs.tapehouse.xyz/md/api/stream): A WebSocket of the index's updates as they happen. - [Get OpenAPI document](https://docs.tapehouse.xyz/md/api/get-open-api): This document.