minara 0.3.0 → 0.3.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/package.json +1 -1
- package/dist/api/copytrade.d.ts +0 -19
- package/dist/api/copytrade.js +0 -37
- package/dist/commands/copy-trade.d.ts +0 -2
- package/dist/commands/copy-trade.js +0 -170
package/package.json
CHANGED
package/dist/api/copytrade.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CreateCopyTradeDto, UpdateCopyTradeDto, CopyTradeInfo } from '../types.js';
|
|
2
|
-
/** Create copy trade */
|
|
3
|
-
export declare function createCopyTrade(token: string, dto: CreateCopyTradeDto): Promise<import("../types.js").ApiResponse<CopyTradeInfo>>;
|
|
4
|
-
/** List user's copy trades */
|
|
5
|
-
export declare function listCopyTrades(token: string): Promise<import("../types.js").ApiResponse<CopyTradeInfo[]>>;
|
|
6
|
-
/** Get copy trade by ID */
|
|
7
|
-
export declare function getCopyTrade(token: string, id: string): Promise<import("../types.js").ApiResponse<CopyTradeInfo>>;
|
|
8
|
-
/** Update copy trade */
|
|
9
|
-
export declare function updateCopyTrade(token: string, id: string, dto: UpdateCopyTradeDto): Promise<import("../types.js").ApiResponse<CopyTradeInfo>>;
|
|
10
|
-
/** Delete copy trade */
|
|
11
|
-
export declare function deleteCopyTrade(token: string, id: string): Promise<import("../types.js").ApiResponse<void>>;
|
|
12
|
-
/** Start copy trade */
|
|
13
|
-
export declare function startCopyTrade(token: string, id: string): Promise<import("../types.js").ApiResponse<void>>;
|
|
14
|
-
/** Stop copy trade */
|
|
15
|
-
export declare function stopCopyTrade(token: string, id: string): Promise<import("../types.js").ApiResponse<void>>;
|
|
16
|
-
/** Get copy trade activity */
|
|
17
|
-
export declare function getCopyTradeActivity(token: string, id: string): Promise<import("../types.js").ApiResponse<Record<string, unknown>[]>>;
|
|
18
|
-
/** Get copy trade PnL chart */
|
|
19
|
-
export declare function getCopyTradePnl(token: string, id: string): Promise<import("../types.js").ApiResponse<Record<string, unknown>>>;
|
package/dist/api/copytrade.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { get, post, patch, del } from './client.js';
|
|
2
|
-
/** Create copy trade */
|
|
3
|
-
export function createCopyTrade(token, dto) {
|
|
4
|
-
return post('/copy-trade', { token, body: dto });
|
|
5
|
-
}
|
|
6
|
-
/** List user's copy trades */
|
|
7
|
-
export function listCopyTrades(token) {
|
|
8
|
-
return get('/copy-trade', { token });
|
|
9
|
-
}
|
|
10
|
-
/** Get copy trade by ID */
|
|
11
|
-
export function getCopyTrade(token, id) {
|
|
12
|
-
return get(`/copy-trade/${encodeURIComponent(id)}`, { token });
|
|
13
|
-
}
|
|
14
|
-
/** Update copy trade */
|
|
15
|
-
export function updateCopyTrade(token, id, dto) {
|
|
16
|
-
return patch(`/copy-trade/${encodeURIComponent(id)}`, { token, body: dto });
|
|
17
|
-
}
|
|
18
|
-
/** Delete copy trade */
|
|
19
|
-
export function deleteCopyTrade(token, id) {
|
|
20
|
-
return del(`/copy-trade/${encodeURIComponent(id)}`, { token });
|
|
21
|
-
}
|
|
22
|
-
/** Start copy trade */
|
|
23
|
-
export function startCopyTrade(token, id) {
|
|
24
|
-
return patch(`/copy-trade/${encodeURIComponent(id)}/start`, { token });
|
|
25
|
-
}
|
|
26
|
-
/** Stop copy trade */
|
|
27
|
-
export function stopCopyTrade(token, id) {
|
|
28
|
-
return patch(`/copy-trade/${encodeURIComponent(id)}/stop`, { token });
|
|
29
|
-
}
|
|
30
|
-
/** Get copy trade activity */
|
|
31
|
-
export function getCopyTradeActivity(token, id) {
|
|
32
|
-
return get(`/copy-trade/${encodeURIComponent(id)}/activity`, { token });
|
|
33
|
-
}
|
|
34
|
-
/** Get copy trade PnL chart */
|
|
35
|
-
export function getCopyTradePnl(token, id) {
|
|
36
|
-
return get(`/copy-trade/${encodeURIComponent(id)}/pnl/chart`, { token });
|
|
37
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { input, select, confirm, number as numberPrompt } from '@inquirer/prompts';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import * as ctApi from '../api/copytrade.js';
|
|
5
|
-
import { requireAuth } from '../config.js';
|
|
6
|
-
import { success, info, spinner, assertApiOk, selectChain, wrapAction } from '../utils.js';
|
|
7
|
-
// ─── create ──────────────────────────────────────────────────────────────
|
|
8
|
-
const createCmd = new Command('create')
|
|
9
|
-
.description('Create a copy trade bot')
|
|
10
|
-
.option('-y, --yes', 'Skip confirmation')
|
|
11
|
-
.action(wrapAction(async (opts) => {
|
|
12
|
-
const creds = requireAuth();
|
|
13
|
-
const chain = await selectChain('Chain:', true);
|
|
14
|
-
const targetAddress = await input({
|
|
15
|
-
message: 'Target wallet address to copy:',
|
|
16
|
-
validate: (v) => (v.length > 5 ? true : 'Enter a valid address'),
|
|
17
|
-
});
|
|
18
|
-
const name = await input({ message: 'Name for this copy trade (optional):' }) || undefined;
|
|
19
|
-
const fixedAmount = await numberPrompt({ message: 'Fixed buy amount (USD) per copy:', min: 1, required: true });
|
|
20
|
-
const copySell = await confirm({ message: 'Also copy sell actions?', default: true });
|
|
21
|
-
let copySellSamePercentage = false;
|
|
22
|
-
let copySellQuitPercentage;
|
|
23
|
-
if (copySell) {
|
|
24
|
-
copySellSamePercentage = await confirm({
|
|
25
|
-
message: 'Copy sell with same percentage as target?',
|
|
26
|
-
default: true,
|
|
27
|
-
});
|
|
28
|
-
copySellQuitPercentage = (await numberPrompt({
|
|
29
|
-
message: 'Clear position alert % (when target sells >= this %, clear your position; 0 to skip):',
|
|
30
|
-
default: 0,
|
|
31
|
-
})) || undefined;
|
|
32
|
-
}
|
|
33
|
-
console.log('');
|
|
34
|
-
console.log(chalk.bold('Copy Trade Bot:'));
|
|
35
|
-
console.log(` Chain : ${chalk.cyan(chain)}`);
|
|
36
|
-
console.log(` Target : ${chalk.yellow(targetAddress)}`);
|
|
37
|
-
if (name)
|
|
38
|
-
console.log(` Name : ${name}`);
|
|
39
|
-
console.log(` Buy Amount : $${fixedAmount}`);
|
|
40
|
-
console.log(` Copy Sell : ${copySell ? 'Yes' : 'No'}`);
|
|
41
|
-
if (copySellSamePercentage)
|
|
42
|
-
console.log(` Same % : Yes`);
|
|
43
|
-
if (copySellQuitPercentage)
|
|
44
|
-
console.log(` Quit Threshold : ${copySellQuitPercentage}%`);
|
|
45
|
-
console.log('');
|
|
46
|
-
if (!opts.yes) {
|
|
47
|
-
const ok = await confirm({ message: 'Create this copy trade?', default: false });
|
|
48
|
-
if (!ok)
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const spin = spinner('Creating copy trade…');
|
|
52
|
-
const res = await ctApi.createCopyTrade(creds.accessToken, {
|
|
53
|
-
chain, targetAddress, name,
|
|
54
|
-
mode: 'fixedAmount',
|
|
55
|
-
fixedAmount: fixedAmount,
|
|
56
|
-
copySell,
|
|
57
|
-
copySellSamePercentage,
|
|
58
|
-
copySellQuitPercentage,
|
|
59
|
-
});
|
|
60
|
-
spin.stop();
|
|
61
|
-
assertApiOk(res, 'Failed to create copy trade');
|
|
62
|
-
success('Copy trade created!');
|
|
63
|
-
if (res.data)
|
|
64
|
-
console.log(JSON.stringify(res.data, null, 2));
|
|
65
|
-
}));
|
|
66
|
-
// ─── list ────────────────────────────────────────────────────────────────
|
|
67
|
-
const listCmd = new Command('list')
|
|
68
|
-
.alias('ls')
|
|
69
|
-
.description('List your copy trades')
|
|
70
|
-
.action(wrapAction(async () => {
|
|
71
|
-
const creds = requireAuth();
|
|
72
|
-
const spin = spinner('Fetching copy trades…');
|
|
73
|
-
const res = await ctApi.listCopyTrades(creds.accessToken);
|
|
74
|
-
spin.stop();
|
|
75
|
-
assertApiOk(res, 'Failed to fetch copy trades');
|
|
76
|
-
const data = res.data;
|
|
77
|
-
if (!data || data.length === 0) {
|
|
78
|
-
console.log(chalk.dim('No copy trades.'));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
console.log(JSON.stringify(data, null, 2));
|
|
82
|
-
}));
|
|
83
|
-
// ─── start / stop ────────────────────────────────────────────────────────
|
|
84
|
-
async function pickCopyTrade(token) {
|
|
85
|
-
const spin = spinner('Fetching copy trades…');
|
|
86
|
-
const res = await ctApi.listCopyTrades(token);
|
|
87
|
-
spin.stop();
|
|
88
|
-
const trades = res.data;
|
|
89
|
-
if (!trades || trades.length === 0) {
|
|
90
|
-
info('No copy trades found.');
|
|
91
|
-
process.exit(0);
|
|
92
|
-
}
|
|
93
|
-
return select({
|
|
94
|
-
message: 'Select copy trade:',
|
|
95
|
-
choices: trades.map((t) => ({
|
|
96
|
-
name: `[${t.id.slice(0, 12)}…] ${t.name ?? t.targetAddress} status=${t.status ?? '?'}`,
|
|
97
|
-
value: t.id,
|
|
98
|
-
})),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
const startCmd = new Command('start')
|
|
102
|
-
.description('Start (resume) a copy trade')
|
|
103
|
-
.argument('[id]', 'Copy trade ID')
|
|
104
|
-
.action(wrapAction(async (idArg) => {
|
|
105
|
-
const creds = requireAuth();
|
|
106
|
-
const id = idArg ?? await pickCopyTrade(creds.accessToken);
|
|
107
|
-
const spin = spinner('Starting…');
|
|
108
|
-
const res = await ctApi.startCopyTrade(creds.accessToken, id);
|
|
109
|
-
spin.stop();
|
|
110
|
-
assertApiOk(res, 'Failed to start copy trade');
|
|
111
|
-
success('Copy trade started.');
|
|
112
|
-
}));
|
|
113
|
-
const stopCmd = new Command('stop')
|
|
114
|
-
.description('Stop (pause) a copy trade')
|
|
115
|
-
.argument('[id]', 'Copy trade ID')
|
|
116
|
-
.action(wrapAction(async (idArg) => {
|
|
117
|
-
const creds = requireAuth();
|
|
118
|
-
const id = idArg ?? await pickCopyTrade(creds.accessToken);
|
|
119
|
-
const ok = await confirm({ message: `Stop copy trade ${id.slice(0, 12)}…?`, default: false });
|
|
120
|
-
if (!ok)
|
|
121
|
-
return;
|
|
122
|
-
const spin = spinner('Stopping…');
|
|
123
|
-
const res = await ctApi.stopCopyTrade(creds.accessToken, id);
|
|
124
|
-
spin.stop();
|
|
125
|
-
assertApiOk(res, 'Failed to stop copy trade');
|
|
126
|
-
success('Copy trade stopped.');
|
|
127
|
-
}));
|
|
128
|
-
// ─── delete ──────────────────────────────────────────────────────────────
|
|
129
|
-
const deleteCmd = new Command('delete')
|
|
130
|
-
.description('Delete a copy trade')
|
|
131
|
-
.argument('[id]', 'Copy trade ID')
|
|
132
|
-
.option('-y, --yes', 'Skip confirmation')
|
|
133
|
-
.action(wrapAction(async (idArg, opts) => {
|
|
134
|
-
const creds = requireAuth();
|
|
135
|
-
const id = idArg ?? await pickCopyTrade(creds.accessToken);
|
|
136
|
-
if (!opts?.yes) {
|
|
137
|
-
const ok = await confirm({ message: `Delete copy trade ${id.slice(0, 12)}…? This cannot be undone.`, default: false });
|
|
138
|
-
if (!ok)
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const spin = spinner('Deleting…');
|
|
142
|
-
const res = await ctApi.deleteCopyTrade(creds.accessToken, id);
|
|
143
|
-
spin.stop();
|
|
144
|
-
assertApiOk(res, 'Failed to delete copy trade');
|
|
145
|
-
success('Copy trade deleted.');
|
|
146
|
-
}));
|
|
147
|
-
// ─── parent ──────────────────────────────────────────────────────────────
|
|
148
|
-
export const copyTradeCommand = new Command('copy-trade')
|
|
149
|
-
.alias('ct')
|
|
150
|
-
.description('Copy trading — follow wallet addresses')
|
|
151
|
-
.addCommand(createCmd)
|
|
152
|
-
.addCommand(listCmd)
|
|
153
|
-
.addCommand(startCmd)
|
|
154
|
-
.addCommand(stopCmd)
|
|
155
|
-
.addCommand(deleteCmd)
|
|
156
|
-
.action(wrapAction(async () => {
|
|
157
|
-
const action = await select({
|
|
158
|
-
message: 'Copy Trade:',
|
|
159
|
-
choices: [
|
|
160
|
-
{ name: 'Create a new copy trade', value: 'create' },
|
|
161
|
-
{ name: 'List copy trades', value: 'list' },
|
|
162
|
-
{ name: 'Start a copy trade', value: 'start' },
|
|
163
|
-
{ name: 'Stop a copy trade', value: 'stop' },
|
|
164
|
-
{ name: 'Delete a copy trade', value: 'delete' },
|
|
165
|
-
],
|
|
166
|
-
});
|
|
167
|
-
const sub = copyTradeCommand.commands.find((c) => c.name() === action);
|
|
168
|
-
if (sub)
|
|
169
|
-
await sub.parseAsync([], { from: 'user' });
|
|
170
|
-
}));
|