@polymarbot/shared 0.1.1 → 0.1.2
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/chunk-QQPFFDMY.js +6 -0
- package/package.json +3 -3
- package/trade-strategy/normalize.cjs +11 -7
- package/trade-strategy/normalize.d.cts +2 -2
- package/trade-strategy/normalize.d.ts +2 -2
- package/trade-strategy/normalize.js +15 -12
- package/trade-strategy/types.cjs +12 -0
- package/trade-strategy/types.d.cts +5 -4
- package/trade-strategy/types.d.ts +5 -4
- package/trade-strategy/types.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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
|
-
|
|
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
|
-
|
|
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) {
|
|
@@ -80,7 +84,7 @@ function normalizeBuyStep(step, options) {
|
|
|
80
84
|
}
|
|
81
85
|
return normalized;
|
|
82
86
|
}
|
|
83
|
-
function
|
|
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) {
|
|
@@ -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 =
|
|
134
|
+
normalizedStep = normalizeTradeStepBuy(step, normalizeOptions);
|
|
131
135
|
} else if (step.side === import_clob_client.Side.SELL) {
|
|
132
|
-
normalizedStep =
|
|
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
|
|
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
|
-
|
|
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
|
|
13
|
+
declare function hasTradeStepsBuy(config: StrategyConfig): boolean;
|
|
14
14
|
|
|
15
|
-
export { type NormalizeStrategyOptions,
|
|
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
|
|
13
|
+
declare function hasTradeStepsBuy(config: StrategyConfig): boolean;
|
|
14
14
|
|
|
15
|
-
export { type NormalizeStrategyOptions,
|
|
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
|
-
|
|
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:
|
|
25
|
+
side: TradeSide.BUY,
|
|
23
26
|
price,
|
|
24
27
|
size,
|
|
25
28
|
start,
|
|
@@ -55,7 +58,7 @@ function normalizeBuyStep(step, options) {
|
|
|
55
58
|
}
|
|
56
59
|
return normalized;
|
|
57
60
|
}
|
|
58
|
-
function
|
|
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:
|
|
80
|
+
side: TradeSide.SELL,
|
|
78
81
|
price,
|
|
79
82
|
size,
|
|
80
83
|
start,
|
|
@@ -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 ===
|
|
105
|
-
normalizedStep =
|
|
106
|
-
} else if (step.side ===
|
|
107
|
-
normalizedStep =
|
|
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
|
|
118
|
-
return config.some((step) => step.side ===
|
|
120
|
+
function hasTradeStepsBuy(config) {
|
|
121
|
+
return config.some((step) => step.side === TradeSide.BUY);
|
|
119
122
|
}
|
|
120
123
|
export {
|
|
121
|
-
|
|
124
|
+
hasTradeStepsBuy,
|
|
122
125
|
normalizeStrategy
|
|
123
126
|
};
|
package/trade-strategy/types.cjs
CHANGED
|
@@ -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,7 +87,7 @@ interface PriceDifferenceInfo {
|
|
|
86
87
|
isFlat: boolean;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
interface
|
|
90
|
+
interface TradeStepBuy {
|
|
90
91
|
side: Side.BUY;
|
|
91
92
|
price: number;
|
|
92
93
|
size: number;
|
|
@@ -98,7 +99,7 @@ interface BuyStep {
|
|
|
98
99
|
minUnderlyingDiff?: number;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
interface
|
|
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 =
|
|
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 {
|
|
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,7 +87,7 @@ interface PriceDifferenceInfo {
|
|
|
86
87
|
isFlat: boolean;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
interface
|
|
90
|
+
interface TradeStepBuy {
|
|
90
91
|
side: Side.BUY;
|
|
91
92
|
price: number;
|
|
92
93
|
size: number;
|
|
@@ -98,7 +99,7 @@ interface BuyStep {
|
|
|
98
99
|
minUnderlyingDiff?: number;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
interface
|
|
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 =
|
|
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 {
|
|
165
|
+
export type { MarketTokenContext, MarketTokenData, MarketTradeContext, MarketTradeRecord, StrategyCallback, StrategyCondition, StrategyConfig, StrategyErrorCallback, StrategyExecQueue, StrategyFn, TokenTradeStepOrder, TradeStep, TradeStepBuy, TradeStepSell };
|