Skip to content

[BUG] Oracle Crypto Resolver Hardcodes BTC Price Threshold #650

Description

@Hahfyeex

Type: BUG
Severity: Medium
Component: oracle/index.js

Context

The resolveCryptoPrice function hardcodes the BTC price threshold check: if the question includes 100k or 100,000, resolve to outcome 0 if BTC price is above 100,000. This means any BTC market with a different threshold (e.g. Will BTC reach ) will always resolve incorrectly because the threshold is not parsed from the market question. It also means non-BTC crypto markets (ETH, SOL) are not handled at all.

Root Cause

The threshold value 100000 is hardcoded in the resolveCryptoPrice function. There is no logic to extract the threshold from the market question text. Non-BTC assets are not handled.

Fix Guide

  1. Add a parseThreshold(question) utility function that extracts the numeric threshold from the question using a regex: /\True([\d,]+)k?/i. Handle k suffix (e.g. 100k = 100000).
  2. Add an extractAsset(question) function that identifies the asset from keywords: bitcoin/btc, ethereum/eth, solana/sol.
  3. Fetch the price for the identified asset from CoinGecko using the correct asset ID.
  4. Compare the fetched price against the parsed threshold to determine the outcome.
  5. Add unit tests for threshold parsing with various formats: , ,000, 100000, .5M.

Guidelines

  • Key requirement: Dynamic Threshold Parsing / Multi-asset Support / Regex Extraction / Unit Tests.

Definition of Done

  • Threshold is correctly parsed from market questions in all tested formats.
  • ETH and SOL markets resolve correctly using the correct CoinGecko asset ID.
  • BTC markets with non-100k thresholds resolve correctly.
  • Unit tests cover all threshold formats and asset extraction scenarios.
  • Test coverage > 95%.

PR and Checkout

git checkout -b fix/oracle-dynamic-threshold-parsing
git add .
git commit -m "fix: implement dynamic threshold parsing and multi-asset support in crypto oracle"
git push origin fix/oracle-dynamic-threshold-parsing

Open a PR against main and include the issue number in the PR description.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions