@polymarbot/shared 0.1.2 → 0.1.4

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