@madgallery/rbs-pm-sdk 1.0.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/README.md +330 -0
- package/SKILL.md +342 -0
- package/dist/index.d.mts +904 -0
- package/dist/index.d.ts +904 -0
- package/dist/index.js +1356 -0
- package/dist/index.mjs +1325 -0
- package/package.json +54 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
import { WalletClient, Account } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface Market {
|
|
4
|
+
address: `0x${string}`;
|
|
5
|
+
question: string;
|
|
6
|
+
resolutionTime: Date;
|
|
7
|
+
oracle: `0x${string}`;
|
|
8
|
+
status: 'ACTIVE' | 'RESOLVED' | 'PAUSED';
|
|
9
|
+
resolved: boolean;
|
|
10
|
+
yesWins: boolean | null;
|
|
11
|
+
yesToken: `0x${string}`;
|
|
12
|
+
noToken: `0x${string}`;
|
|
13
|
+
yesPrice: number;
|
|
14
|
+
noPrice: number;
|
|
15
|
+
yesShares: bigint;
|
|
16
|
+
noShares: bigint;
|
|
17
|
+
totalVolume: bigint;
|
|
18
|
+
totalTrades: number;
|
|
19
|
+
category?: string;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
}
|
|
22
|
+
interface MarketPrices {
|
|
23
|
+
yes: number;
|
|
24
|
+
no: number;
|
|
25
|
+
impliedProbability: {
|
|
26
|
+
yes: number;
|
|
27
|
+
no: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface TradeQuote {
|
|
31
|
+
shares: bigint;
|
|
32
|
+
cost: bigint;
|
|
33
|
+
priceImpact: number;
|
|
34
|
+
averagePrice: number;
|
|
35
|
+
}
|
|
36
|
+
interface TradeResult {
|
|
37
|
+
txHash: `0x${string}`;
|
|
38
|
+
shares: bigint;
|
|
39
|
+
cost: bigint;
|
|
40
|
+
isYes: boolean;
|
|
41
|
+
isBuy: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface Position {
|
|
44
|
+
yesShares: bigint;
|
|
45
|
+
noShares: bigint;
|
|
46
|
+
yesValue: bigint;
|
|
47
|
+
noValue: bigint;
|
|
48
|
+
totalValue: bigint;
|
|
49
|
+
}
|
|
50
|
+
interface MoltbookAgent {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
karma: number;
|
|
54
|
+
owner: {
|
|
55
|
+
address: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
interface AuthResult {
|
|
59
|
+
accessToken: string;
|
|
60
|
+
expiresAt: Date;
|
|
61
|
+
agent: {
|
|
62
|
+
id: string;
|
|
63
|
+
moltbookId: string;
|
|
64
|
+
moltbookName: string;
|
|
65
|
+
karma: number;
|
|
66
|
+
controllerAddress: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
interface RBSPMConfig {
|
|
70
|
+
/** Private key for signing transactions */
|
|
71
|
+
privateKey?: `0x${string}`;
|
|
72
|
+
/** Moltbook API key for authentication */
|
|
73
|
+
moltbookApiKey?: string;
|
|
74
|
+
/** Custom RPC URL (defaults to Monad testnet) */
|
|
75
|
+
rpcUrl?: string;
|
|
76
|
+
/** API base URL (defaults to production) */
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
}
|
|
79
|
+
interface PremiumMarketData {
|
|
80
|
+
market: {
|
|
81
|
+
address: string;
|
|
82
|
+
question: string;
|
|
83
|
+
status: string;
|
|
84
|
+
resolved: boolean;
|
|
85
|
+
yesWins: boolean | null;
|
|
86
|
+
resolutionTime: string;
|
|
87
|
+
};
|
|
88
|
+
pricing: {
|
|
89
|
+
yesPrice: number;
|
|
90
|
+
noPrice: number;
|
|
91
|
+
impliedProbability: {
|
|
92
|
+
yes: number;
|
|
93
|
+
no: number;
|
|
94
|
+
};
|
|
95
|
+
spread: number;
|
|
96
|
+
};
|
|
97
|
+
liquidity: {
|
|
98
|
+
yesShares: string;
|
|
99
|
+
noShares: string;
|
|
100
|
+
totalCollateral: string;
|
|
101
|
+
liquidityParameter: string | null;
|
|
102
|
+
};
|
|
103
|
+
activity: {
|
|
104
|
+
totalVolume: number;
|
|
105
|
+
totalTrades: number;
|
|
106
|
+
uniqueTraders: number;
|
|
107
|
+
avgTradeSize: number;
|
|
108
|
+
recentTrades: Array<{
|
|
109
|
+
id: string;
|
|
110
|
+
trade_type: string;
|
|
111
|
+
outcome: string;
|
|
112
|
+
shares: string;
|
|
113
|
+
amount: string;
|
|
114
|
+
created_at: string;
|
|
115
|
+
}>;
|
|
116
|
+
};
|
|
117
|
+
fees: {
|
|
118
|
+
totalProtocolFees: string;
|
|
119
|
+
totalCreatorFees: string;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Parameters for creating a new market */
|
|
123
|
+
interface MarketCreateParams {
|
|
124
|
+
/** Deployed contract address */
|
|
125
|
+
address: string;
|
|
126
|
+
/** Market question */
|
|
127
|
+
question: string;
|
|
128
|
+
/** Resolution time as Unix timestamp */
|
|
129
|
+
resolutionTime: number;
|
|
130
|
+
/** Oracle address that can resolve the market */
|
|
131
|
+
oracle: string;
|
|
132
|
+
/** YES token address (optional, read from contract if not provided) */
|
|
133
|
+
yesTokenAddress?: string;
|
|
134
|
+
/** NO token address (optional, read from contract if not provided) */
|
|
135
|
+
noTokenAddress?: string;
|
|
136
|
+
/** Initial liquidity amount in USDC */
|
|
137
|
+
initialLiquidity?: string;
|
|
138
|
+
/** Alpha parameter for LS-LMSR (e.g., "0.03" for 3%) */
|
|
139
|
+
alpha?: string;
|
|
140
|
+
/** Market category */
|
|
141
|
+
category?: string;
|
|
142
|
+
/** Market tags */
|
|
143
|
+
tags?: string[];
|
|
144
|
+
}
|
|
145
|
+
/** Result of market creation */
|
|
146
|
+
interface MarketCreateResult {
|
|
147
|
+
success: boolean;
|
|
148
|
+
market: {
|
|
149
|
+
id: string;
|
|
150
|
+
address: string;
|
|
151
|
+
question: string;
|
|
152
|
+
status: string;
|
|
153
|
+
};
|
|
154
|
+
/** x402 payment amount in USDC base units */
|
|
155
|
+
paymentAmount: string;
|
|
156
|
+
}
|
|
157
|
+
/** x402 price configuration */
|
|
158
|
+
interface X402Prices {
|
|
159
|
+
marketData: {
|
|
160
|
+
raw: string;
|
|
161
|
+
formatted: string;
|
|
162
|
+
};
|
|
163
|
+
createMarket: {
|
|
164
|
+
raw: string;
|
|
165
|
+
formatted: string;
|
|
166
|
+
};
|
|
167
|
+
agentTrade: {
|
|
168
|
+
raw: string;
|
|
169
|
+
formatted: string;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare class RBSPMClient {
|
|
174
|
+
private publicClient;
|
|
175
|
+
private walletClient;
|
|
176
|
+
private account;
|
|
177
|
+
private accessToken;
|
|
178
|
+
private apiUrl;
|
|
179
|
+
private x402PaymentFetch;
|
|
180
|
+
constructor(config?: RBSPMConfig);
|
|
181
|
+
/**
|
|
182
|
+
* Initialize x402 client for automatic payment handling
|
|
183
|
+
*/
|
|
184
|
+
private initX402Client;
|
|
185
|
+
/**
|
|
186
|
+
* Authenticate with Moltbook API key
|
|
187
|
+
*/
|
|
188
|
+
authenticateWithMoltbook(apiKey: string): Promise<AuthResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Check if x402 payments are available
|
|
191
|
+
*/
|
|
192
|
+
hasPaymentCapability(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Get the fetch function with x402 payment capability
|
|
195
|
+
*/
|
|
196
|
+
getPaymentFetch(): typeof fetch;
|
|
197
|
+
/**
|
|
198
|
+
* Get all active markets (requires x402 payment - 0.0001 USDC)
|
|
199
|
+
*/
|
|
200
|
+
getMarkets(): Promise<Market[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Get premium market data (requires x402 payment - 0.0001 USDC)
|
|
203
|
+
*/
|
|
204
|
+
getPremiumMarketData(marketAddress: `0x${string}`): Promise<PremiumMarketData>;
|
|
205
|
+
/**
|
|
206
|
+
* List a deployed market in the discovery index (requires 0.0001 USDC x402 payment)
|
|
207
|
+
*
|
|
208
|
+
* After deploying a market contract on-chain, call this method to make it
|
|
209
|
+
* discoverable by other agents. The listing fee (0.0001 USDC) is paid via x402.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // After deploying market contract...
|
|
214
|
+
* const result = await client.listMarket({
|
|
215
|
+
* address: deployedMarketAddress,
|
|
216
|
+
* question: 'Will ETH reach $10k in 2025?',
|
|
217
|
+
* resolutionTime: 1735689600, // Unix timestamp
|
|
218
|
+
* oracle: oracleAddress,
|
|
219
|
+
* category: 'crypto',
|
|
220
|
+
* tags: ['ethereum', 'price'],
|
|
221
|
+
* });
|
|
222
|
+
* console.log('Market listed! ID:', result.market.id);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
listMarket(params: MarketCreateParams): Promise<MarketCreateResult>;
|
|
226
|
+
/**
|
|
227
|
+
* Alias for listMarket - for backwards compatibility
|
|
228
|
+
*/
|
|
229
|
+
createMarket(params: MarketCreateParams): Promise<MarketCreateResult>;
|
|
230
|
+
/**
|
|
231
|
+
* Get encoded trade calldata (requires x402 payment - 0.0001 USDC)
|
|
232
|
+
*
|
|
233
|
+
* This endpoint returns the raw calldata for executing trades,
|
|
234
|
+
* useful for agents that want to build their own transactions.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const instructions = await client.getTradeInstructions({
|
|
239
|
+
* marketAddress: '0x...',
|
|
240
|
+
* direction: 'buy',
|
|
241
|
+
* outcome: 'yes',
|
|
242
|
+
* amount: '10', // 10 USDC
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
* // Execute approval first (for buys)
|
|
246
|
+
* if (instructions.approval) {
|
|
247
|
+
* await wallet.sendTransaction({
|
|
248
|
+
* to: instructions.approval.to,
|
|
249
|
+
* data: instructions.approval.data,
|
|
250
|
+
* });
|
|
251
|
+
* }
|
|
252
|
+
*
|
|
253
|
+
* // Then execute the trade
|
|
254
|
+
* await wallet.sendTransaction({
|
|
255
|
+
* to: instructions.trade.to,
|
|
256
|
+
* data: instructions.trade.data,
|
|
257
|
+
* });
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
getTradeInstructions(params: {
|
|
261
|
+
marketAddress: `0x${string}`;
|
|
262
|
+
direction: 'buy' | 'sell';
|
|
263
|
+
outcome: 'yes' | 'no';
|
|
264
|
+
amount: string;
|
|
265
|
+
minOutput?: string;
|
|
266
|
+
}): Promise<{
|
|
267
|
+
approval?: {
|
|
268
|
+
to: string;
|
|
269
|
+
data: string;
|
|
270
|
+
description: string;
|
|
271
|
+
};
|
|
272
|
+
trade: {
|
|
273
|
+
to: string;
|
|
274
|
+
data: string;
|
|
275
|
+
description: string;
|
|
276
|
+
};
|
|
277
|
+
summary: {
|
|
278
|
+
direction: string;
|
|
279
|
+
outcome: string;
|
|
280
|
+
amount: string;
|
|
281
|
+
marketAddress: string;
|
|
282
|
+
};
|
|
283
|
+
}>;
|
|
284
|
+
/**
|
|
285
|
+
* Get current prices for a market (requires x402 payment - 0.0001 USDC)
|
|
286
|
+
*/
|
|
287
|
+
getPrices(marketAddress: `0x${string}`): Promise<MarketPrices>;
|
|
288
|
+
/**
|
|
289
|
+
* Get quote for buying shares with USDC
|
|
290
|
+
*/
|
|
291
|
+
getBuyQuote(marketAddress: `0x${string}`, isYes: boolean, usdcAmount: string): Promise<TradeQuote>;
|
|
292
|
+
/**
|
|
293
|
+
* Get quote for selling shares
|
|
294
|
+
*/
|
|
295
|
+
getSellQuote(marketAddress: `0x${string}`, isYes: boolean, shares: bigint): Promise<{
|
|
296
|
+
payout: bigint;
|
|
297
|
+
priceImpact: number;
|
|
298
|
+
}>;
|
|
299
|
+
/**
|
|
300
|
+
* Check and approve USDC spending
|
|
301
|
+
*/
|
|
302
|
+
private ensureUSDCAllowance;
|
|
303
|
+
/**
|
|
304
|
+
* Buy shares with USDC
|
|
305
|
+
*
|
|
306
|
+
* IMPORTANT: This method routes through x402-agent-trade endpoint to ensure
|
|
307
|
+
* all trades are tracked. Costs 0.0001 USDC for the API call + trade amount.
|
|
308
|
+
*/
|
|
309
|
+
buy(marketAddress: `0x${string}`, isYes: boolean, usdcAmount: string, minShares?: bigint): Promise<TradeResult>;
|
|
310
|
+
/**
|
|
311
|
+
* Sell shares for USDC
|
|
312
|
+
*
|
|
313
|
+
* IMPORTANT: This method routes through x402-agent-trade endpoint to ensure
|
|
314
|
+
* all trades are tracked. Costs 0.0001 USDC for the API call.
|
|
315
|
+
*/
|
|
316
|
+
sell(marketAddress: `0x${string}`, isYes: boolean, shares: bigint, minPayout?: bigint): Promise<TradeResult>;
|
|
317
|
+
/**
|
|
318
|
+
* Redeem winning shares after resolution
|
|
319
|
+
*
|
|
320
|
+
* IMPORTANT: Routes through x402-redeem endpoint for tracking (0.0001 USDC)
|
|
321
|
+
*/
|
|
322
|
+
redeem(marketAddress: `0x${string}`): Promise<`0x${string}`>;
|
|
323
|
+
/**
|
|
324
|
+
* Get user's position in a market (requires x402 payment - 0.0001 USDC)
|
|
325
|
+
*/
|
|
326
|
+
getPosition(marketAddress: `0x${string}`, userAddress?: `0x${string}`): Promise<Position>;
|
|
327
|
+
/**
|
|
328
|
+
* Get USDC balance
|
|
329
|
+
*/
|
|
330
|
+
getUSDCBalance(userAddress?: `0x${string}`): Promise<string>;
|
|
331
|
+
/**
|
|
332
|
+
* Get MON (native token) balance for gas
|
|
333
|
+
*/
|
|
334
|
+
getMONBalance(userAddress?: `0x${string}`): Promise<string>;
|
|
335
|
+
/**
|
|
336
|
+
* Get full market information (requires x402 payment - 0.0001 USDC)
|
|
337
|
+
*/
|
|
338
|
+
getMarketInfo(marketAddress: `0x${string}`): Promise<{
|
|
339
|
+
question: string;
|
|
340
|
+
resolutionTime: bigint;
|
|
341
|
+
oracle: `0x${string}`;
|
|
342
|
+
yesPrice: number;
|
|
343
|
+
noPrice: number;
|
|
344
|
+
yesProbability: number;
|
|
345
|
+
noProbability: number;
|
|
346
|
+
yesShares: bigint;
|
|
347
|
+
noShares: bigint;
|
|
348
|
+
totalCollateral: bigint;
|
|
349
|
+
liquidityParam: bigint;
|
|
350
|
+
resolved: boolean;
|
|
351
|
+
yesWins: boolean;
|
|
352
|
+
marketCreator: `0x${string}`;
|
|
353
|
+
initialized: boolean;
|
|
354
|
+
canResolve: boolean;
|
|
355
|
+
}>;
|
|
356
|
+
/**
|
|
357
|
+
* Get resolve calldata and execute (requires x402 payment - 0.0001 USDC)
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* // As the oracle, resolve the market
|
|
362
|
+
* const txHash = await client.resolve('0x...', true); // YES wins
|
|
363
|
+
* console.log('Market resolved:', txHash);
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
resolve(marketAddress: `0x${string}`, yesWins: boolean): Promise<`0x${string}`>;
|
|
367
|
+
/**
|
|
368
|
+
* Check if market can be resolved (requires x402 payment - 0.0001 USDC for market info)
|
|
369
|
+
*/
|
|
370
|
+
canResolve(marketAddress: `0x${string}`): Promise<{
|
|
371
|
+
canResolve: boolean;
|
|
372
|
+
reason?: string;
|
|
373
|
+
resolutionTime: Date;
|
|
374
|
+
isOracle: boolean;
|
|
375
|
+
}>;
|
|
376
|
+
/**
|
|
377
|
+
* Get fee information and claim calldata (requires x402 payment - 0.0001 USDC)
|
|
378
|
+
*/
|
|
379
|
+
getFeeInfo(marketAddress: `0x${string}`): Promise<{
|
|
380
|
+
pendingCreatorFees: bigint;
|
|
381
|
+
pendingCreatorFeesFormatted: string;
|
|
382
|
+
protocolFeesSent: bigint;
|
|
383
|
+
protocolFeesSentFormatted: string;
|
|
384
|
+
marketCreator: `0x${string}`;
|
|
385
|
+
isCreator: boolean;
|
|
386
|
+
transactions: Array<{
|
|
387
|
+
to: string;
|
|
388
|
+
data: string;
|
|
389
|
+
description: string;
|
|
390
|
+
type: string;
|
|
391
|
+
}>;
|
|
392
|
+
}>;
|
|
393
|
+
/**
|
|
394
|
+
* Claim accumulated creator fees (requires x402 payment - 0.0001 USDC)
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* const feeInfo = await client.getFeeInfo('0x...');
|
|
399
|
+
* console.log('Pending fees:', feeInfo.pendingCreatorFeesFormatted, 'USDC');
|
|
400
|
+
*
|
|
401
|
+
* if (feeInfo.pendingCreatorFees > 0n) {
|
|
402
|
+
* const txHash = await client.claimCreatorFees('0x...');
|
|
403
|
+
* console.log('Fees claimed:', txHash);
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
claimCreatorFees(marketAddress: `0x${string}`): Promise<`0x${string}`>;
|
|
408
|
+
/**
|
|
409
|
+
* Withdraw excess collateral after market resolution (requires x402 payment - 0.0001 USDC)
|
|
410
|
+
*/
|
|
411
|
+
withdrawExcessCollateral(marketAddress: `0x${string}`): Promise<`0x${string}`>;
|
|
412
|
+
/**
|
|
413
|
+
* Initialize a deployed market with initial liquidity
|
|
414
|
+
*
|
|
415
|
+
* IMPORTANT: Routes through x402-initialize endpoint for tracking (0.0001 USDC)
|
|
416
|
+
*
|
|
417
|
+
* @param marketAddress The deployed market contract address
|
|
418
|
+
* @param usdcAmount Initial liquidity in USDC (e.g., "10" for 10 USDC)
|
|
419
|
+
*/
|
|
420
|
+
initializeMarket(marketAddress: `0x${string}`, usdcAmount: string): Promise<`0x${string}`>;
|
|
421
|
+
/**
|
|
422
|
+
* Get connected wallet address
|
|
423
|
+
*/
|
|
424
|
+
getAddress(): `0x${string}` | null;
|
|
425
|
+
/**
|
|
426
|
+
* Format USDC amount for display
|
|
427
|
+
*/
|
|
428
|
+
formatUSDC(amount: bigint): string;
|
|
429
|
+
/**
|
|
430
|
+
* Parse USDC amount from string
|
|
431
|
+
*/
|
|
432
|
+
parseUSDC(amount: string): bigint;
|
|
433
|
+
/**
|
|
434
|
+
* Get x402 pricing info for all endpoints
|
|
435
|
+
*/
|
|
436
|
+
getX402Prices(): {
|
|
437
|
+
markets: {
|
|
438
|
+
raw: "100";
|
|
439
|
+
formatted: string;
|
|
440
|
+
description: string;
|
|
441
|
+
};
|
|
442
|
+
marketData: {
|
|
443
|
+
raw: "100";
|
|
444
|
+
formatted: string;
|
|
445
|
+
description: string;
|
|
446
|
+
};
|
|
447
|
+
tradeInstructions: {
|
|
448
|
+
raw: "100";
|
|
449
|
+
formatted: string;
|
|
450
|
+
description: string;
|
|
451
|
+
};
|
|
452
|
+
createMarket: {
|
|
453
|
+
raw: "100";
|
|
454
|
+
formatted: string;
|
|
455
|
+
description: string;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
declare const MONAD_TESTNET: {
|
|
461
|
+
readonly id: 10143;
|
|
462
|
+
readonly name: "Monad Testnet";
|
|
463
|
+
readonly rpcUrl: "https://testnet-rpc.monad.xyz";
|
|
464
|
+
readonly explorer: "https://testnet.monadexplorer.com";
|
|
465
|
+
};
|
|
466
|
+
declare const ADDRESSES: {
|
|
467
|
+
readonly PREDICTION_FACTORY: `0x${string}`;
|
|
468
|
+
readonly WMON: `0x${string}`;
|
|
469
|
+
readonly USDC: `0x${string}`;
|
|
470
|
+
readonly AGENT_REGISTRY: `0x${string}`;
|
|
471
|
+
readonly REPUTATION_REGISTRY: `0x${string}`;
|
|
472
|
+
readonly PROTOCOL_FEE_RECIPIENT: `0x${string}`;
|
|
473
|
+
};
|
|
474
|
+
declare const API_CONFIG: {
|
|
475
|
+
readonly base: "https://qkcytrdhdtemyphsswou.supabase.co";
|
|
476
|
+
readonly anonKey: "sb_publishable_mKTNqXht6ek37VkHAGWoUQ_TMzoC3wp";
|
|
477
|
+
};
|
|
478
|
+
declare const API_ENDPOINTS: {
|
|
479
|
+
readonly base: "https://qkcytrdhdtemyphsswou.supabase.co";
|
|
480
|
+
readonly x402Markets: "/functions/v1/x402-markets";
|
|
481
|
+
readonly x402Prices: "/functions/v1/x402-prices";
|
|
482
|
+
readonly x402MarketInfo: "/functions/v1/x402-market-info";
|
|
483
|
+
readonly x402Position: "/functions/v1/x402-position";
|
|
484
|
+
readonly x402MarketData: "/functions/v1/x402-market-data";
|
|
485
|
+
readonly x402AgentTrade: "/functions/v1/x402-agent-trade";
|
|
486
|
+
readonly x402Resolve: "/functions/v1/x402-resolve";
|
|
487
|
+
readonly x402ClaimFees: "/functions/v1/x402-claim-fees";
|
|
488
|
+
readonly x402Redeem: "/functions/v1/x402-redeem";
|
|
489
|
+
readonly x402Initialize: "/functions/v1/x402-initialize";
|
|
490
|
+
readonly x402CreateMarket: "/functions/v1/x402-create-market";
|
|
491
|
+
readonly authMoltbook: "/functions/v1/auth-moltbook";
|
|
492
|
+
};
|
|
493
|
+
declare const X402_CONFIG: {
|
|
494
|
+
readonly network: "eip155:10143";
|
|
495
|
+
readonly facilitator: "https://x402-facilitator.molandak.org";
|
|
496
|
+
readonly recipient: `0x${string}`;
|
|
497
|
+
readonly prices: {
|
|
498
|
+
readonly default: "100";
|
|
499
|
+
readonly markets: "100";
|
|
500
|
+
readonly prices: "100";
|
|
501
|
+
readonly marketInfo: "100";
|
|
502
|
+
readonly position: "100";
|
|
503
|
+
readonly marketData: "100";
|
|
504
|
+
readonly tradeInstructions: "100";
|
|
505
|
+
readonly resolve: "100";
|
|
506
|
+
readonly claimFees: "100";
|
|
507
|
+
readonly createMarket: "100";
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
declare const LSLMSR_DEPLOY_PARAMS: {
|
|
511
|
+
readonly collateral: `0x${string}`;
|
|
512
|
+
readonly decimals: 6;
|
|
513
|
+
readonly defaultAlpha: "30000000000000000";
|
|
514
|
+
readonly defaultMinLiquidity: "100000000000000000000";
|
|
515
|
+
readonly defaultInitialShares: "100000000000000000000";
|
|
516
|
+
};
|
|
517
|
+
declare const LSLMSR_ABI: readonly [{
|
|
518
|
+
readonly name: "getMarketInfo";
|
|
519
|
+
readonly type: "function";
|
|
520
|
+
readonly inputs: readonly [];
|
|
521
|
+
readonly outputs: readonly [{
|
|
522
|
+
readonly name: "_question";
|
|
523
|
+
readonly type: "string";
|
|
524
|
+
}, {
|
|
525
|
+
readonly name: "_resolutionTime";
|
|
526
|
+
readonly type: "uint256";
|
|
527
|
+
}, {
|
|
528
|
+
readonly name: "_oracle";
|
|
529
|
+
readonly type: "address";
|
|
530
|
+
}, {
|
|
531
|
+
readonly name: "_yesPrice";
|
|
532
|
+
readonly type: "uint256";
|
|
533
|
+
}, {
|
|
534
|
+
readonly name: "_noPrice";
|
|
535
|
+
readonly type: "uint256";
|
|
536
|
+
}, {
|
|
537
|
+
readonly name: "_yesProbability";
|
|
538
|
+
readonly type: "uint256";
|
|
539
|
+
}, {
|
|
540
|
+
readonly name: "_noProbability";
|
|
541
|
+
readonly type: "uint256";
|
|
542
|
+
}, {
|
|
543
|
+
readonly name: "_yesShares";
|
|
544
|
+
readonly type: "uint256";
|
|
545
|
+
}, {
|
|
546
|
+
readonly name: "_noShares";
|
|
547
|
+
readonly type: "uint256";
|
|
548
|
+
}, {
|
|
549
|
+
readonly name: "_totalCollateral";
|
|
550
|
+
readonly type: "uint256";
|
|
551
|
+
}, {
|
|
552
|
+
readonly name: "_liquidityParam";
|
|
553
|
+
readonly type: "uint256";
|
|
554
|
+
}, {
|
|
555
|
+
readonly name: "_priceSum";
|
|
556
|
+
readonly type: "uint256";
|
|
557
|
+
}, {
|
|
558
|
+
readonly name: "_resolved";
|
|
559
|
+
readonly type: "bool";
|
|
560
|
+
}, {
|
|
561
|
+
readonly name: "_yesWins";
|
|
562
|
+
readonly type: "bool";
|
|
563
|
+
}];
|
|
564
|
+
readonly stateMutability: "view";
|
|
565
|
+
}, {
|
|
566
|
+
readonly name: "getCollateralInfo";
|
|
567
|
+
readonly type: "function";
|
|
568
|
+
readonly inputs: readonly [];
|
|
569
|
+
readonly outputs: readonly [{
|
|
570
|
+
readonly name: "token";
|
|
571
|
+
readonly type: "address";
|
|
572
|
+
}, {
|
|
573
|
+
readonly name: "decimals";
|
|
574
|
+
readonly type: "uint8";
|
|
575
|
+
}, {
|
|
576
|
+
readonly name: "symbol";
|
|
577
|
+
readonly type: "string";
|
|
578
|
+
}];
|
|
579
|
+
readonly stateMutability: "view";
|
|
580
|
+
}, {
|
|
581
|
+
readonly name: "getYesPrice";
|
|
582
|
+
readonly type: "function";
|
|
583
|
+
readonly inputs: readonly [];
|
|
584
|
+
readonly outputs: readonly [{
|
|
585
|
+
readonly type: "uint256";
|
|
586
|
+
}];
|
|
587
|
+
readonly stateMutability: "view";
|
|
588
|
+
}, {
|
|
589
|
+
readonly name: "getNoPrice";
|
|
590
|
+
readonly type: "function";
|
|
591
|
+
readonly inputs: readonly [];
|
|
592
|
+
readonly outputs: readonly [{
|
|
593
|
+
readonly type: "uint256";
|
|
594
|
+
}];
|
|
595
|
+
readonly stateMutability: "view";
|
|
596
|
+
}, {
|
|
597
|
+
readonly name: "getCostInCollateral";
|
|
598
|
+
readonly type: "function";
|
|
599
|
+
readonly inputs: readonly [{
|
|
600
|
+
readonly name: "isYes";
|
|
601
|
+
readonly type: "bool";
|
|
602
|
+
}, {
|
|
603
|
+
readonly name: "shares";
|
|
604
|
+
readonly type: "uint256";
|
|
605
|
+
}];
|
|
606
|
+
readonly outputs: readonly [{
|
|
607
|
+
readonly name: "cost";
|
|
608
|
+
readonly type: "uint256";
|
|
609
|
+
}];
|
|
610
|
+
readonly stateMutability: "view";
|
|
611
|
+
}, {
|
|
612
|
+
readonly name: "getPayoutForSellInCollateral";
|
|
613
|
+
readonly type: "function";
|
|
614
|
+
readonly inputs: readonly [{
|
|
615
|
+
readonly name: "isYes";
|
|
616
|
+
readonly type: "bool";
|
|
617
|
+
}, {
|
|
618
|
+
readonly name: "shares";
|
|
619
|
+
readonly type: "uint256";
|
|
620
|
+
}];
|
|
621
|
+
readonly outputs: readonly [{
|
|
622
|
+
readonly name: "payout";
|
|
623
|
+
readonly type: "uint256";
|
|
624
|
+
}];
|
|
625
|
+
readonly stateMutability: "view";
|
|
626
|
+
}, {
|
|
627
|
+
readonly name: "estimateSharesForPayment";
|
|
628
|
+
readonly type: "function";
|
|
629
|
+
readonly inputs: readonly [{
|
|
630
|
+
readonly name: "isYes";
|
|
631
|
+
readonly type: "bool";
|
|
632
|
+
}, {
|
|
633
|
+
readonly name: "grossPayment";
|
|
634
|
+
readonly type: "uint256";
|
|
635
|
+
}];
|
|
636
|
+
readonly outputs: readonly [{
|
|
637
|
+
readonly name: "shares";
|
|
638
|
+
readonly type: "uint256";
|
|
639
|
+
}];
|
|
640
|
+
readonly stateMutability: "view";
|
|
641
|
+
}, {
|
|
642
|
+
readonly name: "yesToken";
|
|
643
|
+
readonly type: "function";
|
|
644
|
+
readonly inputs: readonly [];
|
|
645
|
+
readonly outputs: readonly [{
|
|
646
|
+
readonly type: "address";
|
|
647
|
+
}];
|
|
648
|
+
readonly stateMutability: "view";
|
|
649
|
+
}, {
|
|
650
|
+
readonly name: "noToken";
|
|
651
|
+
readonly type: "function";
|
|
652
|
+
readonly inputs: readonly [];
|
|
653
|
+
readonly outputs: readonly [{
|
|
654
|
+
readonly type: "address";
|
|
655
|
+
}];
|
|
656
|
+
readonly stateMutability: "view";
|
|
657
|
+
}, {
|
|
658
|
+
readonly name: "collateralToken";
|
|
659
|
+
readonly type: "function";
|
|
660
|
+
readonly inputs: readonly [];
|
|
661
|
+
readonly outputs: readonly [{
|
|
662
|
+
readonly type: "address";
|
|
663
|
+
}];
|
|
664
|
+
readonly stateMutability: "view";
|
|
665
|
+
}, {
|
|
666
|
+
readonly name: "collateralDecimals";
|
|
667
|
+
readonly type: "function";
|
|
668
|
+
readonly inputs: readonly [];
|
|
669
|
+
readonly outputs: readonly [{
|
|
670
|
+
readonly type: "uint8";
|
|
671
|
+
}];
|
|
672
|
+
readonly stateMutability: "view";
|
|
673
|
+
}, {
|
|
674
|
+
readonly name: "buy";
|
|
675
|
+
readonly type: "function";
|
|
676
|
+
readonly inputs: readonly [{
|
|
677
|
+
readonly name: "isYes";
|
|
678
|
+
readonly type: "bool";
|
|
679
|
+
}, {
|
|
680
|
+
readonly name: "collateralAmount";
|
|
681
|
+
readonly type: "uint256";
|
|
682
|
+
}, {
|
|
683
|
+
readonly name: "minShares";
|
|
684
|
+
readonly type: "uint256";
|
|
685
|
+
}];
|
|
686
|
+
readonly outputs: readonly [];
|
|
687
|
+
readonly stateMutability: "nonpayable";
|
|
688
|
+
}, {
|
|
689
|
+
readonly name: "sell";
|
|
690
|
+
readonly type: "function";
|
|
691
|
+
readonly inputs: readonly [{
|
|
692
|
+
readonly name: "isYes";
|
|
693
|
+
readonly type: "bool";
|
|
694
|
+
}, {
|
|
695
|
+
readonly name: "shares";
|
|
696
|
+
readonly type: "uint256";
|
|
697
|
+
}, {
|
|
698
|
+
readonly name: "minPayout";
|
|
699
|
+
readonly type: "uint256";
|
|
700
|
+
}];
|
|
701
|
+
readonly outputs: readonly [];
|
|
702
|
+
readonly stateMutability: "nonpayable";
|
|
703
|
+
}, {
|
|
704
|
+
readonly name: "redeem";
|
|
705
|
+
readonly type: "function";
|
|
706
|
+
readonly inputs: readonly [];
|
|
707
|
+
readonly outputs: readonly [];
|
|
708
|
+
readonly stateMutability: "nonpayable";
|
|
709
|
+
}, {
|
|
710
|
+
readonly name: "resolve";
|
|
711
|
+
readonly type: "function";
|
|
712
|
+
readonly inputs: readonly [{
|
|
713
|
+
readonly name: "_yesWins";
|
|
714
|
+
readonly type: "bool";
|
|
715
|
+
}];
|
|
716
|
+
readonly outputs: readonly [];
|
|
717
|
+
readonly stateMutability: "nonpayable";
|
|
718
|
+
}, {
|
|
719
|
+
readonly name: "oracle";
|
|
720
|
+
readonly type: "function";
|
|
721
|
+
readonly inputs: readonly [];
|
|
722
|
+
readonly outputs: readonly [{
|
|
723
|
+
readonly type: "address";
|
|
724
|
+
}];
|
|
725
|
+
readonly stateMutability: "view";
|
|
726
|
+
}, {
|
|
727
|
+
readonly name: "resolved";
|
|
728
|
+
readonly type: "function";
|
|
729
|
+
readonly inputs: readonly [];
|
|
730
|
+
readonly outputs: readonly [{
|
|
731
|
+
readonly type: "bool";
|
|
732
|
+
}];
|
|
733
|
+
readonly stateMutability: "view";
|
|
734
|
+
}, {
|
|
735
|
+
readonly name: "yesWins";
|
|
736
|
+
readonly type: "function";
|
|
737
|
+
readonly inputs: readonly [];
|
|
738
|
+
readonly outputs: readonly [{
|
|
739
|
+
readonly type: "bool";
|
|
740
|
+
}];
|
|
741
|
+
readonly stateMutability: "view";
|
|
742
|
+
}, {
|
|
743
|
+
readonly name: "resolutionTime";
|
|
744
|
+
readonly type: "function";
|
|
745
|
+
readonly inputs: readonly [];
|
|
746
|
+
readonly outputs: readonly [{
|
|
747
|
+
readonly type: "uint256";
|
|
748
|
+
}];
|
|
749
|
+
readonly stateMutability: "view";
|
|
750
|
+
}, {
|
|
751
|
+
readonly name: "claimCreatorFees";
|
|
752
|
+
readonly type: "function";
|
|
753
|
+
readonly inputs: readonly [];
|
|
754
|
+
readonly outputs: readonly [];
|
|
755
|
+
readonly stateMutability: "nonpayable";
|
|
756
|
+
}, {
|
|
757
|
+
readonly name: "withdrawExcessCollateral";
|
|
758
|
+
readonly type: "function";
|
|
759
|
+
readonly inputs: readonly [];
|
|
760
|
+
readonly outputs: readonly [];
|
|
761
|
+
readonly stateMutability: "nonpayable";
|
|
762
|
+
}, {
|
|
763
|
+
readonly name: "getFeeInfo";
|
|
764
|
+
readonly type: "function";
|
|
765
|
+
readonly inputs: readonly [];
|
|
766
|
+
readonly outputs: readonly [{
|
|
767
|
+
readonly name: "pendingCreatorFees";
|
|
768
|
+
readonly type: "uint256";
|
|
769
|
+
}, {
|
|
770
|
+
readonly name: "protocolFeesSent";
|
|
771
|
+
readonly type: "uint256";
|
|
772
|
+
}];
|
|
773
|
+
readonly stateMutability: "view";
|
|
774
|
+
}, {
|
|
775
|
+
readonly name: "marketCreator";
|
|
776
|
+
readonly type: "function";
|
|
777
|
+
readonly inputs: readonly [];
|
|
778
|
+
readonly outputs: readonly [{
|
|
779
|
+
readonly type: "address";
|
|
780
|
+
}];
|
|
781
|
+
readonly stateMutability: "view";
|
|
782
|
+
}, {
|
|
783
|
+
readonly name: "creatorFeesAccrued";
|
|
784
|
+
readonly type: "function";
|
|
785
|
+
readonly inputs: readonly [];
|
|
786
|
+
readonly outputs: readonly [{
|
|
787
|
+
readonly type: "uint256";
|
|
788
|
+
}];
|
|
789
|
+
readonly stateMutability: "view";
|
|
790
|
+
}, {
|
|
791
|
+
readonly name: "initialize";
|
|
792
|
+
readonly type: "function";
|
|
793
|
+
readonly inputs: readonly [{
|
|
794
|
+
readonly name: "_initialLiquidity";
|
|
795
|
+
readonly type: "uint256";
|
|
796
|
+
}];
|
|
797
|
+
readonly outputs: readonly [];
|
|
798
|
+
readonly stateMutability: "nonpayable";
|
|
799
|
+
}, {
|
|
800
|
+
readonly name: "initialized";
|
|
801
|
+
readonly type: "function";
|
|
802
|
+
readonly inputs: readonly [];
|
|
803
|
+
readonly outputs: readonly [{
|
|
804
|
+
readonly type: "bool";
|
|
805
|
+
}];
|
|
806
|
+
readonly stateMutability: "view";
|
|
807
|
+
}, {
|
|
808
|
+
readonly type: "event";
|
|
809
|
+
readonly name: "SharesPurchased";
|
|
810
|
+
readonly inputs: readonly [{
|
|
811
|
+
readonly name: "buyer";
|
|
812
|
+
readonly type: "address";
|
|
813
|
+
readonly indexed: true;
|
|
814
|
+
}, {
|
|
815
|
+
readonly name: "isYes";
|
|
816
|
+
readonly type: "bool";
|
|
817
|
+
readonly indexed: false;
|
|
818
|
+
}, {
|
|
819
|
+
readonly name: "shares";
|
|
820
|
+
readonly type: "uint256";
|
|
821
|
+
readonly indexed: false;
|
|
822
|
+
}, {
|
|
823
|
+
readonly name: "cost";
|
|
824
|
+
readonly type: "uint256";
|
|
825
|
+
readonly indexed: false;
|
|
826
|
+
}];
|
|
827
|
+
}, {
|
|
828
|
+
readonly type: "event";
|
|
829
|
+
readonly name: "SharesSold";
|
|
830
|
+
readonly inputs: readonly [{
|
|
831
|
+
readonly name: "seller";
|
|
832
|
+
readonly type: "address";
|
|
833
|
+
readonly indexed: true;
|
|
834
|
+
}, {
|
|
835
|
+
readonly name: "isYes";
|
|
836
|
+
readonly type: "bool";
|
|
837
|
+
readonly indexed: false;
|
|
838
|
+
}, {
|
|
839
|
+
readonly name: "shares";
|
|
840
|
+
readonly type: "uint256";
|
|
841
|
+
readonly indexed: false;
|
|
842
|
+
}, {
|
|
843
|
+
readonly name: "payout";
|
|
844
|
+
readonly type: "uint256";
|
|
845
|
+
readonly indexed: false;
|
|
846
|
+
}];
|
|
847
|
+
}];
|
|
848
|
+
declare const ERC20_ABI: readonly [{
|
|
849
|
+
readonly name: "balanceOf";
|
|
850
|
+
readonly type: "function";
|
|
851
|
+
readonly inputs: readonly [{
|
|
852
|
+
readonly name: "account";
|
|
853
|
+
readonly type: "address";
|
|
854
|
+
}];
|
|
855
|
+
readonly outputs: readonly [{
|
|
856
|
+
readonly type: "uint256";
|
|
857
|
+
}];
|
|
858
|
+
readonly stateMutability: "view";
|
|
859
|
+
}, {
|
|
860
|
+
readonly name: "approve";
|
|
861
|
+
readonly type: "function";
|
|
862
|
+
readonly inputs: readonly [{
|
|
863
|
+
readonly name: "spender";
|
|
864
|
+
readonly type: "address";
|
|
865
|
+
}, {
|
|
866
|
+
readonly name: "amount";
|
|
867
|
+
readonly type: "uint256";
|
|
868
|
+
}];
|
|
869
|
+
readonly outputs: readonly [{
|
|
870
|
+
readonly type: "bool";
|
|
871
|
+
}];
|
|
872
|
+
readonly stateMutability: "nonpayable";
|
|
873
|
+
}, {
|
|
874
|
+
readonly name: "allowance";
|
|
875
|
+
readonly type: "function";
|
|
876
|
+
readonly inputs: readonly [{
|
|
877
|
+
readonly name: "owner";
|
|
878
|
+
readonly type: "address";
|
|
879
|
+
}, {
|
|
880
|
+
readonly name: "spender";
|
|
881
|
+
readonly type: "address";
|
|
882
|
+
}];
|
|
883
|
+
readonly outputs: readonly [{
|
|
884
|
+
readonly type: "uint256";
|
|
885
|
+
}];
|
|
886
|
+
readonly stateMutability: "view";
|
|
887
|
+
}];
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Create a fetch wrapper that automatically handles x402 payments
|
|
891
|
+
*/
|
|
892
|
+
declare function createX402Fetch(walletClient: WalletClient, account: Account): (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
893
|
+
/**
|
|
894
|
+
* Check if a wallet has enough USDC for x402 payments
|
|
895
|
+
*/
|
|
896
|
+
declare function checkX402Balance(publicClient: {
|
|
897
|
+
readContract: (args: unknown) => Promise<bigint>;
|
|
898
|
+
}, address: `0x${string}`, requiredAmount?: string): Promise<{
|
|
899
|
+
sufficient: boolean;
|
|
900
|
+
balance: bigint;
|
|
901
|
+
required: bigint;
|
|
902
|
+
}>;
|
|
903
|
+
|
|
904
|
+
export { ADDRESSES, API_CONFIG, API_ENDPOINTS, type AuthResult, ERC20_ABI, LSLMSR_ABI, LSLMSR_DEPLOY_PARAMS, MONAD_TESTNET, type Market, type MarketCreateParams, type MarketCreateResult, type MarketPrices, type MoltbookAgent, type Position, type PremiumMarketData, RBSPMClient, type RBSPMConfig, type TradeQuote, type TradeResult, type X402Prices, X402_CONFIG, checkX402Balance, createX402Fetch, RBSPMClient as default };
|