Skip to content

fix(perp): honour --dry-run and --yes on transfer and approve-builder-fee - #839

Open
kome12 wants to merge 3 commits into
mainfrom
fix/perp-transfer-fee-dry-run
Open

kome12 wants to merge 3 commits into
mainfrom
fix/perp-transfer-fee-dry-run

Conversation

@kome12

@kome12 kome12 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What

nansen perp transfer and nansen perp approve-builder-fee now go through the same execute guard as perp order, close, cancel and leverage:

  • --dry-run runs validation and the compliance screen, prints a plan, and signs nothing (no wallet password needed).
    • transfer: wallet, direction, and the exact USDC amount string that would be signed.
    • approve-builder-fee: wallet, builder address, maximum fee rate. An already-approved wallet says so and has nothing to preview.
  • In an interactive terminal both ask before signing; --yes / -y / NANSEN_YES=1 skips the question. The wallet key is only loaded after the user says yes.
  • Off a terminal they run unprompted as before, unless NANSEN_REQUIRE_CONFIRM=1 is set, in which case they fail with CONFIRMATION_REQUIRED before any request.

dry-run and yes are added to both commands in src/schema.json, and the perp help, README and trading skill list both commands with the others.

Why

Both commands ignored --dry-run (it is a global boolean flag, so it was parsed and silently dropped): perp transfer --direction perp-to-spot --amount 500 --dry-run signed and submitted the transfer, and approve-builder-fee --dry-run signed the fee approval. Neither ever asked for confirmation.

How it was tested

  • New cases in src/__tests__/perp-execute-guard.test.js for both commands: dry run (plan, nothing signed, no password, blocked wallet, testnet URL refused, unparseable amount), NANSEN_REQUIRE_CONFIRM with and without --yes, terminal decline/accept, off-terminal, already-approved, the transfer nonce taken after the prompt, and the CLI command table. The dry-run tests fail on main with submitExchange called once.
  • npm test and npm run lint pass.
  • Real CLI with a throwaway home directory and an unfunded wallet, against the production API: both --dry-run runs print the plan and exit 0 with nothing signed; NANSEN_REQUIRE_CONFIRM=1 without --yes exits 1 with CONFIRMATION_REQUIRED; nansen schema lists the new options.
before after
perp transfer ... --dry-run signed and submitted plan, nothing signed
perp approve-builder-fee --dry-run signed and submitted plan, nothing signed
terminal, answer n never asked; submitted CONFIRMATION_DECLINED, nothing signed
NANSEN_REQUIRE_CONFIRM=1, no --yes submitted CONFIRMATION_REQUIRED, no request

🤖 Generated with Claude Code

kome12 and others added 2 commits November 16, 2026 12:57
…-fee

Both commands signed and submitted to Hyperliquid even with --dry-run, and
never asked for confirmation. They now go through the same guard as order,
close, cancel and leverage: --dry-run prints the plan and signs nothing, an
interactive terminal asks before signing, and NANSEN_REQUIRE_CONFIRM applies
off a terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
transfer makes no proxy read before the guard, so unlike the other perp
commands its dry run did not check the network and previewed a transfer
the real run refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/perp.js Resolved
@nansen-pr-reviewer

nansen-pr-reviewer Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

nansen-pr-reviewer summary

The change correctly adds dry-run and confirmation guards to perp transfers and builder-fee approval, and the transfer path now rejects values whose float-rendered wire amount would differ from the input. One contradictory skill-documentation statement still says these commands are unchanged, which can mislead agents about confirmation behavior.

Findings by Severity

Severity Count
🔵 Low 1

Deterministic check: success — Found 1 finding(s) within acceptable thresholds

Risk: 3/5 (Elevated)

✅ Auto-approved — Deterministic gates passed: severity thresholds met, recommendation "approve_with_comments", risk level 3/5 within threshold 3.


Token usage: 44,388 input, 3,034 output, 89,697 cache read | Usage Guide

Cooldown: for the next 10 minutes (counting from when this review finished), new pushes to this PR will not trigger another review — the next push after the window expires will. Need a fresh review sooner? Comment @nansen-pr-reviewer[bot] re-review.

The amount went through a float and an 8-decimal string, so an input with
more precision, or too large for a float, was signed as a different amount.
Compare the typed decimal with the string that would be signed, and refuse
the transfer when they differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

**When stdin is *not* a terminal** (agents, CI) the commands submit without prompting, exactly as before, and `--yes` is a no-op. **Exception:** if `NANSEN_REQUIRE_CONFIRM=1` is set, they fail with `CONFIRMATION_REQUIRED` (exit 1) before any request or signature unless `--yes` or `NANSEN_YES=1` is given; follow the operator stop point described above. These are the same rules as `trade execute` and `bridge execute`. `transfer` and `approve-builder-fee` are unchanged.
**When stdin is *not* a terminal** (agents, CI) the commands submit without prompting, exactly as before, and `--yes` is a no-op. **Exception:** if `NANSEN_REQUIRE_CONFIRM=1` is set, they fail with `CONFIRMATION_REQUIRED` (exit 1) before any request or signature unless `--yes` or `NANSEN_YES=1` is given; follow the operator stop point described above. These are the same rules as `trade execute` and `bridge execute`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 - Low | Trading skill incorrectly says transfer and builder-fee approval are unchanged

This statement contradicts the surrounding documentation and the implementation: both commands now support --dry-run, prompt on an interactive terminal, and honor NANSEN_REQUIRE_CONFIRM. Agents following this line may incorrectly assume the old unguarded behavior and fail to account for confirmation or confirmation-required errors.

@nansen-pr-reviewer nansen-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved by Nansen review

Deterministic gates passed: severity thresholds met, recommendation "approve_with_comments", risk level 3/5 within threshold 3.

  • The deterministic severity check passed: Found 1 finding(s) within acceptable thresholds
  • Risk level 3/5 (Elevated)
  • The model recommended: approve_with_comments

Approval was decided by deterministic gates, not by the model. The model's recommendation can block auto-approval but never cause it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant