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

# Introduction

> Introduction to the Based Protocol architecture

<Note>
  We represent the protocol smart contract functionality using the OpenAPI spec, where writes map to `POST` and reads to `GET`. For simplicity, we sometimes refer to the user positions as "tokens", even though they are not represented as tokens/ERC20s.
</Note>

This page provides an overview of the Based Protocol architecture and references for its smart contract functions intended for general use. Administration-related functions are not documented.

## Protocol Architecture

The protocol consists of four main components:

* **BasedProtocol**: The main contract that manages protocol-wide settings, coordinates market creation, and handles market deployment using the clone pattern. Emits events.
* **BasedMarket**: Implementation of the market logic and position management. Buying, selling, claiming fees is done here. Emits events.
* **BasedMarketRouter**: Router contract that provides a simplified interface for interacting with markets. Does not emit events in itself.
* **Interfaces**: Standardised interfaces for contract interaction.

<img src="https://mintcdn.com/based-69235a6b/Tc45NGcMGq3mAafS/protocol/protocol-architecture.png?fit=max&auto=format&n=Tc45NGcMGq3mAafS&q=85&s=2074a073cef7908ff37e5186a6a2de35" alt="Protocol Architecture" width="1890" height="906" data-path="protocol/protocol-architecture.png" />

## Events

The core events to track state changes are:

* Protocol
  * `CreatorFeeUpdated(uint8 newFee);`
  * `MarketCreated(uint64 indexed marketCounter, address indexed marketAddress, address indexed creator);`
  * `MarketImplementationUpdated(address indexed newImplementation);`
  * `InitialAmmLevelUpdated(uint64 newLevel);`
  * `ProtocolFeeUpdated(uint8 newRate);`
* Market
  * `Buy(address indexed user, uint256 usdAmount, bool boughtBased, uint256 tokensReceived);`
  * `Sell(address indexed user, uint256 tokensAmount, bool soldBased, uint256 usdReceived);`
  * `CreatorFeesClaimed(uint256 amount);`
  * `ProtocolFeesClaimed(uint256 amount);`
  * `CreatorFeeRecipientChanged(address indexed newRecipient);`

## Credits

Based Markets use Credits for position settlement and trading. Read more about Credits in the [Exchanger](/exchanger/introduction) -section.
