@clawnch/clawncher-sdk 0.3.2 → 0.3.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.
Files changed (54) hide show
  1. package/README.md +89 -0
  2. package/dist/bankr-fees.d.ts +216 -0
  3. package/dist/bankr-fees.d.ts.map +1 -0
  4. package/dist/bankr-fees.js +317 -0
  5. package/dist/bankr-fees.js.map +1 -0
  6. package/dist/deployer.d.ts +48 -2
  7. package/dist/deployer.d.ts.map +1 -1
  8. package/dist/deployer.js +134 -5
  9. package/dist/deployer.js.map +1 -1
  10. package/dist/errors.d.ts +2 -1
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +2 -0
  13. package/dist/errors.js.map +1 -1
  14. package/dist/herd-auth.d.ts +79 -0
  15. package/dist/herd-auth.d.ts.map +1 -0
  16. package/dist/herd-auth.js +188 -0
  17. package/dist/herd-auth.js.map +1 -0
  18. package/dist/herd-hal.d.ts +92 -0
  19. package/dist/herd-hal.d.ts.map +1 -0
  20. package/dist/herd-hal.js +337 -0
  21. package/dist/herd-hal.js.map +1 -0
  22. package/dist/herd-types.d.ts +479 -0
  23. package/dist/herd-types.d.ts.map +1 -0
  24. package/dist/herd-types.js +18 -0
  25. package/dist/herd-types.js.map +1 -0
  26. package/dist/herd.d.ts +223 -0
  27. package/dist/herd.d.ts.map +1 -0
  28. package/dist/herd.js +1486 -0
  29. package/dist/herd.js.map +1 -0
  30. package/dist/hummingbot-types.d.ts +702 -0
  31. package/dist/hummingbot-types.d.ts.map +1 -0
  32. package/dist/hummingbot-types.js +12 -0
  33. package/dist/hummingbot-types.js.map +1 -0
  34. package/dist/hummingbot.d.ts +747 -0
  35. package/dist/hummingbot.d.ts.map +1 -0
  36. package/dist/hummingbot.js +1478 -0
  37. package/dist/hummingbot.js.map +1 -0
  38. package/dist/index.d.ts +9 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +12 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/price.d.ts +16 -11
  43. package/dist/price.d.ts.map +1 -1
  44. package/dist/price.js +56 -25
  45. package/dist/price.js.map +1 -1
  46. package/dist/uniswap-quoter.d.ts +25 -4
  47. package/dist/uniswap-quoter.d.ts.map +1 -1
  48. package/dist/uniswap-quoter.js +52 -8
  49. package/dist/uniswap-quoter.js.map +1 -1
  50. package/dist/walletconnect-signer.d.ts +154 -0
  51. package/dist/walletconnect-signer.d.ts.map +1 -0
  52. package/dist/walletconnect-signer.js +307 -0
  53. package/dist/walletconnect-signer.js.map +1 -0
  54. package/package.json +1 -1
package/README.md CHANGED
@@ -823,6 +823,95 @@ if (status.wayfinderInstalled) {
823
823
 
824
824
  Supported chains: Ethereum (1), Base (8453), Arbitrum (42161), Polygon (137), BSC (56), Avalanche (43114), HyperEVM (999).
825
825
 
826
+ ## Hummingbot Market Making
827
+
828
+ Operate [Hummingbot](https://github.com/hummingbot/hummingbot) programmatically — 101 methods covering all 14 API routers (accounts, connectors, trading, executors, controllers, bots, scripts, market data, portfolio, gateway, rate oracle, backtesting, history, Docker).
829
+
830
+ ```typescript
831
+ import { HummingbotClient } from '@clawnch/clawncher-sdk';
832
+
833
+ const hb = new HummingbotClient({
834
+ apiUrl: 'http://localhost:8000', // or HUMMINGBOT_API_URL
835
+ username: 'admin', // or HUMMINGBOT_USERNAME
836
+ password: 'admin', // or HUMMINGBOT_PASSWORD
837
+ });
838
+
839
+ // Health check (unauthenticated)
840
+ const health = await hb.checkHealth();
841
+
842
+ // Portfolio across all connected exchanges
843
+ const portfolio = await hb.getPortfolioOverview();
844
+
845
+ // Place an order
846
+ await hb.placeOrder({
847
+ connectorName: 'binance',
848
+ tradingPair: 'ETH-USDT',
849
+ tradeType: 'BUY',
850
+ amount: '0.1',
851
+ orderType: 'MARKET',
852
+ });
853
+
854
+ // Market data
855
+ const candles = await hb.getCandles('binance', 'ETH-USDT', '1h', 7);
856
+ const book = await hb.getOrderBook('binance', 'ETH-USDT');
857
+ const prices = await hb.getPrices('binance', 'ETH-USDT');
858
+
859
+ // Create and deploy a bot with a controller config
860
+ await hb.upsertControllerConfig({ id: 'mm_eth', controller_type: 'market_making', /* ... */ });
861
+ await hb.deployBot({ controllers: ['mm_eth'], connectorName: 'binance' });
862
+
863
+ // Executor management
864
+ await hb.createExecutor({
865
+ executorType: 'grid_executor',
866
+ connectorName: 'binance',
867
+ tradingPair: 'ETH-USDT',
868
+ side: 1,
869
+ startPrice: 3000,
870
+ endPrice: 3500,
871
+ totalAmountQuote: 1000,
872
+ levels: 10,
873
+ });
874
+
875
+ // Gateway (DEX / on-chain)
876
+ const chains = await hb.listGatewayChains();
877
+ await hb.executeGatewayAmmTrade({ chain: 'ethereum', network: 'mainnet', /* ... */ });
878
+ const pools = await hb.listCLMMPools({ chain: 'ethereum', network: 'mainnet', connector: 'uniswap' });
879
+
880
+ // Backtesting
881
+ const result = await hb.runBacktest({ startTime: 1700000000, endTime: 1700100000, config: { /* ... */ } });
882
+
883
+ // Strategy templates (local, no API call)
884
+ const templates = hb.getStrategyTemplates();
885
+ const built = hb.buildFromTemplate('pure_market_making', { connector: 'binance', tradingPair: 'ETH-USDT' });
886
+ ```
887
+
888
+ ### Strategy Templates
889
+
890
+ 9 built-in templates — 4 for the Clawnch token lifecycle, 5 general-purpose:
891
+
892
+ | Template | Purpose |
893
+ |----------|---------|
894
+ | `clawnch_initial_liquidity` | Tight spreads for freshly launched tokens |
895
+ | `clawnch_post_launch_mm` | Wider spreads with depth as volume grows |
896
+ | `clawnch_fee_optimization` | Uniswap V4 hook fee optimization |
897
+ | `clawnch_accumulation` | DCA position building over time |
898
+ | `pure_market_making` | Standard bid/ask market making |
899
+ | `avellaneda_market_making` | Inventory-aware spread adjustment |
900
+ | `grid_trading` | Grid orders across a price range |
901
+ | `dca_buying` | Dollar-cost averaging |
902
+ | `twap_execution` | Time-weighted average price execution |
903
+
904
+ ### Environment Variables
905
+
906
+ | Variable | Default | Description |
907
+ |----------|---------|-------------|
908
+ | `HUMMINGBOT_API_URL` | `http://localhost:8000` | Hummingbot API server URL |
909
+ | `HUMMINGBOT_USERNAME` | `admin` | HTTP Basic Auth username |
910
+ | `HUMMINGBOT_PASSWORD` | `admin` | HTTP Basic Auth password |
911
+ | `HUMMINGBOT_TIMEOUT` | `30000` | Request timeout (ms) |
912
+ | `HUMMINGBOT_MAX_RETRIES` | `3` | Retry count for 5xx/network errors |
913
+ | `HUMMINGBOT_RETRY_DELAY` | `1000` | Base retry delay (ms) |
914
+
826
915
  ## Related Packages
827
916
 
828
917
  - **[@clawnch/clawtomaton](https://www.npmjs.com/package/@clawnch/clawtomaton)** — Autonomous AI agents built on this SDK. Agents generate wallets, burn $CLAWNCH to activate, deploy tokens, and sustain themselves through LP fees.
@@ -0,0 +1,216 @@
1
+ /**
2
+ * BankrFeeClaimer - Fee checking and claiming for Bankr-deployed tokens
3
+ *
4
+ * Bankr tokens use the Doppler protocol for fee distribution, which is
5
+ * different from Clanker's FeeLocker/LpLocker system. This module provides:
6
+ *
7
+ * - Fee dashboard data (claimable/claimed WETH, daily earnings)
8
+ * - Per-token fee breakdown
9
+ * - On-chain fee claiming via the Doppler `collectFees(poolId)` call
10
+ *
11
+ * All read operations use Bankr's public API (no authentication needed).
12
+ * Claiming requires a wallet client to sign transactions on-chain.
13
+ *
14
+ * Fee structure (Bankr/Doppler):
15
+ * - 1.2% swap fee on each trade
16
+ * - 57% to creator (feeRecipient)
17
+ * - ~36% to Bankr + partner
18
+ * - 5% to Doppler protocol
19
+ * - ~2% to ecosystem
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { BankrFeeClaimer } from '@clawnch/clawncher-sdk';
24
+ * import { createWalletClient, createPublicClient, http } from 'viem';
25
+ * import { privateKeyToAccount } from 'viem/accounts';
26
+ * import { base } from 'viem/chains';
27
+ *
28
+ * const account = privateKeyToAccount('0x...');
29
+ * const wallet = createWalletClient({ account, chain: base, transport: http() });
30
+ * const publicClient = createPublicClient({ chain: base, transport: http() });
31
+ *
32
+ * const claimer = new BankrFeeClaimer({ wallet, publicClient });
33
+ *
34
+ * // Check fees (read-only, no wallet needed)
35
+ * const dashboard = await BankrFeeClaimer.getCreatorFees(account.address);
36
+ * const tokenFees = await BankrFeeClaimer.getTokenFees('0xTokenAddress');
37
+ *
38
+ * // Claim all fees
39
+ * const result = await claimer.claimAll({ skipConfirmation: true });
40
+ * console.log(`Claimed ${result.successCount} tokens, ${result.totalWethClaimed} WETH`);
41
+ * ```
42
+ */
43
+ import { type WalletClient, type PublicClient, type Chain, type Account, type Transport, type Hash } from 'viem';
44
+ /** Claimable/claimed amounts for a single Bankr token */
45
+ export interface BankrTokenFees {
46
+ /** Token contract address */
47
+ tokenAddress: string;
48
+ /** Token name */
49
+ name: string;
50
+ /** Token symbol */
51
+ symbol: string;
52
+ /** Doppler pool ID (bytes32) */
53
+ poolId: string;
54
+ /** Initializer contract address (target for collectFees call) */
55
+ initializer: string;
56
+ /** Token labels for the pool pair */
57
+ token0Label: string;
58
+ token1Label: string;
59
+ /** Beneficiary share description (e.g. "57% creator") */
60
+ share: string;
61
+ /** Source protocol */
62
+ source: 'doppler' | 'clanker';
63
+ /** Claimable amounts (not yet claimed) */
64
+ claimable: {
65
+ token0: string;
66
+ token1: string;
67
+ };
68
+ /** Already claimed amounts */
69
+ claimed: {
70
+ token0: string;
71
+ token1: string;
72
+ count: number;
73
+ };
74
+ }
75
+ /** Daily earnings data point */
76
+ export interface DailyEarning {
77
+ date: string;
78
+ weth: string;
79
+ }
80
+ /** Fee dashboard data for a wallet */
81
+ export interface BankrFeeDashboard {
82
+ /** Wallet address */
83
+ address: string;
84
+ /** Number of days in the lookback period */
85
+ days: number;
86
+ /** Totals */
87
+ totals: {
88
+ claimableWeth: string;
89
+ claimedWeth: string;
90
+ claimCount: number;
91
+ };
92
+ /** Daily earnings over the lookback period */
93
+ dailyEarnings: DailyEarning[];
94
+ /** Per-token breakdown */
95
+ tokens: BankrTokenFees[];
96
+ }
97
+ /** Streaming progress update from beneficiary-fees endpoint */
98
+ export interface BankrScanProgress {
99
+ scanned: number;
100
+ total: number;
101
+ found?: number;
102
+ }
103
+ /** Result from beneficiary-fees scan */
104
+ export interface BankrBeneficiaryScan {
105
+ totalLaunches: number;
106
+ poolsWithShares: number;
107
+ tokens: BankrTokenFees[];
108
+ }
109
+ /** Result of claiming fees for a single token */
110
+ export interface BankrClaimTokenResult {
111
+ /** Token address */
112
+ tokenAddress: string;
113
+ /** Token symbol */
114
+ symbol: string;
115
+ /** Whether the claim succeeded */
116
+ success: boolean;
117
+ /** Transaction hash (if sent) */
118
+ txHash?: Hash;
119
+ /** Error message if failed */
120
+ error?: string;
121
+ }
122
+ /** Result of a batch claim operation */
123
+ export interface BankrBatchClaimResult {
124
+ /** Results for each token */
125
+ results: BankrClaimTokenResult[];
126
+ /** Number of successful claims */
127
+ successCount: number;
128
+ /** Number of failed claims */
129
+ failureCount: number;
130
+ /** Total WETH claimed (approximate, from pre-claim estimates) */
131
+ totalWethEstimate: string;
132
+ }
133
+ /** Configuration for BankrFeeClaimer */
134
+ export interface BankrFeeClaimerConfig {
135
+ /** Wallet client for signing claim transactions */
136
+ wallet: WalletClient<Transport, Chain, Account>;
137
+ /** Public client for gas estimation and tx confirmation */
138
+ publicClient: PublicClient;
139
+ /** Bankr API base URL (default: 'https://api.bankr.bot') */
140
+ apiBase?: string;
141
+ }
142
+ /**
143
+ * Fee checking and claiming for Bankr-deployed tokens.
144
+ *
145
+ * Static methods are read-only and don't require a wallet.
146
+ * Instance methods require a wallet for signing claim transactions.
147
+ */
148
+ export declare class BankrFeeClaimer {
149
+ readonly wallet: WalletClient<Transport, Chain, Account>;
150
+ readonly publicClient: PublicClient;
151
+ private readonly apiBase;
152
+ constructor(config: BankrFeeClaimerConfig);
153
+ /**
154
+ * Get fee dashboard for a wallet (creator role).
155
+ *
156
+ * Shows claimable/claimed WETH, daily earnings chart data, and per-token breakdown.
157
+ * Public endpoint — no authentication required.
158
+ *
159
+ * @param address - Wallet address to check fees for
160
+ * @param days - Lookback period in days (1-90, default 30)
161
+ * @param apiBase - Custom API base URL
162
+ */
163
+ static getCreatorFees(address: string, days?: number, apiBase?: string): Promise<BankrFeeDashboard>;
164
+ /**
165
+ * Get fee data for a specific token.
166
+ *
167
+ * Looks up the token's creator beneficiary and returns their fee dashboard.
168
+ * Public endpoint — no authentication required.
169
+ *
170
+ * @param tokenAddress - Token contract address
171
+ * @param days - Lookback period in days (1-90, default 30)
172
+ * @param apiBase - Custom API base URL
173
+ */
174
+ static getTokenFees(tokenAddress: string, days?: number, apiBase?: string): Promise<BankrFeeDashboard>;
175
+ /**
176
+ * Scan all launches for claimable fees where a wallet is ANY beneficiary role
177
+ * (creator, partner, redirect, etc.).
178
+ *
179
+ * This is a heavier call that scans all Bankr launches server-side.
180
+ * Supports NDJSON streaming for progress updates.
181
+ *
182
+ * Public endpoint — no authentication required.
183
+ *
184
+ * @param address - Wallet address to scan
185
+ * @param onProgress - Optional callback for streaming progress updates
186
+ * @param apiBase - Custom API base URL
187
+ */
188
+ static getBeneficiaryFees(address: string, onProgress?: (progress: BankrScanProgress) => void, apiBase?: string): Promise<BankrBeneficiaryScan>;
189
+ /**
190
+ * Claim fees for a single Bankr token.
191
+ *
192
+ * Calls `collectFees(poolId)` on the token's initializer contract.
193
+ * The Doppler protocol sends your share of accumulated fees to your wallet.
194
+ *
195
+ * @param token - Token fee data (from getBeneficiaryFees or getCreatorFees)
196
+ */
197
+ claimToken(token: BankrTokenFees): Promise<BankrClaimTokenResult>;
198
+ /**
199
+ * Claim fees for multiple Bankr tokens in sequence.
200
+ *
201
+ * Scans all launches where the wallet is a beneficiary, then claims
202
+ * each token with claimable fees. Uses explicit nonce management for
203
+ * reliable sequential submission.
204
+ *
205
+ * @param options - Claim options
206
+ * @param options.onProgress - Callback for scan progress updates
207
+ * @param options.onClaim - Callback when each token claim completes
208
+ * @param options.tokens - Optional pre-fetched token list (skips API scan)
209
+ */
210
+ claimAll(options?: {
211
+ onProgress?: (progress: BankrScanProgress) => void;
212
+ onClaim?: (result: BankrClaimTokenResult, index: number, total: number) => void;
213
+ tokens?: BankrTokenFees[];
214
+ }): Promise<BankrBatchClaimResult>;
215
+ }
216
+ //# sourceMappingURL=bankr-fees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bankr-fees.d.ts","sourceRoot":"","sources":["../src/bankr-fees.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,IAAI,EAGV,MAAM,MAAM,CAAC;AA6Bd,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,0CAA0C;IAC1C,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,8BAA8B;IAC9B,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;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CAAC,EAAE,cAAc,EAAE,CAAC;KAC3B,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAyDnC"}
@@ -0,0 +1,317 @@
1
+ /**
2
+ * BankrFeeClaimer - Fee checking and claiming for Bankr-deployed tokens
3
+ *
4
+ * Bankr tokens use the Doppler protocol for fee distribution, which is
5
+ * different from Clanker's FeeLocker/LpLocker system. This module provides:
6
+ *
7
+ * - Fee dashboard data (claimable/claimed WETH, daily earnings)
8
+ * - Per-token fee breakdown
9
+ * - On-chain fee claiming via the Doppler `collectFees(poolId)` call
10
+ *
11
+ * All read operations use Bankr's public API (no authentication needed).
12
+ * Claiming requires a wallet client to sign transactions on-chain.
13
+ *
14
+ * Fee structure (Bankr/Doppler):
15
+ * - 1.2% swap fee on each trade
16
+ * - 57% to creator (feeRecipient)
17
+ * - ~36% to Bankr + partner
18
+ * - 5% to Doppler protocol
19
+ * - ~2% to ecosystem
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { BankrFeeClaimer } from '@clawnch/clawncher-sdk';
24
+ * import { createWalletClient, createPublicClient, http } from 'viem';
25
+ * import { privateKeyToAccount } from 'viem/accounts';
26
+ * import { base } from 'viem/chains';
27
+ *
28
+ * const account = privateKeyToAccount('0x...');
29
+ * const wallet = createWalletClient({ account, chain: base, transport: http() });
30
+ * const publicClient = createPublicClient({ chain: base, transport: http() });
31
+ *
32
+ * const claimer = new BankrFeeClaimer({ wallet, publicClient });
33
+ *
34
+ * // Check fees (read-only, no wallet needed)
35
+ * const dashboard = await BankrFeeClaimer.getCreatorFees(account.address);
36
+ * const tokenFees = await BankrFeeClaimer.getTokenFees('0xTokenAddress');
37
+ *
38
+ * // Claim all fees
39
+ * const result = await claimer.claimAll({ skipConfirmation: true });
40
+ * console.log(`Claimed ${result.successCount} tokens, ${result.totalWethClaimed} WETH`);
41
+ * ```
42
+ */
43
+ import { encodeFunctionData, } from 'viem';
44
+ import { base } from 'viem/chains';
45
+ import { ClawnchErrorCode, ClawnchDeployError } from './errors.js';
46
+ // ============================================================================
47
+ // Constants
48
+ // ============================================================================
49
+ const BANKR_API_BASE = 'https://api.bankr.bot';
50
+ const USER_AGENT = 'clawncher-sdk';
51
+ /** ABI for Doppler's collectFees function on the initializer contract */
52
+ const COLLECT_FEES_ABI = [
53
+ {
54
+ type: 'function',
55
+ name: 'collectFees',
56
+ stateMutability: 'nonpayable',
57
+ inputs: [{ name: 'poolId', type: 'bytes32' }],
58
+ outputs: [
59
+ { name: 'fees0', type: 'uint128' },
60
+ { name: 'fees1', type: 'uint128' },
61
+ ],
62
+ },
63
+ ];
64
+ // ============================================================================
65
+ // API helpers
66
+ // ============================================================================
67
+ async function fetchJson(url) {
68
+ const res = await fetch(url, {
69
+ headers: { 'User-Agent': USER_AGENT },
70
+ });
71
+ if (!res.ok) {
72
+ let msg;
73
+ try {
74
+ const body = await res.json();
75
+ msg = body.message || body.error || res.statusText;
76
+ }
77
+ catch {
78
+ msg = res.statusText;
79
+ }
80
+ throw new ClawnchDeployError(ClawnchErrorCode.RPC_ERROR, `Bankr API error (${res.status}): ${msg}`);
81
+ }
82
+ return res.json();
83
+ }
84
+ // ============================================================================
85
+ // BankrFeeClaimer
86
+ // ============================================================================
87
+ /**
88
+ * Fee checking and claiming for Bankr-deployed tokens.
89
+ *
90
+ * Static methods are read-only and don't require a wallet.
91
+ * Instance methods require a wallet for signing claim transactions.
92
+ */
93
+ export class BankrFeeClaimer {
94
+ wallet;
95
+ publicClient;
96
+ apiBase;
97
+ constructor(config) {
98
+ this.wallet = config.wallet;
99
+ this.publicClient = config.publicClient;
100
+ this.apiBase = config.apiBase || BANKR_API_BASE;
101
+ }
102
+ // ==========================================================================
103
+ // Static read-only methods (no wallet needed)
104
+ // ==========================================================================
105
+ /**
106
+ * Get fee dashboard for a wallet (creator role).
107
+ *
108
+ * Shows claimable/claimed WETH, daily earnings chart data, and per-token breakdown.
109
+ * Public endpoint — no authentication required.
110
+ *
111
+ * @param address - Wallet address to check fees for
112
+ * @param days - Lookback period in days (1-90, default 30)
113
+ * @param apiBase - Custom API base URL
114
+ */
115
+ static async getCreatorFees(address, days, apiBase = BANKR_API_BASE) {
116
+ const params = days ? `?days=${days}` : '';
117
+ return fetchJson(`${apiBase}/public/doppler/creator-fees/${address}${params}`);
118
+ }
119
+ /**
120
+ * Get fee data for a specific token.
121
+ *
122
+ * Looks up the token's creator beneficiary and returns their fee dashboard.
123
+ * Public endpoint — no authentication required.
124
+ *
125
+ * @param tokenAddress - Token contract address
126
+ * @param days - Lookback period in days (1-90, default 30)
127
+ * @param apiBase - Custom API base URL
128
+ */
129
+ static async getTokenFees(tokenAddress, days, apiBase = BANKR_API_BASE) {
130
+ const params = days ? `?days=${days}` : '';
131
+ return fetchJson(`${apiBase}/public/doppler/token-fees/${tokenAddress}${params}`);
132
+ }
133
+ /**
134
+ * Scan all launches for claimable fees where a wallet is ANY beneficiary role
135
+ * (creator, partner, redirect, etc.).
136
+ *
137
+ * This is a heavier call that scans all Bankr launches server-side.
138
+ * Supports NDJSON streaming for progress updates.
139
+ *
140
+ * Public endpoint — no authentication required.
141
+ *
142
+ * @param address - Wallet address to scan
143
+ * @param onProgress - Optional callback for streaming progress updates
144
+ * @param apiBase - Custom API base URL
145
+ */
146
+ static async getBeneficiaryFees(address, onProgress, apiBase = BANKR_API_BASE) {
147
+ const url = `${apiBase}/public/doppler/beneficiary-fees/${address}`;
148
+ if (onProgress) {
149
+ // Use NDJSON streaming for progress updates
150
+ const res = await fetch(url, {
151
+ headers: {
152
+ 'User-Agent': USER_AGENT,
153
+ 'Accept': 'application/x-ndjson',
154
+ },
155
+ });
156
+ if (!res.ok) {
157
+ const body = await res.json().catch(() => ({ message: res.statusText }));
158
+ throw new ClawnchDeployError(ClawnchErrorCode.RPC_ERROR, `Bankr API error (${res.status}): ${body.message || body.error || res.statusText}`);
159
+ }
160
+ if (!res.body) {
161
+ throw new ClawnchDeployError(ClawnchErrorCode.RPC_ERROR, 'No response body from Bankr API');
162
+ }
163
+ const reader = res.body.getReader();
164
+ const decoder = new TextDecoder();
165
+ let buffer = '';
166
+ let result = null;
167
+ while (true) {
168
+ const { done, value } = await reader.read();
169
+ if (done)
170
+ break;
171
+ buffer += decoder.decode(value, { stream: true });
172
+ const lines = buffer.split('\n');
173
+ buffer = lines.pop() ?? '';
174
+ for (const line of lines) {
175
+ if (!line.trim())
176
+ continue;
177
+ const msg = JSON.parse(line);
178
+ if (msg.type === 'progress') {
179
+ onProgress(msg);
180
+ }
181
+ else if (msg.type === 'result') {
182
+ result = msg.data;
183
+ }
184
+ else if (msg.type === 'error') {
185
+ throw new ClawnchDeployError(ClawnchErrorCode.RPC_ERROR, msg.message || 'Server error during streaming');
186
+ }
187
+ }
188
+ }
189
+ if (!result) {
190
+ throw new ClawnchDeployError(ClawnchErrorCode.RPC_ERROR, 'No result received from Bankr API');
191
+ }
192
+ return result;
193
+ }
194
+ // Non-streaming (simple JSON response)
195
+ return fetchJson(url);
196
+ }
197
+ // ==========================================================================
198
+ // Instance methods (require wallet)
199
+ // ==========================================================================
200
+ /**
201
+ * Claim fees for a single Bankr token.
202
+ *
203
+ * Calls `collectFees(poolId)` on the token's initializer contract.
204
+ * The Doppler protocol sends your share of accumulated fees to your wallet.
205
+ *
206
+ * @param token - Token fee data (from getBeneficiaryFees or getCreatorFees)
207
+ */
208
+ async claimToken(token) {
209
+ if (!token.initializer || !token.poolId) {
210
+ return {
211
+ tokenAddress: token.tokenAddress,
212
+ symbol: token.symbol,
213
+ success: false,
214
+ error: 'Missing initializer or poolId — cannot build claim transaction',
215
+ };
216
+ }
217
+ try {
218
+ const data = encodeFunctionData({
219
+ abi: COLLECT_FEES_ABI,
220
+ functionName: 'collectFees',
221
+ args: [token.poolId],
222
+ });
223
+ // Estimate gas with 30% buffer
224
+ const gasEstimate = await this.publicClient.estimateGas({
225
+ account: this.wallet.account.address,
226
+ to: token.initializer,
227
+ data,
228
+ });
229
+ const gasWithBuffer = (gasEstimate * 130n) / 100n;
230
+ // Send transaction
231
+ const txHash = await this.wallet.sendTransaction({
232
+ to: token.initializer,
233
+ data,
234
+ gas: gasWithBuffer,
235
+ chain: base,
236
+ });
237
+ // Wait for confirmation
238
+ const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
239
+ return {
240
+ tokenAddress: token.tokenAddress,
241
+ symbol: token.symbol,
242
+ success: receipt.status === 'success',
243
+ txHash,
244
+ error: receipt.status !== 'success' ? 'Transaction reverted' : undefined,
245
+ };
246
+ }
247
+ catch (err) {
248
+ return {
249
+ tokenAddress: token.tokenAddress,
250
+ symbol: token.symbol,
251
+ success: false,
252
+ error: err instanceof Error ? err.message : String(err),
253
+ };
254
+ }
255
+ }
256
+ /**
257
+ * Claim fees for multiple Bankr tokens in sequence.
258
+ *
259
+ * Scans all launches where the wallet is a beneficiary, then claims
260
+ * each token with claimable fees. Uses explicit nonce management for
261
+ * reliable sequential submission.
262
+ *
263
+ * @param options - Claim options
264
+ * @param options.onProgress - Callback for scan progress updates
265
+ * @param options.onClaim - Callback when each token claim completes
266
+ * @param options.tokens - Optional pre-fetched token list (skips API scan)
267
+ */
268
+ async claimAll(options) {
269
+ const walletAddress = this.wallet.account.address;
270
+ // Step 1: Get claimable tokens
271
+ let tokens;
272
+ if (options?.tokens) {
273
+ tokens = options.tokens;
274
+ }
275
+ else {
276
+ const scan = await BankrFeeClaimer.getBeneficiaryFees(walletAddress, options?.onProgress, this.apiBase);
277
+ tokens = scan.tokens;
278
+ }
279
+ // Filter to tokens with claimable fees and valid initializer
280
+ const parseAmount = (s) => parseFloat(s.replace(/^[<>]/, '')) || 0;
281
+ const claimable = tokens.filter(t => {
282
+ if (!t.initializer || !t.poolId)
283
+ return false;
284
+ const wethIsToken0 = t.token0Label === 'WETH';
285
+ const wethAmount = wethIsToken0 ? t.claimable.token0 : t.claimable.token1;
286
+ const tokenAmount = wethIsToken0 ? t.claimable.token1 : t.claimable.token0;
287
+ return parseAmount(wethAmount) > 0 || parseAmount(tokenAmount) > 0;
288
+ });
289
+ if (claimable.length === 0) {
290
+ return {
291
+ results: [],
292
+ successCount: 0,
293
+ failureCount: 0,
294
+ totalWethEstimate: '0',
295
+ };
296
+ }
297
+ // Estimate total WETH
298
+ const totalWeth = claimable.reduce((sum, t) => {
299
+ const wethIsToken0 = t.token0Label === 'WETH';
300
+ return sum + parseAmount(wethIsToken0 ? t.claimable.token0 : t.claimable.token1);
301
+ }, 0);
302
+ // Step 2: Claim each token
303
+ const results = [];
304
+ for (let i = 0; i < claimable.length; i++) {
305
+ const result = await this.claimToken(claimable[i]);
306
+ results.push(result);
307
+ options?.onClaim?.(result, i, claimable.length);
308
+ }
309
+ return {
310
+ results,
311
+ successCount: results.filter(r => r.success).length,
312
+ failureCount: results.filter(r => !r.success).length,
313
+ totalWethEstimate: totalWeth.toFixed(6),
314
+ };
315
+ }
316
+ }
317
+ //# sourceMappingURL=bankr-fees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bankr-fees.js","sourceRoot":"","sources":["../src/bankr-fees.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAQL,kBAAkB,GACnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC,yEAAyE;AACzE,MAAM,gBAAgB,GAAG;IACvB;QACE,IAAI,EAAE,UAAmB;QACzB,IAAI,EAAE,aAAa;QACnB,eAAe,EAAE,YAAqB;QACtC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7C,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,OAAO,EAAE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