Context
The ShapeShift affiliate revenue API aggregates fee data from multiple external swap provider APIs (0x, Bebop, THORChain, Chainflip, Portals, MAYAChain). The endpoint fetches from all providers in parallel and returns combined results.
Current Problem: If any single provider API fails (e.g., Bebop is down), the entire request fails and returns no data. This is because the code uses Promise.all() which rejects if any promise rejects.
Current Implementation
Location: node/proxy/api/src/affiliateRevenue/index.ts
// Current code - if one fails, all fail
const [zrxFees, bebopFees, ...] = await Promise.all([
zrx.getFees(startTimestamp, endTimestamp),
bebop.getFees(startTimestamp, endTimestamp),
// ... other providers
])
Solution
Use Promise.allSettled() to handle partial failures gracefully. Return successful data even if some providers fail, and log/report which providers had errors.
Acceptance Criteria
Files to Modify
node/proxy/api/src/affiliateRevenue/index.ts
Implementation Guidance
const results = await Promise.allSettled([
zrx.getFees(start, end),
bebop.getFees(start, end),
// ...
])
const fees: Fees[] = []
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
fees.push(...result.value)
} else {
console.error(`[AffiliateRevenue] ${serviceNames[index]} failed:`, result.reason)
}
})
Context
The ShapeShift affiliate revenue API aggregates fee data from multiple external swap provider APIs (0x, Bebop, THORChain, Chainflip, Portals, MAYAChain). The endpoint fetches from all providers in parallel and returns combined results.
Current Problem: If any single provider API fails (e.g., Bebop is down), the entire request fails and returns no data. This is because the code uses
Promise.all()which rejects if any promise rejects.Current Implementation
Location:
node/proxy/api/src/affiliateRevenue/index.tsSolution
Use
Promise.allSettled()to handle partial failures gracefully. Return successful data even if some providers fail, and log/report which providers had errors.Acceptance Criteria
Promise.all()withPromise.allSettled()Files to Modify
node/proxy/api/src/affiliateRevenue/index.tsImplementation Guidance