@polymarbot/shared 0.1.1 → 0.1.3

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.
@@ -0,0 +1,6 @@
1
+ // src/utils/trade-strategy/types.ts
2
+ import { Side as TradeSide } from "@polymarket/clob-client";
3
+
4
+ export {
5
+ TradeSide
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarbot/shared",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "./basic.cjs",
6
6
  "module": "./basic.js",
@@ -64,9 +64,9 @@
64
64
  "**/*.d.cts"
65
65
  ],
66
66
  "dependencies": {
67
+ "@polymarket/clob-client": "^4.22.8",
67
68
  "viem": "^2.38.6",
68
69
  "@polymarket/builder-relayer-client": "^0.0.6",
69
- "@polymarket/builder-signing-sdk": "^0.0.8",
70
- "@polymarket/clob-client": "^4.22.8"
70
+ "@polymarket/builder-signing-sdk": "^0.0.8"
71
71
  }
72
72
  }
@@ -20,12 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/utils/trade-strategy/normalize.ts
21
21
  var normalize_exports = {};
22
22
  __export(normalize_exports, {
23
- hasBuySteps: () => hasBuySteps,
23
+ hasTradeStepsBuy: () => hasTradeStepsBuy,
24
24
  normalizeStrategy: () => normalizeStrategy
25
25
  });
26
26
  module.exports = __toCommonJS(normalize_exports);
27
+
28
+ // src/utils/trade-strategy/types.ts
27
29
  var import_clob_client = require("@polymarket/clob-client");
