Skip to content

Commit 01d99d2

Browse files
committed
fix(polymarket): reject a non-numeric activity timestamp and keep start=0 as full history
1 parent 46ea337 commit 01d99d2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎apps/sim/tools/polymarket/data_api.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,16 @@ describe('Polymarket Data API v2', () => {
122122
})
123123
expect(fromString.searchParams.get('start')).toBe('1700000000')
124124
})
125+
126+
it('rejects a non-numeric start and reads start=0 as the full history', () => {
127+
expect(() =>
128+
requestUrl(polymarketGetActivityTool, {
129+
user: '0xabc',
130+
start: 'yesterday' as unknown as number,
131+
})
132+
).toThrow('Unix timestamp')
133+
expect(
134+
requestUrl(polymarketGetActivityTool, { user: '0xabc', start: 0 }).searchParams.get('start')
135+
).toBe('1')
136+
})
125137
})

‎apps/sim/tools/polymarket/get_activity.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ export const polymarketGetActivityTool: ToolConfig<
132132
const value = params[key]
133133
if (value == null || String(value).trim() === '') continue
134134
const seconds = Number(value)
135-
if (Number.isFinite(seconds)) query.append(key, String(seconds))
135+
if (!Number.isFinite(seconds)) {
136+
throw new Error(`${key} must be a Unix timestamp in seconds, got "${value}".`)
137+
}
138+
// v2 reads start=0 as "three years back"; 1 keeps the full history that 0 asked for.
139+
query.append(key, String(key === 'start' && seconds === 0 ? 1 : seconds))
136140
}
137141
if (params.sortBy) query.append('sort_by', params.sortBy)
138142
if (params.sortDirection) query.append('sort_direction', params.sortDirection)

0 commit comments

Comments
 (0)