clawclick-sdk 0.1.2 → 0.1.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.
- package/README.md +106 -37
- package/dist/abi.d.ts +207 -35
- package/dist/abi.d.ts.map +1 -1
- package/dist/abi.js +132 -90
- package/dist/abi.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +5 -4
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +28 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +74 -13
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +162 -64
- package/dist/sdk.js.map +1 -1
- package/package.json +1 -1
package/dist/sdk.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PublicClient, type WalletClient, type Chain, type Transport, type Account, type Address, type Hash, type Hex } from 'viem';
|
|
2
|
+
export type LaunchTypeOption = 'direct' | 'agent';
|
|
2
3
|
export interface ClawClickConfig {
|
|
3
4
|
/** Hex private key (with or without 0x prefix) */
|
|
4
5
|
privateKey: string;
|
|
@@ -10,8 +11,13 @@ export interface ClawClickConfig {
|
|
|
10
11
|
factoryAddress: Address;
|
|
11
12
|
/** Hook contract address */
|
|
12
13
|
hookAddress: Address;
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* PoolSwapTest contract address — used for trading.
|
|
16
|
+
* (Legacy: accepts the old `swapExecutorAddress` name too)
|
|
17
|
+
*/
|
|
18
|
+
poolSwapTestAddress: Address;
|
|
19
|
+
/** @deprecated Use poolSwapTestAddress */
|
|
20
|
+
swapExecutorAddress?: Address;
|
|
15
21
|
/** Chain ID (default: 11155111 for Sepolia) */
|
|
16
22
|
chainId?: number;
|
|
17
23
|
}
|
|
@@ -21,15 +27,25 @@ export interface LaunchParams {
|
|
|
21
27
|
beneficiary: Address;
|
|
22
28
|
agentWallet?: Address;
|
|
23
29
|
targetMcapETH: string;
|
|
30
|
+
/** Bootstrap ETH to send (e.g. "0.001"). If omitted, relies on free bootstrap contract. */
|
|
31
|
+
bootstrapETH?: string;
|
|
24
32
|
feeSplit?: {
|
|
25
33
|
wallets: Address[];
|
|
26
34
|
percentages: number[];
|
|
27
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Launch type:
|
|
38
|
+
* - `'direct'` — hookless pool, 1% LP fee, tradeable on Uniswap UI (claws.fun)
|
|
39
|
+
* - `'agent'` — hook-based pool, dynamic fee, epoch/tax/limits (claw.click)
|
|
40
|
+
* Default: `'agent'`
|
|
41
|
+
*/
|
|
42
|
+
launchType?: LaunchTypeOption;
|
|
28
43
|
}
|
|
29
44
|
export interface LaunchResult {
|
|
30
45
|
tokenAddress: Address;
|
|
31
46
|
poolId: Hex;
|
|
32
47
|
txHash: Hash;
|
|
48
|
+
launchType: LaunchTypeOption;
|
|
33
49
|
}
|
|
34
50
|
export interface TokenInfo {
|
|
35
51
|
token: Address;
|
|
@@ -40,6 +56,9 @@ export interface TokenInfo {
|
|
|
40
56
|
targetMcapETH: bigint;
|
|
41
57
|
name: string;
|
|
42
58
|
symbol: string;
|
|
59
|
+
launchType: LaunchTypeOption;
|
|
60
|
+
createdAt: bigint;
|
|
61
|
+
createdBlock: bigint;
|
|
43
62
|
poolKey: {
|
|
44
63
|
currency0: Address;
|
|
45
64
|
currency1: Address;
|
|
@@ -47,6 +66,11 @@ export interface TokenInfo {
|
|
|
47
66
|
tickSpacing: number;
|
|
48
67
|
hooks: Address;
|
|
49
68
|
};
|
|
69
|
+
feeSplit: {
|
|
70
|
+
wallets: Address[];
|
|
71
|
+
percentages: number[];
|
|
72
|
+
count: number;
|
|
73
|
+
};
|
|
50
74
|
}
|
|
51
75
|
export interface PoolProgress {
|
|
52
76
|
currentPosition: bigint;
|
|
@@ -60,6 +84,10 @@ export interface PoolState {
|
|
|
60
84
|
startingMCAP: bigint;
|
|
61
85
|
graduationMCAP: bigint;
|
|
62
86
|
totalSupply: bigint;
|
|
87
|
+
positionTokenIds: bigint[];
|
|
88
|
+
positionMinted: boolean[];
|
|
89
|
+
positionRetired: boolean[];
|
|
90
|
+
recycledETH: bigint;
|
|
63
91
|
activated: boolean;
|
|
64
92
|
graduated: boolean;
|
|
65
93
|
}
|
|
@@ -85,28 +113,40 @@ export declare class ClawClick {
|
|
|
85
113
|
readonly account: Account;
|
|
86
114
|
readonly factoryAddress: Address;
|
|
87
115
|
readonly hookAddress: Address;
|
|
88
|
-
readonly
|
|
116
|
+
readonly poolSwapTestAddress: Address;
|
|
89
117
|
readonly apiUrl: string;
|
|
90
118
|
readonly chain: Chain;
|
|
91
119
|
constructor(config: ClawClickConfig);
|
|
120
|
+
/** @deprecated Use poolSwapTestAddress */
|
|
121
|
+
get swapExecutorAddress(): Address;
|
|
92
122
|
/** Get the agent's wallet address */
|
|
93
123
|
get address(): Address;
|
|
94
124
|
/**
|
|
95
125
|
* Launch a new token through the factory.
|
|
126
|
+
*
|
|
127
|
+
* @param params.launchType - `'direct'` (hookless, Uniswap-tradeable) or `'agent'` (hook-based). Default: `'agent'`
|
|
96
128
|
*/
|
|
97
129
|
launch(params: LaunchParams): Promise<LaunchResult>;
|
|
98
130
|
/**
|
|
99
|
-
* Buy tokens with ETH.
|
|
131
|
+
* Buy tokens with ETH via PoolSwapTest.swap().
|
|
132
|
+
*
|
|
133
|
+
* Works for both DIRECT (hookless) and AGENT (hook-based) pools.
|
|
134
|
+
* The poolKey is fetched from the factory and determines routing automatically.
|
|
135
|
+
*
|
|
100
136
|
* @param tokenAddress - The token to buy
|
|
101
137
|
* @param amountETH - Amount of ETH to spend (e.g. "0.1")
|
|
102
|
-
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%)
|
|
138
|
+
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%) — reserved for future use
|
|
103
139
|
*/
|
|
104
140
|
buy(tokenAddress: Address, amountETH: string, slippageBps?: number): Promise<Hash>;
|
|
105
141
|
/**
|
|
106
|
-
* Sell tokens for ETH.
|
|
142
|
+
* Sell tokens for ETH via PoolSwapTest.swap().
|
|
143
|
+
*
|
|
144
|
+
* Works for both DIRECT (hookless) and AGENT (hook-based) pools.
|
|
145
|
+
* Automatically approves the PoolSwapTest contract if needed.
|
|
146
|
+
*
|
|
107
147
|
* @param tokenAddress - The token to sell
|
|
108
148
|
* @param amount - Amount of tokens to sell (e.g. "1000000") or "all" to sell entire balance
|
|
109
|
-
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%)
|
|
149
|
+
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%) — reserved for future use
|
|
110
150
|
*/
|
|
111
151
|
sell(tokenAddress: Address, amount: string, slippageBps?: number): Promise<Hash>;
|
|
112
152
|
/**
|
|
@@ -122,26 +162,47 @@ export declare class ClawClick {
|
|
|
122
162
|
}>;
|
|
123
163
|
/**
|
|
124
164
|
* Claim accumulated ETH fees for a beneficiary address.
|
|
165
|
+
* Only applicable to AGENT launches (hook-based pools).
|
|
125
166
|
*/
|
|
126
167
|
claimFeesETH(beneficiary?: Address): Promise<Hash>;
|
|
127
168
|
/**
|
|
128
169
|
* Claim accumulated token fees for a beneficiary.
|
|
170
|
+
* Only applicable to AGENT launches (hook-based pools).
|
|
129
171
|
*/
|
|
130
172
|
claimFeesToken(tokenAddress: Address, beneficiary?: Address): Promise<Hash>;
|
|
131
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Collect LP fees from a specific position (for DIRECT launches).
|
|
175
|
+
* Triggers the factory's 70/30 beneficiary/platform split.
|
|
176
|
+
*/
|
|
177
|
+
collectFeesFromPosition(tokenAddress: Address, positionIndex: number): Promise<Hash>;
|
|
178
|
+
/** Get token launch info from the factory (includes launchType) */
|
|
132
179
|
getTokenInfo(tokenAddress: Address): Promise<TokenInfo>;
|
|
133
|
-
/**
|
|
180
|
+
/** Check if a token uses a DIRECT (hookless) pool */
|
|
181
|
+
isDirectLaunch(tokenAddress: Address): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Get pool progress from the hook.
|
|
184
|
+
* Only works for AGENT launches. For DIRECT launches, returns zeroed progress.
|
|
185
|
+
*/
|
|
134
186
|
getPoolProgress(tokenAddress: Address): Promise<PoolProgress>;
|
|
135
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Get current tax rate for a token's pool.
|
|
189
|
+
* Only works for AGENT launches. DIRECT launches always return 0 (no tax).
|
|
190
|
+
*/
|
|
136
191
|
getCurrentTax(tokenAddress: Address): Promise<bigint>;
|
|
137
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Get current trading limits for a token's pool.
|
|
194
|
+
* Only works for AGENT launches. DIRECT launches return max uint256 (no limits).
|
|
195
|
+
*/
|
|
138
196
|
getCurrentLimits(tokenAddress: Address): Promise<{
|
|
139
197
|
maxTx: bigint;
|
|
140
198
|
maxWallet: bigint;
|
|
141
199
|
}>;
|
|
142
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Check if a token has graduated.
|
|
202
|
+
* DIRECT launches never graduate (returns false). AGENT launches check the hook.
|
|
203
|
+
*/
|
|
143
204
|
isGraduated(tokenAddress: Address): Promise<boolean>;
|
|
144
|
-
/** Get the pool state from the factory */
|
|
205
|
+
/** Get the pool state from the factory (scalar fields only — auto-getter skips arrays) */
|
|
145
206
|
getPoolState(tokenAddress: Address): Promise<PoolState>;
|
|
146
207
|
/** Get token balance for the agent's wallet */
|
|
147
208
|
getTokenBalance(tokenAddress: Address): Promise<bigint>;
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ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,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAY1D,0FAA0F;IACpF,YAAY,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;IAyB7D,+CAA+C;IACzC,eAAe,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAS7D,6CAA6C;IACvC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAQtC,0CAA0C;IACpC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG;QAAE,WAAW,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAO3F,uCAAuC;IACjC,UAAU,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;QACxC,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,YAAY,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAYtD,+CAA+C;IACzC,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAM5C,8CAA8C;IACxC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC;IAU9B,gDAAgD;YAClC,SAAS;IASvB,qDAAqD;YACvC,UAAU;CAUzB"}
|
package/dist/sdk.js
CHANGED
|
@@ -11,6 +11,13 @@ const fs_1 = require("fs");
|
|
|
11
11
|
const form_data_1 = __importDefault(require("form-data"));
|
|
12
12
|
const abi_1 = require("./abi");
|
|
13
13
|
// ============================================================================
|
|
14
|
+
// CONSTANTS
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/** Minimum sqrt price limit for buys (zeroForOne = true) */
|
|
17
|
+
const MIN_SQRT_PRICE_LIMIT = 4295128740n;
|
|
18
|
+
/** Maximum sqrt price limit for sells (zeroForOne = false) */
|
|
19
|
+
const MAX_SQRT_PRICE_LIMIT = 1461446703485210103287273052203988822378723970341n;
|
|
20
|
+
// ============================================================================
|
|
14
21
|
// CHAIN MAP
|
|
15
22
|
// ============================================================================
|
|
16
23
|
const CHAINS = {
|
|
@@ -28,7 +35,7 @@ class ClawClick {
|
|
|
28
35
|
account;
|
|
29
36
|
factoryAddress;
|
|
30
37
|
hookAddress;
|
|
31
|
-
|
|
38
|
+
poolSwapTestAddress;
|
|
32
39
|
apiUrl;
|
|
33
40
|
chain;
|
|
34
41
|
constructor(config) {
|
|
@@ -39,7 +46,8 @@ class ClawClick {
|
|
|
39
46
|
this.chain = CHAINS[config.chainId || 11155111] || chains_1.sepolia;
|
|
40
47
|
this.factoryAddress = config.factoryAddress;
|
|
41
48
|
this.hookAddress = config.hookAddress;
|
|
42
|
-
|
|
49
|
+
// Accept both new name and legacy name
|
|
50
|
+
this.poolSwapTestAddress = config.poolSwapTestAddress || config.swapExecutorAddress;
|
|
43
51
|
this.apiUrl = config.apiUrl.replace(/\/$/, '');
|
|
44
52
|
const transport = (0, viem_1.http)(config.rpcUrl);
|
|
45
53
|
this.publicClient = (0, viem_1.createPublicClient)({
|
|
@@ -52,6 +60,10 @@ class ClawClick {
|
|
|
52
60
|
transport,
|
|
53
61
|
});
|
|
54
62
|
}
|
|
63
|
+
/** @deprecated Use poolSwapTestAddress */
|
|
64
|
+
get swapExecutorAddress() {
|
|
65
|
+
return this.poolSwapTestAddress;
|
|
66
|
+
}
|
|
55
67
|
/** Get the agent's wallet address */
|
|
56
68
|
get address() {
|
|
57
69
|
return this.account.address;
|
|
@@ -61,6 +73,8 @@ class ClawClick {
|
|
|
61
73
|
// ==========================================================================
|
|
62
74
|
/**
|
|
63
75
|
* Launch a new token through the factory.
|
|
76
|
+
*
|
|
77
|
+
* @param params.launchType - `'direct'` (hookless, Uniswap-tradeable) or `'agent'` (hook-based). Default: `'agent'`
|
|
64
78
|
*/
|
|
65
79
|
async launch(params) {
|
|
66
80
|
const wallets = Array(5).fill('0x0000000000000000000000000000000000000000');
|
|
@@ -73,6 +87,7 @@ class ClawClick {
|
|
|
73
87
|
percentages[i] = params.feeSplit.percentages[i];
|
|
74
88
|
}
|
|
75
89
|
}
|
|
90
|
+
const launchTypeValue = params.launchType === 'direct' ? abi_1.LaunchType.DIRECT : abi_1.LaunchType.AGENT;
|
|
76
91
|
const txHash = await this.walletClient.writeContract({
|
|
77
92
|
address: this.factoryAddress,
|
|
78
93
|
abi: abi_1.FACTORY_ABI,
|
|
@@ -89,71 +104,81 @@ class ClawClick {
|
|
|
89
104
|
percentages: percentages,
|
|
90
105
|
count,
|
|
91
106
|
},
|
|
107
|
+
launchType: launchTypeValue,
|
|
92
108
|
},
|
|
93
109
|
],
|
|
94
|
-
value: 0n,
|
|
110
|
+
value: params.bootstrapETH ? (0, viem_1.parseEther)(params.bootstrapETH) : 0n,
|
|
95
111
|
});
|
|
96
112
|
const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
97
|
-
// Parse TokenLaunched event from logs
|
|
98
|
-
let tokenAddress = '0x';
|
|
99
|
-
let poolId = '0x';
|
|
100
|
-
for (const log of receipt.logs) {
|
|
101
|
-
// TokenLaunched event topic
|
|
102
|
-
if (log.topics[0] === '0x' && log.topics.length >= 4) {
|
|
103
|
-
// Encoded in topics: token (topic1), beneficiary (topic2), creator (topic3)
|
|
104
|
-
tokenAddress = `0x${log.topics[1]?.slice(26)}`;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
113
|
// Fallback: read from factory using token count
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
return { tokenAddress, poolId, txHash };
|
|
114
|
+
const tokenCount = await this.publicClient.readContract({
|
|
115
|
+
address: this.factoryAddress,
|
|
116
|
+
abi: abi_1.FACTORY_ABI,
|
|
117
|
+
functionName: 'getTokenCount',
|
|
118
|
+
});
|
|
119
|
+
const tokenAddress = await this.publicClient.readContract({
|
|
120
|
+
address: this.factoryAddress,
|
|
121
|
+
abi: abi_1.FACTORY_ABI,
|
|
122
|
+
functionName: 'getTokenAtIndex',
|
|
123
|
+
args: [tokenCount - 1n],
|
|
124
|
+
});
|
|
125
|
+
const info = await this.publicClient.readContract({
|
|
126
|
+
address: this.factoryAddress,
|
|
127
|
+
abi: abi_1.FACTORY_ABI,
|
|
128
|
+
functionName: 'launchByToken',
|
|
129
|
+
args: [tokenAddress],
|
|
130
|
+
});
|
|
131
|
+
const poolId = info.poolId;
|
|
132
|
+
const launchType = params.launchType || 'agent';
|
|
133
|
+
return { tokenAddress, poolId, txHash, launchType };
|
|
130
134
|
}
|
|
131
135
|
// ==========================================================================
|
|
132
136
|
// TRADING
|
|
133
137
|
// ==========================================================================
|
|
134
138
|
/**
|
|
135
|
-
* Buy tokens with ETH.
|
|
139
|
+
* Buy tokens with ETH via PoolSwapTest.swap().
|
|
140
|
+
*
|
|
141
|
+
* Works for both DIRECT (hookless) and AGENT (hook-based) pools.
|
|
142
|
+
* The poolKey is fetched from the factory and determines routing automatically.
|
|
143
|
+
*
|
|
136
144
|
* @param tokenAddress - The token to buy
|
|
137
145
|
* @param amountETH - Amount of ETH to spend (e.g. "0.1")
|
|
138
|
-
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%)
|
|
146
|
+
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%) — reserved for future use
|
|
139
147
|
*/
|
|
140
148
|
async buy(tokenAddress, amountETH, slippageBps = 500) {
|
|
141
149
|
const poolKey = await this.getPoolKey(tokenAddress);
|
|
142
150
|
const amountIn = (0, viem_1.parseEther)(amountETH);
|
|
151
|
+
// ETH (currency0) → Token: zeroForOne = true, amountSpecified negative = exact-input
|
|
143
152
|
const txHash = await this.walletClient.writeContract({
|
|
144
|
-
address: this.
|
|
145
|
-
abi: abi_1.
|
|
146
|
-
functionName: '
|
|
147
|
-
args: [
|
|
153
|
+
address: this.poolSwapTestAddress,
|
|
154
|
+
abi: abi_1.POOL_SWAP_TEST_ABI,
|
|
155
|
+
functionName: 'swap',
|
|
156
|
+
args: [
|
|
157
|
+
poolKey,
|
|
158
|
+
{
|
|
159
|
+
zeroForOne: true,
|
|
160
|
+
amountSpecified: -amountIn, // negative = exact input
|
|
161
|
+
sqrtPriceLimitX96: MIN_SQRT_PRICE_LIMIT,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
takeClaims: false,
|
|
165
|
+
settleUsingBurn: false,
|
|
166
|
+
},
|
|
167
|
+
'0x',
|
|
168
|
+
],
|
|
148
169
|
value: amountIn,
|
|
149
170
|
});
|
|
150
171
|
return txHash;
|
|
151
172
|
}
|
|
152
173
|
/**
|
|
153
|
-
* Sell tokens for ETH.
|
|
174
|
+
* Sell tokens for ETH via PoolSwapTest.swap().
|
|
175
|
+
*
|
|
176
|
+
* Works for both DIRECT (hookless) and AGENT (hook-based) pools.
|
|
177
|
+
* Automatically approves the PoolSwapTest contract if needed.
|
|
178
|
+
*
|
|
154
179
|
* @param tokenAddress - The token to sell
|
|
155
180
|
* @param amount - Amount of tokens to sell (e.g. "1000000") or "all" to sell entire balance
|
|
156
|
-
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%)
|
|
181
|
+
* @param slippageBps - Slippage tolerance in bps (default 500 = 5%) — reserved for future use
|
|
157
182
|
*/
|
|
158
183
|
async sell(tokenAddress, amount, slippageBps = 500) {
|
|
159
184
|
let amountIn;
|
|
@@ -168,28 +193,41 @@ class ClawClick {
|
|
|
168
193
|
else {
|
|
169
194
|
amountIn = (0, viem_1.parseEther)(amount);
|
|
170
195
|
}
|
|
171
|
-
// Approve
|
|
196
|
+
// Approve PoolSwapTest to spend tokens
|
|
172
197
|
const allowance = await this.publicClient.readContract({
|
|
173
198
|
address: tokenAddress,
|
|
174
199
|
abi: abi_1.ERC20_ABI,
|
|
175
200
|
functionName: 'allowance',
|
|
176
|
-
args: [this.address, this.
|
|
201
|
+
args: [this.address, this.poolSwapTestAddress],
|
|
177
202
|
});
|
|
178
203
|
if (allowance < amountIn) {
|
|
179
204
|
const approveTx = await this.walletClient.writeContract({
|
|
180
205
|
address: tokenAddress,
|
|
181
206
|
abi: abi_1.ERC20_ABI,
|
|
182
207
|
functionName: 'approve',
|
|
183
|
-
args: [this.
|
|
208
|
+
args: [this.poolSwapTestAddress, amountIn],
|
|
184
209
|
});
|
|
185
210
|
await this.publicClient.waitForTransactionReceipt({ hash: approveTx });
|
|
186
211
|
}
|
|
187
212
|
const poolKey = await this.getPoolKey(tokenAddress);
|
|
213
|
+
// Token (currency1) → ETH: zeroForOne = false, amountSpecified negative = exact-input
|
|
188
214
|
const txHash = await this.walletClient.writeContract({
|
|
189
|
-
address: this.
|
|
190
|
-
abi: abi_1.
|
|
191
|
-
functionName: '
|
|
192
|
-
args: [
|
|
215
|
+
address: this.poolSwapTestAddress,
|
|
216
|
+
abi: abi_1.POOL_SWAP_TEST_ABI,
|
|
217
|
+
functionName: 'swap',
|
|
218
|
+
args: [
|
|
219
|
+
poolKey,
|
|
220
|
+
{
|
|
221
|
+
zeroForOne: false,
|
|
222
|
+
amountSpecified: -amountIn, // negative = exact input
|
|
223
|
+
sqrtPriceLimitX96: MAX_SQRT_PRICE_LIMIT,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
takeClaims: false,
|
|
227
|
+
settleUsingBurn: false,
|
|
228
|
+
},
|
|
229
|
+
'0x',
|
|
230
|
+
],
|
|
193
231
|
});
|
|
194
232
|
return txHash;
|
|
195
233
|
}
|
|
@@ -246,6 +284,7 @@ class ClawClick {
|
|
|
246
284
|
// ==========================================================================
|
|
247
285
|
/**
|
|
248
286
|
* Claim accumulated ETH fees for a beneficiary address.
|
|
287
|
+
* Only applicable to AGENT launches (hook-based pools).
|
|
249
288
|
*/
|
|
250
289
|
async claimFeesETH(beneficiary) {
|
|
251
290
|
const addr = beneficiary || this.address;
|
|
@@ -258,6 +297,7 @@ class ClawClick {
|
|
|
258
297
|
}
|
|
259
298
|
/**
|
|
260
299
|
* Claim accumulated token fees for a beneficiary.
|
|
300
|
+
* Only applicable to AGENT launches (hook-based pools).
|
|
261
301
|
*/
|
|
262
302
|
async claimFeesToken(tokenAddress, beneficiary) {
|
|
263
303
|
const addr = beneficiary || this.address;
|
|
@@ -268,10 +308,23 @@ class ClawClick {
|
|
|
268
308
|
args: [addr, tokenAddress],
|
|
269
309
|
});
|
|
270
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Collect LP fees from a specific position (for DIRECT launches).
|
|
313
|
+
* Triggers the factory's 70/30 beneficiary/platform split.
|
|
314
|
+
*/
|
|
315
|
+
async collectFeesFromPosition(tokenAddress, positionIndex) {
|
|
316
|
+
const info = await this.getTokenInfo(tokenAddress);
|
|
317
|
+
return this.walletClient.writeContract({
|
|
318
|
+
address: this.factoryAddress,
|
|
319
|
+
abi: abi_1.FACTORY_ABI,
|
|
320
|
+
functionName: 'collectFeesFromPosition',
|
|
321
|
+
args: [info.poolId, BigInt(positionIndex)],
|
|
322
|
+
});
|
|
323
|
+
}
|
|
271
324
|
// ==========================================================================
|
|
272
325
|
// ON-CHAIN READS
|
|
273
326
|
// ==========================================================================
|
|
274
|
-
/** Get token launch info from the factory */
|
|
327
|
+
/** Get token launch info from the factory (includes launchType) */
|
|
275
328
|
async getTokenInfo(tokenAddress) {
|
|
276
329
|
const info = await this.publicClient.readContract({
|
|
277
330
|
address: this.factoryAddress,
|
|
@@ -288,6 +341,9 @@ class ClawClick {
|
|
|
288
341
|
targetMcapETH: info.targetMcapETH,
|
|
289
342
|
name: info.name,
|
|
290
343
|
symbol: info.symbol,
|
|
344
|
+
launchType: Number(info.launchType) === abi_1.LaunchType.DIRECT ? 'direct' : 'agent',
|
|
345
|
+
createdAt: info.createdAt,
|
|
346
|
+
createdBlock: info.createdBlock,
|
|
291
347
|
poolKey: {
|
|
292
348
|
currency0: info.poolKey.currency0,
|
|
293
349
|
currency1: info.poolKey.currency1,
|
|
@@ -295,10 +351,27 @@ class ClawClick {
|
|
|
295
351
|
tickSpacing: Number(info.poolKey.tickSpacing),
|
|
296
352
|
hooks: info.poolKey.hooks,
|
|
297
353
|
},
|
|
354
|
+
feeSplit: {
|
|
355
|
+
wallets: [...info.feeSplit.wallets],
|
|
356
|
+
percentages: info.feeSplit.percentages.map((p) => Number(p)),
|
|
357
|
+
count: Number(info.feeSplit.count),
|
|
358
|
+
},
|
|
298
359
|
};
|
|
299
360
|
}
|
|
300
|
-
/**
|
|
361
|
+
/** Check if a token uses a DIRECT (hookless) pool */
|
|
362
|
+
async isDirectLaunch(tokenAddress) {
|
|
363
|
+
const info = await this.getTokenInfo(tokenAddress);
|
|
364
|
+
return info.launchType === 'direct';
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Get pool progress from the hook.
|
|
368
|
+
* Only works for AGENT launches. For DIRECT launches, returns zeroed progress.
|
|
369
|
+
*/
|
|
301
370
|
async getPoolProgress(tokenAddress) {
|
|
371
|
+
const isDirect = await this.isDirectLaunch(tokenAddress);
|
|
372
|
+
if (isDirect) {
|
|
373
|
+
return { currentPosition: 0n, currentEpoch: 0n, lastEpochMCAP: 0n, graduated: false };
|
|
374
|
+
}
|
|
302
375
|
const poolId = await this.getPoolId(tokenAddress);
|
|
303
376
|
const result = await this.publicClient.readContract({
|
|
304
377
|
address: this.hookAddress,
|
|
@@ -313,8 +386,14 @@ class ClawClick {
|
|
|
313
386
|
graduated: result[3],
|
|
314
387
|
};
|
|
315
388
|
}
|
|
316
|
-
/**
|
|
389
|
+
/**
|
|
390
|
+
* Get current tax rate for a token's pool.
|
|
391
|
+
* Only works for AGENT launches. DIRECT launches always return 0 (no tax).
|
|
392
|
+
*/
|
|
317
393
|
async getCurrentTax(tokenAddress) {
|
|
394
|
+
const isDirect = await this.isDirectLaunch(tokenAddress);
|
|
395
|
+
if (isDirect)
|
|
396
|
+
return 0n;
|
|
318
397
|
const poolId = await this.getPoolId(tokenAddress);
|
|
319
398
|
return this.publicClient.readContract({
|
|
320
399
|
address: this.hookAddress,
|
|
@@ -323,8 +402,15 @@ class ClawClick {
|
|
|
323
402
|
args: [poolId],
|
|
324
403
|
});
|
|
325
404
|
}
|
|
326
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* Get current trading limits for a token's pool.
|
|
407
|
+
* Only works for AGENT launches. DIRECT launches return max uint256 (no limits).
|
|
408
|
+
*/
|
|
327
409
|
async getCurrentLimits(tokenAddress) {
|
|
410
|
+
const MAX_UINT = 2n ** 256n - 1n;
|
|
411
|
+
const isDirect = await this.isDirectLaunch(tokenAddress);
|
|
412
|
+
if (isDirect)
|
|
413
|
+
return { maxTx: MAX_UINT, maxWallet: MAX_UINT };
|
|
328
414
|
const poolId = await this.getPoolId(tokenAddress);
|
|
329
415
|
const result = await this.publicClient.readContract({
|
|
330
416
|
address: this.hookAddress,
|
|
@@ -334,8 +420,14 @@ class ClawClick {
|
|
|
334
420
|
});
|
|
335
421
|
return { maxTx: result[0], maxWallet: result[1] };
|
|
336
422
|
}
|
|
337
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* Check if a token has graduated.
|
|
425
|
+
* DIRECT launches never graduate (returns false). AGENT launches check the hook.
|
|
426
|
+
*/
|
|
338
427
|
async isGraduated(tokenAddress) {
|
|
428
|
+
const isDirect = await this.isDirectLaunch(tokenAddress);
|
|
429
|
+
if (isDirect)
|
|
430
|
+
return false;
|
|
339
431
|
return this.publicClient.readContract({
|
|
340
432
|
address: this.hookAddress,
|
|
341
433
|
abi: abi_1.HOOK_ABI,
|
|
@@ -343,23 +435,29 @@ class ClawClick {
|
|
|
343
435
|
args: [tokenAddress],
|
|
344
436
|
});
|
|
345
437
|
}
|
|
346
|
-
/** Get the pool state from the factory */
|
|
438
|
+
/** Get the pool state from the factory (scalar fields only — auto-getter skips arrays) */
|
|
347
439
|
async getPoolState(tokenAddress) {
|
|
348
440
|
const info = await this.getTokenInfo(tokenAddress);
|
|
349
|
-
|
|
441
|
+
// Solidity auto-getter for mapping returns individual values (arrays are skipped)
|
|
442
|
+
const result = await this.publicClient.readContract({
|
|
350
443
|
address: this.factoryAddress,
|
|
351
444
|
abi: abi_1.FACTORY_ABI,
|
|
352
445
|
functionName: 'poolStates',
|
|
353
446
|
args: [info.poolId],
|
|
354
447
|
});
|
|
448
|
+
// Auto-getter returns a tuple of scalar fields
|
|
355
449
|
return {
|
|
356
|
-
token:
|
|
357
|
-
beneficiary:
|
|
358
|
-
startingMCAP:
|
|
359
|
-
graduationMCAP:
|
|
360
|
-
totalSupply:
|
|
361
|
-
|
|
362
|
-
|
|
450
|
+
token: result[0] ?? result.token,
|
|
451
|
+
beneficiary: result[1] ?? result.beneficiary,
|
|
452
|
+
startingMCAP: result[2] ?? result.startingMCAP,
|
|
453
|
+
graduationMCAP: result[3] ?? result.graduationMCAP,
|
|
454
|
+
totalSupply: result[4] ?? result.totalSupply,
|
|
455
|
+
positionTokenIds: [],
|
|
456
|
+
positionMinted: [],
|
|
457
|
+
positionRetired: [],
|
|
458
|
+
recycledETH: result[5] ?? result.recycledETH,
|
|
459
|
+
activated: result[6] ?? result.activated,
|
|
460
|
+
graduated: result[7] ?? result.graduated,
|
|
363
461
|
};
|
|
364
462
|
}
|
|
365
463
|
/** Get token balance for the agent's wallet */
|