nansen-cli 2.6.0 → 2.6.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/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/package.json +5 -5
- package/skills/nansen-alerts-webhook-listener/SKILL.md +1 -1
- package/skills/nansen-smart-alerts/SKILL.md +0 -21
- package/skills/nansen-trading/SKILL.md +5 -5
- package/src/bridge.js +48 -4
- package/src/cli.js +1 -1
- package/src/commands/alerts.js +41 -62
- package/src/crypto.js +17 -0
- package/src/perp.js +58 -4
- package/src/schema.json +348 -6
- package/src/trade-validation.js +57 -2
- package/src/trading.js +14 -14
- package/src/transfer.js +65 -7
- package/src/wallet.js +9 -10
package/src/schema.json
CHANGED
|
@@ -418,11 +418,22 @@
|
|
|
418
418
|
"amount": {
|
|
419
419
|
"type": "string",
|
|
420
420
|
"required": true,
|
|
421
|
-
"description": "USDC amount to transfer"
|
|
421
|
+
"description": "USDC amount to transfer, at most 8 decimal places. An amount that can't be signed exactly is refused."
|
|
422
422
|
},
|
|
423
423
|
"wallet": {
|
|
424
424
|
"type": "string",
|
|
425
425
|
"description": "Wallet name (defaults to the configured default wallet)"
|
|
426
|
+
},
|
|
427
|
+
"dry-run": {
|
|
428
|
+
"type": "boolean",
|
|
429
|
+
"description": "Run the normal validation and the compliance screen, print the transfer plan (wallet, direction, the exact USDC amount that would be signed), then stop. Nothing is signed or sent to Hyperliquid and no wallet password is needed. Exits 0."
|
|
430
|
+
},
|
|
431
|
+
"yes": {
|
|
432
|
+
"type": "boolean",
|
|
433
|
+
"aliases": [
|
|
434
|
+
"y"
|
|
435
|
+
],
|
|
436
|
+
"description": "Skip the confirmation prompt (alias: -y, or set NANSEN_YES=1). The prompt is only shown when stdin is an interactive terminal; when stdin is not a terminal (agents, CI, pipes) the command proceeds unprompted whether or not this is passed, unless NANSEN_REQUIRE_CONFIRM=1 is set, in which case this (or NANSEN_YES=1) is required and a run without it fails with CONFIRMATION_REQUIRED before any request or signature. Declining the prompt exits 1 with nothing signed."
|
|
426
437
|
}
|
|
427
438
|
}
|
|
428
439
|
},
|
|
@@ -437,6 +448,17 @@
|
|
|
437
448
|
"wallet": {
|
|
438
449
|
"type": "string",
|
|
439
450
|
"description": "Wallet name (defaults to the configured default wallet)"
|
|
451
|
+
},
|
|
452
|
+
"dry-run": {
|
|
453
|
+
"type": "boolean",
|
|
454
|
+
"description": "Read the builder-fee status and run the compliance screen, print the approval plan (wallet, builder address, maximum fee rate), then stop. Nothing is signed or sent to Hyperliquid and no wallet password is needed. When the fee is already approved it says so and stops with nothing to preview. Exits 0."
|
|
455
|
+
},
|
|
456
|
+
"yes": {
|
|
457
|
+
"type": "boolean",
|
|
458
|
+
"aliases": [
|
|
459
|
+
"y"
|
|
460
|
+
],
|
|
461
|
+
"description": "Skip the confirmation prompt (alias: -y, or set NANSEN_YES=1). The prompt is only shown when stdin is an interactive terminal; when stdin is not a terminal (agents, CI, pipes) the command proceeds unprompted whether or not this is passed, unless NANSEN_REQUIRE_CONFIRM=1 is set, in which case this (or NANSEN_YES=1) is required and a run without it fails with CONFIRMATION_REQUIRED before any request or signature. Declining the prompt exits 1 with nothing signed."
|
|
440
462
|
}
|
|
441
463
|
}
|
|
442
464
|
},
|
|
@@ -3053,7 +3075,7 @@
|
|
|
3053
3075
|
},
|
|
3054
3076
|
"type": {
|
|
3055
3077
|
"type": "string",
|
|
3056
|
-
"description": "Only alerts of this type (sm-token-flows, common-token-transfer
|
|
3078
|
+
"description": "Only alerts of this type (sm-token-flows, common-token-transfer)"
|
|
3057
3079
|
},
|
|
3058
3080
|
"enabled": {
|
|
3059
3081
|
"type": "boolean",
|
|
@@ -3094,12 +3116,172 @@
|
|
|
3094
3116
|
"type": {
|
|
3095
3117
|
"type": "string",
|
|
3096
3118
|
"required": true,
|
|
3097
|
-
"
|
|
3119
|
+
"enum": [
|
|
3120
|
+
"sm-token-flows",
|
|
3121
|
+
"common-token-transfer"
|
|
3122
|
+
],
|
|
3123
|
+
"description": "Alert type: sm-token-flows or common-token-transfer"
|
|
3098
3124
|
},
|
|
3099
3125
|
"chains": {
|
|
3100
3126
|
"type": "string",
|
|
3101
3127
|
"description": "Comma-separated chains (e.g. ethereum,solana). Merged into data."
|
|
3102
3128
|
},
|
|
3129
|
+
"inflow-1h-min": {
|
|
3130
|
+
"type": "number",
|
|
3131
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last hour, in USD"
|
|
3132
|
+
},
|
|
3133
|
+
"inflow-1h-max": {
|
|
3134
|
+
"type": "number",
|
|
3135
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last hour, in USD"
|
|
3136
|
+
},
|
|
3137
|
+
"inflow-1d-min": {
|
|
3138
|
+
"type": "number",
|
|
3139
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last day, in USD"
|
|
3140
|
+
},
|
|
3141
|
+
"inflow-1d-max": {
|
|
3142
|
+
"type": "number",
|
|
3143
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last day, in USD"
|
|
3144
|
+
},
|
|
3145
|
+
"inflow-7d-min": {
|
|
3146
|
+
"type": "number",
|
|
3147
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last 7 days, in USD"
|
|
3148
|
+
},
|
|
3149
|
+
"inflow-7d-max": {
|
|
3150
|
+
"type": "number",
|
|
3151
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last 7 days, in USD"
|
|
3152
|
+
},
|
|
3153
|
+
"outflow-1h-min": {
|
|
3154
|
+
"type": "number",
|
|
3155
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last hour, in USD"
|
|
3156
|
+
},
|
|
3157
|
+
"outflow-1h-max": {
|
|
3158
|
+
"type": "number",
|
|
3159
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last hour, in USD"
|
|
3160
|
+
},
|
|
3161
|
+
"outflow-1d-min": {
|
|
3162
|
+
"type": "number",
|
|
3163
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last day, in USD"
|
|
3164
|
+
},
|
|
3165
|
+
"outflow-1d-max": {
|
|
3166
|
+
"type": "number",
|
|
3167
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last day, in USD"
|
|
3168
|
+
},
|
|
3169
|
+
"outflow-7d-min": {
|
|
3170
|
+
"type": "number",
|
|
3171
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last 7 days, in USD"
|
|
3172
|
+
},
|
|
3173
|
+
"outflow-7d-max": {
|
|
3174
|
+
"type": "number",
|
|
3175
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last 7 days, in USD"
|
|
3176
|
+
},
|
|
3177
|
+
"netflow-1h-min": {
|
|
3178
|
+
"type": "number",
|
|
3179
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last hour, in USD"
|
|
3180
|
+
},
|
|
3181
|
+
"netflow-1h-max": {
|
|
3182
|
+
"type": "number",
|
|
3183
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last hour, in USD"
|
|
3184
|
+
},
|
|
3185
|
+
"netflow-1d-min": {
|
|
3186
|
+
"type": "number",
|
|
3187
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last day, in USD"
|
|
3188
|
+
},
|
|
3189
|
+
"netflow-1d-max": {
|
|
3190
|
+
"type": "number",
|
|
3191
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last day, in USD"
|
|
3192
|
+
},
|
|
3193
|
+
"netflow-7d-min": {
|
|
3194
|
+
"type": "number",
|
|
3195
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last 7 days, in USD"
|
|
3196
|
+
},
|
|
3197
|
+
"netflow-7d-max": {
|
|
3198
|
+
"type": "number",
|
|
3199
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last 7 days, in USD"
|
|
3200
|
+
},
|
|
3201
|
+
"token": {
|
|
3202
|
+
"type": "string",
|
|
3203
|
+
"repeatable": true,
|
|
3204
|
+
"description": "sm-token-flows, common-token-transfer: Only this token, as address:chain"
|
|
3205
|
+
},
|
|
3206
|
+
"exclude-token": {
|
|
3207
|
+
"type": "string",
|
|
3208
|
+
"repeatable": true,
|
|
3209
|
+
"description": "sm-token-flows, common-token-transfer: Exclude this token, as address:chain"
|
|
3210
|
+
},
|
|
3211
|
+
"token-sector": {
|
|
3212
|
+
"type": "string",
|
|
3213
|
+
"repeatable": true,
|
|
3214
|
+
"description": "sm-token-flows, common-token-transfer: Only tokens in this sector"
|
|
3215
|
+
},
|
|
3216
|
+
"exclude-token-sector": {
|
|
3217
|
+
"type": "string",
|
|
3218
|
+
"repeatable": true,
|
|
3219
|
+
"description": "sm-token-flows, common-token-transfer: Exclude tokens in this sector"
|
|
3220
|
+
},
|
|
3221
|
+
"token-age-min": {
|
|
3222
|
+
"type": "number",
|
|
3223
|
+
"description": "common-token-transfer: Minimum token age, in days"
|
|
3224
|
+
},
|
|
3225
|
+
"token-age-max": {
|
|
3226
|
+
"type": "number",
|
|
3227
|
+
"description": "sm-token-flows, common-token-transfer: Maximum token age, in days"
|
|
3228
|
+
},
|
|
3229
|
+
"market-cap-min": {
|
|
3230
|
+
"type": "number",
|
|
3231
|
+
"description": "sm-token-flows, common-token-transfer: Minimum token market cap, in USD"
|
|
3232
|
+
},
|
|
3233
|
+
"market-cap-max": {
|
|
3234
|
+
"type": "number",
|
|
3235
|
+
"description": "sm-token-flows, common-token-transfer: Maximum token market cap, in USD"
|
|
3236
|
+
},
|
|
3237
|
+
"fdv-min": {
|
|
3238
|
+
"type": "number",
|
|
3239
|
+
"description": "sm-token-flows: Minimum token fully diluted valuation, in USD"
|
|
3240
|
+
},
|
|
3241
|
+
"fdv-max": {
|
|
3242
|
+
"type": "number",
|
|
3243
|
+
"description": "sm-token-flows: Maximum token fully diluted valuation, in USD"
|
|
3244
|
+
},
|
|
3245
|
+
"events": {
|
|
3246
|
+
"type": "string",
|
|
3247
|
+
"description": "common-token-transfer: Comma-separated event types: buy, sell, swap, send, receive"
|
|
3248
|
+
},
|
|
3249
|
+
"usd-min": {
|
|
3250
|
+
"type": "number",
|
|
3251
|
+
"description": "common-token-transfer: Minimum transfer value, in USD"
|
|
3252
|
+
},
|
|
3253
|
+
"usd-max": {
|
|
3254
|
+
"type": "number",
|
|
3255
|
+
"description": "common-token-transfer: Maximum transfer value, in USD"
|
|
3256
|
+
},
|
|
3257
|
+
"token-amount-min": {
|
|
3258
|
+
"type": "number",
|
|
3259
|
+
"description": "common-token-transfer: Minimum token amount transferred"
|
|
3260
|
+
},
|
|
3261
|
+
"token-amount-max": {
|
|
3262
|
+
"type": "number",
|
|
3263
|
+
"description": "common-token-transfer: Maximum token amount transferred"
|
|
3264
|
+
},
|
|
3265
|
+
"subject": {
|
|
3266
|
+
"type": "string",
|
|
3267
|
+
"repeatable": true,
|
|
3268
|
+
"description": "common-token-transfer: Only transfers by this subject, as type:value (address, entity, label, custom-label), e.g. label:\"Centralized Exchange\""
|
|
3269
|
+
},
|
|
3270
|
+
"counterparty": {
|
|
3271
|
+
"type": "string",
|
|
3272
|
+
"repeatable": true,
|
|
3273
|
+
"description": "common-token-transfer: Only transfers with this counterparty, as type:value. Requires --subject"
|
|
3274
|
+
},
|
|
3275
|
+
"exclude-from": {
|
|
3276
|
+
"type": "string",
|
|
3277
|
+
"repeatable": true,
|
|
3278
|
+
"description": "common-token-transfer: Exclude transfers sent from this subject, as type:value"
|
|
3279
|
+
},
|
|
3280
|
+
"exclude-to": {
|
|
3281
|
+
"type": "string",
|
|
3282
|
+
"repeatable": true,
|
|
3283
|
+
"description": "common-token-transfer: Exclude transfers sent to this subject, as type:value"
|
|
3284
|
+
},
|
|
3103
3285
|
"telegram": {
|
|
3104
3286
|
"type": "string",
|
|
3105
3287
|
"description": "Telegram chat ID for notifications"
|
|
@@ -3153,12 +3335,172 @@
|
|
|
3153
3335
|
},
|
|
3154
3336
|
"type": {
|
|
3155
3337
|
"type": "string",
|
|
3156
|
-
"
|
|
3338
|
+
"enum": [
|
|
3339
|
+
"sm-token-flows",
|
|
3340
|
+
"common-token-transfer"
|
|
3341
|
+
],
|
|
3342
|
+
"description": "Alert type: sm-token-flows or common-token-transfer. Must match the alert's current type; it cannot be changed"
|
|
3157
3343
|
},
|
|
3158
3344
|
"chains": {
|
|
3159
3345
|
"type": "string",
|
|
3160
3346
|
"description": "Comma-separated chains. Merged into data."
|
|
3161
3347
|
},
|
|
3348
|
+
"inflow-1h-min": {
|
|
3349
|
+
"type": "number",
|
|
3350
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last hour, in USD"
|
|
3351
|
+
},
|
|
3352
|
+
"inflow-1h-max": {
|
|
3353
|
+
"type": "number",
|
|
3354
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last hour, in USD"
|
|
3355
|
+
},
|
|
3356
|
+
"inflow-1d-min": {
|
|
3357
|
+
"type": "number",
|
|
3358
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last day, in USD"
|
|
3359
|
+
},
|
|
3360
|
+
"inflow-1d-max": {
|
|
3361
|
+
"type": "number",
|
|
3362
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last day, in USD"
|
|
3363
|
+
},
|
|
3364
|
+
"inflow-7d-min": {
|
|
3365
|
+
"type": "number",
|
|
3366
|
+
"description": "sm-token-flows: Minimum smart money inflow over the last 7 days, in USD"
|
|
3367
|
+
},
|
|
3368
|
+
"inflow-7d-max": {
|
|
3369
|
+
"type": "number",
|
|
3370
|
+
"description": "sm-token-flows: Maximum smart money inflow over the last 7 days, in USD"
|
|
3371
|
+
},
|
|
3372
|
+
"outflow-1h-min": {
|
|
3373
|
+
"type": "number",
|
|
3374
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last hour, in USD"
|
|
3375
|
+
},
|
|
3376
|
+
"outflow-1h-max": {
|
|
3377
|
+
"type": "number",
|
|
3378
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last hour, in USD"
|
|
3379
|
+
},
|
|
3380
|
+
"outflow-1d-min": {
|
|
3381
|
+
"type": "number",
|
|
3382
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last day, in USD"
|
|
3383
|
+
},
|
|
3384
|
+
"outflow-1d-max": {
|
|
3385
|
+
"type": "number",
|
|
3386
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last day, in USD"
|
|
3387
|
+
},
|
|
3388
|
+
"outflow-7d-min": {
|
|
3389
|
+
"type": "number",
|
|
3390
|
+
"description": "sm-token-flows: Minimum smart money outflow over the last 7 days, in USD"
|
|
3391
|
+
},
|
|
3392
|
+
"outflow-7d-max": {
|
|
3393
|
+
"type": "number",
|
|
3394
|
+
"description": "sm-token-flows: Maximum smart money outflow over the last 7 days, in USD"
|
|
3395
|
+
},
|
|
3396
|
+
"netflow-1h-min": {
|
|
3397
|
+
"type": "number",
|
|
3398
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last hour, in USD"
|
|
3399
|
+
},
|
|
3400
|
+
"netflow-1h-max": {
|
|
3401
|
+
"type": "number",
|
|
3402
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last hour, in USD"
|
|
3403
|
+
},
|
|
3404
|
+
"netflow-1d-min": {
|
|
3405
|
+
"type": "number",
|
|
3406
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last day, in USD"
|
|
3407
|
+
},
|
|
3408
|
+
"netflow-1d-max": {
|
|
3409
|
+
"type": "number",
|
|
3410
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last day, in USD"
|
|
3411
|
+
},
|
|
3412
|
+
"netflow-7d-min": {
|
|
3413
|
+
"type": "number",
|
|
3414
|
+
"description": "sm-token-flows: Minimum smart money netflow over the last 7 days, in USD"
|
|
3415
|
+
},
|
|
3416
|
+
"netflow-7d-max": {
|
|
3417
|
+
"type": "number",
|
|
3418
|
+
"description": "sm-token-flows: Maximum smart money netflow over the last 7 days, in USD"
|
|
3419
|
+
},
|
|
3420
|
+
"token": {
|
|
3421
|
+
"type": "string",
|
|
3422
|
+
"repeatable": true,
|
|
3423
|
+
"description": "sm-token-flows, common-token-transfer: Only this token, as address:chain"
|
|
3424
|
+
},
|
|
3425
|
+
"exclude-token": {
|
|
3426
|
+
"type": "string",
|
|
3427
|
+
"repeatable": true,
|
|
3428
|
+
"description": "sm-token-flows, common-token-transfer: Exclude this token, as address:chain"
|
|
3429
|
+
},
|
|
3430
|
+
"token-sector": {
|
|
3431
|
+
"type": "string",
|
|
3432
|
+
"repeatable": true,
|
|
3433
|
+
"description": "sm-token-flows, common-token-transfer: Only tokens in this sector"
|
|
3434
|
+
},
|
|
3435
|
+
"exclude-token-sector": {
|
|
3436
|
+
"type": "string",
|
|
3437
|
+
"repeatable": true,
|
|
3438
|
+
"description": "sm-token-flows, common-token-transfer: Exclude tokens in this sector"
|
|
3439
|
+
},
|
|
3440
|
+
"token-age-min": {
|
|
3441
|
+
"type": "number",
|
|
3442
|
+
"description": "common-token-transfer: Minimum token age, in days"
|
|
3443
|
+
},
|
|
3444
|
+
"token-age-max": {
|
|
3445
|
+
"type": "number",
|
|
3446
|
+
"description": "sm-token-flows, common-token-transfer: Maximum token age, in days"
|
|
3447
|
+
},
|
|
3448
|
+
"market-cap-min": {
|
|
3449
|
+
"type": "number",
|
|
3450
|
+
"description": "sm-token-flows, common-token-transfer: Minimum token market cap, in USD"
|
|
3451
|
+
},
|
|
3452
|
+
"market-cap-max": {
|
|
3453
|
+
"type": "number",
|
|
3454
|
+
"description": "sm-token-flows, common-token-transfer: Maximum token market cap, in USD"
|
|
3455
|
+
},
|
|
3456
|
+
"fdv-min": {
|
|
3457
|
+
"type": "number",
|
|
3458
|
+
"description": "sm-token-flows: Minimum token fully diluted valuation, in USD"
|
|
3459
|
+
},
|
|
3460
|
+
"fdv-max": {
|
|
3461
|
+
"type": "number",
|
|
3462
|
+
"description": "sm-token-flows: Maximum token fully diluted valuation, in USD"
|
|
3463
|
+
},
|
|
3464
|
+
"events": {
|
|
3465
|
+
"type": "string",
|
|
3466
|
+
"description": "common-token-transfer: Comma-separated event types: buy, sell, swap, send, receive"
|
|
3467
|
+
},
|
|
3468
|
+
"usd-min": {
|
|
3469
|
+
"type": "number",
|
|
3470
|
+
"description": "common-token-transfer: Minimum transfer value, in USD"
|
|
3471
|
+
},
|
|
3472
|
+
"usd-max": {
|
|
3473
|
+
"type": "number",
|
|
3474
|
+
"description": "common-token-transfer: Maximum transfer value, in USD"
|
|
3475
|
+
},
|
|
3476
|
+
"token-amount-min": {
|
|
3477
|
+
"type": "number",
|
|
3478
|
+
"description": "common-token-transfer: Minimum token amount transferred"
|
|
3479
|
+
},
|
|
3480
|
+
"token-amount-max": {
|
|
3481
|
+
"type": "number",
|
|
3482
|
+
"description": "common-token-transfer: Maximum token amount transferred"
|
|
3483
|
+
},
|
|
3484
|
+
"subject": {
|
|
3485
|
+
"type": "string",
|
|
3486
|
+
"repeatable": true,
|
|
3487
|
+
"description": "common-token-transfer: Only transfers by this subject, as type:value (address, entity, label, custom-label), e.g. label:\"Centralized Exchange\""
|
|
3488
|
+
},
|
|
3489
|
+
"counterparty": {
|
|
3490
|
+
"type": "string",
|
|
3491
|
+
"repeatable": true,
|
|
3492
|
+
"description": "common-token-transfer: Only transfers with this counterparty, as type:value. Requires --subject"
|
|
3493
|
+
},
|
|
3494
|
+
"exclude-from": {
|
|
3495
|
+
"type": "string",
|
|
3496
|
+
"repeatable": true,
|
|
3497
|
+
"description": "common-token-transfer: Exclude transfers sent from this subject, as type:value"
|
|
3498
|
+
},
|
|
3499
|
+
"exclude-to": {
|
|
3500
|
+
"type": "string",
|
|
3501
|
+
"repeatable": true,
|
|
3502
|
+
"description": "common-token-transfer: Exclude transfers sent to this subject, as type:value"
|
|
3503
|
+
},
|
|
3162
3504
|
"telegram": {
|
|
3163
3505
|
"type": "string",
|
|
3164
3506
|
"description": "Telegram chat ID"
|
|
@@ -3635,7 +3977,7 @@
|
|
|
3635
3977
|
"to": {
|
|
3636
3978
|
"type": "string",
|
|
3637
3979
|
"required": true,
|
|
3638
|
-
"description": "Recipient address"
|
|
3980
|
+
"description": "Recipient wallet address. A mixed-case EVM address must have a valid EIP-55 checksum. Refused: the token's own contract, and on Solana any account that is not a wallet (token account, mint, program)"
|
|
3639
3981
|
},
|
|
3640
3982
|
"chain": {
|
|
3641
3983
|
"type": "string",
|
|
@@ -3649,7 +3991,7 @@
|
|
|
3649
3991
|
},
|
|
3650
3992
|
"max": {
|
|
3651
3993
|
"type": "boolean",
|
|
3652
|
-
"description": "Send the entire spendable balance instead of --amount"
|
|
3994
|
+
"description": "Send the entire spendable balance instead of --amount. Cannot be combined with a numeric --amount"
|
|
3653
3995
|
},
|
|
3654
3996
|
"token": {
|
|
3655
3997
|
"type": "string",
|
package/src/trade-validation.js
CHANGED
|
@@ -680,6 +680,61 @@ function tokensEqual(a, b, chain) {
|
|
|
680
680
|
return a.toLowerCase() === b.toLowerCase();
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
/**
|
|
684
|
+
* The quote's input amount as the intent binding reads it: `inputAmount`, or
|
|
685
|
+
* the legacy `inAmount` alias when `inputAmount` is absent. Every pre-sign
|
|
686
|
+
* check that bounds the input (intent match, spend ceiling, native tx.value)
|
|
687
|
+
* must read this same field, or a quote carrying both aliases with different
|
|
688
|
+
* values satisfies each check with a different one.
|
|
689
|
+
*/
|
|
690
|
+
export function quoteInputAmountRaw(quote) {
|
|
691
|
+
return quote?.inputAmount ?? quote?.inAmount;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Check a native-token-input EVM transaction's `value` against the quote and
|
|
696
|
+
* the persisted request intent. Returns null when it is safe to sign, or a
|
|
697
|
+
* reason string the caller reports as a value mismatch.
|
|
698
|
+
*
|
|
699
|
+
* - tx.value must equal the bound input (quoteInputAmountRaw), the same field
|
|
700
|
+
* assertQuoteMatchesRequest / assertInputWithinMax already checked.
|
|
701
|
+
* - tx.value must also not exceed request.maxInputAmount, independently, so
|
|
702
|
+
* the native value is capped by persisted intent whichever alias the API
|
|
703
|
+
* populated.
|
|
704
|
+
*
|
|
705
|
+
* @param {object} request - Persisted intent (quoteData.request)
|
|
706
|
+
* @param {object} quote - The quote being executed
|
|
707
|
+
* @param {bigint} txValue - The transaction value about to be signed
|
|
708
|
+
* @returns {string|null}
|
|
709
|
+
*/
|
|
710
|
+
export function nativeValueMismatch(request, quote, txValue) {
|
|
711
|
+
const inRaw = quoteInputAmountRaw(quote);
|
|
712
|
+
if (inRaw == null || inRaw === '') {
|
|
713
|
+
return `tx.value=${txValue}, but the quote has no input amount to bind it to`;
|
|
714
|
+
}
|
|
715
|
+
let expected;
|
|
716
|
+
try {
|
|
717
|
+
expected = BigInt(inRaw);
|
|
718
|
+
} catch {
|
|
719
|
+
return `tx.value=${txValue}, but the quote input amount (${inRaw}) is not an integer`;
|
|
720
|
+
}
|
|
721
|
+
if (txValue !== expected) {
|
|
722
|
+
return `tx.value=${txValue}, expected=${expected}`;
|
|
723
|
+
}
|
|
724
|
+
if (request?.maxInputAmount != null) {
|
|
725
|
+
let cap;
|
|
726
|
+
try {
|
|
727
|
+
cap = BigInt(request.maxInputAmount);
|
|
728
|
+
} catch {
|
|
729
|
+
return `tx.value=${txValue}, but the persisted maximum input (${request.maxInputAmount}) is not an integer`;
|
|
730
|
+
}
|
|
731
|
+
if (txValue > cap) {
|
|
732
|
+
return `tx.value=${txValue} exceeds the maximum input ${cap}`;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
|
|
683
738
|
/**
|
|
684
739
|
* Revalidate a quote against the immutable request intent that was persisted
|
|
685
740
|
* when the quote was fetched. The Trading API supplies the amounts, token
|
|
@@ -802,7 +857,7 @@ export function assertQuoteMatchesRequest(request, quote, { chain, walletAddress
|
|
|
802
857
|
);
|
|
803
858
|
}
|
|
804
859
|
} else {
|
|
805
|
-
const inRaw = quote
|
|
860
|
+
const inRaw = quoteInputAmountRaw(quote);
|
|
806
861
|
if (inRaw == null) {
|
|
807
862
|
throw new Error(
|
|
808
863
|
`Quote is missing the input amount; cannot confirm it matches the requested input (${requested}). Refusing to sign.`,
|
|
@@ -882,7 +937,7 @@ export function assertInputWithinMax(request, quote, slippage) {
|
|
|
882
937
|
);
|
|
883
938
|
}
|
|
884
939
|
|
|
885
|
-
const inRaw = quote
|
|
940
|
+
const inRaw = quoteInputAmountRaw(quote);
|
|
886
941
|
if (inRaw == null) {
|
|
887
942
|
throw new Error(
|
|
888
943
|
'Quote is missing the input amount; cannot enforce the maximum input. Refusing to sign.',
|
package/src/trading.js
CHANGED
|
@@ -16,7 +16,7 @@ import { buildMessageV0, fetchAddressLookupTables, fetchRecentBlockhash } from '
|
|
|
16
16
|
import { keccak256, signSecp256k1, rlpEncode } from './crypto.js';
|
|
17
17
|
import { getWalletConnectAddress, sendTransactionViaWalletConnect, sendSolanaTransactionViaWalletConnect, sendApprovalViaWalletConnect } from './walletconnect-trading.js';
|
|
18
18
|
import { retrievePassword } from './keychain.js';
|
|
19
|
-
import { validateQuoteInput, validateBalance, resolvePercentAmount, validateGasBalance, encodeApproveCalldata, assertValidApprovalSpender, assertQuoteMatchesRequest, assertSwapCalldataNotBareTransfer, assertSwapOutcome, assertSolanaInstructionsSafe, checkSolanaFeeBalance, assertSolanaSwapOutcome, approvalAmountForSwap, needsAllowanceRevoke, OVERSIZED_ALLOWANCE_MULTIPLIER, EVM_BRIDGE_NATIVE_FEE_SLACK, isBridgeRequest } from './trade-validation.js';
|
|
19
|
+
import { validateQuoteInput, validateBalance, resolvePercentAmount, validateGasBalance, encodeApproveCalldata, assertValidApprovalSpender, assertQuoteMatchesRequest, assertSwapCalldataNotBareTransfer, assertSwapOutcome, assertSolanaInstructionsSafe, checkSolanaFeeBalance, assertSolanaSwapOutcome, approvalAmountForSwap, needsAllowanceRevoke, OVERSIZED_ALLOWANCE_MULTIPLIER, EVM_BRIDGE_NATIVE_FEE_SLACK, isBridgeRequest, nativeValueMismatch } from './trade-validation.js';
|
|
20
20
|
import { readCompactU16 } from './solana-tx.js';
|
|
21
21
|
import { formatPlan, guardExecution, resolveExecuteGuard } from './execute-guard.js';
|
|
22
22
|
export { readCompactU16 };
|
|
@@ -2928,10 +2928,10 @@ async function preflightTradeExecutionCandidate({
|
|
|
2928
2928
|
const nativeInput = isNativeToken(quote.inputMint);
|
|
2929
2929
|
const txValue = BigInt(quote.transaction.value || '0');
|
|
2930
2930
|
if (nativeInput) {
|
|
2931
|
-
const
|
|
2932
|
-
if (
|
|
2931
|
+
const valueMismatch = nativeValueMismatch(quoteData.request, quote, txValue);
|
|
2932
|
+
if (valueMismatch) {
|
|
2933
2933
|
throw new CommandError(
|
|
2934
|
-
`Transaction value mismatch:
|
|
2934
|
+
`Transaction value mismatch: ${valueMismatch}`,
|
|
2935
2935
|
'AMOUNT_MISMATCH',
|
|
2936
2936
|
);
|
|
2937
2937
|
}
|
|
@@ -4037,9 +4037,9 @@ EXAMPLES:
|
|
|
4037
4037
|
const isNative = isNativeToken(currentQuote.inputMint);
|
|
4038
4038
|
const txValue = BigInt(currentQuote.transaction.value || '0');
|
|
4039
4039
|
if (isNative) {
|
|
4040
|
-
const
|
|
4041
|
-
if (
|
|
4042
|
-
log(` ❌ Transaction value mismatch for ${quoteName}:
|
|
4040
|
+
const valueMismatch = nativeValueMismatch(quoteData.request, currentQuote, txValue);
|
|
4041
|
+
if (valueMismatch) {
|
|
4042
|
+
log(` ❌ Transaction value mismatch for ${quoteName}: ${valueMismatch}`);
|
|
4043
4043
|
if (qi + 1 < endIndex) log(` Trying next quote...`);
|
|
4044
4044
|
lastQuoteError = `${quoteName} transaction value mismatch`;
|
|
4045
4045
|
continue;
|
|
@@ -4430,9 +4430,9 @@ EXAMPLES:
|
|
|
4430
4430
|
// Validate transaction.value (same checks as local wallet)
|
|
4431
4431
|
const txValue = BigInt(currentQuote.transaction.value || '0');
|
|
4432
4432
|
if (isNative) {
|
|
4433
|
-
const
|
|
4434
|
-
if (
|
|
4435
|
-
log(` ❌ Transaction value mismatch for ${quoteName}:
|
|
4433
|
+
const valueMismatch = nativeValueMismatch(quoteData.request, currentQuote, txValue);
|
|
4434
|
+
if (valueMismatch) {
|
|
4435
|
+
log(` ❌ Transaction value mismatch for ${quoteName}: ${valueMismatch}`);
|
|
4436
4436
|
if (qi + 1 < endIndex) log(` Trying next quote...`);
|
|
4437
4437
|
lastQuoteError = `${quoteName} transaction value mismatch`;
|
|
4438
4438
|
continue;
|
|
@@ -4822,13 +4822,13 @@ EXAMPLES:
|
|
|
4822
4822
|
|
|
4823
4823
|
// Validate transaction.value matches the swap type.
|
|
4824
4824
|
// ERC-20 swaps transfer tokens via calldata, so value must be 0.
|
|
4825
|
-
// Native ETH swaps must have value matching the
|
|
4825
|
+
// Native ETH swaps must have value matching the bound quote input (and within maxInputAmount).
|
|
4826
4826
|
// A compromised API could attach a large value to drain ETH silently.
|
|
4827
4827
|
const txValue = BigInt(currentQuote.transaction.value || '0');
|
|
4828
4828
|
if (isNative) {
|
|
4829
|
-
const
|
|
4830
|
-
if (
|
|
4831
|
-
log(` ❌ Transaction value mismatch for ${quoteName}:
|
|
4829
|
+
const valueMismatch = nativeValueMismatch(quoteData.request, currentQuote, txValue);
|
|
4830
|
+
if (valueMismatch) {
|
|
4831
|
+
log(` ❌ Transaction value mismatch for ${quoteName}: ${valueMismatch}`);
|
|
4832
4832
|
if (qi + 1 < endIndex) log(` Trying next quote...`);
|
|
4833
4833
|
lastQuoteError = `${quoteName} transaction value mismatch`;
|
|
4834
4834
|
continue;
|