Skip to content

Commit 962df85

Browse files
Merge pull request #677 from AlphadayHQ/dev
v3.7.2 - Polymarket Top Volume Widget + Image Widget Improvements
2 parents b09ee82 + d784f0d commit 962df85

File tree

16 files changed

+768
-5
lines changed

16 files changed

+768
-5
lines changed

packages/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@alphaday/frontend",
33
"private": true,
4-
"version": "3.7.1",
4+
"version": "3.7.2",
55
"type": "module",
66
"scripts": {
77
"prepare": "export VITE_COMMIT=$(git rev-parse --short HEAD)",

packages/frontend/src/api/hooks/useCustomAnalytics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export type TButtonClickEventPayload = {
1212
| "kasandra-date-range"
1313
| "kasandra-disclaimer"
1414
| "kasandra-datapoint"
15-
| "polymarket-market";
15+
| "polymarket-market"
16+
| "polymarket-top-volume";
1617
data?: JSONValue;
1718
};
1819

packages/frontend/src/api/services/polymarket/polymarketEndpoints.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,56 @@ import type {
1010
TGetPolymarketMarketHistoryResponse,
1111
TPolymarketEvent,
1212
TPolymarketMarket,
13+
TRawGetPolymarketMarketByTopVolumeResponse,
14+
TGetPolymarketMarketByTopVolumeRequest,
15+
TGetPolymarketMarketByTopVolumeResponse,
16+
TPolymarketMarketGroup,
1317
} from "./types";
1418

1519
const { POLYMARKET } = CONFIG.API.DEFAULT.ROUTES;
1620

21+
const mapRawGetPolymarketMarketByTopVolumeResponse = (
22+
response: TRawGetPolymarketMarketByTopVolumeResponse
23+
): TPolymarketMarketGroup => {
24+
return {
25+
id: response.id,
26+
title: response.title,
27+
description: response.description,
28+
slug: response.slug,
29+
url: response.url,
30+
image: response.image,
31+
icon: response.icon,
32+
category: response.category,
33+
active: response.active,
34+
eventId: response.event_id,
35+
createdAt: response.created_at,
36+
updatedAt: response.updated_at,
37+
marketsCount: response.markets_count,
38+
volume: response.volume,
39+
markets: response.markets.map((market) => ({
40+
id: market.id,
41+
marketId: market.market_id,
42+
question: market.question,
43+
active: market.active,
44+
closed: market.closed,
45+
archived: market.archived,
46+
volume: market.volume_num,
47+
liquidity: market.liquidity_num,
48+
image: market.image,
49+
category: market.category,
50+
endDate: market.end_date,
51+
outcomes: market.outcomes.map((outcome) => ({
52+
id: outcome.id,
53+
outcomeName: outcome.outcome_name,
54+
outcomeId: outcome.outcome_id,
55+
price: outcome.price,
56+
volume: outcome.volume,
57+
liquidity: outcome.liquidity,
58+
})),
59+
})),
60+
};
61+
};
62+
1763
const polymarketApi = alphadayApi.injectEndpoints({
1864
endpoints: (builder) => ({
1965
getPolymarketEvents: builder.query<
@@ -89,6 +135,27 @@ const polymarketApi = alphadayApi.injectEndpoints({
89135
{ type: "PolymarketHistory", id: market_id },
90136
],
91137
}),
138+
getPolymarketMarketByTopVolume: builder.query<
139+
TGetPolymarketMarketByTopVolumeResponse,
140+
TGetPolymarketMarketByTopVolumeRequest
141+
>({
142+
query: ({ page, tags, limit, active, search, ordering }) => {
143+
const params = queryString.stringify({
144+
page,
145+
limit,
146+
active,
147+
tags,
148+
search,
149+
ordering,
150+
});
151+
return `${POLYMARKET.BASE}${POLYMARKET.TOP_VOLUME}?${params}`;
152+
},
153+
transformResponse: (
154+
response: TRawGetPolymarketMarketByTopVolumeResponse
155+
) => {
156+
return mapRawGetPolymarketMarketByTopVolumeResponse(response);
157+
},
158+
}),
92159
}),
93160
});
94161

