@polymarbot/shared 0.1.3 → 0.2.0
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-6XBSEJGX.js +10 -0
- package/chunk-S6EEUHHX.js +20 -0
- package/markets/tools.cjs +119 -0
- package/markets/tools.d.cts +16 -0
- package/markets/tools.d.ts +16 -0
- package/markets/tools.js +71 -0
- package/markets/types.cjs +45 -0
- package/markets/types.d.cts +75 -0
- package/markets/types.d.ts +75 -0
- package/markets/types.js +8 -0
- package/package.json +22 -2
- package/trade-strategy/normalize.cjs +5 -10
- package/trade-strategy/normalize.d.cts +1 -0
- package/trade-strategy/normalize.d.ts +1 -0
- package/trade-strategy/normalize.js +6 -8
- package/trade-strategy/types.cjs +6 -2
- package/trade-strategy/types.d.cts +11 -64
- package/trade-strategy/types.d.ts +11 -64
- package/trade-strategy/types.js +1 -1
- package/chunk-QQPFFDMY.js +0 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/utils/markets/types.ts
|
|
2
|
+
var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
3
|
+
SupportedSymbol2["ETH"] = "eth";
|
|
4
|
+
SupportedSymbol2["BTC"] = "btc";
|
|
5
|
+
SupportedSymbol2["SOL"] = "sol";
|
|
6
|
+
SupportedSymbol2["XRP"] = "xrp";
|
|
7
|
+
return SupportedSymbol2;
|
|
8
|
+
})(SupportedSymbol || {});
|
|
9
|
+
var SupportedInterval = /* @__PURE__ */ ((SupportedInterval2) => {
|
|
10
|
+
SupportedInterval2["M15"] = "15m";
|
|
11
|
+
SupportedInterval2["H1"] = "1h";
|
|
12
|
+
SupportedInterval2["H4"] = "4h";
|
|
13
|
+
SupportedInterval2["D1"] = "1d";
|
|
14
|
+
return SupportedInterval2;
|
|
15
|
+
})(SupportedInterval || {});
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
SupportedSymbol,
|
|
19
|
+
SupportedInterval
|
|
20
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/utils/markets/tools.ts
|
|
31
|
+
var tools_exports = {};
|
|
32
|
+
__export(tools_exports, {
|
|
33
|
+
SUPPORTED_SYMBOLS: () => SUPPORTED_SYMBOLS,
|
|
34
|
+
SYMBOL_FULL_NAME_MAP: () => SYMBOL_FULL_NAME_MAP,
|
|
35
|
+
generate15mSlug: () => generate15mSlug,
|
|
36
|
+
generate1dSlug: () => generate1dSlug,
|
|
37
|
+
generate1hSlug: () => generate1hSlug,
|
|
38
|
+
generate4hSlug: () => generate4hSlug,
|
|
39
|
+
generateMarketUrl: () => generateMarketUrl
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(tools_exports);
|
|
42
|
+
|
|
43
|
+
// src/utils/dayjs.ts
|
|
44
|
+
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
45
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"), 1);
|
|
46
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone"), 1);
|
|
47
|
+
var import_duration = __toESM(require("dayjs/plugin/duration"), 1);
|
|
48
|
+
import_dayjs.default.extend(import_utc.default);
|
|
49
|
+
import_dayjs.default.extend(import_timezone.default);
|
|
50
|
+
import_dayjs.default.extend(import_duration.default);
|
|
51
|
+
var dayjs_default = import_dayjs.default;
|
|
52
|
+
|
|
53
|
+
// src/utils/markets/types.ts
|
|
54
|
+
var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
55
|
+
SupportedSymbol2["ETH"] = "eth";
|
|
56
|
+
SupportedSymbol2["BTC"] = "btc";
|
|
57
|
+
SupportedSymbol2["SOL"] = "sol";
|
|
58
|
+
SupportedSymbol2["XRP"] = "xrp";
|
|
59
|
+
return SupportedSymbol2;
|
|
60
|
+
})(SupportedSymbol || {});
|
|
61
|
+
|
|
62
|
+
// src/utils/markets/tools.ts
|
|
63
|
+
var SUPPORTED_SYMBOLS = Object.values(SupportedSymbol);
|
|
64
|
+
var SYMBOL_FULL_NAME_MAP = {
|
|
65
|
+
["eth" /* ETH */]: "ethereum",
|
|
66
|
+
["btc" /* BTC */]: "bitcoin",
|
|
67
|
+
["sol" /* SOL */]: "solana"
|
|
68
|
+
};
|
|
69
|
+
var MONTH_NAMES = [
|
|
70
|
+
"january",
|
|
71
|
+
"february",
|
|
72
|
+
"march",
|
|
73
|
+
"april",
|
|
74
|
+
"may",
|
|
75
|
+
"june",
|
|
76
|
+
"july",
|
|
77
|
+
"august",
|
|
78
|
+
"september",
|
|
79
|
+
"october",
|
|
80
|
+
"november",
|
|
81
|
+
"december"
|
|
82
|
+
];
|
|
83
|
+
function generateMarketUrl(slug) {
|
|
84
|
+
return `https://polymarket.com/event/${slug}`;
|
|
85
|
+
}
|
|
86
|
+
function generate15mSlug(timestamp, symbol) {
|
|
87
|
+
const prefix = symbol.toLowerCase();
|
|
88
|
+
return `${prefix}-updown-15m-${timestamp}`;
|
|
89
|
+
}
|
|
90
|
+
function generate1hSlug(timestamp, symbol) {
|
|
91
|
+
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
92
|
+
const etTime = dayjs_default.unix(timestamp).tz("America/New_York");
|
|
93
|
+
const month = etTime.format("MMMM").toLowerCase();
|
|
94
|
+
const day = etTime.date();
|
|
95
|
+
const hour = etTime.format("h");
|
|
96
|
+
const ampm = etTime.format("a");
|
|
97
|
+
return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
|
|
98
|
+
}
|
|
99
|
+
function generate4hSlug(timestamp, symbol) {
|
|
100
|
+
const prefix = symbol.toLowerCase();
|
|
101
|
+
return `${prefix}-updown-4h-${timestamp}`;
|
|
102
|
+
}
|
|
103
|
+
function generate1dSlug(timestamp, symbol) {
|
|
104
|
+
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
105
|
+
const date = new Date(timestamp * 1e3);
|
|
106
|
+
const month = MONTH_NAMES[date.getUTCMonth()];
|
|
107
|
+
const day = date.getUTCDate();
|
|
108
|
+
return `${prefix}-up-or-down-on-${month}-${day}`;
|
|
109
|
+
}
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
SUPPORTED_SYMBOLS,
|
|
113
|
+
SYMBOL_FULL_NAME_MAP,
|
|
114
|
+
generate15mSlug,
|
|
115
|
+
generate1dSlug,
|
|
116
|
+
generate1hSlug,
|
|
117
|
+
generate4hSlug,
|
|
118
|
+
generateMarketUrl
|
|
119
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SupportedSymbol, SymbolFullNameMap } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
declare const SUPPORTED_SYMBOLS: SupportedSymbol[];
|
|
4
|
+
declare const SYMBOL_FULL_NAME_MAP: SymbolFullNameMap;
|
|
5
|
+
|
|
6
|
+
declare function generateMarketUrl(slug: string): string;
|
|
7
|
+
|
|
8
|
+
declare function generate15mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
|
+
|
|
10
|
+
declare function generate1hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
11
|
+
|
|
12
|
+
declare function generate4hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
13
|
+
|
|
14
|
+
declare function generate1dSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
15
|
+
|
|
16
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SupportedSymbol, SymbolFullNameMap } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare const SUPPORTED_SYMBOLS: SupportedSymbol[];
|
|
4
|
+
declare const SYMBOL_FULL_NAME_MAP: SymbolFullNameMap;
|
|
5
|
+
|
|
6
|
+
declare function generateMarketUrl(slug: string): string;
|
|
7
|
+
|
|
8
|
+
declare function generate15mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
|
+
|
|
10
|
+
declare function generate1hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
11
|
+
|
|
12
|
+
declare function generate4hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
13
|
+
|
|
14
|
+
declare function generate1dSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
15
|
+
|
|
16
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
package/markets/tools.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SupportedSymbol
|
|
3
|
+
} from "../chunk-S6EEUHHX.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/dayjs.ts
|
|
6
|
+
import dayjs from "dayjs";
|
|
7
|
+
import utc from "dayjs/plugin/utc";
|
|
8
|
+
import timezone from "dayjs/plugin/timezone";
|
|
9
|
+
import duration from "dayjs/plugin/duration";
|
|
10
|
+
dayjs.extend(utc);
|
|
11
|
+
dayjs.extend(timezone);
|
|
12
|
+
dayjs.extend(duration);
|
|
13
|
+
var dayjs_default = dayjs;
|
|
14
|
+
|
|
15
|
+
// src/utils/markets/tools.ts
|
|
16
|
+
var SUPPORTED_SYMBOLS = Object.values(SupportedSymbol);
|
|
17
|
+
var SYMBOL_FULL_NAME_MAP = {
|
|
18
|
+
["eth" /* ETH */]: "ethereum",
|
|
19
|
+
["btc" /* BTC */]: "bitcoin",
|
|
20
|
+
["sol" /* SOL */]: "solana"
|
|
21
|
+
};
|
|
22
|
+
var MONTH_NAMES = [
|
|
23
|
+
"january",
|
|
24
|
+
"february",
|
|
25
|
+
"march",
|
|
26
|
+
"april",
|
|
27
|
+
"may",
|
|
28
|
+
"june",
|
|
29
|
+
"july",
|
|
30
|
+
"august",
|
|
31
|
+
"september",
|
|
32
|
+
"october",
|
|
33
|
+
"november",
|
|
34
|
+
"december"
|
|
35
|
+
];
|
|
36
|
+
function generateMarketUrl(slug) {
|
|
37
|
+
return `https://polymarket.com/event/${slug}`;
|
|
38
|
+
}
|
|
39
|
+
function generate15mSlug(timestamp, symbol) {
|
|
40
|
+
const prefix = symbol.toLowerCase();
|
|
41
|
+
return `${prefix}-updown-15m-${timestamp}`;
|
|
42
|
+
}
|
|
43
|
+
function generate1hSlug(timestamp, symbol) {
|
|
44
|
+
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
45
|
+
const etTime = dayjs_default.unix(timestamp).tz("America/New_York");
|
|
46
|
+
const month = etTime.format("MMMM").toLowerCase();
|
|
47
|
+
const day = etTime.date();
|
|
48
|
+
const hour = etTime.format("h");
|
|
49
|
+
const ampm = etTime.format("a");
|
|
50
|
+
return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
|
|
51
|
+
}
|
|
52
|
+
function generate4hSlug(timestamp, symbol) {
|
|
53
|
+
const prefix = symbol.toLowerCase();
|
|
54
|
+
return `${prefix}-updown-4h-${timestamp}`;
|
|
55
|
+
}
|
|
56
|
+
function generate1dSlug(timestamp, symbol) {
|
|
57
|
+
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
58
|
+
const date = new Date(timestamp * 1e3);
|
|
59
|
+
const month = MONTH_NAMES[date.getUTCMonth()];
|
|
60
|
+
const day = date.getUTCDate();
|
|
61
|
+
return `${prefix}-up-or-down-on-${month}-${day}`;
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
SUPPORTED_SYMBOLS,
|
|
65
|
+
SYMBOL_FULL_NAME_MAP,
|
|
66
|
+
generate15mSlug,
|
|
67
|
+
generate1dSlug,
|
|
68
|
+
generate1hSlug,
|
|
69
|
+
generate4hSlug,
|
|
70
|
+
generateMarketUrl
|
|
71
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/markets/types.ts
|
|
21
|
+
var types_exports = {};
|
|
22
|
+
__export(types_exports, {
|
|
23
|
+
SupportedInterval: () => SupportedInterval,
|
|
24
|
+
SupportedSymbol: () => SupportedSymbol
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(types_exports);
|
|
27
|
+
var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
28
|
+
SupportedSymbol2["ETH"] = "eth";
|
|
29
|
+
SupportedSymbol2["BTC"] = "btc";
|
|
30
|
+
SupportedSymbol2["SOL"] = "sol";
|
|
31
|
+
SupportedSymbol2["XRP"] = "xrp";
|
|
32
|
+
return SupportedSymbol2;
|
|
33
|
+
})(SupportedSymbol || {});
|
|
34
|
+
var SupportedInterval = /* @__PURE__ */ ((SupportedInterval2) => {
|
|
35
|
+
SupportedInterval2["M15"] = "15m";
|
|
36
|
+
SupportedInterval2["H1"] = "1h";
|
|
37
|
+
SupportedInterval2["H4"] = "4h";
|
|
38
|
+
SupportedInterval2["D1"] = "1d";
|
|
39
|
+
return SupportedInterval2;
|
|
40
|
+
})(SupportedInterval || {});
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
SupportedInterval,
|
|
44
|
+
SupportedSymbol
|
|
45
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare enum SupportedSymbol {
|
|
2
|
+
ETH = "eth",
|
|
3
|
+
BTC = "btc",
|
|
4
|
+
SOL = "sol",
|
|
5
|
+
XRP = "xrp"
|
|
6
|
+
}
|
|
7
|
+
declare enum SupportedInterval {
|
|
8
|
+
M15 = "15m",
|
|
9
|
+
H1 = "1h",
|
|
10
|
+
H4 = "4h",
|
|
11
|
+
D1 = "1d"
|
|
12
|
+
}
|
|
13
|
+
interface MarketConfig {
|
|
14
|
+
marketName: string;
|
|
15
|
+
symbol: SupportedSymbol;
|
|
16
|
+
interval: SupportedInterval;
|
|
17
|
+
intervalName: string;
|
|
18
|
+
intervalSeconds: number;
|
|
19
|
+
generateSlug: (timestamp: number) => string;
|
|
20
|
+
}
|
|
21
|
+
interface RawMarketData {
|
|
22
|
+
id: string;
|
|
23
|
+
conditionId: string;
|
|
24
|
+
question: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
eventStartTime: string;
|
|
27
|
+
endDate: string;
|
|
28
|
+
active: boolean;
|
|
29
|
+
closed: boolean;
|
|
30
|
+
umaResolutionStatus?: string;
|
|
31
|
+
customLiveness?: number;
|
|
32
|
+
outcomes: string;
|
|
33
|
+
outcomePrices?: string;
|
|
34
|
+
clobTokenIds?: string;
|
|
35
|
+
orderPriceMinTickSize: number;
|
|
36
|
+
orderMinSize: number;
|
|
37
|
+
negRisk: boolean;
|
|
38
|
+
volume: string;
|
|
39
|
+
liquidity: string;
|
|
40
|
+
bestBid?: number;
|
|
41
|
+
bestAsk?: number;
|
|
42
|
+
}
|
|
43
|
+
interface Market {
|
|
44
|
+
id: string;
|
|
45
|
+
conditionId: string;
|
|
46
|
+
question: string;
|
|
47
|
+
slug: string;
|
|
48
|
+
url: string;
|
|
49
|
+
startTimestamp: number;
|
|
50
|
+
endTimestamp: number;
|
|
51
|
+
orderMinSize: number;
|
|
52
|
+
orderPriceMinTickSize: number;
|
|
53
|
+
negRisk: boolean;
|
|
54
|
+
outcomes: string[];
|
|
55
|
+
clobTokenIds: string[];
|
|
56
|
+
marketName: string;
|
|
57
|
+
symbol: SupportedSymbol;
|
|
58
|
+
interval: SupportedInterval;
|
|
59
|
+
intervalName: string | null;
|
|
60
|
+
raw: RawMarketData;
|
|
61
|
+
}
|
|
62
|
+
interface IntervalConfig {
|
|
63
|
+
name: string;
|
|
64
|
+
seconds: number;
|
|
65
|
+
generateSlug: (timestamp: number, symbol: SupportedSymbol) => string;
|
|
66
|
+
}
|
|
67
|
+
type SymbolFullNameMap = {
|
|
68
|
+
[key in SupportedSymbol]?: string;
|
|
69
|
+
};
|
|
70
|
+
interface MarketToken {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { type IntervalConfig, type Market, type MarketConfig, type MarketToken, type RawMarketData, SupportedInterval, SupportedSymbol, type SymbolFullNameMap };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare enum SupportedSymbol {
|
|
2
|
+
ETH = "eth",
|
|
3
|
+
BTC = "btc",
|
|
4
|
+
SOL = "sol",
|
|
5
|
+
XRP = "xrp"
|
|
6
|
+
}
|
|
7
|
+
declare enum SupportedInterval {
|
|
8
|
+
M15 = "15m",
|
|
9
|
+
H1 = "1h",
|
|
10
|
+
H4 = "4h",
|
|
11
|
+
D1 = "1d"
|
|
12
|
+
}
|
|
13
|
+
interface MarketConfig {
|
|
14
|
+
marketName: string;
|
|
15
|
+
symbol: SupportedSymbol;
|
|
16
|
+
interval: SupportedInterval;
|
|
17
|
+
intervalName: string;
|
|
18
|
+
intervalSeconds: number;
|
|
19
|
+
generateSlug: (timestamp: number) => string;
|
|
20
|
+
}
|
|
21
|
+
interface RawMarketData {
|
|
22
|
+
id: string;
|
|
23
|
+
conditionId: string;
|
|
24
|
+
question: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
eventStartTime: string;
|
|
27
|
+
endDate: string;
|
|
28
|
+
active: boolean;
|
|
29
|
+
closed: boolean;
|
|
30
|
+
umaResolutionStatus?: string;
|
|
31
|
+
customLiveness?: number;
|
|
32
|
+
outcomes: string;
|
|
33
|
+
outcomePrices?: string;
|
|
34
|
+
clobTokenIds?: string;
|
|
35
|
+
orderPriceMinTickSize: number;
|
|
36
|
+
orderMinSize: number;
|
|
37
|
+
negRisk: boolean;
|
|
38
|
+
volume: string;
|
|
39
|
+
liquidity: string;
|
|
40
|
+
bestBid?: number;
|
|
41
|
+
bestAsk?: number;
|
|
42
|
+
}
|
|
43
|
+
interface Market {
|
|
44
|
+
id: string;
|
|
45
|
+
conditionId: string;
|
|
46
|
+
question: string;
|
|
47
|
+
slug: string;
|
|
48
|
+
url: string;
|
|
49
|
+
startTimestamp: number;
|
|
50
|
+
endTimestamp: number;
|
|
51
|
+
orderMinSize: number;
|
|
52
|
+
orderPriceMinTickSize: number;
|
|
53
|
+
negRisk: boolean;
|
|
54
|
+
outcomes: string[];
|
|
55
|
+
clobTokenIds: string[];
|
|
56
|
+
marketName: string;
|
|
57
|
+
symbol: SupportedSymbol;
|
|
58
|
+
interval: SupportedInterval;
|
|
59
|
+
intervalName: string | null;
|
|
60
|
+
raw: RawMarketData;
|
|
61
|
+
}
|
|
62
|
+
interface IntervalConfig {
|
|
63
|
+
name: string;
|
|
64
|
+
seconds: number;
|
|
65
|
+
generateSlug: (timestamp: number, symbol: SupportedSymbol) => string;
|
|
66
|
+
}
|
|
67
|
+
type SymbolFullNameMap = {
|
|
68
|
+
[key in SupportedSymbol]?: string;
|
|
69
|
+
};
|
|
70
|
+
interface MarketToken {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { type IntervalConfig, type Market, type MarketConfig, type MarketToken, type RawMarketData, SupportedInterval, SupportedSymbol, type SymbolFullNameMap };
|
package/markets/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./basic.cjs",
|
|
6
6
|
"module": "./basic.js",
|
|
@@ -16,6 +16,26 @@
|
|
|
16
16
|
"default": "./basic.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
"./markets/tools": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./markets/tools.d.ts",
|
|
22
|
+
"default": "./markets/tools.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./markets/tools.d.cts",
|
|
26
|
+
"default": "./markets/tools.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./markets/types": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./markets/types.d.ts",
|
|
32
|
+
"default": "./markets/types.js"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./markets/types.d.cts",
|
|
36
|
+
"default": "./markets/types.cjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
19
39
|
"./relayer-client": {
|
|
20
40
|
"import": {
|
|
21
41
|
"types": "./relayer-client.d.ts",
|
|
@@ -64,7 +84,7 @@
|
|
|
64
84
|
"**/*.d.cts"
|
|
65
85
|
],
|
|
66
86
|
"dependencies": {
|
|
67
|
-
"
|
|
87
|
+
"dayjs": "^1.11.19",
|
|
68
88
|
"viem": "^2.38.6",
|
|
69
89
|
"@polymarket/builder-relayer-client": "^0.0.6",
|
|
70
90
|
"@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:
|
|
46
|
+
side: "BUY" /* BUY */,
|
|
52
47
|
price,
|
|
53
48
|
size,
|
|
54
49
|
start,
|
|
@@ -103,7 +98,7 @@ function normalizeTradeStepSell(step, options) {
|
|
|
103
98
|
return null;
|
|
104
99
|
}
|
|
105
100
|
const normalized = {
|
|
106
|
-
side:
|
|
101
|
+
side: "SELL" /* SELL */,
|
|
107
102
|
price,
|
|
108
103
|
size,
|
|
109
104
|
start,
|
|
@@ -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 ===
|
|
128
|
+
if (step.side === "BUY" /* BUY */) {
|
|
134
129
|
normalizedStep = normalizeTradeStepBuy(step, normalizeOptions);
|
|
135
|
-
} else if (step.side ===
|
|
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 ===
|
|
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:
|
|
23
|
+
side: "BUY" /* BUY */,
|
|
26
24
|
price,
|
|
27
25
|
size,
|
|
28
26
|
start,
|
|
@@ -77,7 +75,7 @@ function normalizeTradeStepSell(step, options) {
|
|
|
77
75
|
return null;
|
|
78
76
|
}
|
|
79
77
|
const normalized = {
|
|
80
|
-
side:
|
|
78
|
+
side: "SELL" /* SELL */,
|
|
81
79
|
price,
|
|
82
80
|
size,
|
|
83
81
|
start,
|
|
@@ -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 ===
|
|
105
|
+
if (step.side === "BUY" /* BUY */) {
|
|
108
106
|
normalizedStep = normalizeTradeStepBuy(step, normalizeOptions);
|
|
109
|
-
} else if (step.side ===
|
|
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 ===
|
|
119
|
+
return config.some((step) => step.side === "BUY" /* BUY */);
|
|
122
120
|
}
|
|
123
121
|
export {
|
|
124
122
|
hasTradeStepsBuy,
|
package/trade-strategy/types.cjs
CHANGED
|
@@ -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: () =>
|
|
23
|
+
TradeSide: () => TradeSide
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
|
-
var
|
|
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,63 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare enum SupportedSymbol {
|
|
5
|
-
ETH = "eth",
|
|
6
|
-
BTC = "btc",
|
|
7
|
-
SOL = "sol",
|
|
8
|
-
XRP = "xrp"
|
|
9
|
-
}
|
|
10
|
-
declare enum SupportedInterval {
|
|
11
|
-
M15 = "15m",
|
|
12
|
-
H1 = "1h",
|
|
13
|
-
H4 = "4h",
|
|
14
|
-
D1 = "1d"
|
|
15
|
-
}
|
|
16
|
-
interface RawMarketData {
|
|
17
|
-
id: string;
|
|
18
|
-
conditionId: string;
|
|
19
|
-
question: string;
|
|
20
|
-
slug: string;
|
|
21
|
-
eventStartTime: string;
|
|
22
|
-
endDate: string;
|
|
23
|
-
active: boolean;
|
|
24
|
-
closed: boolean;
|
|
25
|
-
umaResolutionStatus?: string;
|
|
26
|
-
customLiveness?: number;
|
|
27
|
-
outcomes: string;
|
|
28
|
-
outcomePrices?: string;
|
|
29
|
-
clobTokenIds?: string;
|
|
30
|
-
orderPriceMinTickSize: number;
|
|
31
|
-
orderMinSize: number;
|
|
32
|
-
negRisk: boolean;
|
|
33
|
-
volume: string;
|
|
34
|
-
liquidity: string;
|
|
35
|
-
bestBid?: number;
|
|
36
|
-
bestAsk?: number;
|
|
37
|
-
}
|
|
38
|
-
interface Market {
|
|
39
|
-
id: string;
|
|
40
|
-
conditionId: string;
|
|
41
|
-
question: string;
|
|
42
|
-
slug: string;
|
|
43
|
-
url: string;
|
|
44
|
-
startTimestamp: number;
|
|
45
|
-
endTimestamp: number;
|
|
46
|
-
orderMinSize: number;
|
|
47
|
-
orderPriceMinTickSize: number;
|
|
48
|
-
negRisk: boolean;
|
|
49
|
-
outcomes: string[];
|
|
50
|
-
clobTokenIds: string[];
|
|
51
|
-
marketName: string;
|
|
52
|
-
symbol: SupportedSymbol;
|
|
53
|
-
interval: SupportedInterval;
|
|
54
|
-
intervalName: string | null;
|
|
55
|
-
raw: RawMarketData;
|
|
56
|
-
}
|
|
57
|
-
interface MarketToken {
|
|
58
|
-
id: string;
|
|
59
|
-
name: string;
|
|
60
|
-
}
|
|
1
|
+
import { ClobClient } from '@polymarket/clob-client';
|
|
2
|
+
import { Market, MarketToken } from '../markets/types.cjs';
|
|
61
3
|
|
|
62
4
|
interface PositionInfo {
|
|
63
5
|
|
|
@@ -87,8 +29,13 @@ interface PriceDifferenceInfo {
|
|
|
87
29
|
isFlat: boolean;
|
|
88
30
|
}
|
|
89
31
|
|
|
32
|
+
declare enum TradeSide {
|
|
33
|
+
BUY = "BUY",
|
|
34
|
+
SELL = "SELL"
|
|
35
|
+
}
|
|
36
|
+
|
|
90
37
|
interface TradeStepBuy {
|
|
91
|
-
side:
|
|
38
|
+
side: TradeSide.BUY;
|
|
92
39
|
price: number;
|
|
93
40
|
size: number;
|
|
94
41
|
start: number;
|
|
@@ -100,7 +47,7 @@ interface TradeStepBuy {
|
|
|
100
47
|
}
|
|
101
48
|
|
|
102
49
|
interface TradeStepSell {
|
|
103
|
-
side:
|
|
50
|
+
side: TradeSide.SELL;
|
|
104
51
|
price: number;
|
|
105
52
|
size: number;
|
|
106
53
|
start: number;
|
|
@@ -123,7 +70,7 @@ type StrategyFn = (onError?: StrategyErrorCallback) => Promise<void>;
|
|
|
123
70
|
interface TokenTradeStepOrder {
|
|
124
71
|
id: string;
|
|
125
72
|
stepJson: string;
|
|
126
|
-
side:
|
|
73
|
+
side: TradeSide;
|
|
127
74
|
status: string;
|
|
128
75
|
updatedAt: number;
|
|
129
76
|
}
|
|
@@ -162,4 +109,4 @@ interface MarketTokenData extends MarketToken {
|
|
|
162
109
|
|
|
163
110
|
type MarketTokenContext = Record<string, MarketTokenData>;
|
|
164
111
|
|
|
165
|
-
export type
|
|
112
|
+
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,63 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare enum SupportedSymbol {
|
|
5
|
-
ETH = "eth",
|
|
6
|
-
BTC = "btc",
|
|
7
|
-
SOL = "sol",
|
|
8
|
-
XRP = "xrp"
|
|
9
|
-
}
|
|
10
|
-
declare enum SupportedInterval {
|
|
11
|
-
M15 = "15m",
|
|
12
|
-
H1 = "1h",
|
|
13
|
-
H4 = "4h",
|
|
14
|
-
D1 = "1d"
|
|
15
|
-
}
|
|
16
|
-
interface RawMarketData {
|
|
17
|
-
id: string;
|
|
18
|
-
conditionId: string;
|
|
19
|
-
question: string;
|
|
20
|
-
slug: string;
|
|
21
|
-
eventStartTime: string;
|
|
22
|
-
endDate: string;
|
|
23
|
-
active: boolean;
|
|
24
|
-
closed: boolean;
|
|
25
|
-
umaResolutionStatus?: string;
|
|
26
|
-
customLiveness?: number;
|
|
27
|
-
outcomes: string;
|
|
28
|
-
outcomePrices?: string;
|
|
29
|
-
clobTokenIds?: string;
|
|
30
|
-
orderPriceMinTickSize: number;
|
|
31
|
-
orderMinSize: number;
|
|
32
|
-
negRisk: boolean;
|
|
33
|
-
volume: string;
|
|
34
|
-
liquidity: string;
|
|
35
|
-
bestBid?: number;
|
|
36
|
-
bestAsk?: number;
|
|
37
|
-
}
|
|
38
|
-
interface Market {
|
|
39
|
-
id: string;
|
|
40
|
-
conditionId: string;
|
|
41
|
-
question: string;
|
|
42
|
-
slug: string;
|
|
43
|
-
url: string;
|
|
44
|
-
startTimestamp: number;
|
|
45
|
-
endTimestamp: number;
|
|
46
|
-
orderMinSize: number;
|
|
47
|
-
orderPriceMinTickSize: number;
|
|
48
|
-
negRisk: boolean;
|
|
49
|
-
outcomes: string[];
|
|
50
|
-
clobTokenIds: string[];
|
|
51
|
-
marketName: string;
|
|
52
|
-
symbol: SupportedSymbol;
|
|
53
|
-
interval: SupportedInterval;
|
|
54
|
-
intervalName: string | null;
|
|
55
|
-
raw: RawMarketData;
|
|
56
|
-
}
|
|
57
|
-
interface MarketToken {
|
|
58
|
-
id: string;
|
|
59
|
-
name: string;
|
|
60
|
-
}
|
|
1
|
+
import { ClobClient } from '@polymarket/clob-client';
|
|
2
|
+
import { Market, MarketToken } from '../markets/types.js';
|
|
61
3
|
|
|
62
4
|
interface PositionInfo {
|
|
63
5
|
|
|
@@ -87,8 +29,13 @@ interface PriceDifferenceInfo {
|
|
|
87
29
|
isFlat: boolean;
|
|
88
30
|
}
|
|
89
31
|
|
|
32
|
+
declare enum TradeSide {
|
|
33
|
+
BUY = "BUY",
|
|
34
|
+
SELL = "SELL"
|
|
35
|
+
}
|
|
36
|
+
|
|
90
37
|
interface TradeStepBuy {
|
|
91
|
-
side:
|
|
38
|
+
side: TradeSide.BUY;
|
|
92
39
|
price: number;
|
|
93
40
|
size: number;
|
|
94
41
|
start: number;
|
|
@@ -100,7 +47,7 @@ interface TradeStepBuy {
|
|
|
100
47
|
}
|
|
101
48
|
|
|
102
49
|
interface TradeStepSell {
|
|
103
|
-
side:
|
|
50
|
+
side: TradeSide.SELL;
|
|
104
51
|
price: number;
|
|
105
52
|
size: number;
|
|
106
53
|
start: number;
|
|
@@ -123,7 +70,7 @@ type StrategyFn = (onError?: StrategyErrorCallback) => Promise<void>;
|
|
|
123
70
|
interface TokenTradeStepOrder {
|
|
124
71
|
id: string;
|
|
125
72
|
stepJson: string;
|
|
126
|
-
side:
|
|
73
|
+
side: TradeSide;
|
|
127
74
|
status: string;
|
|
128
75
|
updatedAt: number;
|
|
129
76
|
}
|
|
@@ -162,4 +109,4 @@ interface MarketTokenData extends MarketToken {
|
|
|
162
109
|
|
|
163
110
|
type MarketTokenContext = Record<string, MarketTokenData>;
|
|
164
111
|
|
|
165
|
-
export type
|
|
112
|
+
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 };
|
package/trade-strategy/types.js
CHANGED