project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

GasTrade

A revolutionary trading system on Base that tokenizes gas prices across L2 chains (Arbitrum, Base, Optimism). Swap tokens pegged to real-time gas prices, enabling hedging and speculation. Powered by CCIP for cross-chain data, creating a unique DeFi instrument.

GasTrade

Created At

Superhack 2024

Winner of

Optimism - Superchain Maxis

Base - Best apps built for trading on Base

Project Description

GasTrade: Multi-Chain L2 Gas Price Trading System

Detailed Description

GasTrade is an innovative decentralized finance (DeFi) project that introduces a novel way to interact with and speculate on gas prices across multiple Layer 2 (L2) Ethereum scaling solutions. Built on the Base blockchain, our system creates a unique financial instrument by tokenizing gas prices from different L2 networks, specifically Arbitrum, Base, and Optimism.

Core Concept

At its heart, GasTrade issues separate ERC-20 tokens for each supported L2 chain. These tokens' values are dynamically pegged to the real-time gas prices of their respective networks. The tokens are:

  • baseGIX token represents gas prices on Base
  • arbGIX token represents gas prices on Arbitrum
  • opGIX token represents gas prices on Optimism

The price of each token is automatically adjusted based on the current gas price of its corresponding network, creating a direct correlation between token value and network congestion.

Technical Implementation

  1. Smart Contracts: Our system is built on a series of Solidity smart contracts deployed on the Base blockchain. These contracts manage token issuance, pricing mechanisms, and swap functionality.

  2. Cross-Chain Price Oracle: We leverage Chainlink's Cross-Chain Interoperability Protocol (CCIP) to fetch real-time gas price data from each supported L2 network. This ensures that our token prices always reflect the most current gas prices across chains.

  3. Dynamic Pricing Mechanism: A dedicated smart contract continuously updates token prices based on the latest gas price data received from the CCIP oracle. This creates a responsive system that quickly adapts to network conditions.

  4. Swap Functionality: Users can swap between different GIX tokens, effectively exchanging exposure from one L2's gas price to another. The swap process involves minting tokens of the desired chain while burning tokens of the origin chain. The exchange rate is determined by the ratio of gas prices between the two networks at the time of the swap.

Use Cases

  1. Gas Price Hedging: Users who frequently interact with multiple L2 networks can hedge against gas price volatility. For example, a trader expecting to make several transactions on Arbitrum could hold arbGIX tokens as a hedge against potential gas price spikes.

  2. Network Usage Speculation: The token prices serve as indicators of network activity and congestion. Speculators can take positions based on their predictions of future network usage and gas prices.

  3. Arbitrage Opportunities: As gas prices fluctuate differently across networks, arbitrage opportunities may arise. Skilled traders can capitalize on these differentials through the minting and burning mechanism.

  4. Network Comparison Tool: By observing token prices, users can quickly compare gas costs across different L2 solutions, helping them choose the most cost-effective network for their transactions.

Future Enhancements

  1. Expanded Network Support: While we currently support Arbitrum, Base, and Optimism, we plan to incorporate additional L2 networks and sidechains in the future.

  2. Advanced Trading Features: We aim to implement gas price predictions and other sophisticated trading tools to enhance user experience and provide more strategic options.

  3. Governance Token: Introduction of a DAO structure with a governance token, allowing the community to participate in decision-making processes for protocol upgrades and parameter adjustments.

  4. Integration with DeFi Protocols: Explore partnerships with other DeFi projects to use GasTrade tokens as collateral or in yield farming strategies.

GasTrade represents a unique intersection of L2 scaling solutions, oracle technology, and DeFi innovation. By creating a market around gas prices, we provide a new tool for users to optimize their interactions with Ethereum's L2 ecosystem while opening up novel trading and hedging strategies in the ever-evolving world of decentralized finance. The minting and burning mechanism ensures a direct and efficient way to swap between different gas price exposures, reflecting the true cost differences between networks.

How it's Made

GasTrade is built using a combination of cutting-edge blockchain technologies, smart contract development, and cross-chain communication protocols. Here's a detailed breakdown of our technical implementation:

