nansen-cli 1.9.1 → 1.9.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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/src/cli.js +8 -3
- package/src/trading.js +20 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#118](https://github.com/nansen-ai/nansen-cli/pull/118) [`0bd4c3c`](https://github.com/nansen-ai/nansen-cli/commit/0bd4c3c1946e575e2c2db5e02d17f266e79752a4) Thanks [@TimNooren](https://github.com/TimNooren)! - Show warning when trade quote price impact exceeds 5%, and show pin command to avoid fallback to worse quotes
|
|
8
|
+
|
|
9
|
+
## 1.9.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#116](https://github.com/nansen-ai/nansen-cli/pull/116) [`7a2b729`](https://github.com/nansen-ai/nansen-cli/commit/7a2b7293c2e731ae1d5375b15df9c05c5611a9cb) Thanks [@TimNooren](https://github.com/TimNooren)! - Fix usage examples for `nansen trade quote` to show correct command name instead of deprecated `nansen quote`
|
|
14
|
+
|
|
15
|
+
- [#114](https://github.com/nansen-ai/nansen-cli/pull/114) [`37d8c0b`](https://github.com/nansen-ai/nansen-cli/commit/37d8c0b87797145a15b087caa5eb474673217580) Thanks [@TimNooren](https://github.com/TimNooren)! - Show API key URL in non-interactive login error message
|
|
16
|
+
|
|
17
|
+
- [#117](https://github.com/nansen-ai/nansen-cli/pull/117) [`55ad922`](https://github.com/nansen-ai/nansen-cli/commit/55ad922826a7a2411889edeede42fbfc7b70d7a5) Thanks [@TimNooren](https://github.com/TimNooren)! - Add --wallet and WalletConnect documentation to `nansen trade help` output
|
|
18
|
+
|
|
3
19
|
## 1.9.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nansen-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Command-line interface for Nansen API - designed for AI agents",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test:watch": "vitest",
|
|
19
19
|
"test:coverage": "vitest run --coverage",
|
|
20
20
|
"test:live": "NANSEN_LIVE_TEST=1 vitest run",
|
|
21
|
-
"test:
|
|
21
|
+
"test:trade": "vitest run --config vitest.e2e.config.js",
|
|
22
22
|
"changeset": "changeset",
|
|
23
23
|
"changeset:version": "changeset version",
|
|
24
24
|
"changeset:publish": "changeset publish"
|
package/src/cli.js
CHANGED
|
@@ -858,7 +858,7 @@ export function buildCommands(deps = {}) {
|
|
|
858
858
|
// Non-interactive mode: check env var fallback
|
|
859
859
|
apiKey = process.env.NANSEN_API_KEY;
|
|
860
860
|
if (!apiKey) {
|
|
861
|
-
log('❌ No API key provided. Use: nansen login --api-key <key>\n Or set NANSEN_API_KEY environment variable.');
|
|
861
|
+
log('❌ No API key provided. Use: nansen login --api-key <key>\n Or set NANSEN_API_KEY environment variable.\n Get your API key at: https://app.nansen.ai/api');
|
|
862
862
|
exit(1);
|
|
863
863
|
return;
|
|
864
864
|
}
|
|
@@ -1316,14 +1316,19 @@ SUBCOMMANDS:
|
|
|
1316
1316
|
execute Sign and broadcast a quoted swap
|
|
1317
1317
|
|
|
1318
1318
|
USAGE:
|
|
1319
|
-
nansen trade quote --chain <chain> --from <token> --to <token> --amount <units>
|
|
1320
|
-
nansen trade execute --quote <quoteId>
|
|
1319
|
+
nansen trade quote --chain <chain> --from <token> --to <token> --amount <units> [--wallet <name>]
|
|
1320
|
+
nansen trade execute --quote <quoteId> [--wallet <name>]
|
|
1321
1321
|
|
|
1322
1322
|
EXAMPLES:
|
|
1323
1323
|
nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000
|
|
1324
1324
|
nansen trade quote --chain base --from ETH --to USDC --amount 1000000000000000000
|
|
1325
|
+
nansen trade quote --chain base --from ETH --to USDC --amount 1000000000000000000 --wallet walletconnect
|
|
1325
1326
|
nansen trade execute --quote 1708900000000-abc123
|
|
1326
1327
|
|
|
1328
|
+
WALLET:
|
|
1329
|
+
--wallet <name> Use a named wallet, or "walletconnect" / "wc" for WalletConnect (EVM only).
|
|
1330
|
+
Defaults to the default local wallet if omitted.
|
|
1331
|
+
|
|
1327
1332
|
SYMBOLS:
|
|
1328
1333
|
Common tokens resolve automatically: SOL, ETH, BNB, USDC, USDT, WETH, WBNB
|
|
1329
1334
|
Raw addresses are also accepted.`);
|
package/src/trading.js
CHANGED
|
@@ -742,7 +742,7 @@ export function validateBaseUnitAmount(amount) {
|
|
|
742
742
|
return null;
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
-
function formatQuote(quote, index) {
|
|
745
|
+
export function formatQuote(quote, index) {
|
|
746
746
|
const lines = [];
|
|
747
747
|
const label = index !== undefined ? ` Quote #${index + 1}` : ' Best Quote';
|
|
748
748
|
lines.push(`${label} (${quote.aggregator || 'unknown'})`);
|
|
@@ -750,10 +750,21 @@ function formatQuote(quote, index) {
|
|
|
750
750
|
lines.push(` Output: ${quote.outAmount} → ${quote.outputMint?.slice(0, 12)}...`);
|
|
751
751
|
if (quote.inUsdValue) lines.push(` In USD: $${quote.inUsdValue}`);
|
|
752
752
|
if (quote.outUsdValue) lines.push(` Out USD: $${quote.outUsdValue}`);
|
|
753
|
-
if (quote.priceImpactPct)
|
|
753
|
+
if (quote.priceImpactPct) {
|
|
754
|
+
const impactAbs = Math.abs(parseFloat(quote.priceImpactPct));
|
|
755
|
+
if (impactAbs <= 5) {
|
|
756
|
+
lines.push(` Price Impact: ${impactAbs}%`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
754
759
|
if (quote.tradingFeeInUsd) lines.push(` Trading Fee: $${quote.tradingFeeInUsd}`);
|
|
755
760
|
if (quote.networkFeeInUsd) lines.push(` Network Fee: $${quote.networkFeeInUsd}`);
|
|
756
761
|
if (quote.approvalAddress && !isNativeToken(quote.inputMint)) lines.push(` ⚠ Requires token approval to: ${quote.approvalAddress}`);
|
|
762
|
+
if (quote.priceImpactPct) {
|
|
763
|
+
const impactAbs = Math.abs(parseFloat(quote.priceImpactPct));
|
|
764
|
+
if (impactAbs > 5) {
|
|
765
|
+
lines.push(` ⚠ Price impact is ${impactAbs}%! You may lose significant value.`);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
757
768
|
return lines.join('\n');
|
|
758
769
|
}
|
|
759
770
|
|
|
@@ -781,7 +792,7 @@ export function buildTradingCommands(deps = {}) {
|
|
|
781
792
|
|
|
782
793
|
if (!chain || !from || !to || !amount) {
|
|
783
794
|
errorOutput(`
|
|
784
|
-
Usage: nansen quote --chain <chain> --from <token> --to <token> --amount <baseUnits>
|
|
795
|
+
Usage: nansen trade quote --chain <chain> --from <token> --to <token> --amount <baseUnits>
|
|
785
796
|
|
|
786
797
|
OPTIONS:
|
|
787
798
|
--chain <chain> Chain: solana, ethereum, base, bsc
|
|
@@ -795,9 +806,9 @@ OPTIONS:
|
|
|
795
806
|
--swap-mode <mode> exactIn (default) or exactOut
|
|
796
807
|
|
|
797
808
|
EXAMPLES:
|
|
798
|
-
nansen quote --chain solana --from SOL --to USDC --amount 1000000000
|
|
799
|
-
nansen quote --chain base --from ETH --to USDC --amount 1000000000000000000
|
|
800
|
-
nansen quote --chain solana --from So11111111111111111111111111111111111111112 --to EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 1000000000
|
|
809
|
+
nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000
|
|
810
|
+
nansen trade quote --chain base --from ETH --to USDC --amount 1000000000000000000
|
|
811
|
+
nansen trade quote --chain solana --from So11111111111111111111111111111111111111112 --to EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 1000000000
|
|
801
812
|
`);
|
|
802
813
|
exit(1);
|
|
803
814
|
return;
|
|
@@ -877,6 +888,9 @@ EXAMPLES:
|
|
|
877
888
|
const quoteId = saveQuote(response, chain, isWalletConnect ? 'walletconnect' : 'local');
|
|
878
889
|
errorOutput(`\n Quote ID: ${quoteId}`);
|
|
879
890
|
errorOutput(` Execute: nansen trade execute --quote ${quoteId}`);
|
|
891
|
+
if (response.quotes.length > 1) {
|
|
892
|
+
errorOutput(` Pin #1: nansen trade execute --quote ${quoteId} --quote-index 0`);
|
|
893
|
+
}
|
|
880
894
|
|
|
881
895
|
if (response.quotes[0]?.approvalAddress && !isNativeToken(response.quotes[0]?.inputMint)) {
|
|
882
896
|
errorOutput(`\n Warning: This token swap requires an ERC-20 approval step.`);
|