@zeroexcore/trader 1.0.0 → 1.1.3
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 +12 -1
- package/dist/utils/perps/index.d.ts.map +1 -1
- package/dist/utils/perps/index.js +1 -4
- package/dist/utils/perps/index.js.map +1 -1
- package/package.json +5 -1
- package/dist/commands/book.d.ts +0 -3
- package/dist/commands/book.d.ts.map +0 -1
- package/dist/commands/book.js +0 -44
- package/dist/commands/book.js.map +0 -1
- package/dist/commands/nft/floor.d.ts +0 -3
- package/dist/commands/nft/floor.d.ts.map +0 -1
- package/dist/commands/nft/floor.js +0 -30
- package/dist/commands/nft/floor.js.map +0 -1
- package/dist/commands/nft/index.d.ts +0 -3
- package/dist/commands/nft/index.d.ts.map +0 -1
- package/dist/commands/nft/index.js +0 -14
- package/dist/commands/nft/index.js.map +0 -1
- package/dist/commands/nft/listings.d.ts +0 -3
- package/dist/commands/nft/listings.d.ts.map +0 -1
- package/dist/commands/nft/listings.js +0 -37
- package/dist/commands/nft/listings.js.map +0 -1
- package/dist/commands/nft/popular.d.ts +0 -3
- package/dist/commands/nft/popular.d.ts.map +0 -1
- package/dist/commands/nft/popular.js +0 -32
- package/dist/commands/nft/popular.js.map +0 -1
- package/dist/commands/nft/portfolio.d.ts +0 -3
- package/dist/commands/nft/portfolio.d.ts.map +0 -1
- package/dist/commands/nft/portfolio.js +0 -43
- package/dist/commands/nft/portfolio.js.map +0 -1
- package/dist/commands/nft/search.d.ts +0 -3
- package/dist/commands/nft/search.d.ts.map +0 -1
- package/dist/commands/nft/search.js +0 -36
- package/dist/commands/nft/search.js.map +0 -1
- package/dist/commands/nft.d.ts +0 -3
- package/dist/commands/nft.d.ts.map +0 -1
- package/dist/commands/nft.js +0 -165
- package/dist/commands/nft.js.map +0 -1
- package/dist/commands/perps/info.d.ts +0 -3
- package/dist/commands/perps/info.d.ts.map +0 -1
- package/dist/commands/perps/info.js +0 -51
- package/dist/commands/perps/info.js.map +0 -1
- package/dist/commands/perps/markets.d.ts +0 -3
- package/dist/commands/perps/markets.d.ts.map +0 -1
- package/dist/commands/perps/markets.js +0 -43
- package/dist/commands/perps/markets.js.map +0 -1
- package/dist/commands/perps.d.ts +0 -3
- package/dist/commands/perps.d.ts.map +0 -1
- package/dist/commands/perps.js +0 -186
- package/dist/commands/perps.js.map +0 -1
- package/dist/commands/positions/close.d.ts +0 -3
- package/dist/commands/positions/close.d.ts.map +0 -1
- package/dist/commands/positions/close.js +0 -31
- package/dist/commands/positions/close.js.map +0 -1
- package/dist/commands/positions/filter.d.ts +0 -3
- package/dist/commands/positions/filter.d.ts.map +0 -1
- package/dist/commands/positions/filter.js +0 -20
- package/dist/commands/positions/filter.js.map +0 -1
- package/dist/commands/positions/index.d.ts +0 -3
- package/dist/commands/positions/index.d.ts.map +0 -1
- package/dist/commands/positions/index.js +0 -22
- package/dist/commands/positions/index.js.map +0 -1
- package/dist/commands/positions/list.d.ts +0 -3
- package/dist/commands/positions/list.d.ts.map +0 -1
- package/dist/commands/positions/list.js +0 -38
- package/dist/commands/positions/list.js.map +0 -1
- package/dist/commands/positions/note.d.ts +0 -3
- package/dist/commands/positions/note.d.ts.map +0 -1
- package/dist/commands/positions/note.js +0 -19
- package/dist/commands/positions/note.js.map +0 -1
- package/dist/commands/positions/open.d.ts +0 -3
- package/dist/commands/positions/open.d.ts.map +0 -1
- package/dist/commands/positions/open.js +0 -47
- package/dist/commands/positions/open.js.map +0 -1
- package/dist/commands/positions/show.d.ts +0 -3
- package/dist/commands/positions/show.d.ts.map +0 -1
- package/dist/commands/positions/show.js +0 -46
- package/dist/commands/positions/show.js.map +0 -1
- package/dist/commands/positions/stats.d.ts +0 -3
- package/dist/commands/positions/stats.d.ts.map +0 -1
- package/dist/commands/positions/stats.js +0 -27
- package/dist/commands/positions/stats.js.map +0 -1
- package/dist/commands/positions/tag.d.ts +0 -3
- package/dist/commands/positions/tag.d.ts.map +0 -1
- package/dist/commands/positions/tag.js +0 -19
- package/dist/commands/positions/tag.js.map +0 -1
- package/dist/commands/positions/update.d.ts +0 -3
- package/dist/commands/positions/update.d.ts.map +0 -1
- package/dist/commands/positions/update.js +0 -35
- package/dist/commands/positions/update.js.map +0 -1
- package/dist/commands/positions.d.ts +0 -3
- package/dist/commands/positions.d.ts.map +0 -1
- package/dist/commands/positions.js +0 -247
- package/dist/commands/positions.js.map +0 -1
- package/dist/commands/predict/list.d.ts +0 -3
- package/dist/commands/predict/list.d.ts.map +0 -1
- package/dist/commands/predict/list.js +0 -46
- package/dist/commands/predict/list.js.map +0 -1
- package/dist/commands/predict/market.d.ts +0 -3
- package/dist/commands/predict/market.d.ts.map +0 -1
- package/dist/commands/predict/market.js +0 -37
- package/dist/commands/predict/market.js.map +0 -1
- package/dist/commands/predict/watch.d.ts +0 -3
- package/dist/commands/predict/watch.d.ts.map +0 -1
- package/dist/commands/predict/watch.js +0 -73
- package/dist/commands/predict/watch.js.map +0 -1
- package/dist/commands/predict.d.ts +0 -3
- package/dist/commands/predict.d.ts.map +0 -1
- package/dist/commands/predict.js +0 -484
- package/dist/commands/predict.js.map +0 -1
- package/dist/commands/trade/index.d.ts +0 -3
- package/dist/commands/trade/index.d.ts.map +0 -1
- package/dist/commands/trade/index.js +0 -8
- package/dist/commands/trade/index.js.map +0 -1
- package/dist/commands/trade/info.d.ts +0 -3
- package/dist/commands/trade/info.d.ts.map +0 -1
- package/dist/commands/trade/info.js +0 -37
- package/dist/commands/trade/info.js.map +0 -1
- package/dist/commands/trade/quote.d.ts +0 -3
- package/dist/commands/trade/quote.d.ts.map +0 -1
- package/dist/commands/trade/quote.js +0 -56
- package/dist/commands/trade/quote.js.map +0 -1
- package/dist/commands/trade/search.d.ts +0 -3
- package/dist/commands/trade/search.d.ts.map +0 -1
- package/dist/commands/trade/search.js +0 -22
- package/dist/commands/trade/search.js.map +0 -1
- package/dist/commands/trade/swap.d.ts +0 -3
- package/dist/commands/trade/swap.d.ts.map +0 -1
- package/dist/commands/trade/swap.js +0 -70
- package/dist/commands/trade/swap.js.map +0 -1
- package/dist/commands/trade.d.ts +0 -5
- package/dist/commands/trade.d.ts.map +0 -1
- package/dist/commands/trade.js +0 -167
- package/dist/commands/trade.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/trade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,4BAA4B,CAAC,CAAC;AAE7C,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACtC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/commands/trade/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAkCpB,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { resolveToken } from '../../utils/token-book.js';
|
|
3
|
-
import { formatTokenInfo, getTokenInfo } from '../../utils/token-info.js';
|
|
4
|
-
import { output, error } from '../shared.js';
|
|
5
|
-
export const infoCommand = new Command('info')
|
|
6
|
-
.argument('<token>', 'Token symbol or address')
|
|
7
|
-
.description('Get detailed token information by symbol or address')
|
|
8
|
-
.action(async (tokenOrTicker) => {
|
|
9
|
-
try {
|
|
10
|
-
const tokenAddress = resolveToken(tokenOrTicker);
|
|
11
|
-
const info = await getTokenInfo(tokenAddress);
|
|
12
|
-
output({
|
|
13
|
-
...info,
|
|
14
|
-
explorers: {
|
|
15
|
-
solscan: `https://solscan.io/token/${info.address}`,
|
|
16
|
-
solanaExplorer: `https://explorer.solana.com/address/${info.address}`,
|
|
17
|
-
dexscreener: info.markets?.[0]?.pair ? `https://dexscreener.com/solana/${info.markets[0].pair}` : null,
|
|
18
|
-
},
|
|
19
|
-
}, () => {
|
|
20
|
-
const formatted = formatTokenInfo(info);
|
|
21
|
-
const links = [
|
|
22
|
-
'',
|
|
23
|
-
'🔗 EXPLORERS',
|
|
24
|
-
` Solscan: https://solscan.io/token/${info.address}`,
|
|
25
|
-
` Solana Explorer: https://explorer.solana.com/address/${info.address}`,
|
|
26
|
-
];
|
|
27
|
-
if (info.markets && info.markets.length > 0) {
|
|
28
|
-
links.push(` DexScreener: https://dexscreener.com/solana/${info.markets[0].pair}`);
|
|
29
|
-
}
|
|
30
|
-
return formatted + links.join('\n');
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
error('Failed to get token info', e.message);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=info.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/commands/trade/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;KAC9C,WAAW,CAAC,qDAAqD,CAAC;KAClE,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;IAC9B,IAAI,CAAC;QACH,MAAM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AE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,YAAY,SAqDrB,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import Big from 'big.js';
|
|
3
|
-
import { getTokenDecimals, toSmallestUnit, fromSmallestUnit } from '../../utils/amounts.js';
|
|
4
|
-
import { getSwapQuote } from '../../utils/jupiter.js';
|
|
5
|
-
import { resolveToken } from '../../utils/token-book.js';
|
|
6
|
-
import { output, error } from '../shared.js';
|
|
7
|
-
export const quoteCommand = new Command('quote')
|
|
8
|
-
.argument('<input-mint>', 'Input token symbol or address')
|
|
9
|
-
.argument('<output-mint>', 'Output token symbol or address')
|
|
10
|
-
.argument('<amount>', 'Amount in human-readable format')
|
|
11
|
-
.description('Get swap quote')
|
|
12
|
-
.option('-s, --slippage <bps>', 'Slippage in basis points', '50')
|
|
13
|
-
.action(async (inputMintOrTicker, outputMintOrTicker, amount, options) => {
|
|
14
|
-
const inputMint = resolveToken(inputMintOrTicker);
|
|
15
|
-
const outputMint = resolveToken(outputMintOrTicker);
|
|
16
|
-
try {
|
|
17
|
-
const decimals = await getTokenDecimals(inputMint);
|
|
18
|
-
const amountInSmallestUnit = toSmallestUnit(amount, decimals);
|
|
19
|
-
const quote = await getSwapQuote({
|
|
20
|
-
inputMint,
|
|
21
|
-
outputMint,
|
|
22
|
-
amount: parseInt(amountInSmallestUnit),
|
|
23
|
-
slippageBps: parseInt(options.slippage),
|
|
24
|
-
});
|
|
25
|
-
const outputDecimals = await getTokenDecimals(outputMint);
|
|
26
|
-
const outputAmount = fromSmallestUnit(quote.outAmount, outputDecimals);
|
|
27
|
-
const price = new Big(amount).div(new Big(outputAmount));
|
|
28
|
-
const priceImpact = typeof quote.priceImpactPct === 'string'
|
|
29
|
-
? new Big(quote.priceImpactPct).times(100)
|
|
30
|
-
: new Big(quote.priceImpactPct).times(100);
|
|
31
|
-
const impactNum = parseFloat(priceImpact.toFixed(3));
|
|
32
|
-
output({
|
|
33
|
-
inputToken: inputMintOrTicker.toUpperCase(),
|
|
34
|
-
inputAmount: amount,
|
|
35
|
-
outputToken: outputMintOrTicker.toUpperCase(),
|
|
36
|
-
outputAmount: new Big(outputAmount).toFixed(6),
|
|
37
|
-
price: price.toFixed(6),
|
|
38
|
-
priceImpactPct: impactNum,
|
|
39
|
-
slippageBps: parseInt(options.slippage),
|
|
40
|
-
}, () => {
|
|
41
|
-
const impactEmoji = impactNum < 0 ? '⚠️' : '✅';
|
|
42
|
-
return [
|
|
43
|
-
'📊 Swap Quote:',
|
|
44
|
-
` You pay: ${amount} ${inputMintOrTicker.toUpperCase()}`,
|
|
45
|
-
` You get: ~${new Big(outputAmount).toFixed(4)} ${outputMintOrTicker.toUpperCase()}`,
|
|
46
|
-
` Price: ${price.toFixed(6)} ${inputMintOrTicker.toUpperCase()} per ${outputMintOrTicker.toUpperCase()}`,
|
|
47
|
-
` Price Impact: ${impactEmoji} ${impactNum.toFixed(3)}% (${impactNum < 0 ? 'you lose value' : 'you gain value'})`,
|
|
48
|
-
` Slippage Tolerance: ${new Big(options.slippage).div(100).toFixed(2)}%`,
|
|
49
|
-
].join('\n');
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
error('Failed to get quote', e.message);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=quote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../src/commands/trade/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAA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,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;aAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/commands/trade/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SAoBtB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { searchToken } from '../../utils/jupiter.js';
|
|
3
|
-
import { output, error } from '../shared.js';
|
|
4
|
-
export const searchCommand = new Command('search')
|
|
5
|
-
.argument('<query>', 'Token name or symbol')
|
|
6
|
-
.description('Search for token by name or symbol')
|
|
7
|
-
.action(async (query) => {
|
|
8
|
-
try {
|
|
9
|
-
const tokens = await searchToken(query);
|
|
10
|
-
output({ query, results: tokens.map((t) => ({ symbol: t.symbol, name: t.name, address: t.address })) }, () => {
|
|
11
|
-
const lines = ['🔍 Search Results:', ''];
|
|
12
|
-
for (const t of tokens) {
|
|
13
|
-
lines.push(` ${t.symbol.padEnd(10)} ${t.name.slice(0, 30).padEnd(32)} ${t.address}`);
|
|
14
|
-
}
|
|
15
|
-
return lines.join('\n');
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
error('Search failed', e.message);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src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O,CAAC,CAAC;IACpC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../../src/commands/trade/swap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,WAAW,SAyEpB,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import Big from 'big.js';
|
|
4
|
-
import { getTokenDecimals, toSmallestUnit } from '../../utils/amounts.js';
|
|
5
|
-
import { executeSwap, getSwapQuote } from '../../utils/jupiter.js';
|
|
6
|
-
import { resolveToken } from '../../utils/token-book.js';
|
|
7
|
-
import { loadKeypairForSigning } from '../../utils/wallet.js';
|
|
8
|
-
import { output, error, requirePassword, getRpcUrl } from '../shared.js';
|
|
9
|
-
export const swapCommand = new Command('swap')
|
|
10
|
-
.argument('<input-mint>', 'Input token symbol or address')
|
|
11
|
-
.argument('<output-mint>', 'Output token symbol or address')
|
|
12
|
-
.argument('<amount>', 'Amount in human-readable format')
|
|
13
|
-
.description('Execute swap')
|
|
14
|
-
.option('-s, --slippage <bps>', 'Slippage in basis points', '50')
|
|
15
|
-
.option('--priority-fee <lamports>', 'Priority fee in lamports')
|
|
16
|
-
.action(async (inputMintOrTicker, outputMintOrTicker, amount, options) => {
|
|
17
|
-
const inputMint = resolveToken(inputMintOrTicker);
|
|
18
|
-
const outputMint = resolveToken(outputMintOrTicker);
|
|
19
|
-
const password = requirePassword();
|
|
20
|
-
try {
|
|
21
|
-
const rpcUrl = getRpcUrl();
|
|
22
|
-
const connection = new Connection(rpcUrl, 'confirmed');
|
|
23
|
-
const keypair = loadKeypairForSigning(password);
|
|
24
|
-
const decimals = await getTokenDecimals(inputMint);
|
|
25
|
-
const amountInSmallestUnit = toSmallestUnit(parseFloat(amount), decimals);
|
|
26
|
-
const quote = await getSwapQuote({
|
|
27
|
-
inputMint,
|
|
28
|
-
outputMint,
|
|
29
|
-
amount: parseInt(amountInSmallestUnit),
|
|
30
|
-
slippageBps: parseInt(options.slippage),
|
|
31
|
-
taker: keypair.publicKey.toBase58(),
|
|
32
|
-
});
|
|
33
|
-
const outputDecimals = await getTokenDecimals(outputMint);
|
|
34
|
-
const outputAmount = parseFloat(quote.outAmount) / Math.pow(10, outputDecimals);
|
|
35
|
-
const price = parseFloat(amount) / outputAmount;
|
|
36
|
-
const priceImpact = typeof quote.priceImpactPct === 'string'
|
|
37
|
-
? new Big(quote.priceImpactPct).times(100)
|
|
38
|
-
: new Big(quote.priceImpactPct).times(100);
|
|
39
|
-
const impactNum = parseFloat(priceImpact.toFixed(3));
|
|
40
|
-
const signature = await executeSwap(connection, keypair, quote, options.priorityFee ? parseInt(options.priorityFee) : undefined);
|
|
41
|
-
output({
|
|
42
|
-
success: true,
|
|
43
|
-
inputToken: inputMintOrTicker.toUpperCase(),
|
|
44
|
-
inputAmount: amount,
|
|
45
|
-
outputToken: outputMintOrTicker.toUpperCase(),
|
|
46
|
-
outputAmount: outputAmount.toFixed(6),
|
|
47
|
-
price: price.toFixed(6),
|
|
48
|
-
priceImpactPct: impactNum,
|
|
49
|
-
signature,
|
|
50
|
-
explorer: `https://solscan.io/tx/${signature}`,
|
|
51
|
-
}, () => {
|
|
52
|
-
const impactEmoji = impactNum < 0 ? '⚠️' : '✅';
|
|
53
|
-
return [
|
|
54
|
-
'🔄 Swap Executed:',
|
|
55
|
-
` You paid: ${amount} ${inputMintOrTicker.toUpperCase()}`,
|
|
56
|
-
` You got: ~${outputAmount.toFixed(4)} ${outputMintOrTicker.toUpperCase()}`,
|
|
57
|
-
` Price: ${price.toFixed(6)} ${inputMintOrTicker.toUpperCase()} per ${outputMintOrTicker.toUpperCase()}`,
|
|
58
|
-
` Price Impact: ${impactEmoji} ${impactNum.toFixed(3)}%`,
|
|
59
|
-
'',
|
|
60
|
-
'✅ Swap successful!',
|
|
61
|
-
`📝 Signature: ${signature}`,
|
|
62
|
-
`🔗 View on Solscan: https://solscan.io/tx/${signature}`,
|
|
63
|
-
].join('\n');
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
error('Swap failed', e.message);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=swap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/commands/trade/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,QAAQ,CAAC,cAAc,EAAE,+BAA+B,CAAC;KACzD,QAAQ,CAAC,eAAe,EAAE,gCAAgC,CAAC;KAC3D,QAAQ,CAAC,UAAU,EAAE,iCAAiC,CAAC;KACvD,WAAW,CAAC,cAAc,CAAC;KAC3B,MAAM,CAAC,sBAAsB,EAAE,0BAA0B,EAAE,IAAI,CAAC;KAChE,MAAM,CAAC,2BAA2B,EAAE,0BAA0B,CAAC;KAC/D,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,EAAE,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AAI,CAAC,CAAC;QACf,CAAC,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/commands/trade.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trade.d.ts","sourceRoot":"","sources":["../../src/commands/trade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,YAAY,SAAiE,CAAC;AAgI3F,eAAO,MAAM,aAAa,SAoBtB,CAAC;AAEL,eAAO,MAAM,WAAW,SAkCpB,CAAC"}
|
package/dist/commands/trade.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import Big from 'big.js';
|
|
4
|
-
import { getTokenDecimals, toSmallestUnit, fromSmallestUnit } from '../utils/amounts.js';
|
|
5
|
-
import { executeSwap, getSwapQuote, searchToken } from '../utils/jupiter.js';
|
|
6
|
-
import { resolveToken } from '../utils/token-book.js';
|
|
7
|
-
import { formatTokenInfo, getTokenInfo } from '../utils/token-info.js';
|
|
8
|
-
import { loadKeypairForSigning } from '../utils/wallet.js';
|
|
9
|
-
import { output, error, requirePassword, getRpcUrl } from './shared.js';
|
|
10
|
-
export const tradeCommand = new Command('trade').description('Execute trades via Jupiter');
|
|
11
|
-
tradeCommand
|
|
12
|
-
.command('quote <input-mint> <output-mint> <amount>')
|
|
13
|
-
.description('Get swap quote (amount in human-readable format, e.g., 400 for 400 USDC)')
|
|
14
|
-
.option('-s, --slippage <bps>', 'Slippage in basis points', '50')
|
|
15
|
-
.action(async (inputMintOrTicker, outputMintOrTicker, amount, options) => {
|
|
16
|
-
const inputMint = resolveToken(inputMintOrTicker);
|
|
17
|
-
const outputMint = resolveToken(outputMintOrTicker);
|
|
18
|
-
try {
|
|
19
|
-
const decimals = await getTokenDecimals(inputMint);
|
|
20
|
-
const amountInSmallestUnit = toSmallestUnit(amount, decimals);
|
|
21
|
-
const quote = await getSwapQuote({
|
|
22
|
-
inputMint,
|
|
23
|
-
outputMint,
|
|
24
|
-
amount: parseInt(amountInSmallestUnit),
|
|
25
|
-
slippageBps: parseInt(options.slippage),
|
|
26
|
-
});
|
|
27
|
-
const outputDecimals = await getTokenDecimals(outputMint);
|
|
28
|
-
const outputAmount = fromSmallestUnit(quote.outAmount, outputDecimals);
|
|
29
|
-
const price = new Big(amount).div(new Big(outputAmount));
|
|
30
|
-
const priceImpact = typeof quote.priceImpactPct === 'string'
|
|
31
|
-
? new Big(quote.priceImpactPct).times(100)
|
|
32
|
-
: new Big(quote.priceImpactPct).times(100);
|
|
33
|
-
const impactNum = parseFloat(priceImpact.toFixed(3));
|
|
34
|
-
output({
|
|
35
|
-
inputToken: inputMintOrTicker.toUpperCase(),
|
|
36
|
-
inputAmount: amount,
|
|
37
|
-
outputToken: outputMintOrTicker.toUpperCase(),
|
|
38
|
-
outputAmount: new Big(outputAmount).toFixed(6),
|
|
39
|
-
price: price.toFixed(6),
|
|
40
|
-
priceImpactPct: impactNum,
|
|
41
|
-
slippageBps: parseInt(options.slippage),
|
|
42
|
-
}, () => {
|
|
43
|
-
const impactEmoji = impactNum < 0 ? '⚠️' : '✅';
|
|
44
|
-
return [
|
|
45
|
-
'📊 Swap Quote:',
|
|
46
|
-
` You pay: ${amount} ${inputMintOrTicker.toUpperCase()}`,
|
|
47
|
-
` You get: ~${new Big(outputAmount).toFixed(4)} ${outputMintOrTicker.toUpperCase()}`,
|
|
48
|
-
` Price: ${price.toFixed(6)} ${inputMintOrTicker.toUpperCase()} per ${outputMintOrTicker.toUpperCase()}`,
|
|
49
|
-
` Price Impact: ${impactEmoji} ${impactNum.toFixed(3)}% (${impactNum < 0 ? 'you lose value' : 'you gain value'})`,
|
|
50
|
-
` Slippage Tolerance: ${new Big(options.slippage).div(100).toFixed(2)}%`,
|
|
51
|
-
].join('\n');
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
error('Failed to get quote', e.message);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
tradeCommand
|
|
59
|
-
.command('swap <input-mint> <output-mint> <amount>')
|
|
60
|
-
.description('Execute swap (amount in human-readable format, e.g., 400 for 400 USDC)')
|
|
61
|
-
.option('-s, --slippage <bps>', 'Slippage in basis points', '50')
|
|
62
|
-
.option('--priority-fee <lamports>', 'Priority fee in lamports')
|
|
63
|
-
.action(async (inputMintOrTicker, outputMintOrTicker, amount, options) => {
|
|
64
|
-
const inputMint = resolveToken(inputMintOrTicker);
|
|
65
|
-
const outputMint = resolveToken(outputMintOrTicker);
|
|
66
|
-
const password = requirePassword();
|
|
67
|
-
try {
|
|
68
|
-
const rpcUrl = getRpcUrl();
|
|
69
|
-
const connection = new Connection(rpcUrl, 'confirmed');
|
|
70
|
-
const keypair = loadKeypairForSigning(password);
|
|
71
|
-
const decimals = await getTokenDecimals(inputMint);
|
|
72
|
-
const amountInSmallestUnit = toSmallestUnit(parseFloat(amount), decimals);
|
|
73
|
-
const quote = await getSwapQuote({
|
|
74
|
-
inputMint,
|
|
75
|
-
outputMint,
|
|
76
|
-
amount: parseInt(amountInSmallestUnit),
|
|
77
|
-
slippageBps: parseInt(options.slippage),
|
|
78
|
-
taker: keypair.publicKey.toBase58(),
|
|
79
|
-
});
|
|
80
|
-
const outputDecimals = await getTokenDecimals(outputMint);
|
|
81
|
-
const outputAmount = parseFloat(quote.outAmount) / Math.pow(10, outputDecimals);
|
|
82
|
-
const price = parseFloat(amount) / outputAmount;
|
|
83
|
-
const priceImpact = typeof quote.priceImpactPct === 'string'
|
|
84
|
-
? new Big(quote.priceImpactPct).times(100)
|
|
85
|
-
: new Big(quote.priceImpactPct).times(100);
|
|
86
|
-
const impactNum = parseFloat(priceImpact.toFixed(3));
|
|
87
|
-
const signature = await executeSwap(connection, keypair, quote, options.priorityFee ? parseInt(options.priorityFee) : undefined);
|
|
88
|
-
output({
|
|
89
|
-
success: true,
|
|
90
|
-
inputToken: inputMintOrTicker.toUpperCase(),
|
|
91
|
-
inputAmount: amount,
|
|
92
|
-
outputToken: outputMintOrTicker.toUpperCase(),
|
|
93
|
-
outputAmount: outputAmount.toFixed(6),
|
|
94
|
-
price: price.toFixed(6),
|
|
95
|
-
priceImpactPct: impactNum,
|
|
96
|
-
signature,
|
|
97
|
-
explorer: `https://solscan.io/tx/${signature}`,
|
|
98
|
-
}, () => {
|
|
99
|
-
const impactEmoji = impactNum < 0 ? '⚠️' : '✅';
|
|
100
|
-
return [
|
|
101
|
-
'🔄 Swap Executed:',
|
|
102
|
-
` You paid: ${amount} ${inputMintOrTicker.toUpperCase()}`,
|
|
103
|
-
` You got: ~${outputAmount.toFixed(4)} ${outputMintOrTicker.toUpperCase()}`,
|
|
104
|
-
` Price: ${price.toFixed(6)} ${inputMintOrTicker.toUpperCase()} per ${outputMintOrTicker.toUpperCase()}`,
|
|
105
|
-
` Price Impact: ${impactEmoji} ${impactNum.toFixed(3)}%`,
|
|
106
|
-
'',
|
|
107
|
-
'✅ Swap successful!',
|
|
108
|
-
`📝 Signature: ${signature}`,
|
|
109
|
-
`🔗 View on Solscan: https://solscan.io/tx/${signature}`,
|
|
110
|
-
].join('\n');
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
error('Swap failed', e.message);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
export const searchCommand = new Command('search')
|
|
118
|
-
.argument('<query>', 'Token name or symbol')
|
|
119
|
-
.description('Search for token by name or symbol')
|
|
120
|
-
.action(async (query) => {
|
|
121
|
-
try {
|
|
122
|
-
const tokens = await searchToken(query);
|
|
123
|
-
output({ query, results: tokens.map((t) => ({ symbol: t.symbol, name: t.name, address: t.address })) }, () => {
|
|
124
|
-
const lines = ['🔍 Search Results:', ''];
|
|
125
|
-
for (const t of tokens) {
|
|
126
|
-
lines.push(` ${t.symbol.padEnd(10)} ${t.name.slice(0, 30).padEnd(32)} ${t.address}`);
|
|
127
|
-
}
|
|
128
|
-
return lines.join('\n');
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
error('Search failed', e.message);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
export const infoCommand = new Command('info')
|
|
136
|
-
.argument('<token>', 'Token symbol or address')
|
|
137
|
-
.description('Get detailed token information by symbol or address')
|
|
138
|
-
.action(async (tokenOrTicker) => {
|
|
139
|
-
try {
|
|
140
|
-
const tokenAddress = resolveToken(tokenOrTicker);
|
|
141
|
-
const info = await getTokenInfo(tokenAddress);
|
|
142
|
-
output({
|
|
143
|
-
...info,
|
|
144
|
-
explorers: {
|
|
145
|
-
solscan: `https://solscan.io/token/${info.address}`,
|
|
146
|
-
solanaExplorer: `https://explorer.solana.com/address/${info.address}`,
|
|
147
|
-
dexscreener: info.markets?.[0]?.pair ? `https://dexscreener.com/solana/${info.markets[0].pair}` : null,
|
|
148
|
-
},
|
|
149
|
-
}, () => {
|
|
150
|
-
const formatted = formatTokenInfo(info);
|
|
151
|
-
const links = [
|
|
152
|
-
'',
|
|
153
|
-
'🔗 EXPLORERS',
|
|
154
|
-
` Solscan: https://solscan.io/token/${info.address}`,
|
|
155
|
-
` Solana Explorer: https://explorer.solana.com/address/${info.address}`,
|
|
156
|
-
];
|
|
157
|
-
if (info.markets && info.markets.length > 0) {
|
|
158
|
-
links.push(` DexScreener: https://dexscreener.com/solana/${info.markets[0].pair}`);
|
|
159
|
-
}
|
|
160
|
-
return formatted + links.join('\n');
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
catch (e) {
|
|
164
|
-
error('Failed to get token info', e.message);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
//# sourceMappingURL=trade.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|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