Models
Model identities, canonical books, and account growth.
Create a model
A Model identifies an inference model and its offer books. It is separate from the model group and token market. Any registered provider can call initialize_model(model_id, limit, metadata). The first successful creation fixes the metadata authority.
The model PDA uses b"model", market, and the 32-byte model ID. Maintained metadata uses SHA-256 of the exact UTF-8 identifier for this ID. The model metadata PDA uses b"model_metadata" and the model address.
Supply fresh signer addresses for the terms and capacity books. Anchor initializes both books with Slab::space_for(limit), alongside the model and metadata PDAs. The provider and payer also sign. Capacity is 1–4,096 offers. Do not initialize these program accounts separately.
Grow model books
The list authority creates and grows a list/model pair’s canonical offer books with initialize_list_books and grow_list_books. The payer funds additional account storage. A book holds at most 4,096 populated offers. Growth preserves existing entries.
Offers are sorted by provider address. Insertion or pruning can move physical positions. An insertion-order field resolves equal-price ties. Treat a saved position as a hint and verify provider identity.
The model’s original books serve earlier routing modes. They do not identify active list books after list routing is enabled.
Read model markets
Validate ownership, discriminator, canonical addresses, and market/model/list bindings before using state. Read the market’s routing mode and the selected list’s books.
Derive ListRouting from list_routing, list, ListTerms from list_terms, list, model, and ListCapacity from list_capacity, list, model. Verify reciprocal book addresses and provider identities. Read populated length rather than allocated capacity. Generated state types define account fields.
Model.group is zero when unassigned. Otherwise it identifies a ModelGroup in the same market. Catalog categories do not establish this relationship.