28
- function normalizeBuyStep(step, options) {
30
+
31
+ // src/utils/trade-strategy/normalize.ts
32
+ function normalizeTradeStepBuy(step, options) {
29
33
  const { start, end, price, size } = step;
30
34
  const { minPrice, minSize } = options;
31
35
  if (start === void 0 || start === null || start < 0) {
@@ -53,8 +57,8 @@ function normalizeBuyStep(step, options) {
53
57
  if (step.once === true) {
54
58
  normalized.once = true;
55
59
  }
56
- if (step.outcome === "Up" || step.outcome === "Down") {
57
- normalized.outcome = step.outcome;
60
+ if (step.outcomeIndex === 0 || step.outcomeIndex === 1) {
61
+ normalized.outcomeIndex = step.outcomeIndex;
58
62
  }
59
63
  const isLowPriceMode = price <= 0.5;
60
64
  const isChaseMode = price > 0.5;
@@ -80,7 +84,7 @@ function normalizeBuyStep(step, options) {
80
84
  }
81
85
  return normalized;
82
86
  }
83
- function normalizeSellStep(step, options) {
87
+ function normalizeTradeStepSell(step, options) {
84
88
  const { start, end, price, size } = step;
85
89
  const { minPrice, minSize } = options;
86
90
  if (start === void 0 || start === null || start < 0) {
@@ -108,7 +112,7 @@ function normalizeSellStep(step, options) {
108
112
  const stepAsTradeStep = step;
109
113
  const invalidFields = [];
110
114
  if ("once" in stepAsTradeStep && stepAsTradeStep.once !== void 0) invalidFields.push("once");
111
- if ("outcome" in stepAsTradeStep && stepAsTradeStep.outcome !== void 0) invalidFields.push("outcome");
115
+ if ("outcomeIndex" in stepAsTradeStep && stepAsTradeStep.outcomeIndex !== void 0) invalidFields.push("outcomeIndex");
112
116
  if ("maxUnderlyingDiff" in stepAsTradeStep && stepAsTradeStep.maxUnderlyingDiff !== void 0) invalidFields.push("maxUnderlyingDiff");
113
117
  if ("minUnderlyingDiff" in stepAsTradeStep && stepAsTradeStep.minUnderlyingDiff !== void 0) invalidFields.push("minUnderlyingDiff");
114
118
  if (invalidFields.length > 0) {
@@ -127,9 +131,9 @@ function normalizeStrategy(config, options = {}) {
127
131
  config.forEach((step, index) => {
128
132
  let normalizedStep = null;
129
133
  if (step.side === import_clob_client.Side.BUY) {
130
- normalizedStep = normalizeBuyStep(step, normalizeOptions);
134
+ normalizedStep = normalizeTradeStepBuy(step, normalizeOptions);
131
135
  } else if (step.side === import_clob_client.Side.SELL) {
132
- normalizedStep = normalizeSellStep(step, normalizeOptions);
136
+ normalizedStep = normalizeTradeStepSell(step, normalizeOptions);
133
137
  } else {
134
138
  const unknownStep = step;
135
139
  }
@@ -139,11 +143,11 @@ function normalizeStrategy(config, options = {}) {
139
143
  });
140
144
  return normalized;
141
145
  }
142
- function hasBuySteps(config) {
146
+ function hasTradeStepsBuy(config) {
143
147
  return config.some((step) => step.side === import_clob_client.Side.BUY);
144
148
  }
145
149
  // Annotate the CommonJS export names for ESM import in node:
146
150
  0 && (module.exports = {
147
- hasBuySteps,
151
+ hasTradeStepsBuy,
148
152
  normalizeStrategy
149
153
  });
@@ -10,6 +10,6 @@ interface NormalizeStrategyOptions {
10
10
 
11
11
  declare function normalizeStrategy(config: StrategyConfig, options?: NormalizeStrategyOptions): StrategyConfig;
12
12
 
13
- declare function hasBuySteps(config: StrategyConfig): boolean;
13
+ declare function hasTradeStepsBuy(config: StrategyConfig): boolean;
14
14
 
15
- export { type NormalizeStrategyOptions, hasBuySteps, normalizeStrategy };
15
+ export { type NormalizeStrategyOptions, hasTradeStepsBuy, normalizeStrategy };
@@ -10,6 +10,6 @@ interface NormalizeStrategyOptions {
10
10
 
11
11
  declare function normalizeStrategy(config: StrategyConfig, options?: NormalizeStrategyOptions): StrategyConfig;
12
12
 
13
- declare function hasBuySteps(config: StrategyConfig): boolean;
13
+ declare function hasTradeStepsBuy(config: StrategyConfig): boolean;
14
14
 
15
- export { type NormalizeStrategyOptions, hasBuySteps, normalizeStrategy };
15
+ export { type NormalizeStrategyOptions, hasTradeStepsBuy, normalizeStrategy };
@@ -1,6 +1,9 @@
1
+ import {
2
+ TradeSide
3
+ } from "../chunk-QQPFFDMY.js";
4
+
1
5
  // src/utils/trade-strategy/normalize.ts
2
- import { Side } from "@polymarket/clob-client";
3
- function normalizeBuyStep(step, options) {
6
+ function normalizeTradeStepBuy(step, options) {
4
7
  const { start, end, price, size } = step;
5
8
  const { minPrice, minSize } = options;
6
9
  if (start === void 0 || start === null || start < 0) {
@@ -19,7 +22,7 @@ function normalizeBuyStep(step, options) {
19
22
  return null;
20
23
  }
21
24
  const normalized = {
22
- side: Side.BUY,
25
+ side: TradeSide.BUY,
23
26
  price,
24
27
  size,
25
28
  start,
@@ -28,8 +31,8 @@ function normalizeBuyStep(step, options) {
28
31
  if (step.once === true) {
29
32
  normalized.once = true;
30
33
  }
31
- if (step.outcome === "Up" || step.outcome === "Down") {
32
- normalized.outcome = step.outcome;
34
+ if (step.outcomeIndex === 0 || step.outcomeIndex === 1) {
35
+ normalized.outcomeIndex = step.outcomeIndex;
33
36
  }
34
37
  const isLowPriceMode = price <= 0.5;
35
38
  const isChaseMode = price > 0.5;
@@ -55,7 +58,7 @@ function normalizeBuyStep(step, options) {
55
58
  }
56
59
  return normalized;
57
60
  }
58
- function normalizeSellStep(step, options) {
61
+ function normalizeTradeStepSell(step, options) {
59
62
  const { start, end, price, size } = step;
60
63
  const { minPrice, minSize } = options;
61
64
  if (start === void 0 || start === null || start < 0) {
@@ -74,7 +77,7 @@ function normalizeSellStep(step, options) {
74
77
  return null;
75
78
  }
76
79
  const normalized = {
77
- side: Side.SELL,
80
+ side: TradeSide.SELL,
78
81
  price,
79
82
  size,
80
83
  start,
@@ -83,7 +86,7 @@ function normalizeSellStep(step, options) {
83
86
  const stepAsTradeStep = step;
84
87
  const invalidFields = [];
85
88
  if ("once" in stepAsTradeStep && stepAsTradeStep.once !== void 0) invalidFields.push("once");
86
- if ("outcome" in stepAsTradeStep && stepAsTradeStep.outcome !== void 0) invalidFields.push("outcome");
89
+ if ("outcomeIndex" in stepAsTradeStep && stepAsTradeStep.outcomeIndex !== void 0) invalidFields.push("outcomeIndex");
87
90
  if ("maxUnderlyingDiff" in stepAsTradeStep && stepAsTradeStep.maxUnderlyingDiff !== void 0) invalidFields.push("maxUnderlyingDiff");
88
91
  if ("minUnderlyingDiff" in stepAsTradeStep && stepAsTradeStep.minUnderlyingDiff !== void 0) invalidFields.push("minUnderlyingDiff");
89
92
  if (invalidFields.length > 0) {
@@ -101,10 +104,10 @@ function normalizeStrategy(config, options = {}) {
101
104
  const normalized = [];
102
105
  config.forEach((step, index) => {
103
106
  let normalizedStep = null;
104
- if (step.side === Side.BUY) {
105
- normalizedStep = normalizeBuyStep(step, normalizeOptions);
106
- } else if (step.side === Side.SELL) {
107
- normalizedStep = normalizeSellStep(step, normalizeOptions);
107
+ if (step.side === TradeSide.BUY) {
108
+ normalizedStep = normalizeTradeStepBuy(step, normalizeOptions);
109
+ } else if (step.side === TradeSide.SELL) {
110
+ normalizedStep = normalizeTradeStepSell(step, normalizeOptions);
108
111
  } else {
109
112
  const unknownStep = step;
110
113
  }
@@ -114,10 +117,10 @@ function normalizeStrategy(config, options = {}) {
114
117
  });
115
118
  return normalized;
116
119
  }
117
- function hasBuySteps(config) {
118
- return config.some((step) => step.side === Side.BUY);
120
+ function hasTradeStepsBuy(config) {
121
+ return config.some((step) => step.side === TradeSide.BUY);
119
122
  }
120
123
  export {
121
- hasBuySteps,
124
+ hasTradeStepsBuy,
122
125
  normalizeStrategy
123
126
  };
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,4 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/utils/trade-strategy/types.ts
17
21
  var types_exports = {};
22
+ __export(types_exports, {
23
+ TradeSide: () => import_clob_client.Side
24
+ });
18
25
  module.exports = __toCommonJS(types_exports);
26
+ var import_clob_client = require("@polymarket/clob-client");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ TradeSide
30
+ });
@@ -1,4 +1,5 @@
1
1
  import { Side, ClobClient } from '@polymarket/clob-client';
2
+ export { Side as TradeSide } from '@polymarket/clob-client';
2
3
 
3
4
  declare enum SupportedSymbol {
4
5
  ETH = "eth",
@@ -86,19 +87,19 @@ interface PriceDifferenceInfo {
86
87
  isFlat: boolean;
87
88
  }
88
89
 
89
- interface BuyStep {
90
+ interface TradeStepBuy {
90
91
  side: Side.BUY;
91
92
  price: number;
92
93
  size: number;
93
94
  start: number;
94
95
  end: number;
95
96
  once?: boolean;
96
- outcome?: 'Up' | 'Down';
97
+ outcomeIndex?: 0 | 1;
97
98
  maxUnderlyingDiff?: number;
98
99
  minUnderlyingDiff?: number;
99
100
  }
100
101
 
101
- interface SellStep {
102
+ interface TradeStepSell {
102
103
  side: Side.SELL;
103
104
  price: number;
104
105
  size: number;
@@ -106,7 +107,7 @@ interface SellStep {
106
107
  end: number;
107
108
  }
108
109
 
109
- type TradeStep = BuyStep | SellStep;
110
+ type TradeStep = TradeStepBuy | TradeStepSell;
110
111
 
111
112
  type StrategyConfig = TradeStep[];
112
113
 
@@ -161,4 +162,4 @@ interface MarketTokenData extends MarketToken {
161
162
 
162
163
  type MarketTokenContext = Record<string, MarketTokenData>;
163
164
 
164
- export type { BuyStep, MarketTokenContext, MarketTokenData, MarketTradeContext, MarketTradeRecord, SellStep, StrategyCallback, StrategyCondition, StrategyConfig, StrategyErrorCallback, StrategyExecQueue, StrategyFn, TokenTradeStepOrder, TradeStep };
165
+ export type { MarketTokenContext, MarketTokenData, MarketTradeContext, MarketTradeRecord, StrategyCallback, StrategyCondition, StrategyConfig, StrategyErrorCallback, StrategyExecQueue, StrategyFn, TokenTradeStepOrder, TradeStep, TradeStepBuy, TradeStepSell };
@@ -1,4 +1,5 @@
1
1
  import { Side, ClobClient } from '@polymarket/clob-client';
2
+ export { Side as TradeSide } from '@polymarket/clob-client';
2
3
 
3
4
  declare enum SupportedSymbol {
4
5
  ETH = "eth",
@@ -86,19 +87,19 @@ interface PriceDifferenceInfo {
86
87
  isFlat: boolean;
87
88
  }
88
89
 
89
- interface BuyStep {
90
+ interface TradeStepBuy {
90
91
  side: Side.BUY;
91
92
  price: number;
92
93
  size: number;
93
94
  start: number;
94
95
  end: number;
95
96
  once?: boolean;
96
- outcome?: 'Up' | 'Down';
97
+ outcomeIndex?: 0 | 1;
97
98
  maxUnderlyingDiff?: number;
98
99
  minUnderlyingDiff?: number;
99
100
  }
100
101
 
101
- interface SellStep {
102
+ interface TradeStepSell {
102
103
  side: Side.SELL;
103
104
  price: number;
104
105
  size: number;
@@ -106,7 +107,7 @@ interface SellStep {
106
107
  end: number;
107
108
  }
108
109
 
109
- type TradeStep = BuyStep | SellStep;
110
+ type TradeStep = TradeStepBuy | TradeStepSell;
110
111
 
111
112
  type StrategyConfig = TradeStep[];
112
113
 
@@ -161,4 +162,4 @@ interface MarketTokenData extends MarketToken {
161
162
 
162
163
  type MarketTokenContext = Record<string, MarketTokenData>;
163
164
 
164
- export type { BuyStep, MarketTokenContext, MarketTokenData, MarketTradeContext, MarketTradeRecord, SellStep, StrategyCallback, StrategyCondition, StrategyConfig, StrategyErrorCallback, StrategyExecQueue, StrategyFn, TokenTradeStepOrder, TradeStep };
165
+ export type { MarketTokenContext, MarketTokenData, MarketTradeContext, MarketTradeRecord, StrategyCallback, StrategyCondition, StrategyConfig, StrategyErrorCallback, StrategyExecQueue, StrategyFn, TokenTradeStepOrder, TradeStep, TradeStepBuy, TradeStepSell };
@@ -0,0 +1,6 @@
1
+ import {
2
+ TradeSide
3
+ } from "../chunk-QQPFFDMY.js";
4
+ export {
5
+ TradeSide
6
+ };