@blockrun/franklin 3.29.15 → 3.30.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.
Files changed (33) hide show
  1. package/dist/commands/start.js +4 -10
  2. package/dist/stats/insights.js +1 -3
  3. package/dist/tools/index.js +3 -1
  4. package/dist/tools/polymarket/client.d.ts +61 -0
  5. package/dist/tools/polymarket/client.js +236 -0
  6. package/dist/tools/polymarket/constants.d.ts +192 -0
  7. package/dist/tools/polymarket/constants.js +205 -0
  8. package/dist/tools/polymarket/creds.d.ts +33 -0
  9. package/dist/tools/polymarket/creds.js +96 -0
  10. package/dist/tools/polymarket/fund.d.ts +5 -0
  11. package/dist/tools/polymarket/fund.js +141 -0
  12. package/dist/tools/polymarket/l1-auth-1271.d.ts +29 -0
  13. package/dist/tools/polymarket/l1-auth-1271.js +198 -0
  14. package/dist/tools/polymarket/orders.d.ts +44 -0
  15. package/dist/tools/polymarket/orders.js +420 -0
  16. package/dist/tools/polymarket/positions.d.ts +26 -0
  17. package/dist/tools/polymarket/positions.js +88 -0
  18. package/dist/tools/polymarket/redeem.d.ts +5 -0
  19. package/dist/tools/polymarket/redeem.js +121 -0
  20. package/dist/tools/polymarket/relayer.d.ts +37 -0
  21. package/dist/tools/polymarket/relayer.js +140 -0
  22. package/dist/tools/polymarket/setup.d.ts +9 -0
  23. package/dist/tools/polymarket/setup.js +360 -0
  24. package/dist/tools/polymarket/wallet-key.d.ts +14 -0
  25. package/dist/tools/polymarket/wallet-key.js +69 -0
  26. package/dist/tools/polymarket/withdraw.d.ts +8 -0
  27. package/dist/tools/polymarket/withdraw.js +108 -0
  28. package/dist/tools/polymarket-bet.d.ts +4 -0
  29. package/dist/tools/polymarket-bet.js +164 -0
  30. package/dist/tools/tool-categories.js +4 -0
  31. package/package.json +7 -2
  32. package/dist/agent/media-router.d.ts +0 -98
  33. package/dist/agent/media-router.js +0 -328
@@ -5,7 +5,7 @@ import { getOrCreateWallet, getOrCreateSolanaWallet } from '@blockrun/llm';
5
5
  import { BLOCKRUN_DIR, loadChain, API_URLS } from '../config.js';
6
6
  import { retryFetchBalance } from './balance-retry.js';
7
7
  import { flushStats, loadStats } from '../stats/tracker.js';
8
- import { OPUS_PRICING, MODEL_PRICING } from '../pricing.js';
8
+ import { OPUS_PRICING } from '../pricing.js';
9
9
  import { loadConfig } from './config.js';
10
10
  import { printBanner } from '../banner.js';
11
11
  import { assembleInstructions } from '../agent/context.js';
@@ -190,15 +190,9 @@ export async function startCommand(options) {
190
190
  process.exitCode = exitCode;
191
191
  return;
192
192
  }
193
- // Warn when a paid model is active so users know they'll be charged.
194
- // Derive "free" from MODEL_PRICING so adding a new free entry there is enough —
195
- // no second hardcoded list to keep in sync.
196
- const pricing = MODEL_PRICING[model];
197
- const isFree = pricing != null && pricing.input === 0 && pricing.output === 0 && (pricing.perCall ?? 0) === 0;
198
- if (!isFree) {
199
- console.log(chalk.yellow(` Model: ${model} (paid — charges from your wallet per call)`));
200
- console.log(chalk.dim(` Switch to free with: /model free\n`));
201
- }
193
+ // Show the active model at startup. No paid/free framing — Franklin is the
194
+ // agent with a wallet; spending is the point, not a warning.
195
+ console.log(chalk.dim(` Model: ${model}\n`));
202
196
  // Auto-create wallet if needed (no interruption — free models work without funding)
203
197
  let walletAddress = '';
204
198
  if (chain === 'solana') {
@@ -11,7 +11,7 @@
11
11
  * - Cost projections and efficiency metrics
12
12
  */
13
13
  import { loadStats } from './tracker.js';
14
- import { OPUS_PRICING, MODEL_PRICING } from '../pricing.js';
14
+ import { OPUS_PRICING } from '../pricing.js';
15
15
  import { formatTokens, formatUsd, shortModelName } from './format.js';
16
16
  // ─── Generate Report ──────────────────────────────────────────────────────
17
17
  export function generateInsights(days = 30) {
@@ -193,5 +193,3 @@ export function formatInsights(report, days) {
193
193
  lines.push('');
194
194
  return lines.join('\n');
195
195
  }
196
- // Silence unused import warning
197
- void MODEL_PRICING;
@@ -32,6 +32,7 @@ import { base0xGaslessSwapCapability } from './zerox-gasless.js';
32
32
  import { defiLlamaProtocolsCapability, defiLlamaProtocolCapability, defiLlamaChainsCapability, defiLlamaYieldsCapability, defiLlamaPriceCapability, } from './defillama.js';
33
33
  import { multiChainRpcCapability } from './rpc.js';
34
34
  import { predictionMarketCapability } from './prediction.js';
35
+ import { polymarketBetCapability } from './polymarket-bet.js';
35
36
  import { modalCapabilities } from './modal.js';
36
37
  import { blockrunCapability } from './blockrun.js';
37
38
  import { surfCapabilities } from './surf.js';
@@ -169,7 +170,8 @@ export const allCapabilities = [
169
170
  defiLlamaYieldsCapability,
170
171
  defiLlamaPriceCapability,
171
172
  multiChainRpcCapability, // read-only JSON-RPC across 40+ chains ($0.002/call)
172
- predictionMarketCapability, // Polymarket / Kalshi / matching / smart money via Predexon
173
+ predictionMarketCapability, // Polymarket / Kalshi / matching / smart money via Predexon (read-only research)
174
+ polymarketBetCapability, // PolymarketBet — real-money betting execution: setup/fund/buy/sell/redeem/withdraw (CLOB V2)
173
175
  blockrunCapability, // Generic x402-paid gateway primitive — future partners + long-tail Surf paths
174
176
  ...surfCapabilities, // SurfMarket / SurfChain / SurfSocial — endpoint-enum function tools (no path guessing, auto x402)
175
177
  // Phone & Voice — typed surface so the agent pattern-matches on the user
@@ -0,0 +1,61 @@
1
+ import { HttpsProxyAgent } from "https-proxy-agent";
2
+ import { type PrivateKeyAccount } from "viem/accounts";
3
+ import { ClobClient } from "@polymarket/clob-client-v2";
4
+ /**
5
+ * Install a request interceptor on an axios instance that duplicates each
6
+ * underscore auth header as its hyphenated form so it survives header-stripping
7
+ * proxies. Idempotent per instance (guarded by the caller).
8
+ */
9
+ export declare function installUnderscoreHeaderBridge(instance: {
10
+ interceptors: {
11
+ request: {
12
+ use: (fn: (config: unknown) => unknown) => void;
13
+ };
14
+ };
15
+ }): void;
16
+ /** The local EOA account (BlockRun session key) used as the Polymarket signer. */
17
+ export declare function getPolymarketAccount(): PrivateKeyAccount;
18
+ /**
19
+ * The shared HttpsProxyAgent for POLYMARKET_CLOB_PROXY, or null when unset.
20
+ * Built once. Reused for both the CLOB axios (v1, here) and the relayer's own
21
+ * axios (0.27) instance (relayer.ts injects it), so a US-egress demo can route
22
+ * ALL geoblockable Polymarket traffic — order placement AND the relayer
23
+ * deploy/approve/redeem calls — through one permitted egress.
24
+ */
25
+ export declare function getClobProxyAgent(): HttpsProxyAgent<string> | null;
26
+ /**
27
+ * Route CLOB traffic through POLYMARKET_CLOB_PROXY when set. Applied to the
28
+ * axios v1 defaults, which clob-client-v2 (and our l1-auth / geoblock / Data-API
29
+ * calls) share via the hoisted axios install; @blockrun/llm and the other tools
30
+ * use fetch (which ignores this), so it scopes to Polymarket traffic. Plain
31
+ * HTTPS_PROXY is honored by BOTH axios copies natively (proxy-from-env) without
32
+ * any of this — the simplest option for a US-egress demo.
33
+ */
34
+ export declare function applyClobProxyOnce(): void;
35
+ /**
36
+ * Cached, authenticated ClobClient for the active signature mode. Requires
37
+ * setup to have persisted the deposit wallet address first in POLY_1271 mode.
38
+ */
39
+ export declare function getClobClient(): Promise<ClobClient>;
40
+ /** Drop the cached client (after creds invalidation or a sig-type switch). */
41
+ export declare function resetClobClient(): void;
42
+ export interface GeoblockStatus {
43
+ orderPlacement: "permitted" | "blocked" | "unknown";
44
+ country: string | null;
45
+ ip: string | null;
46
+ raw: unknown;
47
+ }
48
+ /**
49
+ * Region check for ORDER PLACEMENT. The authoritative signal is the CLOB order
50
+ * endpoint itself: an unauthenticated POST returns 403 ("Trading restricted in
51
+ * your region") when geoblocked, or 401/400 (auth/validation) when NOT — and it
52
+ * routes through POLYMARKET_CLOB_HOST, i.e. the exact egress real orders use.
53
+ *
54
+ * We deliberately do NOT trust polymarket.com/api/geoblock's boolean: it
55
+ * reflects FRONTEND blocking (it returns blocked=true for Japan even though the
56
+ * Japanese API accepts orders — verified: POST /order from a Tokyo egress
57
+ * returns 401, not 403). The /api/geoblock call is kept only for country/ip
58
+ * context. Cached 10 min; fail-open (unknown) on network error so a hiccup never
59
+ * blocks a call that might succeed.
60
+ */
61
+ export declare function checkGeoblock(): Promise<GeoblockStatus>;
@@ -0,0 +1,236 @@
1
+ // src/utils/polymarket/client.ts
2
+ //
3
+ // ClobClient factory for Polymarket CLOB V2 trading. The signer is the same
4
+ // local EVM key that pays BlockRun x402 fees on Base (~/.blockrun/.session) —
5
+ // a private key is chain-agnostic, so one identity pays API fees on Base and
6
+ // authorizes bets on Polygon. The key never leaves this machine.
7
+ //
8
+ // POLY_1271 note (issue #65): the CLOB authenticates L1/L2 by the OWNER EOA, not
9
+ // the deposit wallet — the reference Rust client (rs-clob-client-v2 src/auth.rs)
10
+ // derives API creds from the owner's plain ECDSA ClobAuth signature and binds the
11
+ // key to the EOA. Orders then carry signer/maker = deposit wallet (POLY_1271) and
12
+ // are validated on-chain by the wallet's ERC-1271 isValidSignature. So the signer
13
+ // handed to ClobClient is the real EOA (L2 POLY_ADDRESS = EOA = API key address),
14
+ // and funderAddress carries the deposit wallet for order building. (An earlier
15
+ // attempt to bind creds to the deposit wallet via an ERC-7739-wrapped L1 ClobAuth
16
+ // — the fix issue #65 proposed — is rejected by the CLOB with "Invalid L1 Request
17
+ // headers"; see the note in getClobClient.)
18
+ import axios from "axios";
19
+ import { HttpsProxyAgent } from "https-proxy-agent";
20
+ import { createWalletClient, http } from "viem";
21
+ import { privateKeyToAccount } from "viem/accounts";
22
+ import { polygon } from "viem/chains";
23
+ import { ClobClient, SignatureTypeV2 } from "@polymarket/clob-client-v2";
24
+ import { getOrCreateWalletKey } from "./wallet-key.js";
25
+ import { assertContractConfig, CLOB_HOST, GEOBLOCK_URL, getBuilderCode, getClobProxy, getSigType, POLYGON_CHAIN_ID, POLYGON_RPC_URLS, } from "./constants.js";
26
+ import { loadDepositWalletForSigner, loadL2Creds, saveL2Creds } from "./creds.js";
27
+ import { deriveApiCreds } from "./l1-auth-1271.js";
28
+ let _account = null;
29
+ let _clobClient = null;
30
+ let _clobClientKey = "";
31
+ let _proxyApplied = false;
32
+ let _proxyAgent;
33
+ let _bridgeApplied = false;
34
+ // Polymarket's auth headers all contain UNDERSCORES, which HTTP proxies
35
+ // (Caddy/Cloud Run and others) frequently drop or refuse to forward. When the
36
+ // MCP routes through a relay (POLYMARKET_CLOB_HOST / POLYMARKET_RELAYER_URL),
37
+ // that silently strips POLY_ADDRESS et al. and every authed call fails with
38
+ // "missing address header" / "Invalid L1 Request headers". Fix: also send each
39
+ // as a hyphenated copy (POLY_ADDRESS → poly-address) which survives proxies; the
40
+ // relay maps them back to underscores (see deploy/tokyo-egress/Caddyfile).
41
+ // Sending both is harmless direct — Polymarket reads the underscore header and
42
+ // ignores the extra hyphenated one.
43
+ const UNDERSCORE_AUTH_HEADERS = [
44
+ "POLY_ADDRESS", "POLY_SIGNATURE", "POLY_TIMESTAMP", "POLY_NONCE",
45
+ "POLY_API_KEY", "POLY_PASSPHRASE",
46
+ "POLY_BUILDER_API_KEY", "POLY_BUILDER_PASSPHRASE",
47
+ "POLY_BUILDER_SIGNATURE", "POLY_BUILDER_TIMESTAMP",
48
+ ];
49
+ /**
50
+ * Install a request interceptor on an axios instance that duplicates each
51
+ * underscore auth header as its hyphenated form so it survives header-stripping
52
+ * proxies. Idempotent per instance (guarded by the caller).
53
+ */
54
+ export function installUnderscoreHeaderBridge(instance) {
55
+ instance.interceptors.request.use((config) => {
56
+ const headers = config.headers;
57
+ if (!headers)
58
+ return config;
59
+ for (const name of UNDERSCORE_AUTH_HEADERS) {
60
+ const value = typeof headers.get === "function" ? headers.get(name) : headers[name];
61
+ if (value == null)
62
+ continue;
63
+ const hyphen = name.replace(/_/g, "-").toLowerCase();
64
+ if (typeof headers.set === "function")
65
+ headers.set(hyphen, value);
66
+ else
67
+ headers[hyphen] = value;
68
+ }
69
+ return config;
70
+ });
71
+ }
72
+ // Install the underscore-header bridge on the shared axios at module load, so
73
+ // EVERY Polymarket axios call has it regardless of call order — including
74
+ // credential derivation and builder-key creation, which can run before the CLOB
75
+ // client (and thus before applyClobProxyOnce) is first built.
76
+ installUnderscoreHeaderBridge(axios);
77
+ _bridgeApplied = true;
78
+ /** The local EOA account (BlockRun session key) used as the Polymarket signer. */
79
+ export function getPolymarketAccount() {
80
+ if (!_account) {
81
+ _account = privateKeyToAccount(getOrCreateWalletKey());
82
+ }
83
+ return _account;
84
+ }
85
+ /**
86
+ * The shared HttpsProxyAgent for POLYMARKET_CLOB_PROXY, or null when unset.
87
+ * Built once. Reused for both the CLOB axios (v1, here) and the relayer's own
88
+ * axios (0.27) instance (relayer.ts injects it), so a US-egress demo can route
89
+ * ALL geoblockable Polymarket traffic — order placement AND the relayer
90
+ * deploy/approve/redeem calls — through one permitted egress.
91
+ */
92
+ export function getClobProxyAgent() {
93
+ if (_proxyAgent === undefined) {
94
+ const proxy = getClobProxy();
95
+ _proxyAgent = proxy ? new HttpsProxyAgent(proxy) : null;
96
+ }
97
+ return _proxyAgent;
98
+ }
99
+ /**
100
+ * Route CLOB traffic through POLYMARKET_CLOB_PROXY when set. Applied to the
101
+ * axios v1 defaults, which clob-client-v2 (and our l1-auth / geoblock / Data-API
102
+ * calls) share via the hoisted axios install; @blockrun/llm and the other tools
103
+ * use fetch (which ignores this), so it scopes to Polymarket traffic. Plain
104
+ * HTTPS_PROXY is honored by BOTH axios copies natively (proxy-from-env) without
105
+ * any of this — the simplest option for a US-egress demo.
106
+ */
107
+ export function applyClobProxyOnce() {
108
+ // The header bridge is harmless everywhere and needed whenever a relay is in
109
+ // play, so install it unconditionally (once) on the shared axios the CLOB
110
+ // client + l1-auth use.
111
+ if (!_bridgeApplied) {
112
+ _bridgeApplied = true;
113
+ installUnderscoreHeaderBridge(axios);
114
+ }
115
+ if (_proxyApplied)
116
+ return;
117
+ _proxyApplied = true;
118
+ const agent = getClobProxyAgent();
119
+ if (!agent)
120
+ return;
121
+ axios.defaults.httpsAgent = agent;
122
+ axios.defaults.proxy = false;
123
+ }
124
+ /**
125
+ * Wallet client that reports `reportAddress` but signs with the real key.
126
+ * See the POLY_1271 note in the file header for why this is sound.
127
+ */
128
+ function buildWalletClient(reportAddress) {
129
+ const real = getPolymarketAccount();
130
+ const account = reportAddress ? { ...real, address: reportAddress } : real;
131
+ return createWalletClient({
132
+ account,
133
+ chain: polygon,
134
+ transport: http(POLYGON_RPC_URLS[0]),
135
+ });
136
+ }
137
+ /**
138
+ * Cached, authenticated ClobClient for the active signature mode. Requires
139
+ * setup to have persisted the deposit wallet address first in POLY_1271 mode.
140
+ */
141
+ export async function getClobClient() {
142
+ assertContractConfig();
143
+ applyClobProxyOnce();
144
+ const sigType = getSigType();
145
+ const account = getPolymarketAccount();
146
+ const depositWallet = loadDepositWalletForSigner(account.address);
147
+ if (sigType === 3 && !depositWallet) {
148
+ throw new Error(`No Polymarket deposit wallet configured for this signer yet. Run blockrun_polymarket ` +
149
+ `action:"setup" first (or set POLYMARKET_SIG_TYPE=0 for plain EOA mode).`);
150
+ }
151
+ // L2 API credentials are ALWAYS bound to the owner EOA (POLY_ADDRESS = EOA),
152
+ // even in POLY_1271 mode. This mirrors the reference Rust client (rs-clob-
153
+ // client-v2 src/auth.rs): L1/L2 auth uses the owner's plain ECDSA signature,
154
+ // while POLY_1271 orders carry signer/maker = deposit wallet and are validated
155
+ // on-chain by the wallet's ERC-1271 isValidSignature. The earlier attempt to
156
+ // bind creds to the deposit wallet via an ERC-7739-wrapped L1 ClobAuth is what
157
+ // the CLOB rejects with "Invalid L1 Request headers" — issue #65 misdiagnosed
158
+ // the fix as wrapping L1 auth; the real path keeps L1 auth as the EOA.
159
+ const cacheKey = `${sigType}:${account.address.toLowerCase()}`;
160
+ if (_clobClient && _clobClientKey === cacheKey)
161
+ return _clobClient;
162
+ let creds = loadL2Creds(account.address, 0);
163
+ if (!creds) {
164
+ const derived = await deriveApiCreds(account, { sigType: 0 });
165
+ saveL2Creds(account.address, 0, derived);
166
+ creds = loadL2Creds(account.address, 0);
167
+ if (!creds)
168
+ throw new Error("failed to persist derived Polymarket API credentials");
169
+ }
170
+ const builderCode = getBuilderCode();
171
+ _clobClient = new ClobClient({
172
+ host: CLOB_HOST,
173
+ chain: POLYGON_CHAIN_ID,
174
+ // Real EOA signer: the L2 header POLY_ADDRESS must equal the API key's
175
+ // address (the EOA). funderAddress carries the deposit wallet for orders.
176
+ signer: buildWalletClient(),
177
+ creds: { key: creds.key, secret: creds.secret, passphrase: creds.passphrase },
178
+ signatureType: sigType === 3 ? SignatureTypeV2.POLY_1271 : SignatureTypeV2.EOA,
179
+ ...(sigType === 3 ? { funderAddress: depositWallet } : {}),
180
+ ...(builderCode ? { builderConfig: { builderCode } } : {}),
181
+ throwOnError: true,
182
+ });
183
+ _clobClientKey = cacheKey;
184
+ return _clobClient;
185
+ }
186
+ /** Drop the cached client (after creds invalidation or a sig-type switch). */
187
+ export function resetClobClient() {
188
+ _clobClient = null;
189
+ _clobClientKey = "";
190
+ }
191
+ let _geoCache = null;
192
+ /**
193
+ * Region check for ORDER PLACEMENT. The authoritative signal is the CLOB order
194
+ * endpoint itself: an unauthenticated POST returns 403 ("Trading restricted in
195
+ * your region") when geoblocked, or 401/400 (auth/validation) when NOT — and it
196
+ * routes through POLYMARKET_CLOB_HOST, i.e. the exact egress real orders use.
197
+ *
198
+ * We deliberately do NOT trust polymarket.com/api/geoblock's boolean: it
199
+ * reflects FRONTEND blocking (it returns blocked=true for Japan even though the
200
+ * Japanese API accepts orders — verified: POST /order from a Tokyo egress
201
+ * returns 401, not 403). The /api/geoblock call is kept only for country/ip
202
+ * context. Cached 10 min; fail-open (unknown) on network error so a hiccup never
203
+ * blocks a call that might succeed.
204
+ */
205
+ export async function checkGeoblock() {
206
+ applyClobProxyOnce();
207
+ if (_geoCache && Date.now() - _geoCache.at < 10 * 60_000)
208
+ return _geoCache.value;
209
+ let orderPlacement = "unknown";
210
+ try {
211
+ const res = await axios.post(`${CLOB_HOST}/order`, {}, { timeout: 6_000, validateStatus: () => true });
212
+ orderPlacement = res.status === 403 ? "blocked" : "permitted";
213
+ }
214
+ catch { /* network error → unknown */ }
215
+ // Country/ip context — route it through the SAME egress as orders so the
216
+ // reported country is the relay's, not the local IP. If POLYMARKET_GEOBLOCK_URL
217
+ // is explicitly set, GEOBLOCK_URL already honors it; otherwise, when CLOB_HOST
218
+ // is a relay (not the direct Polymarket host), derive the relay's geoblock path.
219
+ let geoUrl = GEOBLOCK_URL;
220
+ if (!process.env.POLYMARKET_GEOBLOCK_URL && !CLOB_HOST.includes("clob.polymarket.com")) {
221
+ geoUrl = `${CLOB_HOST.replace(/\/clob\/?$/, "")}/geoblock/api/geoblock`;
222
+ }
223
+ let country = null;
224
+ let ip = null;
225
+ try {
226
+ const g = await axios.get(geoUrl, { timeout: 3_000 });
227
+ const d = g.data;
228
+ country = typeof d?.country === "string" ? d.country : null;
229
+ ip = typeof d?.ip === "string" ? d.ip : null;
230
+ }
231
+ catch { /* context is optional */ }
232
+ const value = { orderPlacement, country, ip, raw: { orderPlacement, country, ip } };
233
+ if (orderPlacement !== "unknown")
234
+ _geoCache = { at: Date.now(), value };
235
+ return value;
236
+ }
@@ -0,0 +1,192 @@
1
+ export declare const POLYGON_CHAIN_ID = 137;
2
+ export declare const CTF_EXCHANGE_V2 = "0xE111180000d2663C0091e4f400237545B87B996B";
3
+ export declare const NEG_RISK_CTF_EXCHANGE_V2 = "0xe2222d279d744050d28e00520010520000310F59";
4
+ export declare const NEG_RISK_ADAPTER = "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296";
5
+ export declare const CONDITIONAL_TOKENS = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045";
6
+ export declare const PUSD_COLLATERAL = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB";
7
+ export declare const COLLATERAL_ONRAMP = "0x93070a847efEf7F70739046A929D47a521F5B8ee";
8
+ export declare const DEPOSIT_WALLET_FACTORY = "0x00000000000Fb5C9ADea0298D729A0CB3823Cc07";
9
+ /**
10
+ * Cross-check our address copies against the SDK's canonical config. Called
11
+ * once from the client factory; throwing here is deliberate — a silent
12
+ * mismatch would mean approvals/redeem target different contracts than the
13
+ * orders the SDK signs.
14
+ */
15
+ export declare function assertContractConfig(): void;
16
+ export declare const CLOB_HOST: string;
17
+ export declare const RELAYER_URL: string;
18
+ export declare const DATA_API_HOST: string;
19
+ export declare const BRIDGE_API_HOST: string;
20
+ export declare const BASE_CHAIN_ID = 8453;
21
+ export declare const BASE_USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
22
+ export declare const GEOBLOCK_URL: string;
23
+ export declare const BRIDGE_UI_URL = "https://polymarket.com";
24
+ export declare const POLYGON_RPC_URLS: string[];
25
+ /** Hard per-order notional cap in pUSD dollars (default $25; 0/invalid blocks). */
26
+ export declare function getMaxBetUsd(): number;
27
+ /** Optional cumulative per-process cap; null = uncapped (unset); 0 = freeze. */
28
+ export declare function getMaxSessionUsd(): number | null;
29
+ /**
30
+ * Bounded pUSD approvals in dollars; null = unlimited (maxUint256). The CTF
31
+ * ERC-1155 approval is inherently all-or-nothing either way. Only a valid
32
+ * positive value bounds; 0/garbage → unlimited (approvals are not a per-order
33
+ * spend gate, so failing them "closed" would just block setup).
34
+ */
35
+ export declare function getBoundedApprovalsUsd(): number | null;
36
+ /**
37
+ * Signature type override: 3 (POLY_1271 deposit wallet, default) or 0 (plain
38
+ * EOA "demo insurance" mode — EOA holds pUSD itself, pays its own POL gas).
39
+ */
40
+ export declare function getSigType(): 0 | 3;
41
+ /**
42
+ * Optional builder attribution code (bytes32 or plain string per Polymarket
43
+ * builder settings). Absent → orders carry no builder fee attribution.
44
+ */
45
+ export declare function getBuilderCode(): string | undefined;
46
+ /** Egress proxy for CLOB order traffic (see README: geoblock). */
47
+ export declare function getClobProxy(): string | undefined;
48
+ /**
49
+ * Relayer API credentials — required for the deposit-wallet path (Phase 1:
50
+ * user-provided from polymarket.com → Settings → API Keys; Phase 2 moves these
51
+ * behind the BlockRun gateway). The relayer only ever receives pre-signed
52
+ * payloads; these creds authenticate use of its gas-sponsoring service and
53
+ * grant no control over funds.
54
+ */
55
+ export interface RelayerCreds {
56
+ key: string;
57
+ keyAddress: string;
58
+ }
59
+ export declare function getRelayerCreds(): RelayerCreds | null;
60
+ export declare const ERC20_ABI: readonly [{
61
+ readonly name: "allowance";
62
+ readonly type: "function";
63
+ readonly stateMutability: "view";
64
+ readonly inputs: readonly [{
65
+ readonly name: "owner";
66
+ readonly type: "address";
67
+ }, {
68
+ readonly name: "spender";
69
+ readonly type: "address";
70
+ }];
71
+ readonly outputs: readonly [{
72
+ readonly name: "";
73
+ readonly type: "uint256";
74
+ }];
75
+ }, {
76
+ readonly name: "approve";
77
+ readonly type: "function";
78
+ readonly stateMutability: "nonpayable";
79
+ readonly inputs: readonly [{
80
+ readonly name: "spender";
81
+ readonly type: "address";
82
+ }, {
83
+ readonly name: "amount";
84
+ readonly type: "uint256";
85
+ }];
86
+ readonly outputs: readonly [{
87
+ readonly name: "";
88
+ readonly type: "bool";
89
+ }];
90
+ }, {
91
+ readonly name: "transfer";
92
+ readonly type: "function";
93
+ readonly stateMutability: "nonpayable";
94
+ readonly inputs: readonly [{
95
+ readonly name: "to";
96
+ readonly type: "address";
97
+ }, {
98
+ readonly name: "amount";
99
+ readonly type: "uint256";
100
+ }];
101
+ readonly outputs: readonly [{
102
+ readonly name: "";
103
+ readonly type: "bool";
104
+ }];
105
+ }, {
106
+ readonly name: "balanceOf";
107
+ readonly type: "function";
108
+ readonly stateMutability: "view";
109
+ readonly inputs: readonly [{
110
+ readonly name: "account";
111
+ readonly type: "address";
112
+ }];
113
+ readonly outputs: readonly [{
114
+ readonly name: "";
115
+ readonly type: "uint256";
116
+ }];
117
+ }];
118
+ export declare const ERC1155_ABI: readonly [{
119
+ readonly name: "isApprovedForAll";
120
+ readonly type: "function";
121
+ readonly stateMutability: "view";
122
+ readonly inputs: readonly [{
123
+ readonly name: "account";
124
+ readonly type: "address";
125
+ }, {
126
+ readonly name: "operator";
127
+ readonly type: "address";
128
+ }];
129
+ readonly outputs: readonly [{
130
+ readonly name: "";
131
+ readonly type: "bool";
132
+ }];
133
+ }, {
134
+ readonly name: "balanceOf";
135
+ readonly type: "function";
136
+ readonly stateMutability: "view";
137
+ readonly inputs: readonly [{
138
+ readonly name: "account";
139
+ readonly type: "address";
140
+ }, {
141
+ readonly name: "id";
142
+ readonly type: "uint256";
143
+ }];
144
+ readonly outputs: readonly [{
145
+ readonly name: "";
146
+ readonly type: "uint256";
147
+ }];
148
+ }, {
149
+ readonly name: "setApprovalForAll";
150
+ readonly type: "function";
151
+ readonly stateMutability: "nonpayable";
152
+ readonly inputs: readonly [{
153
+ readonly name: "operator";
154
+ readonly type: "address";
155
+ }, {
156
+ readonly name: "approved";
157
+ readonly type: "bool";
158
+ }];
159
+ readonly outputs: readonly [];
160
+ }, {
161
+ readonly name: "redeemPositions";
162
+ readonly type: "function";
163
+ readonly stateMutability: "nonpayable";
164
+ readonly inputs: readonly [{
165
+ readonly name: "collateralToken";
166
+ readonly type: "address";
167
+ }, {
168
+ readonly name: "parentCollectionId";
169
+ readonly type: "bytes32";
170
+ }, {
171
+ readonly name: "conditionId";
172
+ readonly type: "bytes32";
173
+ }, {
174
+ readonly name: "indexSets";
175
+ readonly type: "uint256[]";
176
+ }];
177
+ readonly outputs: readonly [];
178
+ }];
179
+ export declare const NEG_RISK_ADAPTER_ABI: readonly [{
180
+ readonly name: "redeemPositions";
181
+ readonly type: "function";
182
+ readonly stateMutability: "nonpayable";
183
+ readonly inputs: readonly [{
184
+ readonly name: "conditionId";
185
+ readonly type: "bytes32";
186
+ }, {
187
+ readonly name: "amounts";
188
+ readonly type: "uint256[]";
189
+ }];
190
+ readonly outputs: readonly [];
191
+ }];
192
+ export declare const PUSD_DECIMALS = 6;