Skip to content

Conversation

@erdinc333
Copy link

@erdinc333 erdinc333 commented Nov 23, 2025

Added a standalone TypeScript example for calculating liquidity rewards using additive spread logic.


Note

Adds a standalone TypeScript script and README to fetch market/order book data, sort bids/asks, compute additive-spread depth, and estimate daily rewards per outcome.

  • Example Script (reward-calculation/calculate-rewards.ts):
    • Fetches event/market data from Gamma API and order books from CLOB API.
    • Parses clobTokenIds/outcomes, iterates outcomes, and computes mid-price from best bid/ask.
    • Correctly sorts order books (bids desc, asks asc).
    • Calculates depth within additive spreads (±$0.01/0.02/0.03) and estimates daily rewards using rewardsDailyRate, investment amount, and mid-price weighting.
    • Logs per-outcome mid-price, depth breakdown, and estimated daily rewards.
  • Docs (reward-calculation/README.md):
    • Describes features, usage (via ts-node), and logic overview (sorting, additive spread, depth calculation).

Written by Cursor Bugbot for commit 6ed7731. This will update automatically on new commits. Configure here.

// In reality, rewards are split by outcome probability.
const userShare = INVESTMENT_AMOUNT / (totalDepth + INVESTMENT_AMOUNT);
// Adjust reward by probability (approximate using price)
const outcomeRewardPool = dailyRewardPool * midPrice;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Reward pool allocation can exceed 100%

The calculation multiplies dailyRewardPool by midPrice for each outcome independently. Since midPrices across outcomes don't necessarily sum to 1.0 due to bid-ask spreads, the total allocated rewards across all outcomes can exceed the actual daily reward pool, making the reward estimates inaccurate.

Fix in Cursor Fix in Web

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.

1 participant