polytown 0.1.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +63 -27
  2. 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
- console.log(JSON.stringify(result, null, 2));
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
- console.log(JSON.stringify(result, null, 2));
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 })
@@ -1452,7 +1489,7 @@ var DataClient = class {
1452
1489
  // Market data
1453
1490
  async getHolders(conditionId, params) {
1454
1491
  return fetchJson2(
1455
- buildUrl2(this.baseUrl, "/holders", { conditionId, ...params })
1492
+ buildUrl2(this.baseUrl, "/holders", { market: conditionId, ...params })
1456
1493
  );
1457
1494
  }
1458
1495
  async getOpenInterest(conditionId) {
@@ -1466,7 +1503,7 @@ var DataClient = class {
1466
1503
  // Leaderboards
1467
1504
  async getLeaderboard(params) {
1468
1505
  return fetchJson2(
1469
- buildUrl2(this.baseUrl, "/leaderboard", {
1506
+ buildUrl2(this.baseUrl, "/v1/leaderboard", {
1470
1507
  period: params?.period,
1471
1508
  order_by: params?.orderBy,
1472
1509
  limit: params?.limit,
@@ -1476,20 +1513,10 @@ var DataClient = class {
1476
1513
  }
1477
1514
  async getBuilderLeaderboard(params) {
1478
1515
  return fetchJson2(
1479
- buildUrl2(
1480
- this.baseUrl,
1481
- "/leaderboard/builders",
1482
- params
1483
- )
1484
- );
1485
- }
1486
- async getBuilderVolume(params) {
1487
- return fetchJson2(
1488
- buildUrl2(
1489
- this.baseUrl,
1490
- "/leaderboard/builders/volume",
1491
- params
1492
- )
1516
+ buildUrl2(this.baseUrl, "/v1/leaderboard", {
1517
+ builders: true,
1518
+ ...params
1519
+ })
1493
1520
  );
1494
1521
  }
1495
1522
  };
@@ -1529,10 +1556,24 @@ dataCommand.command("traded [address]").description("Check if address has traded
1529
1556
  const result = await client.getTraded(addr);
1530
1557
  out5(result);
1531
1558
  });
1532
- dataCommand.command("trades [address]").description("Get trade 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) => {
1559
+ dataCommand.command("trades [address]").description("Get trade history (defaults to your wallet)").option("--private-key <key>", "Private key").option("--market <condition_id>", "Filter by market condition ID").option("--limit <n>", "Limit results", parseInt).option("--offset <n>", "Offset results", parseInt).action(async (address, opts) => {
1533
1560
  const addr = resolveAddr(address, opts);
1534
1561
  const client = new DataClient();
1535
- const result = await client.getTrades(addr, opts);
1562
+ const result = await client.getTrades(addr, {
1563
+ limit: opts.limit,
1564
+ offset: opts.offset,
1565
+ market: opts.market
1566
+ });
1567
+ out5(result);
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
+ });
1536
1577
  out5(result);
1537
1578
  });
1538
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) => {
@@ -1571,11 +1612,6 @@ dataCommand.command("builder-leaderboard").description("Get builder leaderboard"
1571
1612
  const result = await client.getBuilderLeaderboard(opts);
1572
1613
  out5(result);
1573
1614
  });
1574
- dataCommand.command("builder-volume").description("Get builder volume").option("--period <period>", "Time period").action(async (opts) => {
1575
- const client = new DataClient();
1576
- const result = await client.getBuilderVolume(opts);
1577
- out5(result);
1578
- });
1579
1615
 
1580
1616
  // src/commands/approve.ts
1581
1617
  import { Command as Command12 } from "commander";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polytown",
3
- "version": "0.1.2",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polytown": "./dist/index.js"