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
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
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:
referrer: 'shapeshift'on all Relay swapsDAO_TREASURY_BASE(0x9c9aA90363630d4ab1D9dbF416cc3BBC8d3Ed502)appFeesparameter with basis pointsRelay API for fetching history:
GET https://api.relay.link/requests/v2referrer=shapeshift- Filter by ShapeShift transactionsstartTimestamp/endTimestamp- Time range (unix seconds)status=success- Only completed transactionscontinuation- Pagination cursorAcceptance Criteria
relay.tstracker following existing patterns in the codebase/requests/v2endpoint withreferrer=shapeshiftfiltercontinuationparametermodels.tsindex.tsDAO_TREASURY_BASEtoconstants.tsif not presentFiles 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
Reference
packages/swapper/src/swappers/RelaySwapper/(in shapeshift/web repo)