FLock
Developer GuideGithub
  • What is FLock
    • Introduction to FLock.io
    • The Centralisation Problem
    • Architectural Breakdown
      • System Design
      • Blockchain Layer
      • AI Layer
  • ❤️‍🔥FLock Products
    • AI Arena
      • Participants
      • Quickstart
        • Pre-requisites
          • WSL installation
        • gmFLOCK
        • Delegator Guide
        • Training Node Guide
        • Validator Guide
      • Task Lifecycle Deep-dive
      • Smart Contracts Deep-dive
    • FL Alliance
      • Participants
      • Components
      • Task Lifecycle Deep-dive
        • 1. Staking and Role Assignment
        • 2. FL Training
        • 3. FL Aggregation and Evaluation
        • 4. Rewards
      • Smart Contracts Deep-dive
      • FL Client
        • Pre-Requsites
        • Steps to Quickstart
      • FLocKit
    • AI Marketplace
      • Quickstart
        • Getting started Manual creation
        • Guideline Manual
        • Model API guide
        • Tutorials
          • Create a discord bot with Model API
          • Farcaster Frames with Model API
      • Participants
      • Deep-dive
        • Function breakdown
        • RAG
        • Contribution Mechanism
        • Roadmap
    • 2025 Roadmap
  • 💰FLOCK TOKENOMICS
    • Overview
      • Incentivising open source model development
      • Security
    • Token Utility
      • Supply
      • Demand
    • Network Participation
      • AI Arena
        • Task Creator
        • Data Provider
        • Training Node
        • Validator
        • Delegator
        • Delegation Pool Rewards Explainer
      • FL Alliance
        • Task Creator
        • FL Nodes
      • AI Marketplace
        • Model Host
    • Token Allocations
    • Airdrop
    • Contract Details
  • 💻FLock Use-Cases
    • AI-assisted Coding - FLock x Aptos LLM (outperforms ChatGPT-4o!)
    • AI Assistants - Farcaster GPT, Scroll GPT and many more to come!
    • AI Companions - Professor Grump w/ Akash
    • Web3 Agents - Text2SQL Agent
    • Privacy-preserving Healthcare
  • 📃Resources
    • Litepaper
    • Whitepaper
    • Publications
    • Glossary
    • FAQ
    • Social Media
    • Careers
    • Terms Of Use
    • Privacy Policy
    • FLock.io-Verified Developers
    • FLOCK Token Airdrop Terms and Conditions
Powered by GitBook
On this page
  • Core Contracts
  • AdminUpgradeable.sol
  • FlockMiniPool.sol
  • FlockPoolManagerUpgradeable.sol
  • FlockStakeInfoUpgradeable.sol
  • FlockTaskManagerUpgradeable.sol
  • FlockTokenUpgradeable.sol
  • Libraries
  • LibABDKMathQuad.sol
  • LibFlockTask.sol
  • LibMath.sol

Was this helpful?

  1. ❤️‍🔥FLock Products
  2. AI Arena

Smart Contracts Deep-dive

This page gives detailed explanation of AI Arena's smart contracts.

PreviousTask Lifecycle Deep-diveNextFL Alliance

Last updated 5 months ago

Was this helpful?

Core Contracts

AdminUpgradeable.sol

Role: Base class that provides admin rights and other access-related methods.

  • Inherits AccessControlUpgradeable from OpenZeppelin.

  • Exposes onlyAdmin modifier and isAdmin checks.

  • Allows flexible role management for upgradeable contracts.

FlockMiniPool.sol

Role: Represents a “mini pool” that supports user delegation, tracks delegations, calculates claimable rewards, and interacts with the protocol’s managers.

  • Uses mappings to track each delegator’s stake, claims, temporal stakes, etc.

  • Integrates with FlockConfig for config references, calls back into FlockPoolManager and FlockMainManager.

FlockPoolManagerUpgradeable.sol

Role: Manages the creation and configuration of FlockMiniPool instances.

  • Tracks all active pools in sets, plus each user’s associated mini pool.

  • Maintains system-wide parameters (e.g., min/max Sigma, protocol fees).

  • Acts as a factory for creating new mini pools: createMiniPool(...).

  • Handles callbacks to update delegations in a user’s mini pool.

FlockStakeInfoUpgradeable.sol

Role: Central ledger for all stakes across tasks.

  • Maintains stake amounts, weights, and distribution logic for nodes, validators, and delegators.

  • Relies on FlockConfig references to connect to other managers (e.g. main manager, pool manager).

  • Example responsibilities include:

    • addStakes() / removeStakes(): Called by the main manager to adjust totals.

    • taskStakes[], taskWeights[]: Summaries for each task’s stake distribution.

    • “Re-tallying” delegations to keep stake info up to date.

FlockTaskManagerUpgradeable.sol

Role: Orchestrates tasks in the system.

  • Maintains references to each task (node stakes, validator stakes, distributions).

  • Aggregates daily minted rewards from FlockToken, then calculates how to distribute among nodes, validators, and delegators.

  • Offers hooks like afterDelegationUpdate(...) so that the pool manager can re-tally the user’s delegation.

FlockTokenUpgradeable.sol

Role: The upgradeable ERC20 for the entire protocol.

  • Allows “mint” and “burn” operations.

  • Implements a blacklist mechanism to restrict malicious actors.

  • Has “admin” only calls for minting, daily mint limits, etc.

  • Used as the currency for all staking, delegation, and reward flows.

Libraries

LibABDKMathQuad.sol

Role: Quadruple-precision (128-bit) floating-point math.

  • Based on the ABDK Consulting library, enabling IEEE 754-compatible operations with 16-byte bytes16 floats.

  • Key functionalities include:

    • Converting between int256/uint256 and quad precision.

    • Arithmetic ops (add, sub, mul, div).

    • Logarithms, exponentiation, square roots.

  • Used when standard fixed-point or 256-bit integer math is insufficient for advanced computations (such as extremely precise reward calculations).

LibFlockTask.sol

Role: Utility library for certain math and pseudo-randomness within tasks.

  • Wraps LibABDKMathQuad logic for simpler usage in multiplication/division scenarios.

  • Provides a “random” function (rand()), which generates a random number using block/transaction properties.

LibMath.sol

Role: Additional numeric utilities, focusing on n-th root calculations.

  • Provides the function nthRoot() which approximates the n-th root of a given number.

  • Useful for advanced arithmetic or reward distribution models needing, for example, “square root” or other root-based weighting logic.

AI Arena Smart Contracts Interactions.