Skip to content

Conversation

0xNx
Copy link
Contributor

@0xNx 0xNx commented Aug 28, 2025

Add SparkDEX Adapter for Flare Network

Overview

This PR adds a new SparkDEX adapter to provide yield information for the SPRK token ecosystem on the Flare network. The adapter integrates with SparkDEX's dividends smart contract to deliver real-time APY data for xSPRK staking pools.

What is SparkDEX?

SparkDEX is a decentralized exchange and staking protocol on the Flare network that allows users to:

  • Stake SPRK tokens to receive xSPRK (escrowed tokens)
  • Earn dividends from multiple reward tokens (WFLR, SPRK, etc.)
  • Participate in a 7-day epoch-based reward distribution system

Adapter Details

Project Information

Smart Contract Integration

  • Dividends Contract: 0x710a578356A3Dfa7C207B839D3E244807b2f5AFE
  • SPRK Token: 0x657097cC15fdEc9e383dB8628B57eA4a763F2ba0
  • xSPRK Token: 0xB5Dc569d06be81Eb222a00cEe810c42976981986

Data Sources

  • On-chain Data: Direct smart contract calls using @defillama/sdk
  • Price Feeds: DefiLlama API (primary), FlareMetrics API (fallback)
  • Yield Calculation: Real-time APR based on current cycle distributions

Implementation

Contract Calls

The adapter makes the following smart contract calls:

  • distributedTokensLength() - Get count of distributed tokens
  • distributedToken(index) - Get token address at specific index
  • totalAllocation() - Get total xSPRK allocation
  • dividendsInfo(token) - Get dividend information for specific token

APR Calculation

// APR = (Current Distribution USD / TVL USD) × (365 days / 7 days) × 100
const apr = (totalCurrentDistributionUsd / tvlUsd) * (365 / 7) * 100;

Pool Structure

{
  pool: '0xb5dc569d06be81eb222a00cee810c42976981986-flare',
  symbol: 'xSPRK',
  project: 'sparkdex',
  chain: 'flare',
  tvlUsd: 1507368.0982089366,
  apyBase: 24.44979864303484,
  underlyingTokens: ['0xB5Dc569d06be81Eb222a00cEe810c42976981986'],
  rewardTokens: [
    '0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d', // WFLR
    '0x657097cC15fdEc9e383dB8628B57eA4a763F2ba0'  // SPRK
  ],
  url: 'https://sparkdex.ai/stake'
}

Testing

Contract Integration

  • ✅ All smart contract calls successful
  • ✅ Data parsing and validation working
  • ✅ Error handling implemented
  • ✅ Price API integration functional

Sample Data (from live contract)

  • Distributed Tokens: 2 (WFLR, SPRK)
  • Total Allocation: 48,673,435.10 xSPRK
  • TVL: $1,507,368.10
  • Calculated APR: 24.45%
  • Epoch Duration: 7 days

Files Added

  • src/adaptors/sparkdex/index.js - Main adapter implementation
  • src/adaptors/sparkdex/dividends-abi.json - Smart contract ABI
  • src/adaptors/sparkdex/README.md - Documentation

Checklist

  • Adapter follows DefiLlama patterns
  • Uses @defillama/sdk for contract calls
  • Implements proper error handling
  • Includes comprehensive testing
  • Follows naming conventions
  • Provides accurate yield calculations
  • Handles edge cases gracefully

Why This Adapter?

  1. Real Yield Data: Provides actual on-chain yield information for Flare network users
  2. Growing Protocol: SparkDEX is an active protocol with significant TVL
  3. Unique Offering: Staking-based yield farming with multi-token rewards
  4. Network Coverage: Expands DefiLlama's coverage of the Flare ecosystem

Related Links


Note: This adapter has been tested with live contract data and provides accurate yield information for the SparkDEX protocol on Flare network.

@llamatester
Copy link

Error while running sparkdex adapter:

Test Suites: 1 failed, 1 total
Tests: 1 failed, 10 passed, 11 total
Snapshots: 0 total
Time: 0.27 s
Ran all test suites.

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────┬─────────┬────────────┬─────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                               │ symbol  │ project    │ chain   │ tvlUsd             │ apyBase            │ underlyingTokens                                 │ rewardTokens                                                                                   │ url                         │
├─────────┼────────────────────────────────────────────────────┼─────────┼────────────┼─────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0xb5dc569d06be81eb222a00cee810c42976981986-flare' │ 'xSPRK' │ 'sparkdex' │ 'flare' │ 1507964.1250339726 │ 24.440134795191213 │ [ '0xB5Dc569d06be81Eb222a00cEe810c42976981986' ] │ [ '0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d', '0x657097cC15fdEc9e383dB8628B57eA4a763F2ba0' ] │ 'https://sparkdex.ai/stake' │
└─────────┴────────────────────────────────────────────────────┴─────────┴────────────┴─────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────┘
}

@0xNx
Copy link
Contributor Author

0xNx commented Aug 28, 2025

Submitted PR to add protocol slug "sparkdex".
DefiLlama/DefiLlama-Adapters#16099

Once the PR merged, the protocol slug will be valid and the test will pass.

@llamatester
Copy link

Error while running sparkdex adapter:

Test Suites: 1 failed, 1 total
Tests: 1 failed, 10 passed, 11 total
Snapshots: 0 total
Time: 0.281 s
Ran all test suites.

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────┬─────────┬────────────┬─────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                               │ symbol  │ project    │ chain   │ tvlUsd             │ apyBase            │ underlyingTokens                                 │ rewardTokens                                                                                   │ url                         │
├─────────┼────────────────────────────────────────────────────┼─────────┼────────────┼─────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0xb5dc569d06be81eb222a00cee810c42976981986-flare' │ 'xSPRK' │ 'sparkdex' │ 'flare' │ 1747003.3629396518 │ 22.179946837128234 │ [ '0xB5Dc569d06be81Eb222a00cEe810c42976981986' ] │ [ '0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d', '0x657097cC15fdEc9e383dB8628B57eA4a763F2ba0' ] │ 'https://sparkdex.ai/stake' │
└─────────┴────────────────────────────────────────────────────┴─────────┴────────────┴─────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────┘
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants