@polymarbot/shared 0.5.2 → 0.5.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/package.json
CHANGED
|
@@ -120,6 +120,10 @@ function normalizeStrategy(config, options = {}) {
|
|
|
120
120
|
if (!config || !Array.isArray(config) || config.length === 0) {
|
|
121
121
|
return [];
|
|
122
122
|
}
|
|
123
|
+
const totalBuySize = config.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
124
|
+
if (totalBuySize <= 0) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
123
127
|
const normalizeOptions = {
|
|
124
128
|
minPrice: options.minPrice ?? 0.01,
|
|
125
129
|
minSize: options.minSize ?? 5
|
|
@@ -138,7 +142,6 @@ function normalizeStrategy(config, options = {}) {
|
|
|
138
142
|
normalized.push(normalizedStep);
|
|
139
143
|
}
|
|
140
144
|
});
|
|
141
|
-
const totalBuySize = normalized.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
142
145
|
for (const step of normalized) {
|
|
143
146
|
if (step.side === "SELL" /* SELL */ && step.size > totalBuySize) {
|
|
144
147
|
step.size = totalBuySize;
|
|
@@ -96,6 +96,10 @@ function normalizeStrategy(config, options = {}) {
|
|
|
96
96
|
if (!config || !Array.isArray(config) || config.length === 0) {
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
|
+
const totalBuySize = config.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
100
|
+
if (totalBuySize <= 0) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
99
103
|
const normalizeOptions = {
|
|
100
104
|
minPrice: options.minPrice ?? 0.01,
|
|
101
105
|
minSize: options.minSize ?? 5
|
|
@@ -114,7 +118,6 @@ function normalizeStrategy(config, options = {}) {
|
|
|
114
118
|
normalized.push(normalizedStep);
|
|
115
119
|
}
|
|
116
120
|
});
|
|
117
|
-
const totalBuySize = normalized.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
118
121
|
for (const step of normalized) {
|
|
119
122
|
if (step.side === "SELL" /* SELL */ && step.size > totalBuySize) {
|
|
120
123
|
step.size = totalBuySize;
|
package/wallet.cjs
CHANGED
|
@@ -59,7 +59,8 @@ var getPublicClient = /* @__PURE__ */ (() => {
|
|
|
59
59
|
};
|
|
60
60
|
})();
|
|
61
61
|
function formatBalance(rawBalance, decimals = USDC_DECIMALS) {
|
|
62
|
-
|
|
62
|
+
const num = parseFloat((0, import_viem.formatUnits)(BigInt(rawBalance), decimals));
|
|
63
|
+
return (Math.floor(num * 100) / 100).toFixed(2);
|
|
63
64
|
}
|
|
64
65
|
async function getUSDCBalance(address) {
|
|
65
66
|
const publicClient = getPublicClient();
|
package/wallet.js
CHANGED
|
@@ -30,7 +30,8 @@ var getPublicClient = /* @__PURE__ */ (() => {
|
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
32
|
function formatBalance(rawBalance, decimals = USDC_DECIMALS) {
|
|
33
|
-
|
|
33
|
+
const num = parseFloat(formatUnits(BigInt(rawBalance), decimals));
|
|
34
|
+
return (Math.floor(num * 100) / 100).toFixed(2);
|
|
34
35
|
}
|
|
35
36
|
async function getUSDCBalance(address) {
|
|
36
37
|
const publicClient = getPublicClient();
|