radFi
  • Overview
  • Economics
  • User Guides
    • Trading Wallet
  • Trading
  • Automated Market Making
  • User Flows
    • Swap Tab
    • Pool Tab
      • Positions
      • Pools
    • Portfolio Tab
  • Walk-Through Video
  • Technical Architecture
    • Automated Market Maker
    • radFi OP_12
    • Bitcoin Data Availability
    • Trading Wallet
  • Validator
  • Smart Contract
  • radFi Actions Flowchart
  • DEV
    • API Endpoints
      • Create Trading Wallet
      • Swap
      • AMM
        • Init Liquidity
        • Supply Liquidity
        • Increase Liquidity
        • Withdraw Liquidity
        • Collect Fees
  • Terms and Conditions
  • Privacy Policy
Powered by GitBook
On this page
  • Key Components
  • Flow Overview

Smart Contract

PreviousValidatorNextradFi Actions Flowchart

Last updated 3 months ago

The smart contracts are written in Solidity and the implementation can be found at

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

Key Components

Relay Contract

  • The relay contract is responsible for handling validator 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 Validator node, responsible for validating and storing protocol state. Below is the calldata structure for the Relay contract.

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 
}

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.

The contract is triggered at step (3) in , which will verify and update the contract state based on a user request.

RadFi Validator Interaction
https://github.com/lydialabs/RadFi-Contracts