@@ -98,6 +165,7 @@ export const {
98165
useGetPolymarketMarketsQuery,
99166
useGetPolymarketMarketByIdQuery,
100167
useGetPolymarketMarketHistoryQuery,
168+
useGetPolymarketMarketByTopVolumeQuery,
101169
} = polymarketApi;
102170

103171
export default polymarketApi;

packages/frontend/src/api/services/polymarket/types.ts

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,203 @@ export type TPolymarketMarketCard = {
5656
top_outcome: TPolymarketOutcome | null;
5757
};
5858

59+
export type TPolymarketMarketGroup = {
60+
id: number;
61+
eventId: string;
62+
title: string;
63+
description: string;
64+
slug: string;
65+
url: string;
66+
image: string;
67+
icon: string;
68+
category: string | null;
69+
active: boolean;
70+
createdAt: string;
71+
updatedAt: string;
72+
marketsCount: number;
73+
volume: number;
74+
markets: {
75+
id: number;
76+
marketId: string;
77+
question: string;
78+
active: boolean;
79+
closed: boolean;
80+
archived: boolean;
81+
volume: number;
82+
liquidity: number;
83+
image: string;
84+
category: string | null;
85+
endDate: string | null;
86+
outcomes: {
87+
id: number;
88+
outcomeName: string;
89+
outcomeId: string;
90+
price: number;
91+
volume: number;
92+
liquidity: number;
93+
}[];
94+
}[];
95+
};
96+
97+
// sample market in market group data
98+
export const sampleMarketData = {
99+
id: 611,
100+
market_id: "574073",
101+
question: "Will Bitcoin reach $170,000 by December 31, 2025?",
102+
active: true,
103+
closed: false,
104+
archived: false,
105+
volume_num: 790855.69,
106+
liquidity_num: 49062.87,
107+
image: "https://polymarket-upload.s3.us-east-2.amazonaws.com/BTC+fullsize.png",
108+
category: null,
109+
tags: [
110+
{
111+
id: 136,
112+
name: "bitcoin",
113+
slug: "bitcoin",
114+
keywords: [
115+
{
116+
id: 212,
117+
name: "BTC",
118+
is_excluded: false,
119+
ignore_trending: false,
120+
},
121+
{
122+
id: 7241,
123+
name: "Bitcoins",
124+
is_excluded: false,
125+
ignore_trending: false,
126+
},
127+
{
128+
id: 211,
129+
name: "Bitcoin",
130+
is_excluded: false,
131+
ignore_trending: false,
132+
},
133+
],
134+
parents: [
135+
{
136+
name: "chain",
137+
slug: "chain",
138+
keywords: [
139+
{
140+
id: 81379,
141+
name: "Chain",
142+
is_excluded: false,
143+
ignore_trending: true,
144+
},
145+
],
146+
},
147+
{
148+
name: "coin",
149+
slug: "coin",
150+
keywords: [],
151+
},
152+
{
153+
name: "layer1 (l1)",
154+
slug: "layer-1",
155+
keywords: [
156+
{
157+
id: 15830,
158+
name: "Layer1",
159+
is_excluded: false,
160+
ignore_trending: true,
161+
},
162+
{
163+
id: 15831,
164+
name: "Layer 1",
165+
is_excluded: false,
166+
ignore_trending: true,
167+
},
168+
{
169+
id: 15832,
170+
name: "L1",
171+
is_excluded: false,
172+
ignore_trending: true,
173+
},
174+
{
175+
id: 19257,
176+
name: "Layer 1s",
177+
is_excluded: false,
178+
ignore_trending: true,
179+
},
180+
],
181+
},
182+
{
183+
name: "pow",
184+
slug: "proof-of-work",
185+
keywords: [
186+
{
187+
id: 6714,
188+
name: "Proof of Work",
189+
is_excluded: false,
190+
ignore_trending: true,
191+
},
192+
{
193+
id: 12590,
194+
name: "Proof-of-Work",
195+
is_excluded: false,
196+
ignore_trending: true,
197+
},
198+
{
199+
id: 6715,
200+
name: "PoW",
201+
is_excluded: false,
202+
ignore_trending: true,
203+
},
204+
],
205+
},
206+
],
207+
},
208+
{
209+
id: 185485,
210+
name: "reach",
211+
slug: "reach",
212+
keywords: [
213+
{
214+
id: 70499,
215+
name: "Reach",
216+
is_excluded: false,
217+
ignore_trending: true,
218+
},
219+
{
220+
id: 70500,
221+
name: "$REACH",
222+
is_excluded: false,
223+
ignore_trending: true,
224+
},
225+
],
226+
parents: [],
227+
},
228+
],
229+
end_date: null,
230+
outcomes: [
231+
{
232+
id: 5571,
233+
outcome_name: "Yes",
234+
outcome_id:
235+
"54897787457036657865994456184914764553135864680096835028443076525607070890895",
236+
price: 0.085,
237+
volume: 67222.73,
238+
liquidity: 4170.34,
239+
created_at: "2025-10-15T16:01:21.753474Z",
240+
updated_at: "2025-10-15T16:01:21.816557Z",
241+
},
242+
{
243+
id: 5572,
244+
outcome_name: "No",
245+
outcome_id:
246+
"78805316555677329424627438782382022900925020552651782446877236048212682328103",
247+
price: 0.915,
248+
volume: 723632.95,
249+
liquidity: 44892.52,
250+
created_at: "2025-10-15T16:01:21.753487Z",
251+
updated_at: "2025-10-15T16:01:21.816583Z",
252+
},
253+
],
254+
};
255+
59256
/**
60257
* API Request/Response types
61258
*/
@@ -103,3 +300,54 @@ export type TGetPolymarketMarketHistoryResponse = {
103300
[outcome_id: string]: TPolymarketPricePoint[];
104301
};
105302
};
303+
304+
export type TGetPolymarketMarketByTopVolumeRequest = {
305+
page?: number;
306+
limit?: number;
307+
active?: boolean;
308+
tags?: string;
309+
search?: string;
310+
ordering?: string;
311+
};
312+
313+
export type TRawGetPolymarketMarketByTopVolumeResponse = {
314+
id: number;
315+
event_id: string;
316+
title: string;
317+
description: string;
318+
slug: string;
319+
url: string;
320+
image: string;
321+
icon: string;
322+
category: string | null;
323+
active: boolean;
324+
created_at: string;
325+
updated_at: string;
326+
markets_count: number;
327+
volume: number;
328+
markets: {
329+
id: number;
330+
market_id: string;
331+
question: string;
332+
active: boolean;
333+
closed: boolean;
334+
archived: boolean;
335+
volume_num: number;
336+
liquidity_num: number;
337+
image: string;
338+
category: string | null;
339+
end_date: string | null;
340+
outcomes: {
341+
id: number;
342+
outcome_name: string;
343+
outcome_id: string;
344+
price: number;
345+
volume: number;
346+
liquidity: number;
347+
created_at: string;
348+
updated_at: string;
349+
}[];
350+
}[];
351+
};
352+
353+
export type TGetPolymarketMarketByTopVolumeResponse = TPolymarketMarketGroup;

packages/frontend/src/components/image/ImageModule.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface IImageModule {
77
title: string;
88
contentHeight?: string;
99
isLoading: boolean;
10+
showImage: boolean;
1011
type?: "one_col_image" | "two_col_image";
1112
onAspectRatioDetected?: (aspectRatio: number) => void;
1213
}
@@ -16,6 +17,7 @@ export const ImageModule: FC<IImageModule> = ({
1617
title,
1718
contentHeight,
1819
isLoading,
20+
showImage,
1921
type,
2022
onAspectRatioDetected,
2123
}) => {
@@ -37,6 +39,7 @@ export const ImageModule: FC<IImageModule> = ({
3739
title={title}
3840
isLoading={isLoading}
3941
onAspectRatioDetected={onAspectRatioDetected}
42+
showImage={showImage}
4043
/>
4144
</div>
4245
);

0 commit comments

Comments
 (0)