-
Notifications
You must be signed in to change notification settings - Fork 49
Closed
Description
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
appFeesparameter 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 transactionsstartTimestamp/endTimestamp- Time range (unix seconds)status=success- Only completed transactionscontinuation- Pagination cursor
Acceptance Criteria
- Create
relay.tstracker following existing patterns in the codebase - Query
/requests/v2endpoint withreferrer=shapeshiftfilter - Handle pagination using
continuationparameter - 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_BASEtoconstants.tsif 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
- Relay API docs: https://docs.relay.link/references/api
- Main app Relay integration:
packages/swapper/src/swappers/RelaySwapper/(in shapeshift/web repo)
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done