pandora-cli-skills 1.1.11 → 1.1.13
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/SKILL.md +2 -2
- package/cli/lib/contract_error_decoder.cjs +138 -0
- package/cli/lib/market_admin_service.cjs +868 -0
- package/cli/lib/mirror_service.cjs +1 -0
- package/cli/lib/mirror_sync_service.cjs +7 -1
- package/cli/lib/pandora_deploy_service.cjs +69 -27
- package/cli/lib/polymarket_trade_adapter.cjs +6 -1
- package/cli/pandora.cjs +514 -58
- package/package.json +1 -1
- package/references/creation-script.md +1 -1
- package/scripts/.env.example +2 -0
- package/scripts/create_market_launcher.ts +1 -1
- package/scripts/create_polymarket_clone_and_bet.ts +1 -1
package/SKILL.md
CHANGED
|
@@ -217,7 +217,7 @@ pandora clone-bet \
|
|
|
217
217
|
--sources "https://www.premierleague.com" "https://www.bbc.com/sport/football" \
|
|
218
218
|
--target-timestamp 1772323200 \
|
|
219
219
|
--target-timestamp-offset-hours 1 \
|
|
220
|
-
--arbiter
|
|
220
|
+
--arbiter 0x0D7B957C47Da86c2968dc52111D633D42cb7a5F7 \
|
|
221
221
|
--category 3 \
|
|
222
222
|
--liquidity 10 \
|
|
223
223
|
--curve-flattener 7 \
|
|
@@ -229,7 +229,7 @@ pandora clone-bet \
|
|
|
229
229
|
For live execution, replace `--dry-run` with `--execute`.
|
|
230
230
|
If `pandora` is not linked yet, use `node cli/pandora.cjs clone-bet ...`.
|
|
231
231
|
|
|
232
|
-
Default arbiter (whitelisted): `
|
|
232
|
+
Default arbiter (whitelisted): `0x0D7B957C47Da86c2968dc52111D633D42cb7a5F7`
|
|
233
233
|
|
|
234
234
|
## Launch AMM/Parimutuel (market launcher)
|
|
235
235
|
```bash
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const CONTRACT_ERROR_ABI = [
|
|
2
|
+
{
|
|
3
|
+
type: 'error',
|
|
4
|
+
name: 'TxTooOld',
|
|
5
|
+
inputs: [
|
|
6
|
+
{ name: 'blockTimestamp', type: 'uint256' },
|
|
7
|
+
{ name: 'deadline', type: 'uint256' },
|
|
8
|
+
],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: 'error',
|
|
12
|
+
name: 'SlippageExceeded',
|
|
13
|
+
inputs: [
|
|
14
|
+
{ name: 'expected', type: 'uint256' },
|
|
15
|
+
{ name: 'actual', type: 'uint256' },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'error',
|
|
20
|
+
name: 'InsufficientLiquidity',
|
|
21
|
+
inputs: [],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'error',
|
|
25
|
+
name: 'PriceSwingExceeded',
|
|
26
|
+
inputs: [
|
|
27
|
+
{ name: 'before', type: 'uint64' },
|
|
28
|
+
{ name: 'after', type: 'uint64' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'error',
|
|
33
|
+
name: 'InvalidOutcome',
|
|
34
|
+
inputs: [],
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function isHexData(value) {
|
|
39
|
+
return /^0x[0-9a-fA-F]*$/.test(String(value || ''));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeErrorArg(value) {
|
|
43
|
+
if (typeof value === 'bigint') return value.toString();
|
|
44
|
+
if (Array.isArray(value)) return value.map((item) => normalizeErrorArg(item));
|
|
45
|
+
if (value && typeof value === 'object') {
|
|
46
|
+
const entries = Object.entries(value);
|
|
47
|
+
const output = {};
|
|
48
|
+
for (const [key, nested] of entries) {
|
|
49
|
+
output[key] = normalizeErrorArg(nested);
|
|
50
|
+
}
|
|
51
|
+
return output;
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function extractRevertData(error, depth = 0) {
|
|
57
|
+
if (!error || depth > 4) return null;
|
|
58
|
+
const directCandidates = [
|
|
59
|
+
error.data,
|
|
60
|
+
error.revertData,
|
|
61
|
+
error.cause && error.cause.data,
|
|
62
|
+
error.cause && error.cause.revertData,
|
|
63
|
+
error.walk && error.walk().data,
|
|
64
|
+
error.walk && error.walk().revertData,
|
|
65
|
+
error.details && error.details.data,
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
for (const candidate of directCandidates) {
|
|
69
|
+
if (isHexData(candidate) && String(candidate).length >= 4) {
|
|
70
|
+
return String(candidate);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
extractRevertData(error.cause, depth + 1) ||
|
|
76
|
+
extractRevertData(error.details, depth + 1) ||
|
|
77
|
+
null
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function decodeContractError(error, deps = {}) {
|
|
82
|
+
const data = extractRevertData(error);
|
|
83
|
+
if (!data || data === '0x') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let decodeErrorResult;
|
|
88
|
+
try {
|
|
89
|
+
if (deps.viemRuntime && typeof deps.viemRuntime.decodeErrorResult === 'function') {
|
|
90
|
+
decodeErrorResult = deps.viemRuntime.decodeErrorResult;
|
|
91
|
+
} else {
|
|
92
|
+
({ decodeErrorResult } = await import('viem'));
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
return { data };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const decoded = decodeErrorResult({
|
|
100
|
+
abi: CONTRACT_ERROR_ABI,
|
|
101
|
+
data,
|
|
102
|
+
});
|
|
103
|
+
const args = normalizeErrorArg(decoded.args);
|
|
104
|
+
return {
|
|
105
|
+
data,
|
|
106
|
+
errorName: decoded.errorName,
|
|
107
|
+
args,
|
|
108
|
+
};
|
|
109
|
+
} catch {
|
|
110
|
+
return { data };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function formatDecodedContractError(decoded) {
|
|
115
|
+
if (!decoded) return null;
|
|
116
|
+
if (decoded.errorName === 'TxTooOld' && decoded.args) {
|
|
117
|
+
return `TxTooOld: blockTimestamp=${decoded.args.blockTimestamp}, deadline=${decoded.args.deadline}`;
|
|
118
|
+
}
|
|
119
|
+
if (decoded.errorName === 'SlippageExceeded' && decoded.args) {
|
|
120
|
+
return `SlippageExceeded: expected=${decoded.args.expected}, actual=${decoded.args.actual}`;
|
|
121
|
+
}
|
|
122
|
+
if (decoded.errorName === 'PriceSwingExceeded' && decoded.args) {
|
|
123
|
+
return `PriceSwingExceeded: before=${decoded.args.before}, after=${decoded.args.after}`;
|
|
124
|
+
}
|
|
125
|
+
if (decoded.errorName) {
|
|
126
|
+
return decoded.errorName;
|
|
127
|
+
}
|
|
128
|
+
if (decoded.data) {
|
|
129
|
+
return `Contract reverted (${decoded.data})`;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
module.exports = {
|
|
135
|
+
CONTRACT_ERROR_ABI,
|
|
136
|
+
decodeContractError,
|
|
137
|
+
formatDecodedContractError,
|
|
138
|
+
};
|