feat(backend): add market metadata storage and outcomes extension
This commit is contained in:
@@ -12,6 +12,38 @@ class MarketService:
|
||||
def __init__(self, session: AsyncSession):
|
||||
self.session = session
|
||||
|
||||
async def save_market_metadata(
|
||||
self,
|
||||
market_address: str,
|
||||
question_id: str,
|
||||
title: str,
|
||||
description: Optional[str],
|
||||
category: str,
|
||||
outcomes: List[str],
|
||||
resolution_time,
|
||||
creator: str
|
||||
) -> MarketModel:
|
||||
market = MarketModel(
|
||||
market_address=market_address.lower(),
|
||||
question_id=question_id.lower(),
|
||||
title=title,
|
||||
description=description,
|
||||
category=category or "Others",
|
||||
tier=1,
|
||||
creator=creator.lower(),
|
||||
curve_address="0xF0E189974c413506098AFB6Bc6Bf4C6715fBf7B1",
|
||||
collateral_address="0xe776e957953EA69b7Eaa9d7d4098aBC076bDD5E7",
|
||||
fee_rate=Decimal("0.006"),
|
||||
resolution_time=resolution_time,
|
||||
outcomes=outcomes,
|
||||
num_outcomes=len(outcomes),
|
||||
status=MarketStatus.ACTIVE,
|
||||
created_at_block=0
|
||||
)
|
||||
self.session.add(market)
|
||||
await self.session.flush()
|
||||
return market
|
||||
|
||||
async def list_markets(self, category: Optional[str] = None, status: Optional[str] = None) -> List[MarketModel]:
|
||||
stmt = select(MarketModel)
|
||||
if category:
|
||||
|
||||
Reference in New Issue
Block a user