Alpha Arena

Alpha Arena: P2P DeFi trading duels where winner takes all based on on-chain P&L. No middlemen.

Alpha Arena

Created At

Unite Defi

Winner of

1inch

1inch - Build a full Application using 1inch APIs 3rd place

Project Description

Alpha Arena is a decentralized application that transforms DeFi trading into a competitive, skill-based social game. It creates a dedicated platform where two traders can enter a head-to-head "duel," wagering cryptocurrency on who can achieve a higher trading performance over a set period. The entire process, from wagering to judging and payout, is automated and secured by smart contracts and a backend referee powered by the 1inch Network's APIs.

Core Concept and Vision The fundamental vision of Alpha Arena is to provide a transparent and exciting environment for traders to prove their skills. While the crypto market is often a solo endeavor focused on personal profit, Alpha Arena introduces a competitive layer, making trading a direct, measurable, and social competition. It answers the question, "Who is the better trader?" not by looking at the size of their portfolio, but by measuring the skill of their execution through profit and loss percentage (P&L%).

The platform is designed to be trustless and non-custodial. Users always maintain control over their main portfolio assets in their own wallets. Only the agreed-upon wager is locked in a secure, transparent smart contract escrow, whose rules are immutable and publicly verifiable.

The User Journey: A Step-by-Step Duel The entire experience is designed to be a seamless and engaging loop.

Challenge Creation: A user, the "Challenger," initiates a duel by defining the terms. They select the wager asset (e.g., 100 USDC) and the duration of the competition (e.g., 24 hours, 3 days, or 1 week). This creates an open challenge in the app's public lobby.

Joining and Staking: An "Opponent" can browse the lobby and accept any open challenge. Upon acceptance, both players are prompted to approve and deposit their wager into the Duel.sol smart contract. This contract acts as the neutral escrow, securely holding the combined prize pool until a winner is declared.

The Competition Phase: Once both wagers are locked, the duel's status changes to "Active" and the countdown timer begins. For the entire duration, players trade assets directly from their personal wallets. To facilitate this, the Alpha Arena dApp features an integrated 1inch Swap API widget. This allows players to research, quote, and execute optimal trades without ever needing to leave the application, creating a fluid and focused experience.

Automated Resolution and Judging: When the duel's timer expires, the backend "Referee" service is automatically triggered.

It uses the 1inch Portfolio and Spot Price APIs to get a precise USD value snapshot of each player's wallet at the moment the duel started and at the moment it ended.

It then calculates the P&L percentage for both players. This ensures the competition is about skill, not size—a trader who turns $500 into $750 (+50%) will beat a whale who turns $1 million into $1.2 million (+20%).

The backend then securely calls the resolveDuel function on the smart contract, passing the wallet address of the verified winner.

Winner-Take-All Payout: The smart contract, receiving the instruction from the trusted referee, automatically transfers the entire prize pool (the sum of both players' wagers) to the winner's wallet. This process is immediate, transparent, and requires no manual intervention.

Key Features and Differentiators P&L Percentage-Based Victory: The fairest measure of trading skill, creating a level playing field regardless of a user's starting capital.

Trustless Smart Contract Escrow: Wagers are secured by immutable on-chain logic, removing any need to trust a central party.

Integrated Trading Terminal: The built-in 1inch Swap functionality provides a best-in-class trading experience directly within the competitive environment.

Automated and Unbiased Judging: The backend referee uses reliable 1inch API data to ensure fair and timely resolution of every duel.

Public Leaderboards: A system to track top traders, win/loss records, and showcase the most skilled participants in the Arena.

How it's Made

Smart Contract: Built with Solidity and Hardhat. Backend API: Built with Node.js and Express.js. Frontend App: Built with React, Vite, and Tailwind CSS.

These three components communicate to create the full application flow.

Smart Contract (Duel.sol) The smart contract's sole purpose is to act as a secure on-chain escrow for player wagers.

It holds the funds during a duel and has a permissioned resolveDuel function that can only be called by our trusted backend referee. This ensures funds are only released to the verified winner. We used OpenZeppelin's ReentrancyGuard for security.

Backend Service (The Referee) The backend has two jobs: act as the referee and provide data to the frontend.

We use node-cron to schedule a job that periodically checks for ended duels. When a duel finishes, the backend uses 1inch APIs to calculate each player's Profit & Loss (P&L).

1inch Benefit: The Portfolio API and Spot Price API were critical. They allowed us to accurately get each player's wallet value at specific times without building a complex and unreliable data pipeline. This provided the financial data needed to judge duels fairly.

Frontend Application The frontend is the user interface where all interactions happen. We used Wagmi and Viem hooks for all blockchain interactions.

This makes it simple to connect a wallet, call contract functions (createDuel), and sign transactions. The frontend fetches duel data from our backend's API endpoints.

1inch Benefit: The 1inch Swap API simplified in-app trading. We get a transaction object from the API and pass it directly to Wagmi for the user to sign. This allowed us to integrate a powerful multi-DEX swap feature quickly.

background image mobile

Join the mailing list

Get the latest news and updates