@clawnch/clawncher-sdk 0.1.2 → 0.1.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.
@@ -0,0 +1,175 @@
1
+ /**
2
+ * WayfinderClient - Cross-chain DeFi via Wayfinder Paths
3
+ *
4
+ * Two-tier integration:
5
+ * - Tier 1 (REST): Swap quotes, token resolution, balances, pool data.
6
+ * Always available — calls the Wayfinder API directly.
7
+ * - Tier 2 (CLI bridge): Execute swaps, run strategies, Hyperliquid trading.
8
+ * Requires Python 3.12+ and the wayfinder-paths pip package installed locally.
9
+ * Shells out to the `wayfinder` CLI for operations that need local tx signing.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { WayfinderClient } from '@clawnch/clawncher-sdk';
14
+ *
15
+ * const wf = new WayfinderClient({
16
+ * apiKey: 'wk_...',
17
+ * });
18
+ *
19
+ * // Tier 1: Get a cross-chain swap quote (no Python needed)
20
+ * const quote = await wf.quoteSwap({
21
+ * fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC on Ethereum
22
+ * toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
23
+ * fromChain: 1,
24
+ * toChain: 8453,
25
+ * fromWallet: '0x...',
26
+ * amount: '5000000', // 5 USDC in raw units (6 decimals)
27
+ * });
28
+ * console.log('Best route:', quote.bestQuote?.provider);
29
+ *
30
+ * // Tier 1: Get multi-chain balances
31
+ * const balances = await wf.getBalances('0x...');
32
+ * console.log('Total value:', balances.totalValueUsd);
33
+ *
34
+ * // Tier 2: Execute a swap (requires Python + wayfinder-paths)
35
+ * const status = await wf.checkPython();
36
+ * if (status.wayfinderInstalled) {
37
+ * const result = await wf.executeSwap({
38
+ * kind: 'swap',
39
+ * walletLabel: 'main',
40
+ * amount: '5',
41
+ * fromToken: 'usd-coin',
42
+ * toToken: 'ethereum',
43
+ * });
44
+ * console.log('Tx:', result.result?.effects);
45
+ * }
46
+ * ```
47
+ */
48
+ import type { WayfinderConfig, PythonStatus, WayfinderTokenDetail, WayfinderTokenSearchResult, WayfinderQuoteParams, WayfinderQuoteResponse, WayfinderBalancesResponse, WayfinderActivityResponse, WayfinderPool, WayfinderFundingEntry, WayfinderCandle, WayfinderHyperLendMarket, WayfinderStrategyInfo, WayfinderStrategyStatus, WayfinderStrategyParams, WayfinderStrategyResult, WayfinderExecuteParams, WayfinderExecuteResult } from './wayfinder-types.js';
49
+ export declare class WayfinderError extends Error {
50
+ readonly code: string;
51
+ readonly details?: unknown | undefined;
52
+ constructor(message: string, code: string, details?: unknown | undefined);
53
+ }
54
+ export declare class WayfinderClient {
55
+ private readonly apiKey;
56
+ private readonly apiUrl;
57
+ private readonly timeout;
58
+ private readonly pythonPathOverride?;
59
+ private pythonStatusCache;
60
+ constructor(config: WayfinderConfig);
61
+ /**
62
+ * Check whether Python 3 and wayfinder-paths are available.
63
+ * Results are cached after the first call.
64
+ */
65
+ checkPython(): Promise<PythonStatus>;
66
+ /**
67
+ * Clear the cached Python status (e.g. after installing wayfinder-paths).
68
+ */
69
+ clearPythonCache(): void;
70
+ /**
71
+ * Resolve a token by name, symbol, address, or CoinGecko ID.
72
+ *
73
+ * @param query - Token identifier (e.g. "USDC", "0xA0b8...", "usd-coin")
74
+ * @param chainId - Optional chain ID filter
75
+ * @param marketData - Include market data (price, market cap)
76
+ */
77
+ resolveToken(query: string, chainId?: number, marketData?: boolean): Promise<WayfinderTokenDetail>;
78
+ /**
79
+ * Fuzzy search for tokens across chains.
80
+ *
81
+ * @param query - Search term
82
+ * @param chain - Chain code (e.g. "base", "ethereum")
83
+ */
84
+ searchTokens(query: string, chain: string): Promise<WayfinderTokenSearchResult[]>;
85
+ /**
86
+ * Get the gas token for a chain.
87
+ *
88
+ * @param chain - Chain code (e.g. "base", "ethereum")
89
+ */
90
+ getGasToken(chain: string): Promise<WayfinderTokenDetail>;
91
+ /**
92
+ * Get a cross-chain swap quote via the BRAP aggregator.
93
+ * Compares routes from multiple providers (LiFi, Squid, etc.)
94
+ * and returns the best option.
95
+ *
96
+ * @param params - Quote parameters (tokens, chains, amount in WEI)
97
+ */
98
+ quoteSwap(params: WayfinderQuoteParams): Promise<WayfinderQuoteResponse>;
99
+ /**
100
+ * Get enriched multi-chain wallet balances.
101
+ *
102
+ * @param walletAddress - Ethereum wallet address
103
+ * @param excludeSpam - Exclude spam tokens (default: true)
104
+ */
105
+ getBalances(walletAddress: string, excludeSpam?: boolean): Promise<WayfinderBalancesResponse>;
106
+ /**
107
+ * Get wallet transaction activity.
108
+ *
109
+ * @param walletAddress - Ethereum wallet address
110
+ * @param limit - Max results (default: 20)
111
+ * @param offset - Pagination offset
112
+ */
113
+ getWalletActivity(walletAddress: string, limit?: number, offset?: number): Promise<WayfinderActivityResponse>;
114
+ /**
115
+ * Get DeFi pool data (Moonwell, Aave, Morpho, etc.)
116
+ *
117
+ * @param chainId - Optional chain ID filter
118
+ * @param protocol - Optional protocol filter (e.g. "moonwell", "aave")
119
+ */
120
+ getPools(chainId?: number, protocol?: string): Promise<WayfinderPool[]>;
121
+ /**
122
+ * Get Hyperliquid funding rate history.
123
+ *
124
+ * @param coin - Coin symbol (e.g. "BTC", "ETH")
125
+ * @param startMs - Start timestamp in milliseconds
126
+ * @param endMs - End timestamp in milliseconds
127
+ */
128
+ getHyperliquidFunding(coin: string, startMs?: number, endMs?: number): Promise<WayfinderFundingEntry[]>;
129
+ /**
130
+ * Get Hyperliquid OHLCV candle data.
131
+ *
132
+ * @param coin - Coin symbol
133
+ * @param interval - Candle interval (e.g. "1h", "4h", "1d")
134
+ * @param startMs - Start timestamp in milliseconds
135
+ * @param endMs - End timestamp in milliseconds
136
+ */
137
+ getHyperliquidCandles(coin: string, interval: string, startMs?: number, endMs?: number): Promise<WayfinderCandle[]>;
138
+ /**
139
+ * Get HyperLend stable market data.
140
+ */
141
+ getHyperLendMarkets(): Promise<WayfinderHyperLendMarket[]>;
142
+ /**
143
+ * Execute a swap, send, or Hyperliquid deposit via the Wayfinder CLI.
144
+ * Signs transactions locally using wallets from wayfinder config.json.
145
+ *
146
+ * Requires Python 3.12+ and wayfinder-paths installed.
147
+ */
148
+ executeSwap(params: WayfinderExecuteParams): Promise<WayfinderExecuteResult>;
149
+ /**
150
+ * Run a Wayfinder strategy action (status, deposit, update, exit, etc.)
151
+ *
152
+ * Requires Python 3.12+ and wayfinder-paths installed.
153
+ */
154
+ runStrategy(params: WayfinderStrategyParams): Promise<WayfinderStrategyResult>;
155
+ /**
156
+ * List available Wayfinder strategies.
157
+ *
158
+ * Requires Python 3.12+ and wayfinder-paths installed.
159
+ */
160
+ listStrategies(): Promise<WayfinderStrategyInfo[]>;
161
+ /**
162
+ * Get the status of a specific strategy.
163
+ *
164
+ * Requires Python 3.12+ and wayfinder-paths installed.
165
+ */
166
+ getStrategyStatus(name: string): Promise<WayfinderStrategyStatus>;
167
+ private restRequest;
168
+ private cliExec;
169
+ private parseTokenDetail;
170
+ private parseFuzzySearchResults;
171
+ private parseBRAPQuoteResponse;
172
+ private parseBalancesResponse;
173
+ private parseStrategyList;
174
+ }
175
+ //# sourceMappingURL=wayfinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wayfinder.d.ts","sourceRoot":"","sources":["../src/wayfinder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAIH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EAEtB,yBAAyB,EACzB,yBAAyB,EACzB,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAgB9B,qBAAa,cAAe,SAAQ,KAAK;aAGrB,IAAI,EAAE,MAAM;aACZ,O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