@polymarbot/shared 0.3.2 → 0.3.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.
- package/basic.js +2 -0
- package/chunk-BBDXS63M.js +17 -0
- package/chunk-JSBRDJBE.js +30 -0
- package/crypto.js +2 -0
- package/index.cjs +2 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/loadEnv.cjs +47 -0
- package/loadEnv.d.cts +3 -0
- package/loadEnv.d.ts +3 -0
- package/loadEnv.js +24 -0
- package/markets/types.js +1 -0
- package/markets/utils.cjs +693 -0
- package/markets/utils.js +645 -0
- package/package.json +17 -7
- package/relayer-client.js +2 -0
- package/trade-strategy/normalize.js +2 -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 +4 -1
- package/wallet.js +2 -0
- package/chunk-6XBSEJGX.js +0 -10
- package/markets/tools.cjs +0 -130
- package/markets/tools.js +0 -81
- /package/markets/{tools.d.cts → utils.d.cts} +0 -0
- /package/markets/{tools.d.ts → utils.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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": {
|
|
@@ -56,6 +56,16 @@
|
|
|
56
56
|
"default": "./markets/types.cjs"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
"./markets/utils": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./markets/utils.d.ts",
|
|
62
|
+
"default": "./markets/utils.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./markets/utils.d.cts",
|
|
66
|
+
"default": "./markets/utils.cjs"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
59
69
|
"./relayer-client": {
|
|
60
70
|
"import": {
|
|
61
71
|
"types": "./relayer-client.d.ts",
|
|
@@ -104,7 +114,7 @@
|
|
|
104
114
|
"**/*.d.cts"
|
|
105
115
|
],
|
|
106
116
|
"dependencies": {
|
|
107
|
-
"
|
|
117
|
+
"dotenv": "^17.2.3",
|
|
108
118
|
"viem": "^2.38.6",
|
|
109
119
|
"@polymarket/builder-relayer-client": "^0.0.6",
|
|
110
120
|
"@polymarket/builder-signing-sdk": "^0.0.8"
|
package/relayer-client.js
CHANGED
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/wallet.js
CHANGED
package/chunk-6XBSEJGX.js
DELETED
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.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
|
-
};
|
|
File without changes
|
|
File without changes
|