Skip to content

Add Relay Tracker #1245

@premiumjibles

Description

@premiumjibles

Context

The ShapeShift affiliate revenue API aggregates fee data from multiple swap providers. Relay is a cross-chain bridge/swap provider that ShapeShift actively uses. When users swap through Relay via ShapeShift, an affiliate fee is collected.

Current Problem: There is no Relay tracker implemented.

Relay Integration Details

How ShapeShift uses Relay:

  • ShapeShift passes referrer: 'shapeshift' on all Relay swaps
  • Affiliate fees are sent to DAO_TREASURY_BASE (0x9c9aA90363630d4ab1D9dbF416cc3BBC8d3Ed502)
  • Fee amount specified via appFees parameter with basis points

Relay API for fetching history:

  • Endpoint: GET https://api.relay.link/requests/v2
  • Documentation: https://docs.relay.link/references/api
  • Key parameters:
    • referrer=shapeshift - Filter by ShapeShift transactions
    • startTimestamp / endTimestamp - Time range (unix seconds)
    • status=success - Only completed transactions
    • continuation - Pagination cursor

Acceptance Criteria

  • Create relay.ts tracker following existing patterns in the codebase
  • Query /requests/v2 endpoint with referrer=shapeshift filter
  • Handle pagination using continuation parameter
  • Extract affiliate fee data from transaction responses
  • Add 'relay' to services array in models.ts
  • Import and call relay tracker in index.ts
  • Add DAO_TREASURY_BASE to constants.ts if not present

Files to Create/Modify

  • node/proxy/api/src/affiliateRevenue/relay.ts (new file)
  • node/proxy/api/src/affiliateRevenue/index.ts (add import and integrate)
  • node/proxy/api/src/affiliateRevenue/constants.ts (add treasury address)
  • node/proxy/api/src/models.ts (add 'relay' to services array)

Implementation Template

// relay.ts
import axios from 'axios'
import { Fees } from '.'

const RELAY_API_URL = 'https://api.relay.link'
const SHAPESHIFT_REFERRER = 'shapeshift'

export const getFees = async (startTimestamp: number, endTimestamp: number): Promise<Array<Fees>> => {
  const fees: Array<Fees> = []
  let continuation: string | undefined

  do {
    const { data } = await axios.get(`${RELAY_API_URL}/requests/v2`, {
      params: {
        referrer: SHAPESHIFT_REFERRER,
        startTimestamp,
        endTimestamp,
        status: 'success',
        continuation,
      },
    })

    for (const request of data.requests) {
      // Extract chain ID, asset ID, fee amount, tx hash from request
      // Map to Fees type following existing tracker patterns
    }

    continuation = data.continuation
  } while (continuation)

  return fees
}

Reference

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions