@polymarbot/shared 0.2.1 → 0.2.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/index.cjs +9 -0
- package/index.d.cts +7 -0
- package/index.d.ts +7 -0
- package/index.js +7 -0
- package/package.json +14 -4
- package/trade-strategy/normalize.cjs +10 -10
- package/trade-strategy/normalize.js +10 -10
- package/trade-strategy/types.d.cts +4 -4
- package/trade-strategy/types.d.ts +4 -4
package/index.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
...require('./basic.cjs'),
|
|
3
|
+
...require('./markets/tools.cjs'),
|
|
4
|
+
...require('./markets/types.cjs'),
|
|
5
|
+
...require('./relayer-client.cjs'),
|
|
6
|
+
...require('./trade-strategy/normalize.cjs'),
|
|
7
|
+
...require('./trade-strategy/types.cjs'),
|
|
8
|
+
...require('./wallet.cjs')
|
|
9
|
+
}
|
package/index.d.cts
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/shared",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./
|
|
7
|
-
"types": "./
|
|
5
|
+
"main": "./index.cjs",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./index.d.cts",
|
|
16
|
+
"default": "./index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
"./basic": {
|
|
10
20
|
"import": {
|
|
11
21
|
"types": "./basic.d.ts",
|
|
@@ -58,23 +58,23 @@ function normalizeTradeStepBuy(step, options) {
|
|
|
58
58
|
const isLowPriceMode = price <= 0.5;
|
|
59
59
|
const isChaseMode = price > 0.5;
|
|
60
60
|
if (isLowPriceMode) {
|
|
61
|
-
if (step.
|
|
62
|
-
if (step.
|
|
63
|
-
normalized.
|
|
61
|
+
if (step.maxUnderlyingChange !== void 0) {
|
|
62
|
+
if (step.maxUnderlyingChange >= 1 && step.maxUnderlyingChange <= 1e3) {
|
|
63
|
+
normalized.maxUnderlyingChange = step.maxUnderlyingChange;
|
|
64
64
|
} else {
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
if (step.
|
|
67
|
+
if (step.minUnderlyingChange !== void 0) {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
if (isChaseMode) {
|
|
71
|
-
if (step.
|
|
72
|
-
if (step.
|
|
73
|
-
normalized.
|
|
71
|
+
if (step.minUnderlyingChange !== void 0) {
|
|
72
|
+
if (step.minUnderlyingChange >= 1 && step.minUnderlyingChange <= 1e3) {
|
|
73
|
+
normalized.minUnderlyingChange = step.minUnderlyingChange;
|
|
74
74
|
} else {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
if (step.
|
|
77
|
+
if (step.maxUnderlyingChange !== void 0) {
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
return normalized;
|
|
@@ -108,8 +108,8 @@ function normalizeTradeStepSell(step, options) {
|
|
|
108
108
|
const invalidFields = [];
|
|
109
109
|
if ("once" in stepAsTradeStep && stepAsTradeStep.once !== void 0) invalidFields.push("once");
|
|
110
110
|
if ("outcomeIndex" in stepAsTradeStep && stepAsTradeStep.outcomeIndex !== void 0) invalidFields.push("outcomeIndex");
|
|
111
|
-
if ("
|
|
112
|
-
if ("
|
|
111
|
+
if ("maxUnderlyingChange" in stepAsTradeStep && stepAsTradeStep.maxUnderlyingChange !== void 0) invalidFields.push("maxUnderlyingChange");
|
|
112
|
+
if ("minUnderlyingChange" in stepAsTradeStep && stepAsTradeStep.minUnderlyingChange !== void 0) invalidFields.push("minUnderlyingChange");
|
|
113
113
|
if (invalidFields.length > 0) {
|
|
114
114
|
}
|
|
115
115
|
return normalized;
|
|
@@ -35,23 +35,23 @@ function normalizeTradeStepBuy(step, options) {
|
|
|
35
35
|
const isLowPriceMode = price <= 0.5;
|
|
36
36
|
const isChaseMode = price > 0.5;
|
|
37
37
|
if (isLowPriceMode) {
|
|
38
|
-
if (step.
|
|
39
|
-
if (step.
|
|
40
|
-
normalized.
|
|
38
|
+
if (step.maxUnderlyingChange !== void 0) {
|
|
39
|
+
if (step.maxUnderlyingChange >= 1 && step.maxUnderlyingChange <= 1e3) {
|
|
40
|
+
normalized.maxUnderlyingChange = step.maxUnderlyingChange;
|
|
41
41
|
} else {
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
if (step.
|
|
44
|
+
if (step.minUnderlyingChange !== void 0) {
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (isChaseMode) {
|
|
48
|
-
if (step.
|
|
49
|
-
if (step.
|
|
50
|
-
normalized.
|
|
48
|
+
if (step.minUnderlyingChange !== void 0) {
|
|
49
|
+
if (step.minUnderlyingChange >= 1 && step.minUnderlyingChange <= 1e3) {
|
|
50
|
+
normalized.minUnderlyingChange = step.minUnderlyingChange;
|
|
51
51
|
} else {
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
if (step.
|
|
54
|
+
if (step.maxUnderlyingChange !== void 0) {
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
return normalized;
|
|
@@ -85,8 +85,8 @@ function normalizeTradeStepSell(step, options) {
|
|
|
85
85
|
const invalidFields = [];
|
|
86
86
|
if ("once" in stepAsTradeStep && stepAsTradeStep.once !== void 0) invalidFields.push("once");
|
|
87
87
|
if ("outcomeIndex" in stepAsTradeStep && stepAsTradeStep.outcomeIndex !== void 0) invalidFields.push("outcomeIndex");
|
|
88
|
-
if ("
|
|
89
|
-
if ("
|
|
88
|
+
if ("maxUnderlyingChange" in stepAsTradeStep && stepAsTradeStep.maxUnderlyingChange !== void 0) invalidFields.push("maxUnderlyingChange");
|
|
89
|
+
if ("minUnderlyingChange" in stepAsTradeStep && stepAsTradeStep.minUnderlyingChange !== void 0) invalidFields.push("minUnderlyingChange");
|
|
90
90
|
if (invalidFields.length > 0) {
|
|
91
91
|
}
|
|
92
92
|
return normalized;
|
|
@@ -8,7 +8,7 @@ interface PositionInfo {
|
|
|
8
8
|
balance: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
interface
|
|
11
|
+
interface PriceChangeInfo {
|
|
12
12
|
|
|
13
13
|
start: number;
|
|
14
14
|
|
|
@@ -42,8 +42,8 @@ interface TradeStepBuy {
|
|
|
42
42
|
end: number;
|
|
43
43
|
once?: boolean;
|
|
44
44
|
outcomeIndex?: 0 | 1;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
maxUnderlyingChange?: number;
|
|
46
|
+
minUnderlyingChange?: number;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
interface TradeStepSell {
|
|
@@ -95,7 +95,7 @@ interface MarketTradeContext {
|
|
|
95
95
|
|
|
96
96
|
tradeRecord: MarketTradeRecord;
|
|
97
97
|
|
|
98
|
-
underlyingPrice:
|
|
98
|
+
underlyingPrice: PriceChangeInfo | null;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
interface MarketTokenData extends MarketToken {
|
|
@@ -8,7 +8,7 @@ interface PositionInfo {
|
|
|
8
8
|
balance: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
interface
|
|
11
|
+
interface PriceChangeInfo {
|
|
12
12
|
|
|
13
13
|
start: number;
|
|
14
14
|
|
|
@@ -42,8 +42,8 @@ interface TradeStepBuy {
|
|
|
42
42
|
end: number;
|
|
43
43
|
once?: boolean;
|
|
44
44
|
outcomeIndex?: 0 | 1;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
maxUnderlyingChange?: number;
|
|
46
|
+
minUnderlyingChange?: number;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
interface TradeStepSell {
|
|
@@ -95,7 +95,7 @@ interface MarketTradeContext {
|
|
|
95
95
|
|
|
96
96
|
tradeRecord: MarketTradeRecord;
|
|
97
97
|
|
|
98
|
-
underlyingPrice:
|
|
98
|
+
underlyingPrice: PriceChangeInfo | null;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
interface MarketTokenData extends MarketToken {
|