nansen-cli 1.9.2 → 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 +6 -0
- package/package.json +2 -2
- package/src/trading.js +16 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 1.9.2
|
|
4
10
|
|
|
5
11
|
### 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/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
|
|
|
@@ -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.`);
|