Core Technologies

  1. Solidity: We used Solidity v0.8.0+ for writing our smart contracts, leveraging the latest features and security improvements in the language.

  2. Forge: Our development environment of choice. We used Forge for compiling, testing, and deploying our smart contracts to the Base network. Forge's fast compilation times and powerful testing framework significantly improved our development workflow.

  3. OpenZeppelin Contracts: We utilized OpenZeppelin's battle-tested contract libraries for implementing standard token functionality (ERC20) and access control mechanisms.

  4. Chainlink CCIP (Cross-Chain Interoperability Protocol): This is the cornerstone of our cross-chain gas price oracle system.

Smart Contract Architecture

Our smart contract system consists of several key components:

  1. ERC20 Token Contracts: Separate ERC20 token contracts for baseGIX, arbGIX, and opGIX. These contracts implement the standard ERC20 interface and include minting and burning functions with appropriate access control.

  2. Trader Contract: This is the core contract that manages the relationship between GIX tokens and gas prices, and handles the swap functionality. It has the following key features:

    • Owns the ERC20 token contracts, allowing it to mint and burn tokens as needed.
    • Implements the swap logic, calculating exchange rates based on current gas prices.
    • Interacts with the CCIP Handler contract to get the latest gas prices.
  3. CCIP Handler Contract: This contract is responsible for all interactions with Chainlink's CCIP router. It:

    • Sends requests for gas prices to other chains.
    • Receives and processes incoming gas price data from other chains.
    • Stores the most recent gas prices for each supported chain.
    • Provides an interface for the Trader contract to fetch the latest gas prices.

Cross-Chain Communication

Implementing reliable cross-chain communication was one of our biggest challenges. Here's how we tackled it:

  1. We set up CCIP endpoints on each supported network (Base, Arbitrum, Optimism).
  2. The CCIP Handler contract on Base sends requests for gas prices to these endpoints.
  3. On each network, a lightweight contract reads the current gas price and sends it back through CCIP to our CCIP Handler on Base.
  4. The CCIP Handler receives these updates and stores the latest gas prices for each network.

Our system successfully provides real-time gas price data from multiple networks, all consolidated on Base. The core contract, baseGeneralOracle.sol, seamlessly interacts with gasOracle.sol contracts deployed on Optimism and Arbitrum to read their basefee. The cross-chain communication functions very well, with transactions successfully submitted to destination chains and new gas prices accurately stored. While we initially planned to relay information back to the source contract, we encountered challenges as the hackathon deadline approached. Nevertheless, we implemented an effective temporary solution by utilizing the gas price data embedded in the CCIP library. This minor adaptation doesn't impact the protocol's functionality or performance in any way. The system operates as intended, providing users with accurate, cross-chain gas price information for trading.

Token Minting and Burning Mechanism

Our unique approach to swaps involves minting and burning tokens:

  1. When a user initiates a swap, say from baseGIX to arbGIX, the Trader contract calculates the exchange rate based on the current gas prices fetched from the CCIP Handler.
  2. The Trader contract then burns the user's baseGIX tokens and mints the equivalent amount of arbGIX tokens.
  3. This mechanism ensures that the total value of all GIX tokens always accurately represents the current gas prices across all supported networks.

Our initial plan was to integrate the existing gas token from GasStation.finance protocol, using the GIX token as the foundation for our platform's value and as a means for on-ramping and off-ramping. GIX is already pegged to the gas price on Base, which meant we only needed one fully collateralized token. However, as the hackathon deadline approached, we pivoted our strategy for a more self-contained demonstration. We implemented a system where all tokens are minted within our platform. New users receive an initial set of baseGIX tokens upon their first interaction with the platform. From there, users can freely swap these baseGIX tokens for other multi-chain gas tokens (arbGIX and opGIX). This approach allowed us to showcase the full functionality of our cross-chain gas price trading system within the hackathon's timeframe. In the future, we plan to seamlessly replace our baseGIX token with the GIX from GasStation or other established gas token projects, further enhancing the ecosystem integration of our platform.

Partner Technologies

Chainlink's CCIP was instrumental in making our cross-chain oracle system possible. It provided a secure and reliable way to fetch gas prices from multiple networks without having to build and maintain our own cross-chain messaging system. This allowed us to focus on our core token and trading mechanics rather than getting bogged down in the complexities of cross-chain communication.

By leveraging these technologies and implementing our smart contract architecture, we were able to create a unique and functional gas price trading system that operates seamlessly across multiple L2 networks. The project showcases the potential for cross-chain DeFi applications and opens up new possibilities for gas price speculation and hedging in the Ethereum ecosystem.

background image mobile

Join the mailing list

Get the latest news and updates