polytown 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -194,7 +194,7 @@ var GammaClient = class {
|
|
|
194
194
|
var marketsCommand = new Command2("markets").description(
|
|
195
195
|
"Markets commands"
|
|
196
196
|
);
|
|
197
|
-
marketsCommand.command("list").description("List markets").option("--active", "Only active markets").option("--closed", "Only closed markets").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by market IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--clob-token-ids <ids>", "Filter by CLOB token IDs").option("--condition-ids <ids>", "Filter by condition IDs").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--related-tags", "Include related tags").option("--include-tag", "Include tag data").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").option("--uma-resolution-status <status>", "UMA resolution status").option("--game-id <id>", "Filter by game ID").option("--sports-market-types <types>", "Filter by sports market types").option("--rewards-min-size <n>", "Min rewards size", parseFloat).option("--question-ids <ids>", "Filter by question IDs").action(async (opts) => {
|
|
197
|
+
marketsCommand.command("list").description("List markets").option("--full", "Output full format (default: simplified)").option("--active", "Only active markets").option("--closed", "Only closed markets").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by market IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--clob-token-ids <ids>", "Filter by CLOB token IDs").option("--condition-ids <ids>", "Filter by condition IDs").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--related-tags", "Include related tags").option("--include-tag", "Include tag data").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").option("--uma-resolution-status <status>", "UMA resolution status").option("--game-id <id>", "Filter by game ID").option("--sports-market-types <types>", "Filter by sports market types").option("--rewards-min-size <n>", "Min rewards size", parseFloat).option("--question-ids <ids>", "Filter by question IDs").action(async (opts) => {
|
|
198
198
|
const gamma = new GammaClient();
|
|
199
199
|
const params = {
|
|
200
200
|
active: opts.active ?? true,
|
|
@@ -226,7 +226,26 @@ marketsCommand.command("list").description("List markets").option("--active", "O
|
|
|
226
226
|
if (opts.rewardsMinSize) params.rewards_min_size = opts.rewardsMinSize;
|
|
227
227
|
if (opts.questionIds) params.question_ids = opts.questionIds;
|
|
228
228
|
const result = await gamma.getMarkets(params);
|
|
229
|
-
|
|
229
|
+
if (opts.full) {
|
|
230
|
+
console.log(JSON.stringify(result, null, 2));
|
|
231
|
+
} else {
|
|
232
|
+
const simplified = result.map((m) => ({
|
|
233
|
+
id: m.id,
|
|
234
|
+
question: m.question,
|
|
235
|
+
slug: m.slug,
|
|
236
|
+
conditionId: m.conditionId,
|
|
237
|
+
clobTokenIds: m.clobTokenIds,
|
|
238
|
+
description: m.description,
|
|
239
|
+
outcomes: m.outcomes,
|
|
240
|
+
outcomePrices: m.outcomePrices,
|
|
241
|
+
closed: m.closed,
|
|
242
|
+
endDate: m.endDate,
|
|
243
|
+
volume: m.volumeNum || m.volume,
|
|
244
|
+
volume24hr: m.volume24hr,
|
|
245
|
+
image: m.image
|
|
246
|
+
}));
|
|
247
|
+
console.log(JSON.stringify(simplified, null, 2));
|
|
248
|
+
}
|
|
230
249
|
});
|
|
231
250
|
marketsCommand.command("get <id_or_slug>").description("Get market by ID or slug").action(async (idOrSlug) => {
|
|
232
251
|
const gamma = new GammaClient();
|
|
@@ -244,7 +263,7 @@ import { Command as Command3 } from "commander";
|
|
|
244
263
|
var eventsCommand = new Command3("events").description(
|
|
245
264
|
"Events commands"
|
|
246
265
|
);
|
|
247
|
-
eventsCommand.command("list").description("List events").option("--active", "Only active events").option("--closed", "Only closed events").option("--archived", "Include archived events").option("--featured", "Only featured events").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by event IDs (comma-separated)").option("--tag <tag>", "Filter by tag slug").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--exclude-tag-id <ids>", "Exclude tag IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--related-tags", "Include related tags").option("--recurrence <pattern>", "Filter by recurrence pattern").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").action(async (opts) => {
|
|
266
|
+
eventsCommand.command("list").description("List events").option("--full", "Output full format (default: simplified)").option("--active", "Only active events").option("--closed", "Only closed events").option("--archived", "Include archived events").option("--featured", "Only featured events").option("--cyom", "Filter by create-your-own-market").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).option("--order <field>", "Order by field").option("--ascending", "Sort ascending").option("--id <ids>", "Filter by event IDs (comma-separated)").option("--tag <tag>", "Filter by tag slug").option("--tag-id <id>", "Filter by tag ID", parseInt).option("--exclude-tag-id <ids>", "Exclude tag IDs (comma-separated)").option("--slug <slugs>", "Filter by slug(s)").option("--related-tags", "Include related tags").option("--recurrence <pattern>", "Filter by recurrence pattern").option("--liquidity-min <n>", "Min liquidity", parseFloat).option("--liquidity-max <n>", "Max liquidity", parseFloat).option("--volume-min <n>", "Min volume", parseFloat).option("--volume-max <n>", "Max volume", parseFloat).option("--start-date-min <date>", "Earliest start date").option("--start-date-max <date>", "Latest start date").option("--end-date-min <date>", "Earliest end date").option("--end-date-max <date>", "Latest end date").action(async (opts) => {
|
|
248
267
|
const gamma = new GammaClient();
|
|
249
268
|
const params = {
|
|
250
269
|
active: opts.active ?? true,
|
|
@@ -273,7 +292,21 @@ eventsCommand.command("list").description("List events").option("--active", "Onl
|
|
|
273
292
|
if (opts.endDateMin) params.end_date_min = opts.endDateMin;
|
|
274
293
|
if (opts.endDateMax) params.end_date_max = opts.endDateMax;
|
|
275
294
|
const result = await gamma.getEvents(params);
|
|
276
|
-
|
|
295
|
+
if (opts.full) {
|
|
296
|
+
console.log(JSON.stringify(result, null, 2));
|
|
297
|
+
} else {
|
|
298
|
+
const simplified = result.map((e) => ({
|
|
299
|
+
id: e.id,
|
|
300
|
+
title: e.title,
|
|
301
|
+
slug: e.slug,
|
|
302
|
+
description: e.description,
|
|
303
|
+
closed: e.closed,
|
|
304
|
+
endDate: e.endDate,
|
|
305
|
+
volume: e.volume,
|
|
306
|
+
markets: e.markets?.length || 0
|
|
307
|
+
}));
|
|
308
|
+
console.log(JSON.stringify(simplified, null, 2));
|
|
309
|
+
}
|
|
277
310
|
});
|
|
278
311
|
eventsCommand.command("get <id_or_slug>").description("Get event by ID or slug").action(async (idOrSlug) => {
|
|
279
312
|
const gamma = new GammaClient();
|
|
@@ -1444,6 +1477,10 @@ var DataClient = class {
|
|
|
1444
1477
|
buildUrl2(this.baseUrl, "/trades", { user: address, ...params })
|
|
1445
1478
|
);
|
|
1446
1479
|
}
|
|
1480
|
+
// Get all trades for a market (no user filter)
|
|
1481
|
+
async getMarketTrades(params) {
|
|
1482
|
+
return fetchJson2(buildUrl2(this.baseUrl, "/trades", params));
|
|
1483
|
+
}
|
|
1447
1484
|
async getActivity(address, params) {
|
|
1448
1485
|
return fetchJson2(
|
|
1449
1486
|
buildUrl2(this.baseUrl, "/activity", { user: address, ...params })
|
|
@@ -1529,6 +1566,16 @@ dataCommand.command("trades [address]").description("Get trade history (defaults
|
|
|
1529
1566
|
});
|
|
1530
1567
|
out5(result);
|
|
1531
1568
|
});
|
|
1569
|
+
dataCommand.command("market-trades").description("Get all trades for a market (no user filter)").option("--market <condition_id>", "Market condition ID").option("--slug <slug>", "Market slug").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).action(async (opts) => {
|
|
1570
|
+
const client = new DataClient();
|
|
1571
|
+
const result = await client.getMarketTrades({
|
|
1572
|
+
limit: opts.limit,
|
|
1573
|
+
offset: opts.offset,
|
|
1574
|
+
market: opts.market,
|
|
1575
|
+
slug: opts.slug
|
|
1576
|
+
});
|
|
1577
|
+
out5(result);
|
|
1578
|
+
});
|
|
1532
1579
|
dataCommand.command("activity [address]").description("Get activity history (defaults to your wallet)").option("--private-key <key>", "Private key").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).action(async (address, opts) => {
|
|
1533
1580
|
const addr = resolveAddr(address, opts);
|
|
1534
1581
|
const client = new DataClient();
|