@polymarbot/shared 0.3.2 → 0.3.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.
- package/chunk-BBDXS63M.js +17 -0
- package/index.cjs +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/loadEnv.cjs +47 -0
- package/loadEnv.d.cts +3 -0
- package/loadEnv.d.ts +3 -0
- package/loadEnv.js +22 -0
- package/markets/types.js +15 -4
- package/package.json +7 -7
- package/trade-strategy/normalize.js +1 -1
- package/trade-strategy/types.cjs +8 -0
- package/trade-strategy/types.d.cts +10 -2
- package/trade-strategy/types.d.ts +10 -2
- package/trade-strategy/types.js +3 -1
- package/chunk-6XBSEJGX.js +0 -10
- package/chunk-S6EEUHHX.js +0 -20
- package/markets/tools.cjs +0 -130
- package/markets/tools.d.cts +0 -18
- package/markets/tools.d.ts +0 -18
- package/markets/tools.js +0 -81
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
8
|
+
OrderStatus2["LIVE"] = "LIVE";
|
|
9
|
+
OrderStatus2["MATCHED"] = "MATCHED";
|
|
10
|
+
OrderStatus2["CANCELED"] = "CANCELED";
|
|
11
|
+
return OrderStatus2;
|
|
12
|
+
})(OrderStatus || {});
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
TradeSide,
|
|
16
|
+
OrderStatus
|
|
17
|
+
};
|
package/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
...require('./basic.cjs'),
|
|
3
3
|
...require('./crypto.cjs'),
|
|
4
|
-
...require('./
|
|
4
|
+
...require('./loadEnv.cjs'),
|
|
5
5
|
...require('./markets/types.cjs'),
|
|
6
6
|
...require('./relayer-client.cjs'),
|
|
7
7
|
...require('./trade-strategy/normalize.cjs'),
|
package/index.d.cts
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/loadEnv.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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/loadEnv.ts
|
|
21
|
+
var loadEnv_exports = {};
|
|
22
|
+
__export(loadEnv_exports, {
|
|
23
|
+
loadEnv: () => loadEnv
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(loadEnv_exports);
|
|
26
|
+
var import_node_fs = require("fs");
|
|
27
|
+
var import_dotenv = require("dotenv");
|
|
28
|
+
function loadEnv(cwd = process.cwd(), extraPaths = []) {
|
|
29
|
+
const envPath = `${cwd}/.env`;
|
|
30
|
+
const envLocalPath = `${cwd}/.env.local`;
|
|
31
|
+
if ((0, import_node_fs.existsSync)(envPath)) {
|
|
32
|
+
(0, import_dotenv.config)({ path: envPath });
|
|
33
|
+
}
|
|
34
|
+
if ((0, import_node_fs.existsSync)(envLocalPath)) {
|
|
35
|
+
(0, import_dotenv.config)({ path: envLocalPath, override: true });
|
|
36
|
+
}
|
|
37
|
+
for (const relativePath of extraPaths) {
|
|
38
|
+
const fullPath = `${cwd}/${relativePath}`;
|
|
39
|
+
if ((0, import_node_fs.existsSync)(fullPath)) {
|
|
40
|
+
(0, import_dotenv.config)({ path: fullPath, override: true });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
loadEnv
|
|
47
|
+
});
|
package/loadEnv.d.cts
ADDED
package/loadEnv.d.ts
ADDED
package/loadEnv.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/utils/loadEnv.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { config as dotenvConfig } from "dotenv";
|
|
4
|
+
function loadEnv(cwd = process.cwd(), extraPaths = []) {
|
|
5
|
+
const envPath = `${cwd}/.env`;
|
|
6
|
+
const envLocalPath = `${cwd}/.env.local`;
|
|
7
|
+
if (existsSync(envPath)) {
|
|
8
|
+
dotenvConfig({ path: envPath });
|
|
9
|
+
}
|
|
10
|
+
if (existsSync(envLocalPath)) {
|
|
11
|
+
dotenvConfig({ path: envLocalPath, override: true });
|
|
12
|
+
}
|
|
13
|
+
for (const relativePath of extraPaths) {
|
|
14
|
+
const fullPath = `${cwd}/${relativePath}`;
|
|
15
|
+
if (existsSync(fullPath)) {
|
|
16
|
+
dotenvConfig({ path: fullPath, override: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
loadEnv
|
|
22
|
+
};
|
package/markets/types.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 || {});
|
|
5
16
|
export {
|
|
6
17
|
SupportedInterval,
|
|
7
18
|
SupportedSymbol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"default": "./crypto.cjs"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"./
|
|
39
|
+
"./loadEnv": {
|
|
40
40
|
"import": {
|
|
41
|
-
"types": "./
|
|
42
|
-
"default": "./
|
|
41
|
+
"types": "./loadEnv.d.ts",
|
|
42
|
+
"default": "./loadEnv.js"
|
|
43
43
|
},
|
|
44
44
|
"require": {
|
|
45
|
-
"types": "./
|
|
46
|
-
"default": "./
|
|
45
|
+
"types": "./loadEnv.d.cts",
|
|
46
|
+
"default": "./loadEnv.cjs"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"./markets/types": {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"**/*.d.cts"
|
|
105
105
|
],
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"
|
|
107
|
+
"dotenv": "^17.2.3",
|
|
108
108
|
"viem": "^2.38.6",
|
|
109
109
|
"@polymarket/builder-relayer-client": "^0.0.6",
|
|
110
110
|
"@polymarket/builder-signing-sdk": "^0.0.8"
|
package/trade-strategy/types.cjs
CHANGED
|
@@ -20,6 +20,7 @@ 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
|
+
OrderStatus: () => OrderStatus,
|
|
23
24
|
TradeSide: () => TradeSide
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(types_exports);
|
|
@@ -28,7 +29,14 @@ var TradeSide = /* @__PURE__ */ ((TradeSide2) => {
|
|
|
28
29
|
TradeSide2["SELL"] = "SELL";
|
|
29
30
|
return TradeSide2;
|
|
30
31
|
})(TradeSide || {});
|
|
32
|
+
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
33
|
+
OrderStatus2["LIVE"] = "LIVE";
|
|
34
|
+
OrderStatus2["MATCHED"] = "MATCHED";
|
|
35
|
+
OrderStatus2["CANCELED"] = "CANCELED";
|
|
36
|
+
return OrderStatus2;
|
|
37
|
+
})(OrderStatus || {});
|
|
31
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
39
|
0 && (module.exports = {
|
|
40
|
+
OrderStatus,
|
|
33
41
|
TradeSide
|
|
34
42
|
});
|
|
@@ -30,10 +30,16 @@ interface PriceChangeInfo {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
declare enum TradeSide {
|
|
33
|
-
BUY = "BUY"
|
|
33
|
+
BUY = "BUY",// 买入
|
|
34
34
|
SELL = "SELL"
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
declare enum OrderStatus {
|
|
38
|
+
LIVE = "LIVE",// 挂单中
|
|
39
|
+
MATCHED = "MATCHED",// 已成交
|
|
40
|
+
CANCELED = "CANCELED"
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
interface TradeStepBuy {
|
|
38
44
|
side: TradeSide.BUY;
|
|
39
45
|
price: number;
|
|
@@ -71,8 +77,10 @@ interface TokenTradeStepOrder {
|
|
|
71
77
|
id: string;
|
|
72
78
|
stepJson: string;
|
|
73
79
|
side: TradeSide;
|
|
80
|
+
size: number;
|
|
74
81
|
status: string;
|
|
75
82
|
updatedAt: number;
|
|
83
|
+
keep?: boolean;
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
interface MarketTradeRecord {
|
|
@@ -109,4 +117,4 @@ interface MarketTokenData extends MarketToken {
|
|
|
109
117
|
|
|
110
118
|
type MarketTokenContext = Record<string, MarketTokenData>;
|
|
111
119
|
|
|
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 };
|
|
120
|
+
export { type MarketTokenContext, type MarketTokenData, type MarketTradeContext, type MarketTradeRecord, OrderStatus, type StrategyCallback, type StrategyCondition, type StrategyConfig, type StrategyErrorCallback, type StrategyExecQueue, type StrategyFn, type TokenTradeStepOrder, TradeSide, type TradeStep, type TradeStepBuy, type TradeStepSell };
|
|
@@ -30,10 +30,16 @@ interface PriceChangeInfo {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
declare enum TradeSide {
|
|
33
|
-
BUY = "BUY"
|
|
33
|
+
BUY = "BUY",// 买入
|
|
34
34
|
SELL = "SELL"
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
declare enum OrderStatus {
|
|
38
|
+
LIVE = "LIVE",// 挂单中
|
|
39
|
+
MATCHED = "MATCHED",// 已成交
|
|
40
|
+
CANCELED = "CANCELED"
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
interface TradeStepBuy {
|
|
38
44
|
side: TradeSide.BUY;
|
|
39
45
|
price: number;
|
|
@@ -71,8 +77,10 @@ interface TokenTradeStepOrder {
|
|
|
71
77
|
id: string;
|
|
72
78
|
stepJson: string;
|
|
73
79
|
side: TradeSide;
|
|
80
|
+
size: number;
|
|
74
81
|
status: string;
|
|
75
82
|
updatedAt: number;
|
|
83
|
+
keep?: boolean;
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
interface MarketTradeRecord {
|
|
@@ -109,4 +117,4 @@ interface MarketTokenData extends MarketToken {
|
|
|
109
117
|
|
|
110
118
|
type MarketTokenContext = Record<string, MarketTokenData>;
|
|
111
119
|
|
|
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 };
|
|
120
|
+
export { type MarketTokenContext, type MarketTokenData, type MarketTradeContext, type MarketTradeRecord, OrderStatus, 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
package/chunk-6XBSEJGX.js
DELETED
package/chunk-S6EEUHHX.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
package/markets/tools.cjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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
|
-
calculatePeriodStartInET: () => calculatePeriodStartInET,
|
|
36
|
-
generate15mSlug: () => generate15mSlug,
|
|
37
|
-
generate1dSlug: () => generate1dSlug,
|
|
38
|
-
generate1hSlug: () => generate1hSlug,
|
|
39
|
-
generate4hSlug: () => generate4hSlug,
|
|
40
|
-
generateMarketUrl: () => generateMarketUrl
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(tools_exports);
|
|
43
|
-
|
|
44
|
-
// src/utils/dayjs.ts
|
|
45
|
-
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
46
|
-
var import_utc = __toESM(require("dayjs/plugin/utc"), 1);
|
|
47
|
-
var import_timezone = __toESM(require("dayjs/plugin/timezone"), 1);
|
|
48
|
-
var import_duration = __toESM(require("dayjs/plugin/duration"), 1);
|
|
49
|
-
import_dayjs.default.extend(import_utc.default);
|
|
50
|
-
import_dayjs.default.extend(import_timezone.default);
|
|
51
|
-
import_dayjs.default.extend(import_duration.default);
|
|
52
|
-
var dayjs_default = import_dayjs.default;
|
|
53
|
-
|
|
54
|
-
// src/utils/markets/types.ts
|
|
55
|
-
var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
56
|
-
SupportedSymbol2["ETH"] = "eth";
|
|
57
|
-
SupportedSymbol2["BTC"] = "btc";
|
|
58
|
-
SupportedSymbol2["SOL"] = "sol";
|
|
59
|
-
SupportedSymbol2["XRP"] = "xrp";
|
|
60
|
-
return SupportedSymbol2;
|
|
61
|
-
})(SupportedSymbol || {});
|
|
62
|
-
|
|
63
|
-
// src/utils/markets/tools.ts
|
|
64
|
-
var SUPPORTED_SYMBOLS = Object.values(SupportedSymbol);
|
|
65
|
-
var SYMBOL_FULL_NAME_MAP = {
|
|
66
|
-
["eth" /* ETH */]: "ethereum",
|
|
67
|
-
["btc" /* BTC */]: "bitcoin",
|
|
68
|
-
["sol" /* SOL */]: "solana"
|
|
69
|
-
};
|
|
70
|
-
var MONTH_NAMES = [
|
|
71
|
-
"january",
|
|
72
|
-
"february",
|
|
73
|
-
"march",
|
|
74
|
-
"april",
|
|
75
|
-
"may",
|
|
76
|
-
"june",
|
|
77
|
-
"july",
|
|
78
|
-
"august",
|
|
79
|
-
"september",
|
|
80
|
-
"october",
|
|
81
|
-
"november",
|
|
82
|
-
"december"
|
|
83
|
-
];
|
|
84
|
-
function generateMarketUrl(slug) {
|
|
85
|
-
return `https://polymarket.com/event/${slug}`;
|
|
86
|
-
}
|
|
87
|
-
function generate15mSlug(timestamp, symbol) {
|
|
88
|
-
const prefix = symbol.toLowerCase();
|
|
89
|
-
return `${prefix}-updown-15m-${timestamp}`;
|
|
90
|
-
}
|
|
91
|
-
function generate1hSlug(timestamp, symbol) {
|
|
92
|
-
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
93
|
-
const etTime = dayjs_default.unix(timestamp).tz("America/New_York");
|
|
94
|
-
const month = etTime.format("MMMM").toLowerCase();
|
|
95
|
-
const day = etTime.date();
|
|
96
|
-
const hour = etTime.format("h");
|
|
97
|
-
const ampm = etTime.format("a");
|
|
98
|
-
return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
|
|
99
|
-
}
|
|
100
|
-
function generate4hSlug(timestamp, symbol) {
|
|
101
|
-
const prefix = symbol.toLowerCase();
|
|
102
|
-
return `${prefix}-updown-4h-${timestamp}`;
|
|
103
|
-
}
|
|
104
|
-
function generate1dSlug(timestamp, symbol) {
|
|
105
|
-
const prefix = SYMBOL_FULL_NAME_MAP[symbol] || symbol.toLowerCase();
|
|
106
|
-
const date = new Date(timestamp * 1e3);
|
|
107
|
-
const month = MONTH_NAMES[date.getUTCMonth()];
|
|
108
|
-
const day = date.getUTCDate();
|
|
109
|
-
return `${prefix}-up-or-down-on-${month}-${day}`;
|
|
110
|
-
}
|
|
111
|
-
function calculatePeriodStartInET(intervalSeconds) {
|
|
112
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
113
|
-
const utcTime = dayjs_default.unix(now).utc();
|
|
114
|
-
const etTime = dayjs_default.unix(now).tz("America/New_York");
|
|
115
|
-
const offset = utcTime.utcOffset() * 60 - etTime.utcOffset() * 60;
|
|
116
|
-
const nowInET = now - offset;
|
|
117
|
-
const periodStartInET = Math.floor(nowInET / intervalSeconds) * intervalSeconds;
|
|
118
|
-
return periodStartInET + offset;
|
|
119
|
-
}
|
|
120
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
-
0 && (module.exports = {
|
|
122
|
-
SUPPORTED_SYMBOLS,
|
|
123
|
-
SYMBOL_FULL_NAME_MAP,
|
|
124
|
-
calculatePeriodStartInET,
|
|
125
|
-
generate15mSlug,
|
|
126
|
-
generate1dSlug,
|
|
127
|
-
generate1hSlug,
|
|
128
|
-
generate4hSlug,
|
|
129
|
-
generateMarketUrl
|
|
130
|
-
});
|
package/markets/tools.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
declare function calculatePeriodStartInET(intervalSeconds: number): number;
|
|
17
|
-
|
|
18
|
-
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
package/markets/tools.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
declare function calculatePeriodStartInET(intervalSeconds: number): number;
|
|
17
|
-
|
|
18
|
-
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl };
|
package/markets/tools.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
function calculatePeriodStartInET(intervalSeconds) {
|
|
64
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
65
|
-
const utcTime = dayjs_default.unix(now).utc();
|
|
66
|
-
const etTime = dayjs_default.unix(now).tz("America/New_York");
|
|
67
|
-
const offset = utcTime.utcOffset() * 60 - etTime.utcOffset() * 60;
|
|
68
|
-
const nowInET = now - offset;
|
|
69
|
-
const periodStartInET = Math.floor(nowInET / intervalSeconds) * intervalSeconds;
|
|
70
|
-
return periodStartInET + offset;
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
SUPPORTED_SYMBOLS,
|
|
74
|
-
SYMBOL_FULL_NAME_MAP,
|
|
75
|
-
calculatePeriodStartInET,
|
|
76
|
-
generate15mSlug,
|
|
77
|
-
generate1dSlug,
|
|
78
|
-
generate1hSlug,
|
|
79
|
-
generate4hSlug,
|
|
80
|
-
generateMarketUrl
|
|
81
|
-
};
|