Skip to content

feat: add /basket endpoint for weighted multi-asset basket pricing#111

Open
collinsezedike wants to merge 1 commit into
Miracle656:mainfrom
collinsezedike:feat/multi-asset-basket-pricing
Open

feat: add /basket endpoint for weighted multi-asset basket pricing#111
collinsezedike wants to merge 1 commit into
Miracle656:mainfrom
collinsezedike:feat/multi-asset-basket-pricing

Conversation

@collinsezedike

Copy link
Copy Markdown

Closes #97

Summary

  • Adds GET /basket?asset=...&weight=... accepting repeated query params for multi-asset baskets
  • Normalizes supplied weights to sum to 1.0 before computing the basket price, regardless of raw input
  • Fetches the 5-minute VWAP per asset from price_points (same pattern as the oracle comparison route)
  • Returns a full breakdown per component (asset, price, normalized weight, weighted contribution)
  • Validates: minimum 2 assets, matching asset/weight array lengths, all weights positive, and price data availability

New files

  • src/routes/basket.ts: route handler
  • src/__tests__/basket.test.ts: unit tests covering happy path, weight normalization, and all validation/error branches

Test plan

  • Equal weights produce a 50/50 split and correct basket price
  • Unequal raw weights (e.g., 3:1) normalize to 0.75/0.25 and basket price matches
  • Single asset returns 400
  • Mismatched asset/weight counts return 400
  • Zero or negative weight returns 400
  • Asset with no recent price data returns 404

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Multi-asset basket pricing

1 participant