Skip to content

Add Bitget as a Source for Rates and Refactor External Market Logic #423

Open
@chibie

Description

@chibie

User Story
As a developer, I want to add Bitget as a source for fetching rates for all supported currencies (e.g., NGN, KES, GHS, etc.), so that we can calculate the median rate from multiple providers (Quidax, Binance, and Bitget) to improve accuracy and reliability.

Acceptance Criteria

  1. GIVEN a supported currency (e.g., NGN, KES, GHS)
    WHEN fetching rates for a token/fiat pair
    THEN the system should fetch rates from Bitget, Binance, and Quidax (if applicable) and calculate the median

  2. GIVEN the currency is NGN
    WHEN fetching rates for USDT/NGN
    THEN the system should fetch rates from Quidax and Bitget

  3. GIVEN the currency is not NGN
    WHEN fetching rates for USDT/
    THEN the system should fetch rates from Binance and Bitget

  4. GIVEN the logic for fetching rates from external providers
    WHEN refactoring the code
    THEN the logic should be moved to /utils/external_markets.go for better organization and reusability

  5. GIVEN the Bitget API is called
    WHEN fetching P2P ads
    THEN the system should fetch the last 20 ads and calculate the median price

Tech Details

  • Add support for the Bitget API to fetch P2P ads.
  • Move the logic for fetching rates from external providers to /utils/external_markets.go.
    • Create utility functions for fetching rates from each provider: Quidax, Binance, and Bitget.
  • Rate Calculation:
    • For USDT/NGN: Fetch rates from Quidax and Bitget, then calculate the median.
    • For other currencies: Fetch rates from Binance and Bitget, then calculate the median.
  • Write tests for the new util functions

Notes/Assumptions

  • The Bitget API is stable and returns data in the expected format.
  • The median rate calculation is sufficient for determining the market rate.
  • The system should handle API failures gracefully and continue with available rates.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions