clanker-sdk 1.8.0 → 3.1.1

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 CHANGED
@@ -1,277 +1,122 @@
1
- # Clanker SDK
1
+ # Clanker SDK v3.1.0
2
2
 
3
- A lightweight TypeScript SDK for interacting with the Clanker API. Deploy tokens, manage splits, and track rewards with ease.
3
+ A lightweight TypeScript SDK for deploying tokens using Clanker v3.1.0. This SDK provides a simple interface for deploying tokens with configurable market caps, vaulting, and reward distributions.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install clanker-sdk
8
+ npm install clanker-sdk viem
9
9
  ```
10
10
 
11
- ## Getting Started
12
-
13
- ### 1. Request API Access
14
- Currently, API access is granted on a case-by-case basis to interested platforms. To request access, please contact:
15
- - Telegram: `btayengco`
16
- - Warpcast: `btayengco`
17
-
18
- We'll evaluate each request individually as we carefully scale our platform access.
19
-
20
- ### 2. Environment Setup
21
- Create a `.env` file in your project root:
22
-
23
- ```bash
24
- # Clanker API Key (required for token operations)
25
- CLANKER_API_KEY=your_api_key_here
26
-
27
- # Dune Analytics API Key (optional)
28
- DUNE_API_KEY=your_dune_api_key_here
29
-
30
- # The Graph API Key (optional)
31
- GRAPH_API_KEY=your_graph_api_key_here
32
-
33
- # CoinGecko Pro API Key (optional)
34
- COINGECKO_API_KEY=your_coingecko_api_key_here
35
- ```
36
-
37
- Copy the `.env.example` file to get started:
38
-
39
- ```bash
40
- cp .env.example .env
41
- ```
42
-
43
- Make sure to add your API keys to the `.env` file and never commit it to version control.
44
-
45
- ### 3. Getting Your API Keys
46
-
47
- #### Clanker API Key
48
- Contact `btayengco` on Telegram or Warpcast to request access.
49
-
50
- #### Dune Analytics API Key (Optional)
51
- To access market data features:
52
- 1. Visit [dune.xyz](https://dune.xyz) and sign up for an account
53
- 2. Go to your [API Keys page](https://dune.com/settings/api)
54
- 3. Create a new API key
55
- 4. Add the key to your `.env` file as `DUNE_API_KEY`
56
-
57
- Note: Dune API access requires a paid subscription. Check their [pricing page](https://dune.com/pricing) for more details.
58
-
59
- #### The Graph API Key (Optional)
60
- To access Uniswap data:
61
- 1. Visit [thegraph.com](https://thegraph.com) and create an account
62
- 2. Go to your billing settings
63
- 3. Create an API key
64
- 4. Add the key to your `.env` file as `GRAPH_API_KEY`
65
-
66
- #### CoinGecko Pro API Key (Optional)
67
- To access CoinGecko's comprehensive market data:
68
- 1. Visit [CoinGecko](https://www.coingecko.com) and create an account
69
- 2. Go to your [Developer Dashboard](https://www.coingecko.com/en/api/pricing)
70
- 3. Choose a subscription plan and create an API key
71
- 4. Add the key to your `.env` file as `COINGECKO_API_KEY`
72
-
73
- For detailed instructions on setting up your CoinGecko API key, visit their [official documentation](https://docs.coingecko.com/reference/setting-up-your-api-key).
74
-
75
- ### 4. Basic Usage
11
+ ## Usage
76
12
 
77
13
  ```typescript
78
- import * as dotenv from 'dotenv';
79
- import { ClankerSDK, MarketDataClient } from 'clanker-sdk';
80
-
81
- // Load environment variables
82
- dotenv.config();
83
-
84
- // Initialize market data client (CoinGecko API key required for token prices)
85
- const marketData = new MarketDataClient(
86
- process.env.DUNE_API_KEY, // Optional: For Dune Analytics data
87
- process.env.GRAPH_API_KEY, // Optional: For Uniswap data
88
- process.env.COINGECKO_API_KEY // Required for token price lookups
89
- );
90
-
91
- // Example 1: Get price for your token on Base/Ethereum
92
- const tokenAddress = '0x1234567890123456789012345678901234567890'; // Your token address
93
-
94
- // Direct CoinGecko API usage
95
- const url = 'https://pro-api.coingecko.com/api/v3/simple/token_price/id';
96
- const options = {
97
- method: 'GET',
98
- headers: {
99
- 'accept': 'application/json',
100
- 'x-cg-pro-api-key': process.env.COINGECKO_API_KEY
101
- }
102
- };
103
-
104
- // You can use the API directly
105
- fetch(url, options)
106
- .then(res => res.json())
107
- .then(json => console.log('Token price:', json))
108
- .catch(err => console.error('Error:', err));
109
-
110
- // Or use our SDK wrapper for easier handling
111
- const tokenPrices = await marketData.getGeckoTokenPrice({
112
- 'ethereum': [tokenAddress] // For tokens on Base/Ethereum
14
+ import { createWalletClient, http } from 'viem';
15
+ import { privateKeyToAccount } from 'viem/accounts';
16
+ import { base } from 'viem/chains';
17
+ import { Clanker } from 'clanker-sdk';
18
+
19
+ // Initialize wallet
20
+ const account = privateKeyToAccount('0x...');
21
+ const wallet = createWalletClient({
22
+ account,
23
+ chain: base,
24
+ transport: http()
113
25
  });
114
- console.log('Token prices:', tokenPrices);
115
-
116
- // Example 2: Other SDK features (optional)
117
- const clanker = new ClankerSDK(process.env.CLANKER_API_KEY);
118
26
 
119
- // Deploy a token
120
- const token = await clanker.deployToken({
121
- name: "Community Token",
122
- symbol: "CMTY",
123
- image: "https://example.com/token.png",
124
- requestorAddress: "0x1234567890123456789012345678901234567890"
27
+ // Initialize Clanker SDK
28
+ const clanker = new Clanker({
29
+ wallet,
30
+ factoryAddress: '0x2A787b2362021cC3eEa3C24C4748a6cD5B687382', // Clanker factory address on Base
31
+ chainId: base.id
125
32
  });
126
33
 
127
- // Get additional market data
128
- const additionalData = await Promise.all([
129
- marketData.getClankerDictionary(),
130
- marketData.getDexPairStats('ethereum', token.contractAddress),
131
- marketData.getUniswapData([token.contractAddress])
132
- ]);
133
- ```
134
-
135
- ## Features
136
-
137
- - 🚀 Token Deployment
138
- - 💰 Split Management
139
- - 📊 Rewards Tracking
140
- - 🔒 Type-safe API
141
- - 📝 Full TypeScript Support
142
- - 📈 Market Data Analytics
143
-
144
- ## Market Data Features
145
-
146
- The SDK provides access to comprehensive market data through multiple sources:
147
-
148
- ### Clanker Top Performers View
149
- Access our curated list of top-performing Clanker tokens using our materialized view:
150
-
151
- ```sql
152
- -- Query our materialized view for top Clankers on Base & Farcaster
153
- -- Filtered for high-quality tokens meeting these criteria:
154
- -- - Market Cap > $100,000
155
- -- - 24hr Volume > $10,000
156
- -- - 3-day Volume > $50,000
157
- SELECT *
158
- FROM dune.clanker_protection_team.result_clnkr_100_k_mkt_share_2_0
159
- ```
160
-
161
- This view provides real-time insights into the best-performing tokens deployed through Clanker on Base & Farcaster.
162
-
163
- ### CoinGecko Market Data
164
- Get token prices by contract address on Base/Ethereum:
165
-
166
- ```typescript
167
- // Example 1: Get price for your token (RECOMMENDED)
168
- const tokenAddress = '0x1234567890123456789012345678901234567890'; // Your token address
169
-
170
- // The SDK uses this CoinGecko endpoint under the hood:
171
- // GET https://pro-api.coingecko.com/api/v3/simple/token_price/id
172
- // You can also use it directly:
173
- const url = 'https://pro-api.coingecko.com/api/v3/simple/token_price/id';
174
- const options = {
175
- method: 'GET',
176
- headers: {
177
- 'accept': 'application/json',
178
- 'x-cg-pro-api-key': process.env.COINGECKO_API_KEY
34
+ // Deploy a token
35
+ const tokenAddress = await clanker.deploy({
36
+ tokenConfig: {
37
+ name: 'My Token',
38
+ symbol: 'MTK',
39
+ salt: '0x...', // bytes32 for address customization
40
+ image: 'ipfs://...',
41
+ metadata: 'ipfs://...',
42
+ context: 'Deployed via SDK',
43
+ originatingChainId: BigInt(base.id)
44
+ },
45
+ poolConfig: {
46
+ pairedToken: '0x4200000000000000000000000000000000000006', // WETH on Base
47
+ initialMarketCapInPairedToken: BigInt(10) * BigInt(10)**BigInt(18) // 10 WETH initial mcap
48
+ },
49
+ // Optional: Lock tokens in vault
50
+ vaultConfig: {
51
+ vaultPercentage: 30, // 30% of supply
52
+ vaultDuration: BigInt(30 * 24 * 60 * 60) // 30 days in seconds
53
+ },
54
+ // Optional: Perform initial buy with ETH
55
+ initialBuyConfig: {
56
+ pairedTokenPoolFee: 3000, // 0.3% fee tier for ETH -> pairedToken swap
57
+ pairedTokenSwapAmountOutMinimum: BigInt('1000000000000000000') // 1 ETH
58
+ },
59
+ rewardsConfig: {
60
+ creatorReward: BigInt(80), // 80% of remaining rewards (after 20% team cut)
61
+ creatorAdmin: '0x...', // Address to manage creator's locked tokens
62
+ creatorRewardRecipient: '0x...', // Address to receive creator's trading fees
63
+ interfaceAdmin: '0x...', // Address to manage interface's trading fees
64
+ interfaceRewardRecipient: '0x...' // Address to receive interface's trading fees
179
65
  }
180
- };
181
-
182
- // Direct API usage
183
- fetch(url, options)
184
- .then(res => res.json())
185
- .then(json => console.log(json))
186
- .catch(err => console.error(err));
187
-
188
- // Or use our SDK wrapper (handles authentication and error handling)
189
- const tokenPrices = await marketData.getGeckoTokenPrice({
190
- 'ethereum': [tokenAddress] // For tokens on Base/Ethereum
191
66
  });
192
- ```
193
67
 
194
- This endpoint is specifically designed for getting token prices on Base/Ethereum. For other data sources or chains, see below.
195
-
196
- ### Clanker Dictionary
197
- Get detailed information about all Clanker tokens:
198
- ```typescript
199
- const dictionary = await marketData.getClankerDictionary();
200
- // Returns: Array of tokens with market cap, volume, and liquidity data
68
+ console.log('Token deployed at:', tokenAddress);
201
69
  ```
202
70
 
203
- ### DEX Pair Statistics
204
- Get detailed DEX pair statistics for any token:
205
- ```typescript
206
- const dexStats = await marketData.getDexPairStats(
207
- 'ethereum', // Chain name (ethereum, arbitrum, etc.)
208
- '0x1234...' // Optional: Token address to filter by
209
- );
210
- // Returns: Detailed DEX pair statistics including:
211
- // - Trading volumes (24h, 7d, 30d)
212
- // - Liquidity
213
- // - Volume/Liquidity ratios
214
- ```
71
+ ## Features
215
72
 
216
- ### Uniswap Data
217
- Get detailed Uniswap pool data for tokens (requires Graph API key):
218
- ```typescript
219
- const uniswapData = await marketData.getUniswapData(
220
- ['0x1234...', '0x5678...'], // Array of token addresses
221
- 15_000_000 // Optional: Block number for historical data
222
- );
223
- // Returns: Array of tokens with:
224
- // - WETH price
225
- // - Transaction count
226
- // - Volume in USD
227
- // - Decimals
228
- ```
73
+ - Deploy tokens with customizable parameters
74
+ - Calculate initial token price based on desired market cap in paired token
75
+ - Support for token vaulting with configurable duration and percentage
76
+ - Configure reward distribution between creator and interface
77
+ - Support for initial token buys with ETH
78
+ - Super-chain compatibility for cross-chain deployments
229
79
 
230
- Supported chains for DEX stats:
231
- - ethereum
232
- - arbitrum
233
- - base
234
- - bnb
235
- - celo
236
- - fantom
237
- - gnosis
238
- - optimism
239
- - polygon
240
- - scroll
241
- - zk_sync
242
- - solana
80
+ ## Configuration
243
81
 
244
- ## Examples
82
+ ### TokenConfig
83
+ - `name`: Token name
84
+ - `symbol`: Token symbol
85
+ - `salt`: Address salt value for token address customization
86
+ - `image`: Token image URI
87
+ - `metadata`: Token metadata URI
88
+ - `context`: Additional deployment context
89
+ - `originatingChainId`: Chain ID where token supply is deployed
245
90
 
246
- Check out the `examples/` directory for more usage examples:
91
+ ### PoolConfig
92
+ - `pairedToken`: Token to pair with (e.g., WETH)
93
+ - `initialMarketCapInPairedToken`: Desired initial market cap in paired token units
247
94
 
248
- - Token Deployment (`examples/token-deployment.ts`)
249
- - Rewards and Fees (`examples/rewards-and-fees.ts`)
250
- - Market Data (`examples/market-data.ts`)
95
+ ### VaultConfig (Optional)
96
+ - `vaultPercentage`: Percentage of supply to lock (max 30)
97
+ - `vaultDuration`: Lock duration in seconds (min 30 days)
251
98
 
252
- Run examples using:
99
+ ### InitialBuyConfig (Optional)
100
+ - `pairedTokenPoolFee`: Fee tier for ETH -> pairedToken swap
101
+ - `pairedTokenSwapAmountOutMinimum`: Minimum amount of paired tokens to receive
253
102
 
254
- ```bash
255
- npm run example:deploy # Run token deployment example
256
- npm run example:rewards # Run rewards tracking example
257
- npm run example:market # Run market data example
258
- npm run example # Run all examples
259
- ```
103
+ ### RewardsConfig
104
+ - `creatorReward`: Creator's percentage of remaining rewards after team cut (max 80)
105
+ - `creatorAdmin`: Address to manage creator's locked tokens
106
+ - `creatorRewardRecipient`: Address to receive creator's trading fees
107
+ - `interfaceAdmin`: Address to manage interface's trading fees
108
+ - `interfaceRewardRecipient`: Address to receive interface's trading fees
260
109
 
261
- ## Development
110
+ ## Super-chain Compatibility
262
111
 
263
- ```bash
264
- npm install # Install dependencies
265
- npm run build # Build the SDK
266
- npm test # Run tests
267
- npm run lint # Run linter
268
- npm run format # Format code
269
- ```
112
+ The SDK supports deploying tokens that are compatible with the super-chain architecture. When deploying a token:
270
113
 
271
- ## Contributing
114
+ 1. Set `originatingChainId` to the chain ID where the token's supply should be minted
115
+ 2. Deploy the token on other super-chain networks using the same parameters
116
+ 3. Use the super-chain's bridge to migrate tokens between networks
272
117
 
273
- Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) for details.
118
+ Note: Tokens can only be minted with supply on the originating chain. Make sure the target chains are part of the same super-chain cluster.
274
119
 
275
120
  ## License
276
121
 
277
- ISC © Clanker Team
122
+ MIT
package/dist/index.d.mts CHANGED
@@ -1,143 +1,56 @@
1
- interface Token {
2
- chainId: number;
3
- address: string;
4
- symbol: string;
5
- decimals: number;
6
- name: string;
7
- }
8
- interface DeployTokenOptions {
1
+ import { Address, WalletClient, Account } from 'viem';
2
+
3
+ interface TokenConfig {
9
4
  name: string;
10
5
  symbol: string;
6
+ salt: `0x${string}`;
11
7
  image: string;
12
- requestorAddress: string;
13
- requestKey?: string;
14
- }
15
- interface DeployTokenWithSplitsOptions extends DeployTokenOptions {
16
- splitAddress: string;
17
- }
18
- interface UncollectedFeesResponse {
19
- lockerAddress: string;
20
- lpNftId: number;
21
- token0UncollectedRewards: string;
22
- token1UncollectedRewards: string;
23
- token0: Token;
24
- token1: Token;
25
- }
26
- interface DeployedToken {
27
- id: number;
28
- created_at: string;
29
- tx_hash: string;
30
- requestor_fid: number;
31
- contract_address: string;
32
- name: string;
33
- symbol: string;
34
- img_url: string | null;
35
- pool_address: string;
36
- cast_hash: string;
37
- type: string;
38
- pair: string;
39
- }
40
- interface DeployedTokensResponse {
41
- data: DeployedToken[];
42
- hasMore: boolean;
43
- total: number;
44
- }
45
- interface EstimatedRewardsResponse {
46
- userRewards: number;
47
- }
48
- declare class ClankerError extends Error {
49
- readonly code?: string | undefined;
50
- readonly status?: number | undefined;
51
- readonly details?: any | undefined;
52
- constructor(message: string, code?: string | undefined, status?: number | undefined, details?: any | undefined);
53
- }
54
-
55
- declare class ClankerSDK {
56
- private readonly api;
57
- private readonly baseURL;
58
- constructor(apiKey: string);
59
- getEstimatedUncollectedFees(contractAddress: string): Promise<UncollectedFeesResponse>;
60
- deployToken(options: DeployTokenOptions): Promise<DeployedToken>;
61
- deployTokenWithSplits(options: DeployTokenWithSplitsOptions): Promise<DeployedToken>;
62
- fetchDeployedByAddress(address: string, page?: number): Promise<DeployedTokensResponse>;
63
- getEstimatedRewardsByPoolAddress(poolAddress: string): Promise<EstimatedRewardsResponse>;
64
- getClankerByAddress(address: string): Promise<DeployedToken>;
65
- private generateRequestKey;
66
- private isValidAddress;
67
- private validateDeployOptions;
8
+ metadata: string;
9
+ context: string;
10
+ originatingChainId: bigint;
11
+ }
12
+ interface VaultConfig {
13
+ vaultPercentage: number;
14
+ vaultDuration: bigint;
15
+ }
16
+ interface PoolConfig {
17
+ pairedToken: Address;
18
+ initialMarketCapInPairedToken: bigint;
19
+ }
20
+ interface InitialBuyConfig {
21
+ pairedTokenPoolFee: number;
22
+ pairedTokenSwapAmountOutMinimum: bigint;
23
+ }
24
+ interface RewardsConfig {
25
+ creatorReward: bigint;
26
+ creatorAdmin: Address;
27
+ creatorRewardRecipient: Address;
28
+ interfaceAdmin: Address;
29
+ interfaceRewardRecipient: Address;
30
+ }
31
+ interface DeploymentConfig {
32
+ tokenConfig: TokenConfig;
33
+ vaultConfig?: VaultConfig;
34
+ poolConfig: PoolConfig;
35
+ initialBuyConfig?: InitialBuyConfig;
36
+ rewardsConfig: RewardsConfig;
37
+ }
38
+ interface ClankerConfig {
39
+ wallet: WalletClient & {
40
+ account: Account;
41
+ };
42
+ factoryAddress: Address;
43
+ chainId: number;
68
44
  }
69
45
 
70
- interface ClankerMarketData {
71
- name: string;
72
- symbol: string;
73
- marketCap?: number;
74
- volume24h?: number;
75
- volume7d?: number;
76
- liquidity?: number;
77
- }
78
- interface DexPairStats {
79
- token_a_address: string;
80
- token_a_symbol: string;
81
- token_b_address: string;
82
- token_b_symbol: string;
83
- volume_24h: number;
84
- volume_7d: number;
85
- volume_30d: number;
86
- liquidity: number;
87
- volume_to_liquidity_ratio: number;
88
- }
89
- interface GraphToken {
90
- contractAddress: string;
91
- decimals: number;
92
- transactionCount: number;
93
- volumeUSD: number;
94
- priceWETH: number;
95
- }
96
- interface CoinGeckoTokenData {
97
- price: number;
98
- marketCap: number;
99
- volume24h: number;
100
- priceChange24h: number;
101
- lastUpdated: Date;
102
- }
103
- declare class MarketDataClient {
104
- private readonly dune?;
105
- private readonly duneApiKey?;
106
- private readonly graphApiKey?;
107
- private readonly geckoApiKey?;
108
- private readonly DICTIONARY_QUERY_ID;
109
- private readonly GRAPH_API_ENDPOINT;
110
- private readonly UNISWAP_SUBGRAPH_ID;
111
- private readonly COINGECKO_API_ENDPOINT;
112
- constructor(duneApiKey?: string, graphApiKey?: string, geckoApiKey?: string);
113
- /**
114
- * Get market data from CoinGecko (requires CoinGecko API key)
115
- * @param tokenIds Array of CoinGecko token IDs
116
- */
117
- getGeckoTokenData(tokenIds: string[]): Promise<Record<string, CoinGeckoTokenData>>;
118
- /**
119
- * Get market data from the materialized view (requires Dune API key)
120
- */
121
- getClankerDictionary(): Promise<ClankerMarketData[]>;
122
- /**
123
- * Get DEX pair stats for a specific chain (requires Dune API key)
124
- * @param chain - The blockchain to query (e.g., 'ethereum', 'arbitrum', etc.)
125
- * @param tokenAddress - Optional token address to filter by
126
- */
127
- getDexPairStats(chain: string, tokenAddress?: string): Promise<DexPairStats[]>;
128
- /**
129
- * Fetch Uniswap data for multiple tokens using The Graph (requires Graph API key)
130
- * @param contractAddresses Array of token contract addresses
131
- * @param blockNumber Optional block number for historical data
132
- */
133
- getUniswapData(contractAddresses: string[], blockNumber?: number): Promise<GraphToken[]>;
134
- /**
135
- * Filter DEX pairs by token address
136
- */
137
- private filterPairsByToken;
138
- private buildUniswapQuery;
139
- private transformUniswapData;
140
- private calculatePrice;
46
+ declare class Clanker {
47
+ private readonly wallet;
48
+ private readonly factoryAddress;
49
+ private readonly chainId;
50
+ private readonly publicClient;
51
+ constructor(config: ClankerConfig);
52
+ private calculateTick;
53
+ deploy(config: DeploymentConfig): Promise<Address>;
141
54
  }
142
55
 
143
- export { ClankerError, type ClankerMarketData, ClankerSDK, type CoinGeckoTokenData, type DeployTokenOptions, type DeployTokenWithSplitsOptions, type DeployedToken, type DeployedTokensResponse, type DexPairStats, type EstimatedRewardsResponse, type GraphToken, MarketDataClient, type Token, type UncollectedFeesResponse, ClankerSDK as default };
56
+ export { Clanker, type ClankerConfig, type DeploymentConfig, type InitialBuyConfig, type PoolConfig, type RewardsConfig, type TokenConfig, type VaultConfig };