project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4

NewsQuantar

News-Driven Trading Agent: Powered by Polygon MCP & 1inch APIs

NewsQuantar

Created At

ETHGlobal Taipei

Winner of

1inch

1inch - Use the Dev Portal APIs to streamline your dApp development 2nd place

Project Description

Background

Cryptocurrency markets are highly responsive to social media statements from influential figures like Vitalik Buterin or Donald Trump. For instance, on April 3, 2025, when Justin Sun criticized FUSDT, it triggered significant de-pegging. However, once the FUSDT team provided clarification, the price quickly returned to its pegged value. This volatility creates substantial arbitrage opportunities for traders who can quickly react to news and statements from media outlets and key opinion leaders (KOLs).

The challenge is that a single person cannot effectively monitor all relevant news sources and KOLs across various platforms, leading to missed trading opportunities.

Introduction

NewsQuantar is a sophisticated solution that leverages AI agents to monitor news and statements from media outlets and influential figures on social media and automatically execute trading decisions on the Polygon blockchain. By combining natural language processing with blockchain technology, the system can identify market-moving information and execute trades faster than human traders.

Key Features

  • Real-time News and KOL Monitoring: Continuously tracks statements from media outlets and key opinion leaders on platforms like Farcaster
  • Sentiment Analysis: Uses advanced AI to determine if statements are bullish or bearish for specific tokens
  • Autonomous Trading: Makes independent decisions to long or short tokens based on analyzed sentiment
  • Polygon Integration: Executes all transactions on Polygon PoS for fast, low-cost trading
  • 1inch Integration: Leverages 1inch's aggregation API for optimal trading routes and reduced costs while maintaining decentralization

Technology Stack/Core Components

polygon-mcp with 1inch Dev Portal APIs

A TypeScript implementation of the Polygon Model Context Protocol that enables:

  • Direct blockchain interaction from AI agents
  • Token balance checking and transfers
  • Smart contract deployment and interaction
  • Gas price optimization
  • 1inch swap integration for efficient token exchanges
  • Secure wallet management through seed phrases

webhook-sdk for Farcaster

A Python SDK for Farcaster event monitoring that provides:

  • Creation and management of Neynar webhooks
  • Real-time event reception for Farcaster casts
  • Filtering capabilities to focus on specific content or users
  • Event deduplication to prevent duplicate trade execution
  • Seamless integration with the trading engine

chat.py

A standalone interactive CLI for blockchain operations that:

  • Provides a conversational interface to the Polygon blockchain
  • Allows manual querying of wallet addresses, gas prices, and token balances
  • Supports manual token swaps and transfers for testing
  • Serves as a development and debugging tool for the trading system
  • Uses the Fast-Agent framework for natural language blockchain interaction

quantar.py

The core trading engine that:

  • Connects the webhook system to the trading infrastructure
  • Analyzes Farcaster messages for trading signals
  • Implements strict trading limits and security measures
  • Executes trades through the Polygon MCP
  • Supports multiple token types with proper decimal handling
  • Restricts trading to authorized users only
  • Ensures proper token address usage (e.g., native USDC vs USDC.e)

How it's Made

Architecture Overview

Our News Quantar project is built on a three-tier architecture that combines blockchain interaction capabilities with natural language processing and social media monitoring:

  1. Polygon MCP (Modified Client for Polygon): A forked and enhanced version of the official Polygon MCP that serves as our blockchain interaction layer
  2. Fast-Agent Framework: The intelligence layer that processes natural language and makes trading decisions
  3. Webhook SDK: A lightweight service that monitors Farcaster for real-time social signals

Technical Implementation

Polygon MCP Enhancements with 1inch Integration

We forked the official Polygon MCP and made several critical enhancements. The Polygon MCP serves as the essential execution layer for our agent - functioning as its "hands and feet" in the blockchain world. Without this component, our intelligent agent would be unable to interact with the blockchain or execute trades, making it the foundational element that enables the entire system to function effectively.

  • 1inch Swap Integration: We implemented a comprehensive swap handler (inchSwapHandler) that connects to the 1inch API for optimal trading routes and best execution prices. The integration includes:

    • Automatic slippage management
    • Gas estimation with safety buffers
    • Token approval checks
    • USDC/USDC.e safety mechanisms to prevent using deprecated tokens
    • Optimized routing through 1inch's aggregation API, which significantly reduces trading costs by finding the most efficient paths across multiple DEXes while maintaining full decentralization
  • Token Management Tools: We added specialized handlers for:

    • checkAllowanceHandler: Verifies if sufficient token approvals exist
    • approveTokenHandler: Streamlines the token approval process
    • getTokenDecimalsHandler: Ensures accurate decimal handling across different tokens

Fast-Agent Framework Implementation

We built our agent using the Fast-Agent framework, which provides a clean abstraction for LLM-powered applications. Our implementation includes:

  • Dual-mode Operation:

    • chat.py: A direct interface for manual blockchain interactions through natural language
    • quantar.py: An automated trading agent that processes Farcaster messages and executes trades based on social signals
  • Prompt Engineering: We carefully crafted system instructions that:

    • Enforce trading limits (max 1 USDC per trade)
    • Implement strict token address validation
    • Prevent the use of deprecated tokens (USDC.e)
    • Handle token decimal precision correctly
  • Claude 3.7 Sonnet Integration: We integrated with Claude's API for advanced natural language understanding, using the endpoint at https://chat.cloudapi.vip/v1

Webhook SDK for Farcaster Monitoring

We developed a lightweight but robust webhook service using FastAPI that:

  • Provides a /webhook endpoint to receive Farcaster events
  • Implements event deduplication to prevent double-processing
  • Uses an asynchronous callback system to process events without blocking
  • Logs all activities for audit and debugging purposes

Security and Configuration Management

We implemented a comprehensive security approach:

  • Environment Variable Management: Sensitive data like API keys and seed phrases are stored in .env files and excluded from git
  • Configuration Separation: We use fastagent.config.yaml for non-sensitive configuration and load sensitive data from environment variables
  • Token Address Safety: We maintain a TOKEN_ADDRESSES dictionary with verified addresses to prevent using incorrect or deprecated tokens
  • Trading Limits: Hard-coded maximum trade size of 1 USDC to limit risk exposure
  • Authorized User Restrictions: Only specified Farcaster accounts can trigger trades

Hacky But Effective Solutions

  1. USDC.e Protection: We implemented multiple safeguards to prevent the use of USDC.e, including:

    • Setting the USDC.e address to DO_NOT_USE in the token dictionary
    • Adding automatic replacement of USDC.e with native USDC in the swap handler
    • Including explicit warnings in agent instructions
    • Avoiding USDC.e entirely due to its persistent liquidity issues, which often lead to failed trades, higher slippage, and suboptimal execution prices
  2. Webhook Event Deduplication: We created a simple but effective event ID generation system using event_type_created_at to prevent duplicate processing without needing a database

  3. Decimal Precision Handling: We added explicit reminders about token decimal differences in agent instructions and implemented a dedicated tool to verify token decimals before calculations

The combination of these components creates a system that can monitor social media for trading signals, analyze them using advanced AI, and execute trades automatically with built-in safety mechanisms.

background image mobile

Join the mailing list

Get the latest news and updates