> For the complete documentation index, see [llms.txt](https://docs.radfi.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.radfi.co/smart-contract.md).

# Smart Contract

The smart contracts are deployed in an **EVM environment** and can only be called by Sequencers.

<figure><img src="/files/YXgoeoIcf4FCtHndBm0r" alt=""><figcaption></figcaption></figure>

### **Key Components**

**Relay Contract**

* The relay contract is responsible for handling sequencer requests.
* It stores these requests separately and ensures that consensus is reached.
* Once consensus is achieved, the relay contract forwards the request to the Bitcoinstate contract.

**Bitcoinstate Contract**

* This contract tracks user data, specifically the **liquidity provider (LP) positions** of each user.
* It parses the request data into a **Uniswap-compatible format**.
* The contract then interacts with Uniswap V3 by calling the appropriate functions and handling the response.

**Uniswap V3 Contract**

* The final contract in the flow is the Uniswap V3 contract, which processes the request sent from the Bitcoinstate contract.
* It executes the necessary actions related to liquidity provisioning or trading.

The contract is the core of the Sequencer node, responsible for validating and storing protocol state. Below is the `calldata` structure for the **Relay contract**.

```solidity
struct CSMessageRequestV2 {
    string from; // bitcoin address
    string to; // bitcoin state contract address
    uint256 sn; // sequence number
    int messageType; // message type
    bytes data; // uniswap v3 calldata
    string[] protocols; // validator addresses 
}

```

The contract is triggered at step (3) in [**RadFi Sequencer Interaction**](/sequencer.md), which will verify and update the contract state based on a user request.

### **Flow Overview**

The **Relay Contract** forwards requests → **Bitcoinstate Contract** processes & formats data → Calls **Uniswap V3 Contract** for execution.

This setup ensures a structured, validated, and efficient interaction between Bitcoin state tracking and Uniswap V3 liquidity operations.
