Skip to content

Implement Market Cloning for Recurring Event Templates#625

Open
dev-fatima-24 wants to merge 1 commit intoHahfyeex:Defaultfrom
dev-fatima-24:feat/market-cloning
Open

Implement Market Cloning for Recurring Event Templates#625
dev-fatima-24 wants to merge 1 commit intoHahfyeex:Defaultfrom
dev-fatima-24:feat/market-cloning

Conversation

@dev-fatima-24
Copy link
Copy Markdown
Contributor

Pull Request: Implement Market Cloning for Recurring Event Templates

Description

This PR introduces a market cloning feature to streamline the creation of recurring event markets (e.g., weekly BTC predictions, monthly inflation tracking).

Previously, admins had to manually recreate markets from scratch, leading to inefficiencies and potential data entry errors. This implementation enables cloning of an existing market while allowing a new end date to be specified.

Changes Implemented

API Endpoint

  • Added POST /api/markets/:id/clone
  • Requires admin JWT authentication

Core Functionality

  • Accepts endDate in the request body
  • Clones the following fields from the source market:
    • question
    • outcomes
    • category_id
    • fee_rate_bps
    • token
  • Creates a new market with:
    • Copied fields
    • New endDate
    • New auto-generated ID

Audit Logging

  • Logs cloning activity in the admin audit trail:
    • source_market_id
    • new_market_id
  • Ensures traceability and accountability for admin actions

Error Handling

  • Returns 404 Not Found when attempting to clone a non-existent market

Acceptance Criteria

  • Cloned market contains all fields identical to the source (except ID and endDate)
  • New market uses the provided endDate
  • Clone action is recorded in the admin audit trail
  • Invalid source market ID returns 404

Testing

  • Unit tests added for:
    • Successful market cloning
    • Handling non-existent source market
    • Audit log verification
  • Ensured test coverage exceeds 95%
  • Verified:
    • Data integrity between source and cloned market
    • Proper authentication enforcement

Notes

  • Reduces admin workload for recurring markets
  • Minimizes risk of manual input errors
  • Designed to be extensible for future template-based market creation

Issues Closed

Closes #612

Commit

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.

[BE] Implement Market Cloning for Recurring Event Templates

1 participant