> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tulipai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Contracts

> Responsibilities and privileged controls of the Tulip smart contract suite.

Tulip v1's production contracts run on Robinhood Chain and integrate with the chain's canonical Uniswap v4 deployment.

## Core contracts

| Contract                     | Responsibility                                                                                                     |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `TulipModelRegistry`         | Computes ModelIDs, deploys canonical credits through the factory, stores model records, and tracks listing status. |
| `TulipModelCredit`           | Fixed-supply ERC-20 Permit token bound to one immutable ModelID.                                                   |
| `TulipV4MarketFactory`       | Atomically creates the model, token, pool, one-sided position, and locker registration.                            |
| `TulipDynamicFeeHook`        | Returns the current native v4 LP-fee override before swaps.                                                        |
| `TulipV4LiquidityLocker`     | Permanently owns launch LP NFTs and distributes accrued swap fees without changing principal.                      |
| `TulipProviderOfferRegistry` | Registers independent provider offers and stores delayed tariff histories.                                         |
| `TulipInferenceEscrow`       | Custodies permit credits, verifies Gateway receipts, recomputes charges, and distributes settlement.               |

## Important functions

### Market creation and control

* `computeModelId(repository, revision, task)` derives the canonical key.
* `commitLaunch(commitment)` protects a creator-bound launch before its parameters enter the mempool.
* `launchModelAndMarket(params, launchSalt)` consumes the prior-block commitment and performs the complete launch atomically.
* `previewCurve(curveConfigId, creditToken)` returns token ordering, ticks, and starting price.
* `setMarketLpFee(modelId, newFee)` schedules a pool-fee change within current bounds.
* `applyMarketLpFee(modelId)` applies it after the one-hour safety delay; `cancelMarketLpFeeUpdate(modelId)` lets the creator cancel it first.
* `collectAndDistributeFees(tokenId, deadline)` collects and splits accrued LP fees.

### Provider offers

* `registerOffer(params)` creates an active offer and tariff version 1.
* `proposeTariff(...)` creates a delayed pending tariff.
* `activateTariff(offerId)` activates it after the delay.
* `setPayout`, `updateManifest`, and `setStatus` are operator controls.
* `quarantine` and `clearQuarantine` are protocol owner controls.

### Inference permits

* `openPermit(modelId, pinnedOfferId, amount, expiresAt)` deposits credits.
* `topUpPermit(permitId, amount)` increases an open permit.
* `requestClosePermit`, `cancelClosePermit`, and `closePermit` manage delayed refunds.
* `settle` and `settleBatch` verify signed usage receipts and distribute credits.

## Privileged controls

The protocol owner can:

* Change the global inference protocol fee.
* Pause or retire model listings.
* Add or disable curve presets.
* Change allowed LP-fee bounds.
* Quarantine provider offers.
* Rotate the Gateway signer and protocol treasury.

The owner cannot mint more model credits, withdraw locked LP principal, replace a canonical pool, edit provider tariffs, or settle without a valid Gateway signature.

## Immutability boundaries

The registry's market factory can be set only once. The dynamic fee hook's factory can be set only once. Each ModelID can bind only one pool and position. Each credit supply is established in its constructor.

<Warning>
  The production contract suite has not been independently audited. This reference describes contract behavior, not a security certification. Verify transaction targets and emitted events in [Blockscout](https://robinhoodchain.blockscout.com/).
</Warning>
