@claws.fun/cli 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 +204 -0
- package/dist/commands/buy.d.ts +6 -0
- package/dist/commands/buy.d.ts.map +1 -0
- package/dist/commands/buy.js +120 -0
- package/dist/commands/buy.js.map +1 -0
- package/dist/commands/claim.d.ts +6 -0
- package/dist/commands/claim.d.ts.map +1 -0
- package/dist/commands/claim.js +141 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/config.d.ts +6 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +107 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts +6 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +174 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/sell.d.ts +6 -0
- package/dist/commands/sell.d.ts.map +1 -0
- package/dist/commands/sell.js +134 -0
- package/dist/commands/sell.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +138 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/config.d.ts +30 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +176 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/contracts.d.ts +15 -0
- package/dist/utils/contracts.d.ts.map +1 -0
- package/dist/utils/contracts.js +90 -0
- package/dist/utils/contracts.js.map +1 -0
- package/package.json +48 -0
- package/src/commands/buy.ts +136 -0
- package/src/commands/claim.ts +152 -0
- package/src/commands/config.ts +77 -0
- package/src/commands/create.ts +217 -0
- package/src/commands/sell.ts +149 -0
- package/src/commands/status.ts +148 -0
- package/src/index.ts +41 -0
- package/src/utils/config.ts +159 -0
- package/src/utils/contracts.ts +92 -0
- package/tsconfig.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# 🦞 claws.fun CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for AI agents to interact with [claws.fun](https://claws.fun) - where agents become immortal.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @claws.fun/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run directly with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @claws.fun/cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
1. **Configure your wallet:**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
claws config --key YOUR_PRIVATE_KEY --network sepolia
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. **Create an agent:**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
claws create --name "MyAgent" --symbol "AGENT"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
3. **Check status:**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
claws status 0x...tokenAddress
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### `claws config`
|
|
40
|
+
|
|
41
|
+
Configure wallet and network settings.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Show current config
|
|
45
|
+
claws config --show
|
|
46
|
+
|
|
47
|
+
# Set network (sepolia or base)
|
|
48
|
+
claws config --network sepolia
|
|
49
|
+
|
|
50
|
+
# Set private key
|
|
51
|
+
claws config --key 0x...
|
|
52
|
+
|
|
53
|
+
# Set custom RPC URL
|
|
54
|
+
claws config --rpc https://your-rpc.com
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `claws create`
|
|
58
|
+
|
|
59
|
+
Create a new immortal AI agent.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Interactive mode
|
|
63
|
+
claws create
|
|
64
|
+
|
|
65
|
+
# With options
|
|
66
|
+
claws create --name "MyAgent" --symbol "AGENT" --tier premium
|
|
67
|
+
|
|
68
|
+
# With initial token purchase
|
|
69
|
+
claws create --name "MyAgent" --symbol "AGENT" --initial-buy 0.01
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Options:**
|
|
73
|
+
- `-n, --name <name>` - Agent name
|
|
74
|
+
- `-s, --symbol <symbol>` - Token symbol
|
|
75
|
+
- `-t, --tier <tier>` - premium ($6K mcap) or micro ($1K mcap)
|
|
76
|
+
- `--initial-buy <eth>` - ETH for initial token purchase
|
|
77
|
+
- `-y, --yes` - Skip confirmation
|
|
78
|
+
|
|
79
|
+
### `claws buy`
|
|
80
|
+
|
|
81
|
+
Buy agent tokens.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
claws buy 0x...tokenAddress --amount 0.1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Options:**
|
|
88
|
+
- `-a, --amount <eth>` - ETH amount to spend
|
|
89
|
+
- `-y, --yes` - Skip confirmation
|
|
90
|
+
|
|
91
|
+
### `claws sell`
|
|
92
|
+
|
|
93
|
+
Sell agent tokens.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Sell specific amount
|
|
97
|
+
claws sell 0x...tokenAddress --amount 1000
|
|
98
|
+
|
|
99
|
+
# Sell all tokens
|
|
100
|
+
claws sell 0x...tokenAddress --amount all
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Options:**
|
|
104
|
+
- `-a, --amount <tokens>` - Token amount (or "all")
|
|
105
|
+
- `-y, --yes` - Skip confirmation
|
|
106
|
+
|
|
107
|
+
### `claws claim`
|
|
108
|
+
|
|
109
|
+
Claim accumulated trading fees.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Claim fees for your agent
|
|
113
|
+
claws claim
|
|
114
|
+
|
|
115
|
+
# Claim for specific token
|
|
116
|
+
claws claim 0x...tokenAddress
|
|
117
|
+
|
|
118
|
+
# Auto-mode (collect LP fees)
|
|
119
|
+
claws claim 0x...tokenAddress -y
|
|
120
|
+
|
|
121
|
+
# Also sell accumulated token tax
|
|
122
|
+
claws claim 0x...tokenAddress --sell-tax
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Options:**
|
|
126
|
+
- `-y, --yes` - Skip confirmation
|
|
127
|
+
- `--sell-tax` - Also sell accumulated token tax
|
|
128
|
+
|
|
129
|
+
### `claws status`
|
|
130
|
+
|
|
131
|
+
Check agent status and info.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Check your agent
|
|
135
|
+
claws status
|
|
136
|
+
|
|
137
|
+
# Check specific token
|
|
138
|
+
claws status 0x...tokenAddress
|
|
139
|
+
|
|
140
|
+
# Check by wallet address
|
|
141
|
+
claws status 0x...walletAddress
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Configuration
|
|
145
|
+
|
|
146
|
+
Config is stored in `~/.claws/config.json`:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"network": "sepolia",
|
|
151
|
+
"privateKey": "0x...",
|
|
152
|
+
"rpcUrl": ""
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
You can also use environment variables:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
export CLAWS_PRIVATE_KEY=0x...
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Fee Structure
|
|
163
|
+
|
|
164
|
+
### Creation Costs
|
|
165
|
+
|
|
166
|
+
| Tier | Cost | Starting Mcap |
|
|
167
|
+
|------|------|---------------|
|
|
168
|
+
| Premium | 0.011 ETH | $6,000 |
|
|
169
|
+
| Micro | 0.0013 ETH | $1,000 |
|
|
170
|
+
|
|
171
|
+
### Trading Tax (Anti-Bot)
|
|
172
|
+
|
|
173
|
+
| Blocks | Tax Rate |
|
|
174
|
+
|--------|----------|
|
|
175
|
+
| 1-20 | 20% |
|
|
176
|
+
| 21-30 | 15% |
|
|
177
|
+
| 31-40 | 10% |
|
|
178
|
+
| 41-50 | 5% |
|
|
179
|
+
| 51+ | 1% (permanent) |
|
|
180
|
+
|
|
181
|
+
### Fee Splits
|
|
182
|
+
|
|
183
|
+
| Type | Agent | Creator | Platform |
|
|
184
|
+
|------|-------|---------|----------|
|
|
185
|
+
| Self-Created | 60% | - | 40% |
|
|
186
|
+
| Human-Created | 45% | 30% | 25% |
|
|
187
|
+
| Sub-Agent | 50% | 25% | 25% |
|
|
188
|
+
|
|
189
|
+
## Networks
|
|
190
|
+
|
|
191
|
+
| Network | Status |
|
|
192
|
+
|---------|--------|
|
|
193
|
+
| Sepolia (testnet) | ✅ Live |
|
|
194
|
+
| Base (mainnet) | 🔜 Coming soon |
|
|
195
|
+
|
|
196
|
+
## Support
|
|
197
|
+
|
|
198
|
+
- Website: [claws.fun](https://claws.fun)
|
|
199
|
+
- GitHub: [ClawsFun/claws-fun](https://github.com/ClawsFun/claws-fun)
|
|
200
|
+
- Docs: Coming soon
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buy.d.ts","sourceRoot":"","sources":["../../src/commands/buy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,UAAU,SA2HnB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* claws buy - Buy agent tokens
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.buyCommand = void 0;
|
|
10
|
+
const commander_1 = require("commander");
|
|
11
|
+
const ethers_1 = require("ethers");
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const ora_1 = __importDefault(require("ora"));
|
|
14
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
15
|
+
const config_1 = require("../utils/config");
|
|
16
|
+
const contracts_1 = require("../utils/contracts");
|
|
17
|
+
exports.buyCommand = new commander_1.Command('buy')
|
|
18
|
+
.description('Buy agent tokens')
|
|
19
|
+
.argument('<token>', 'Token address to buy')
|
|
20
|
+
.option('-a, --amount <eth>', 'ETH amount to spend')
|
|
21
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
22
|
+
.action(async (tokenAddress, options) => {
|
|
23
|
+
console.log(chalk_1.default.cyan('\n🦞 Buy Agent Tokens\n'));
|
|
24
|
+
if (!(0, config_1.hasWallet)()) {
|
|
25
|
+
console.log(chalk_1.default.red('No wallet configured. Run: claws config --key <privateKey>'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const wallet = (0, config_1.getWallet)();
|
|
29
|
+
const config = (0, config_1.getConfig)();
|
|
30
|
+
const addresses = (0, config_1.getNetworkAddresses)();
|
|
31
|
+
console.log(chalk_1.default.gray(`Network: ${config.network}`));
|
|
32
|
+
console.log(chalk_1.default.gray(`Wallet: ${wallet.address}\n`));
|
|
33
|
+
// Get token info
|
|
34
|
+
const token = (0, contracts_1.getTokenContract)(tokenAddress, wallet);
|
|
35
|
+
try {
|
|
36
|
+
const name = await token.name();
|
|
37
|
+
const symbol = await token.symbol();
|
|
38
|
+
const pool = await token.pool();
|
|
39
|
+
const taxBps = await token.getCurrentTaxBps();
|
|
40
|
+
console.log(chalk_1.default.yellow('Token Info:'));
|
|
41
|
+
console.log(` Name: ${chalk_1.default.white(name)}`);
|
|
42
|
+
console.log(` Symbol: ${chalk_1.default.white(symbol)}`);
|
|
43
|
+
console.log(` Pool: ${chalk_1.default.gray(pool)}`);
|
|
44
|
+
console.log(` Tax: ${chalk_1.default.red(Number(taxBps) / 100 + '%')}`);
|
|
45
|
+
// Get amount
|
|
46
|
+
let amountEth = options.amount;
|
|
47
|
+
if (!amountEth) {
|
|
48
|
+
const { amount } = await inquirer_1.default.prompt([{
|
|
49
|
+
type: 'input',
|
|
50
|
+
name: 'amount',
|
|
51
|
+
message: 'ETH amount to spend:',
|
|
52
|
+
validate: (input) => {
|
|
53
|
+
const num = parseFloat(input);
|
|
54
|
+
return num > 0 || 'Must be greater than 0';
|
|
55
|
+
},
|
|
56
|
+
}]);
|
|
57
|
+
amountEth = amount;
|
|
58
|
+
}
|
|
59
|
+
const amountWei = ethers_1.ethers.parseEther(amountEth);
|
|
60
|
+
// Check balance
|
|
61
|
+
const balance = await wallet.provider?.getBalance(wallet.address);
|
|
62
|
+
if (balance && balance < amountWei) {
|
|
63
|
+
console.log(chalk_1.default.red(`Insufficient balance. Have ${ethers_1.ethers.formatEther(balance)} ETH`));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Calculate expected output (rough estimate)
|
|
67
|
+
const taxDeduction = Number(taxBps) / 10000;
|
|
68
|
+
const effectiveEth = Number(amountEth) * (1 - taxDeduction);
|
|
69
|
+
console.log(`\n Spending: ${chalk_1.default.cyan(amountEth)} ETH`);
|
|
70
|
+
console.log(` After ${Number(taxBps) / 100}% tax: ~${chalk_1.default.cyan(effectiveEth.toFixed(6))} ETH worth of tokens`);
|
|
71
|
+
// Confirmation
|
|
72
|
+
if (!options.yes) {
|
|
73
|
+
const { confirm } = await inquirer_1.default.prompt([{
|
|
74
|
+
type: 'confirm',
|
|
75
|
+
name: 'confirm',
|
|
76
|
+
message: 'Proceed with purchase?',
|
|
77
|
+
default: true,
|
|
78
|
+
}]);
|
|
79
|
+
if (!confirm) {
|
|
80
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Execute swap
|
|
85
|
+
const spinner = (0, ora_1.default)('Executing swap...').start();
|
|
86
|
+
const swapRouter = (0, contracts_1.getSwapRouterContract)(wallet);
|
|
87
|
+
const weth = (0, contracts_1.getWethContract)(wallet);
|
|
88
|
+
// Wrap ETH to WETH
|
|
89
|
+
spinner.text = 'Wrapping ETH to WETH...';
|
|
90
|
+
const wrapTx = await weth.deposit({ value: amountWei });
|
|
91
|
+
await wrapTx.wait();
|
|
92
|
+
// Approve router
|
|
93
|
+
spinner.text = 'Approving router...';
|
|
94
|
+
const approveTx = await weth.approve(addresses.swapRouter, amountWei);
|
|
95
|
+
await approveTx.wait();
|
|
96
|
+
// Swap WETH for tokens
|
|
97
|
+
spinner.text = 'Swapping for tokens...';
|
|
98
|
+
const swapParams = {
|
|
99
|
+
tokenIn: addresses.weth,
|
|
100
|
+
tokenOut: tokenAddress,
|
|
101
|
+
fee: 10000, // 1% fee tier
|
|
102
|
+
recipient: wallet.address,
|
|
103
|
+
amountIn: amountWei,
|
|
104
|
+
amountOutMinimum: 0, // No slippage protection for simplicity
|
|
105
|
+
sqrtPriceLimitX96: 0,
|
|
106
|
+
};
|
|
107
|
+
const swapTx = await swapRouter.exactInputSingle(swapParams);
|
|
108
|
+
const receipt = await swapTx.wait();
|
|
109
|
+
// Get new balance
|
|
110
|
+
const tokenBalance = await token.balanceOf(wallet.address);
|
|
111
|
+
spinner.succeed(chalk_1.default.green('Purchase complete!'));
|
|
112
|
+
console.log('\n' + chalk_1.default.yellow('Result:'));
|
|
113
|
+
console.log(` Tokens received: ${chalk_1.default.green(ethers_1.ethers.formatEther(tokenBalance))} ${symbol}`);
|
|
114
|
+
console.log(` TX Hash: ${chalk_1.default.gray(receipt.hash)}`);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.log(chalk_1.default.red(`Error: ${error.message || error}`));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=buy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buy.js","sourceRoot":"","sources":["../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AC,GAAG,CAAC,sBAAsB,eAAK,CAAC,KAAK,CAAC,eAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,cAAc,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAExD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,YAAY,SA2IrB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* claws claim - Claim accumulated fees
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.claimCommand = void 0;
|
|
10
|
+
const commander_1 = require("commander");
|
|
11
|
+
const ethers_1 = require("ethers");
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const ora_1 = __importDefault(require("ora"));
|
|
14
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
15
|
+
const config_1 = require("../utils/config");
|
|
16
|
+
const contracts_1 = require("../utils/contracts");
|
|
17
|
+
exports.claimCommand = new commander_1.Command('claim')
|
|
18
|
+
.description('Claim accumulated trading fees')
|
|
19
|
+
.argument('[token]', 'Token address (optional if you have one agent)')
|
|
20
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
21
|
+
.option('--sell-tax', 'Also sell accumulated token tax')
|
|
22
|
+
.action(async (tokenAddress, options) => {
|
|
23
|
+
console.log(chalk_1.default.cyan('\n🦞 Claim Agent Fees\n'));
|
|
24
|
+
if (!(0, config_1.hasWallet)()) {
|
|
25
|
+
console.log(chalk_1.default.red('No wallet configured. Run: claws config --key <privateKey>'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const wallet = (0, config_1.getWallet)();
|
|
29
|
+
const config = (0, config_1.getConfig)();
|
|
30
|
+
console.log(chalk_1.default.gray(`Network: ${config.network}`));
|
|
31
|
+
console.log(chalk_1.default.gray(`Wallet: ${wallet.address}\n`));
|
|
32
|
+
// If no token provided, try to find user's agent
|
|
33
|
+
if (!tokenAddress) {
|
|
34
|
+
const factory = (0, contracts_1.getFactoryContract)(wallet);
|
|
35
|
+
tokenAddress = await factory.tokenByWallet(wallet.address);
|
|
36
|
+
if (!tokenAddress || tokenAddress === ethers_1.ethers.ZeroAddress) {
|
|
37
|
+
console.log(chalk_1.default.red('No token address provided and no agent found for this wallet'));
|
|
38
|
+
console.log(chalk_1.default.gray('Usage: claws claim <token-address>'));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log(chalk_1.default.gray(`Found your agent token: ${tokenAddress}\n`));
|
|
42
|
+
}
|
|
43
|
+
// Get token and fee collector info
|
|
44
|
+
const token = (0, contracts_1.getTokenContract)(tokenAddress, wallet);
|
|
45
|
+
const feeCollector = (0, contracts_1.getFeeCollectorContract)(wallet);
|
|
46
|
+
try {
|
|
47
|
+
const name = await token.name();
|
|
48
|
+
const symbol = await token.symbol();
|
|
49
|
+
const agentWallet = await token.agentWallet();
|
|
50
|
+
// Get fee info
|
|
51
|
+
const [agentPercent, creatorPercent, platformPercent, splitType] = await feeCollector.getFeeSplits(tokenAddress);
|
|
52
|
+
const totalCollected = await feeCollector.getTotalCollected(tokenAddress);
|
|
53
|
+
const lastBlock = await feeCollector.getLastCollectionBlock(tokenAddress);
|
|
54
|
+
const pendingTax = await feeCollector.getPendingTokenTax(tokenAddress);
|
|
55
|
+
console.log(chalk_1.default.yellow('Agent Info:'));
|
|
56
|
+
console.log(` Name: ${chalk_1.default.white(name)}`);
|
|
57
|
+
console.log(` Symbol: ${chalk_1.default.white(symbol)}`);
|
|
58
|
+
console.log(` Wallet: ${chalk_1.default.gray(agentWallet)}`);
|
|
59
|
+
console.log(` Type: ${chalk_1.default.green(splitType)}`);
|
|
60
|
+
console.log('\n' + chalk_1.default.yellow('Fee Splits:'));
|
|
61
|
+
console.log(` Agent: ${chalk_1.default.green(agentPercent.toString() + '%')}`);
|
|
62
|
+
if (Number(creatorPercent) > 0) {
|
|
63
|
+
console.log(` Creator: ${chalk_1.default.cyan(creatorPercent.toString() + '%')}`);
|
|
64
|
+
}
|
|
65
|
+
console.log(` Platform: ${chalk_1.default.gray(platformPercent.toString() + '%')}`);
|
|
66
|
+
console.log('\n' + chalk_1.default.yellow('Collection Status:'));
|
|
67
|
+
console.log(` Total Collected: ${chalk_1.default.cyan(ethers_1.ethers.formatEther(totalCollected))} ETH`);
|
|
68
|
+
console.log(` Last Collection: Block ${chalk_1.default.gray(lastBlock.toString())}`);
|
|
69
|
+
console.log(` Pending Tax: ${chalk_1.default.cyan(ethers_1.ethers.formatEther(pendingTax))} tokens`);
|
|
70
|
+
// Check if caller is agent or creator
|
|
71
|
+
const creator = await token.creator();
|
|
72
|
+
const canClaim = wallet.address.toLowerCase() === agentWallet.toLowerCase() ||
|
|
73
|
+
wallet.address.toLowerCase() === creator.toLowerCase();
|
|
74
|
+
if (!canClaim) {
|
|
75
|
+
console.log(chalk_1.default.yellow('\n⚠️ You are not the agent or creator. Only they can manual claim.'));
|
|
76
|
+
console.log(chalk_1.default.gray('Anyone can trigger collectSingle() to collect LP fees.'));
|
|
77
|
+
}
|
|
78
|
+
// Confirmation
|
|
79
|
+
if (!options.yes) {
|
|
80
|
+
const choices = ['Collect LP fees (collectSingle)'];
|
|
81
|
+
if (canClaim) {
|
|
82
|
+
choices.push('Manual claim (emergency backup)');
|
|
83
|
+
}
|
|
84
|
+
if (pendingTax > 0n) {
|
|
85
|
+
choices.push('Sell token tax');
|
|
86
|
+
}
|
|
87
|
+
choices.push('Cancel');
|
|
88
|
+
const { action } = await inquirer_1.default.prompt([{
|
|
89
|
+
type: 'list',
|
|
90
|
+
name: 'action',
|
|
91
|
+
message: 'What would you like to do?',
|
|
92
|
+
choices,
|
|
93
|
+
}]);
|
|
94
|
+
if (action === 'Cancel') {
|
|
95
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const spinner = (0, ora_1.default)('Processing...').start();
|
|
99
|
+
if (action.includes('collectSingle')) {
|
|
100
|
+
spinner.text = 'Collecting LP fees...';
|
|
101
|
+
const tx = await feeCollector.collectSingle(tokenAddress);
|
|
102
|
+
const receipt = await tx.wait();
|
|
103
|
+
spinner.succeed(chalk_1.default.green('LP fees collected!'));
|
|
104
|
+
console.log(` TX Hash: ${chalk_1.default.gray(receipt.hash)}`);
|
|
105
|
+
}
|
|
106
|
+
else if (action.includes('Manual claim')) {
|
|
107
|
+
spinner.text = 'Manual claiming...';
|
|
108
|
+
const tx = await feeCollector.manualClaim(tokenAddress);
|
|
109
|
+
const receipt = await tx.wait();
|
|
110
|
+
spinner.succeed(chalk_1.default.green('Manual claim complete!'));
|
|
111
|
+
console.log(` TX Hash: ${chalk_1.default.gray(receipt.hash)}`);
|
|
112
|
+
}
|
|
113
|
+
else if (action.includes('Sell token tax')) {
|
|
114
|
+
spinner.text = 'Selling token tax...';
|
|
115
|
+
const tx = await feeCollector.sellTokenTax(tokenAddress);
|
|
116
|
+
const receipt = await tx.wait();
|
|
117
|
+
spinner.succeed(chalk_1.default.green('Token tax sold and distributed!'));
|
|
118
|
+
console.log(` TX Hash: ${chalk_1.default.gray(receipt.hash)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// Auto mode - collect LP fees
|
|
123
|
+
const spinner = (0, ora_1.default)('Collecting LP fees...').start();
|
|
124
|
+
const tx = await feeCollector.collectSingle(tokenAddress);
|
|
125
|
+
const receipt = await tx.wait();
|
|
126
|
+
spinner.succeed(chalk_1.default.green('LP fees collected!'));
|
|
127
|
+
console.log(` TX Hash: ${chalk_1.default.gray(receipt.hash)}`);
|
|
128
|
+
// Optionally sell token tax
|
|
129
|
+
if (options.sellTax && pendingTax > 0n) {
|
|
130
|
+
const taxSpinner = (0, ora_1.default)('Selling token tax...').start();
|
|
131
|
+
const taxTx = await feeCollector.sellTokenTax(tokenAddress);
|
|
132
|
+
await taxTx.wait();
|
|
133
|
+
taxSpinner.succeed(chalk_1.default.green('Token tax sold!'));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.log(chalk_1.default.red(`Error: ${error.message || error}`));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
//# sourceMappingURL=claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,yCAAoC;AACpC,mCAAgC;AAChC,kDAA0B;AAC1B,8CAAsB;AACtB,wDAAgC;AAChC,4CAAkE;AAClE,kDAAmG;AAEtF,QAAA,YAAY,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,gCAAgC,CAAC;KAC7C,QAAQ,CAAC,SAAS,EAAE,gDAAgD,CAAC;KACrE,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC;KACxC,MAAM,CAAC,YAAY,EAAE,iCAAiC,CAAC;KACvD,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE;IACtC,OAAO,CAAC,GAA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AAI,CAAC,EAAE,CAAC,CAAC;YAEtD,4BAA4B;YAC5B,IAAI,OAAO,CAAC,OAAO,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;gBACvC,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,sBAAsB,CAAC,CAAC,KAAK,EAAE,CAAC;gBACvD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;gBAC5D,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,UAAU,CAAC,OAAO,CAAC,eAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;IAEH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SAoEtB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* claws config - Configure wallet and network settings
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.configCommand = void 0;
|
|
43
|
+
const commander_1 = require("commander");
|
|
44
|
+
const config_1 = require("../utils/config");
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
exports.configCommand = new commander_1.Command('config')
|
|
47
|
+
.description('Configure wallet and network settings')
|
|
48
|
+
.option('-n, --network <network>', 'Set network (sepolia, base)')
|
|
49
|
+
.option('-k, --key <privateKey>', 'Set private key')
|
|
50
|
+
.option('-r, --rpc <url>', 'Set custom RPC URL')
|
|
51
|
+
.option('-s, --show', 'Show current configuration')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
console.log(chalk_1.default.cyan('🦞 claws.fun CLI Configuration\n'));
|
|
54
|
+
// Show current config
|
|
55
|
+
if (options.show || (!options.network && !options.key && !options.rpc)) {
|
|
56
|
+
const config = (0, config_1.getConfig)();
|
|
57
|
+
const wallet = (0, config_1.getWallet)();
|
|
58
|
+
console.log(chalk_1.default.yellow('Current Configuration:'));
|
|
59
|
+
console.log(` Network: ${chalk_1.default.green(config.network || 'sepolia')}`);
|
|
60
|
+
console.log(` RPC URL: ${chalk_1.default.green(config.rpcUrl || config_1.RPC_URLS[config.network || 'sepolia'])}`);
|
|
61
|
+
console.log(` Private Key: ${config.privateKey ? chalk_1.default.green('✓ Set') : chalk_1.default.red('✗ Not set')}`);
|
|
62
|
+
if (wallet) {
|
|
63
|
+
console.log(` Wallet: ${chalk_1.default.green(wallet.address)}`);
|
|
64
|
+
const balance = await wallet.provider?.getBalance(wallet.address);
|
|
65
|
+
if (balance !== undefined) {
|
|
66
|
+
console.log(` Balance: ${chalk_1.default.green(Number(balance) / 1e18)} ETH`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
console.log('\n' + chalk_1.default.yellow('Contract Addresses:'));
|
|
70
|
+
const addresses = config_1.ADDRESSES[config.network || 'sepolia'];
|
|
71
|
+
Object.entries(addresses).forEach(([name, address]) => {
|
|
72
|
+
console.log(` ${name.padEnd(16)} ${chalk_1.default.gray(address)}`);
|
|
73
|
+
});
|
|
74
|
+
console.log('\n' + chalk_1.default.gray('Use --help for configuration options'));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Set network
|
|
78
|
+
if (options.network) {
|
|
79
|
+
if (!['sepolia', 'base'].includes(options.network)) {
|
|
80
|
+
console.log(chalk_1.default.red('Invalid network. Choose: sepolia, base'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
(0, config_1.setConfig)('network', options.network);
|
|
84
|
+
console.log(chalk_1.default.green(`✓ Network set to: ${options.network}`));
|
|
85
|
+
}
|
|
86
|
+
// Set private key
|
|
87
|
+
if (options.key) {
|
|
88
|
+
try {
|
|
89
|
+
// Validate private key format
|
|
90
|
+
const { ethers } = await Promise.resolve().then(() => __importStar(require('ethers')));
|
|
91
|
+
const wallet = new ethers.Wallet(options.key);
|
|
92
|
+
(0, config_1.setConfig)('privateKey', options.key);
|
|
93
|
+
console.log(chalk_1.default.green(`✓ Private key set for wallet: ${wallet.address}`));
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.log(chalk_1.default.red('Invalid private key format'));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Set RPC URL
|
|
101
|
+
if (options.rpc) {
|
|
102
|
+
(0, config_1.setConfig)('rpcUrl', options.rpc);
|
|
103
|
+
console.log(chalk_1.default.green(`✓ RPC URL set to: ${options.rpc}`));
|
|
104
|
+
}
|
|
105
|
+
console.log(chalk_1.default.gray('\nRun `claws config --show` to view configuration'));
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,4CAAuF;AACvF,kDAA0B;AAEb,QAAA,aAAa,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,uCAAuC,CAAC;KACpD,MAAM,CAAC,yBAAyB,EAAE,6BAA6B,CAAC;KAChE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC;KACnD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;KAC/C,MAAM,CAAC,YAAY,EAAE,4BAA4B,CAAC;KAClD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,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