Skip to content

EonswapAggregator/subgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EonSwap Subgraph

Indexes EonSwap Base mainnet contracts for:

  • AMM pairs discovered from EonAmmFactory
  • swaps, public activity, self activity, pool reserves
  • LP token balance changes and liquidity activity
  • points aggregates for wallets and daily wallet points
  • farm deposits, withdrawals, harvests, and farm positions
  • vesting grants and claims
  • optional referral and airdrop claim mappings when those contracts are deployed

Current Base Mainnet Sources

The default subgraph.yaml is wired to active deployment addresses:

Contract Address
Factory 0x24FF44E8B0839660Dfc381466be1fF8d946cE5C8
MasterChef 0xbdD705BF5D4844db3d62ee8B6A8f7865CAd731A1
VestingVault 0xDDfa6d58762E8841B6aCFDbbfde0Fb22CbeE88E3

Pair contracts are indexed dynamically from PairCreated.

Install And Build

cd subgraph
npm install
npm run codegen
npm run build

Deploy to The Graph Studio:

graph auth <DEPLOY_KEY>
npm run deploy:studio

Query Examples

Leaderboard:

{
  wallets(first: 100, orderBy: totalPoints, orderDirection: desc) {
    id
    totalPoints
    swapPoints
    liquidityPoints
    farmPoints
    referralPoints
    totalWethVolume
  }
}

Public activity:

{
  activities(first: 100, orderBy: timestamp, orderDirection: desc) {
    id
    type
    wallet { id }
    pair { id }
    amount0
    amount1
    points
    txHash
    timestamp
  }
}

Self activity:

{
  activities(
    first: 100
    orderBy: timestamp
    orderDirection: desc
    where: { wallet: "0xuser..." }
  ) {
    id
    type
    amount0
    amount1
    points
    txHash
    timestamp
  }
}

Points by day:

{
  dailyWalletPoints(
    first: 30
    orderBy: day
    orderDirection: desc
    where: { wallet: "0xuser..." }
  ) {
    day
    swapPoints
    liquidityPoints
    farmPoints
    referralPoints
    totalPoints
  }
}

Points Model

This subgraph stores deterministic on-chain point units:

  • SWAP: WETH-side swap volume in wei
  • LIQUIDITY: LP token mint amount times 5
  • FARM: staked LP amount times 2
  • REFERRAL: on-chain referral volume USD scaled by 1e18 times 10%

For a production airdrop, treat these as an auditable source ledger. Final campaign scoring should still apply sybil review, daily caps, USD conversion, and manual exclusions off-chain before generating the Merkle tree.

Enabling Airdrop Or Referral Contracts

src/airdrop.ts, src/referral.ts, and their ABIs are ready. They are also registered as templates so graph codegen can generate types before production addresses exist. Templates alone do not index events; add a data source after the contract address exists.

Airdrop:

  - kind: ethereum
    name: EonMerkleAirdrop
    network: base
    source:
      address: "0xAIRDROP_CONTRACT"
      abi: EonMerkleAirdrop
      startBlock: AIRDROP_DEPLOY_BLOCK
    mapping:
      kind: ethereum/events
      apiVersion: 0.0.8
      language: wasm/assemblyscript
      entities:
        - Wallet
        - AirdropClaim
        - Activity
      abis:
        - name: EonMerkleAirdrop
          file: ./abis/EonMerkleAirdrop.json
      eventHandlers:
        - event: Claimed(indexed uint256,indexed address,uint256)
          handler: handleAirdropClaimed
      file: ./src/airdrop.ts

Referral:

  - kind: ethereum
    name: EonReferral
    network: base
    source:
      address: "0xREFERRAL_CONTRACT"
      abi: EonReferral
      startBlock: REFERRAL_DEPLOY_BLOCK
    mapping:
      kind: ethereum/events
      apiVersion: 0.0.8
      language: wasm/assemblyscript
      entities:
        - Wallet
        - Referral
        - ReferralEvent
        - Activity
        - PointEvent
      abis:
        - name: EonReferral
          file: ./abis/EonReferral.json
      eventHandlers:
        - event: ReferralRegistered(indexed address,indexed address,uint256)
          handler: handleReferralRegistered
        - event: SwapTracked(indexed address,indexed address,uint256,uint256,uint256)
          handler: handleSwapTracked
        - event: RewardsClaimed(indexed address,uint256)
          handler: handleRewardsClaimed
      file: ./src/referral.ts

Notes

  • This subgraph reduces frontend/RPC pressure by moving event queries into a GraphQL index.
  • It should not be the only anti-sybil system. Use final exports plus review logic before token distribution.
  • Token price/USD conversion is intentionally not hardcoded inside mappings except for referral events that already emit USD-scaled volume.

About

Subgraph for EonSwap — indexing swaps, liquidity pools, tokens, transactions, and on-chain analytics for the EonSwap DEX ecosystem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors