@polymarbot/shared 0.4.0 → 0.5.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-DF467RX7.js → chunk-U2Y7SE3C.js} +1 -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 → load-env.cjs} +4 -4
- package/{loadEnv.js → load-env.js} +1 -1
- package/markets/types.cjs +1 -0
- package/markets/types.d.cts +1 -0
- package/markets/types.d.ts +1 -0
- package/markets/types.js +1 -1
- package/markets/utils.cjs +13 -2
- package/markets/utils.d.cts +3 -1
- package/markets/utils.d.ts +3 -1
- package/markets/utils.js +13 -3
- package/package.json +9 -9
- package/wallet.cjs +1 -4
- package/wallet.d.cts +9 -1
- package/wallet.d.ts +9 -1
- package/wallet.js +1 -4
- /package/{loadEnv.d.cts → load-env.d.cts} +0 -0
- /package/{loadEnv.d.ts → load-env.d.ts} +0 -0
|
@@ -7,6 +7,7 @@ var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
|
7
7
|
return SupportedSymbol2;
|
|
8
8
|
})(SupportedSymbol || {});
|
|
9
9
|
var SupportedInterval = /* @__PURE__ */ ((SupportedInterval2) => {
|
|
10
|
+
SupportedInterval2["M5"] = "5m";
|
|
10
11
|
SupportedInterval2["M15"] = "15m";
|
|
11
12
|
SupportedInterval2["H1"] = "1h";
|
|
12
13
|
SupportedInterval2["H4"] = "4h";
|
package/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ module.exports = {
|
|
|
3
3
|
...require('./crypto.cjs'),
|
|
4
4
|
...require('./execution-queue/manager.cjs'),
|
|
5
5
|
...require('./hash.cjs'),
|
|
6
|
-
...require('./
|
|
6
|
+
...require('./load-env.cjs'),
|
|
7
7
|
...require('./markets/types.cjs'),
|
|
8
8
|
...require('./markets/utils.cjs'),
|
|
9
9
|
...require('./relayer-client.cjs'),
|
package/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './basic.js'
|
|
|
2
2
|
export * from './crypto.js'
|
|
3
3
|
export * from './execution-queue/manager.js'
|
|
4
4
|
export * from './hash.js'
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './load-env.js'
|
|
6
6
|
export * from './markets/types.js'
|
|
7
7
|
export * from './markets/utils.js'
|
|
8
8
|
export * from './relayer-client.js'
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './basic.js'
|
|
|
2
2
|
export * from './crypto.js'
|
|
3
3
|
export * from './execution-queue/manager.js'
|
|
4
4
|
export * from './hash.js'
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './load-env.js'
|
|
6
6
|
export * from './markets/types.js'
|
|
7
7
|
export * from './markets/utils.js'
|
|
8
8
|
export * from './relayer-client.js'
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from './basic.js'
|
|
|
2
2
|
export * from './crypto.js'
|
|
3
3
|
export * from './execution-queue/manager.js'
|
|
4
4
|
export * from './hash.js'
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './load-env.js'
|
|
6
6
|
export * from './markets/types.js'
|
|
7
7
|
export * from './markets/utils.js'
|
|
8
8
|
export * from './relayer-client.js'
|
|
@@ -17,12 +17,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/utils/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
20
|
+
// src/utils/load-env.ts
|
|
21
|
+
var load_env_exports = {};
|
|
22
|
+
__export(load_env_exports, {
|
|
23
23
|
loadEnv: () => loadEnv
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(load_env_exports);
|
|
26
26
|
var import_node_fs = require("fs");
|
|
27
27
|
var import_dotenv = require("dotenv");
|
|
28
28
|
function loadEnv(cwd = process.cwd(), extraPaths = []) {
|
package/markets/types.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var SupportedSymbol = /* @__PURE__ */ ((SupportedSymbol2) => {
|
|
|
32
32
|
return SupportedSymbol2;
|
|
33
33
|
})(SupportedSymbol || {});
|
|
34
34
|
var SupportedInterval = /* @__PURE__ */ ((SupportedInterval2) => {
|
|
35
|
+
SupportedInterval2["M5"] = "5m";
|
|
35
36
|
SupportedInterval2["M15"] = "15m";
|
|
36
37
|
SupportedInterval2["H1"] = "1h";
|
|
37
38
|
SupportedInterval2["H4"] = "4h";
|
package/markets/types.d.cts
CHANGED
package/markets/types.d.ts
CHANGED
package/markets/types.js
CHANGED
package/markets/utils.cjs
CHANGED
|
@@ -600,6 +600,7 @@ __export(utils_exports, {
|
|
|
600
600
|
generate1dSlug: () => generate1dSlug,
|
|
601
601
|
generate1hSlug: () => generate1hSlug,
|
|
602
602
|
generate4hSlug: () => generate4hSlug,
|
|
603
|
+
generate5mSlug: () => generate5mSlug,
|
|
603
604
|
generateMarketUrl: () => generateMarketUrl,
|
|
604
605
|
getIntervalSeconds: () => getIntervalSeconds,
|
|
605
606
|
parseIntervalFromSlug: () => parseIntervalFromSlug,
|
|
@@ -652,6 +653,10 @@ var MONTH_NAMES = [
|
|
|
652
653
|
function generateMarketUrl(slug) {
|
|
653
654
|
return `https://polymarket.com/event/${slug}`;
|
|
654
655
|
}
|
|
656
|
+
function generate5mSlug(timestamp, symbol) {
|
|
657
|
+
const prefix = symbol.toLowerCase();
|
|
658
|
+
return `${prefix}-updown-5m-${timestamp}`;
|
|
659
|
+
}
|
|
655
660
|
function generate15mSlug(timestamp, symbol) {
|
|
656
661
|
const prefix = symbol.toLowerCase();
|
|
657
662
|
return `${prefix}-updown-15m-${timestamp}`;
|
|
@@ -707,6 +712,9 @@ function parseSymbolFromSlug(slug) {
|
|
|
707
712
|
}
|
|
708
713
|
function parseIntervalFromSlug(slug) {
|
|
709
714
|
const lowerSlug = slug.toLowerCase();
|
|
715
|
+
if (lowerSlug.includes("-updown-5m-")) {
|
|
716
|
+
return "5m" /* M5 */;
|
|
717
|
+
}
|
|
710
718
|
if (lowerSlug.includes("-updown-15m-")) {
|
|
711
719
|
return "15m" /* M15 */;
|
|
712
720
|
}
|
|
@@ -723,6 +731,8 @@ function parseIntervalFromSlug(slug) {
|
|
|
723
731
|
}
|
|
724
732
|
function getIntervalSeconds(interval) {
|
|
725
733
|
const intervalSecondsMap = {
|
|
734
|
+
["5m" /* M5 */]: 5 * 60,
|
|
735
|
+
// 300秒
|
|
726
736
|
["15m" /* M15 */]: 15 * 60,
|
|
727
737
|
// 900秒
|
|
728
738
|
["1h" /* H1 */]: 60 * 60,
|
|
@@ -742,8 +752,8 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
|
|
|
742
752
|
const intervalSeconds = getIntervalSeconds(interval);
|
|
743
753
|
let startTime = null;
|
|
744
754
|
const lowerSlug = slug.toLowerCase();
|
|
745
|
-
if (interval === "15m" /* M15 */ || interval === "4h" /* H4 */) {
|
|
746
|
-
const match = lowerSlug.match(/-updown-(?:15m|4h)-(\d+)$/);
|
|
755
|
+
if (interval === "5m" /* M5 */ || interval === "15m" /* M15 */ || interval === "4h" /* H4 */) {
|
|
756
|
+
const match = lowerSlug.match(/-updown-(?:5m|15m|4h)-(\d+)$/);
|
|
747
757
|
if (match) {
|
|
748
758
|
startTime = parseInt(match[1], 10);
|
|
749
759
|
}
|
|
@@ -807,6 +817,7 @@ function parseSlug(slug, referenceYear) {
|
|
|
807
817
|
generate1dSlug,
|
|
808
818
|
generate1hSlug,
|
|
809
819
|
generate4hSlug,
|
|
820
|
+
generate5mSlug,
|
|
810
821
|
generateMarketUrl,
|
|
811
822
|
getIntervalSeconds,
|
|
812
823
|
parseIntervalFromSlug,
|
package/markets/utils.d.cts
CHANGED
|
@@ -5,6 +5,8 @@ declare const SYMBOL_FULL_NAME_MAP: SymbolFullNameMap;
|
|
|
5
5
|
|
|
6
6
|
declare function generateMarketUrl(slug: string): string;
|
|
7
7
|
|
|
8
|
+
declare function generate5mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
|
+
|
|
8
10
|
declare function generate15mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
11
|
|
|
10
12
|
declare function generate1hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
@@ -33,4 +35,4 @@ declare function parseSlug(slug: string, referenceYear?: number): {
|
|
|
33
35
|
endTime: number | null;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl, getIntervalSeconds, parseIntervalFromSlug, parseSlug, parseSymbolFromSlug, parseTimeRangeFromSlug };
|
|
38
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generate5mSlug, generateMarketUrl, getIntervalSeconds, parseIntervalFromSlug, parseSlug, parseSymbolFromSlug, parseTimeRangeFromSlug };
|
package/markets/utils.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare const SYMBOL_FULL_NAME_MAP: SymbolFullNameMap;
|
|
|
5
5
|
|
|
6
6
|
declare function generateMarketUrl(slug: string): string;
|
|
7
7
|
|
|
8
|
+
declare function generate5mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
|
+
|
|
8
10
|
declare function generate15mSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
9
11
|
|
|
10
12
|
declare function generate1hSlug(timestamp: number, symbol: SupportedSymbol): string;
|
|
@@ -33,4 +35,4 @@ declare function parseSlug(slug: string, referenceYear?: number): {
|
|
|
33
35
|
endTime: number | null;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generateMarketUrl, getIntervalSeconds, parseIntervalFromSlug, parseSlug, parseSymbolFromSlug, parseTimeRangeFromSlug };
|
|
38
|
+
export { SUPPORTED_SYMBOLS, SYMBOL_FULL_NAME_MAP, calculatePeriodStartInET, generate15mSlug, generate1dSlug, generate1hSlug, generate4hSlug, generate5mSlug, generateMarketUrl, getIntervalSeconds, parseIntervalFromSlug, parseSlug, parseSymbolFromSlug, parseTimeRangeFromSlug };
|
package/markets/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SupportedSymbol
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-U2Y7SE3C.js";
|
|
4
4
|
import {
|
|
5
5
|
__commonJS,
|
|
6
6
|
__toESM
|
|
@@ -600,6 +600,10 @@ var MONTH_NAMES = [
|
|
|
600
600
|
function generateMarketUrl(slug) {
|
|
601
601
|
return `https://polymarket.com/event/${slug}`;
|
|
602
602
|
}
|
|
603
|
+
function generate5mSlug(timestamp, symbol) {
|
|
604
|
+
const prefix = symbol.toLowerCase();
|
|
605
|
+
return `${prefix}-updown-5m-${timestamp}`;
|
|
606
|
+
}
|
|
603
607
|
function generate15mSlug(timestamp, symbol) {
|
|
604
608
|
const prefix = symbol.toLowerCase();
|
|
605
609
|
return `${prefix}-updown-15m-${timestamp}`;
|
|
@@ -655,6 +659,9 @@ function parseSymbolFromSlug(slug) {
|
|
|
655
659
|
}
|
|
656
660
|
function parseIntervalFromSlug(slug) {
|
|
657
661
|
const lowerSlug = slug.toLowerCase();
|
|
662
|
+
if (lowerSlug.includes("-updown-5m-")) {
|
|
663
|
+
return "5m" /* M5 */;
|
|
664
|
+
}
|
|
658
665
|
if (lowerSlug.includes("-updown-15m-")) {
|
|
659
666
|
return "15m" /* M15 */;
|
|
660
667
|
}
|
|
@@ -671,6 +678,8 @@ function parseIntervalFromSlug(slug) {
|
|
|
671
678
|
}
|
|
672
679
|
function getIntervalSeconds(interval) {
|
|
673
680
|
const intervalSecondsMap = {
|
|
681
|
+
["5m" /* M5 */]: 5 * 60,
|
|
682
|
+
// 300秒
|
|
674
683
|
["15m" /* M15 */]: 15 * 60,
|
|
675
684
|
// 900秒
|
|
676
685
|
["1h" /* H1 */]: 60 * 60,
|
|
@@ -690,8 +699,8 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
|
|
|
690
699
|
const intervalSeconds = getIntervalSeconds(interval);
|
|
691
700
|
let startTime = null;
|
|
692
701
|
const lowerSlug = slug.toLowerCase();
|
|
693
|
-
if (interval === "15m" /* M15 */ || interval === "4h" /* H4 */) {
|
|
694
|
-
const match = lowerSlug.match(/-updown-(?:15m|4h)-(\d+)$/);
|
|
702
|
+
if (interval === "5m" /* M5 */ || interval === "15m" /* M15 */ || interval === "4h" /* H4 */) {
|
|
703
|
+
const match = lowerSlug.match(/-updown-(?:5m|15m|4h)-(\d+)$/);
|
|
695
704
|
if (match) {
|
|
696
705
|
startTime = parseInt(match[1], 10);
|
|
697
706
|
}
|
|
@@ -754,6 +763,7 @@ export {
|
|
|
754
763
|
generate1dSlug,
|
|
755
764
|
generate1hSlug,
|
|
756
765
|
generate4hSlug,
|
|
766
|
+
generate5mSlug,
|
|
757
767
|
generateMarketUrl,
|
|
758
768
|
getIntervalSeconds,
|
|
759
769
|
parseIntervalFromSlug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"default": "./hash.cjs"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"./
|
|
59
|
+
"./load-env": {
|
|
60
60
|
"import": {
|
|
61
|
-
"types": "./
|
|
62
|
-
"default": "./
|
|
61
|
+
"types": "./load-env.d.ts",
|
|
62
|
+
"default": "./load-env.js"
|
|
63
63
|
},
|
|
64
64
|
"require": {
|
|
65
|
-
"types": "./
|
|
66
|
-
"default": "./
|
|
65
|
+
"types": "./load-env.d.cts",
|
|
66
|
+
"default": "./load-env.cjs"
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"./markets/types": {
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
"**/*.d.cts"
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
|
-
"dotenv": "^17.
|
|
138
|
-
"viem": "^2.
|
|
139
|
-
"@polymarket/builder-relayer-client": "^0.0.
|
|
137
|
+
"dotenv": "^17.3.1",
|
|
138
|
+
"viem": "^2.46.2",
|
|
139
|
+
"@polymarket/builder-relayer-client": "^0.0.8",
|
|
140
140
|
"@polymarket/builder-signing-sdk": "^0.0.8"
|
|
141
141
|
}
|
|
142
142
|
}
|
package/wallet.cjs
CHANGED
|
@@ -65,7 +65,7 @@ async function getUSDCBalancesBatch(addresses) {
|
|
|
65
65
|
return [];
|
|
66
66
|
}
|
|
67
67
|
const publicClient = getPublicClient();
|
|
68
|
-
|
|
68
|
+
return await publicClient.multicall({
|
|
69
69
|
contracts: addresses.map((address) => ({
|
|
70
70
|
address: USDC_ADDRESS,
|
|
71
71
|
abi: USDC_ABI,
|
|
@@ -74,9 +74,6 @@ async function getUSDCBalancesBatch(addresses) {
|
|
|
74
74
|
})),
|
|
75
75
|
allowFailure: true
|
|
76
76
|
});
|
|
77
|
-
return multicallResults.map(
|
|
78
|
-
(result) => result.status === "success" ? result.result : 0n
|
|
79
|
-
);
|
|
80
77
|
}
|
|
81
78
|
function isAddressEqual(a, b) {
|
|
82
79
|
if (!a) return false;
|
package/wallet.d.cts
CHANGED
|
@@ -20,7 +20,15 @@ declare function formatBalance(rawBalance: string | bigint, decimals?: number):
|
|
|
20
20
|
|
|
21
21
|
declare function getUSDCBalance(address: string): Promise<bigint>;
|
|
22
22
|
|
|
23
|
-
declare function getUSDCBalancesBatch(addresses: string[]): Promise<
|
|
23
|
+
declare function getUSDCBalancesBatch(addresses: string[]): Promise<({
|
|
24
|
+
error?: undefined;
|
|
25
|
+
result: bigint;
|
|
26
|
+
status: "success";
|
|
27
|
+
} | {
|
|
28
|
+
error: Error;
|
|
29
|
+
result?: undefined;
|
|
30
|
+
status: "failure";
|
|
31
|
+
})[]>;
|
|
24
32
|
|
|
25
33
|
declare function isAddressEqual(a?: Address | string | null, b?: Address | string | null): boolean;
|
|
26
34
|
|
package/wallet.d.ts
CHANGED
|
@@ -20,7 +20,15 @@ declare function formatBalance(rawBalance: string | bigint, decimals?: number):
|
|
|
20
20
|
|
|
21
21
|
declare function getUSDCBalance(address: string): Promise<bigint>;
|
|
22
22
|
|
|
23
|
-
declare function getUSDCBalancesBatch(addresses: string[]): Promise<
|
|
23
|
+
declare function getUSDCBalancesBatch(addresses: string[]): Promise<({
|
|
24
|
+
error?: undefined;
|
|
25
|
+
result: bigint;
|
|
26
|
+
status: "success";
|
|
27
|
+
} | {
|
|
28
|
+
error: Error;
|
|
29
|
+
result?: undefined;
|
|
30
|
+
status: "failure";
|
|
31
|
+
})[]>;
|
|
24
32
|
|
|
25
33
|
declare function isAddressEqual(a?: Address | string | null, b?: Address | string | null): boolean;
|
|
26
34
|
|
package/wallet.js
CHANGED
|
@@ -36,7 +36,7 @@ async function getUSDCBalancesBatch(addresses) {
|
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
38
|
const publicClient = getPublicClient();
|
|
39
|
-
|
|
39
|
+
return await publicClient.multicall({
|
|
40
40
|
contracts: addresses.map((address) => ({
|
|
41
41
|
address: USDC_ADDRESS,
|
|
42
42
|
abi: USDC_ABI,
|
|
@@ -45,9 +45,6 @@ async function getUSDCBalancesBatch(addresses) {
|
|
|
45
45
|
})),
|
|
46
46
|
allowFailure: true
|
|
47
47
|
});
|
|
48
|
-
return multicallResults.map(
|
|
49
|
-
(result) => result.status === "success" ? result.result : 0n
|
|
50
|
-
);
|
|
51
48
|
}
|
|
52
49
|
function isAddressEqual(a, b) {
|
|
53
50
|
if (!a) return false;
|
|
File without changes
|
|
File without changes
|