Skip to content

fix: rename to @mento-protocol/cli, fix install + collateral resolution#6

Merged
chapati23 merged 2 commits intomainfrom
worktree-inherited-popping-pillow
Apr 28, 2026
Merged

fix: rename to @mento-protocol/cli, fix install + collateral resolution#6
chapati23 merged 2 commits intomainfrom
worktree-inherited-popping-pillow

Conversation

@chapati23
Copy link
Copy Markdown
Contributor

@chapati23 chapati23 commented Apr 27, 2026

Summary

Following the README's install instructions did not work — npm install -g mento-cli 404'd, and the existing published @mento-protocol/mento-cli@0.1.0 install threw Volta errors because its tarball was missing the bin entrypoint. This PR makes the repo installable end-to-end, renames it to a clean scope, and fixes a class of token-resolution bugs.

Install / publish

  • Rename to @mento-protocol/cli (binary stays mento); bump to 3.0.0 to match the v3 SDK rewrite.
  • Add prepack: tsc + files: ["bin", "dist"] so the npm tarball ships a pre-built dist/.
  • README install command updated; Installing from source section explains the npm pack && npm install -g <tarball> path that avoids the Volta-symlink bug seen with npm install -g ..

Token resolution (real bug)

  • Old resolveToken only consulted the SDK's getCachedTokens (stable tokens). Any command resolving a collateral asset by symbol or address — CELO, USDC, axlUSDC, USD₮, axlEUROC — failed with Token not found (quote / swap / routes --from/--to / trading status <pair>) or rendered raw addresses instead of symbols (pools, trading limits, routes tables, mermaid graph).
  • New prefetchTokens(mento, chainId) fetches mento.tokens.getCollateralAssets() once per chain. Concurrent first-callers share an in-flight promise; the entry is cleared via .finally so a transient RPC failure doesn't poison the chain for the process lifetime.
  • resolveToken short-circuits when the symbol is already in the stable cache (e.g. USDm → USDC pairs no longer wait on a collateral fetch).
  • New tokenSymbolOrAddress helper replaces three near-identical copies of getTokenSymbol/symbolForAddress across pools.ts, trading.ts, routes.ts.

Misc cleanup

  • Drop pricingUnavailableReason references in pools.ts — field doesn't exist on the SDK's FPMMPoolDetails, was breaking the build.
  • Lift duplicated parseAmount from quote.ts + swap.ts into format.ts.
  • README examples updated from USDm CELO (no direct route exists on-chain) to USDm USDC (real FPMM pool); removed dead docs/PRD.md link.

Test plan

  • npm install from clean tree, npm pack, npm install -g ./mento-protocol-cli-3.0.0.tgz — installs cleanly via Volta
  • mento --version3.0.0
  • mento info → mainnet contract addresses
  • mento tokens / mento tokens --collateral / mento tokens --all
  • mento quote USDm USDC 100 → real on-chain quote (was previously failing)
  • mento pools → symbols resolve correctly (USDm, axlUSDC, USDC etc.) instead of raw addresses
  • mento routes --from USDm --to USDC → renders the route
  • mento trading status USDm USDC → ✓ Tradable
  • Reviewer to verify npm publish --access public --dry-run looks correct before publishing

🤖 Generated with Claude Code


Note

Medium Risk
Medium risk because it changes published package metadata/packaging and modifies token-resolution paths used by quote/swap and other on-chain commands, which could affect runtime behavior if caching or resolution is wrong.

Overview
Updates the npm package to @mento-protocol/cli (v3.0.0) with corrected publish/install behavior: adds files + prepack build so tarballs include bin/ and dist/, sets publishConfig.access=public, ignores generated *.tgz, and refreshes README install/source-install guidance and examples.

Fixes a class of collateral-token lookup issues by introducing prefetchTokens + async resolveToken/resolveTokenSync and a shared tokenSymbolOrAddress helper, then wiring these into quote, swap, routes, pools, and trading (including mermaid graph output) so collateral symbols resolve and display correctly. Also centralizes decimal parsing via parseAmount in lib/format and removes references to a non-existent pricingUnavailableReason field in pool details.

Reviewed by Cursor Bugbot for commit c560d59. Bugbot is set up for automated code reviews on this repo. Configure here.

chapati23 and others added 2 commits April 27, 2026 18:53
- Package renamed to @mento-protocol/cli (3.0.0); binary stays `mento`.
- Add `prepack: tsc` and `files: ["bin", "dist"]` so the published tarball
  ships a built dist and `npm install -g` works without volta symlink bugs.
- README install instructions updated; examples use USDm/USDC (a real
  on-chain route) instead of USDm/CELO (no direct route exists).
- Token resolution now also covers collateral assets (CELO, USDC, …).
  Previously every quote/swap/trading-status with a collateral symbol
  failed with "Token not found"; pools/routes/trading tables rendered
  collateral addresses instead of symbols.
- Race-safe `prefetchTokens` cache: in-flight requests dedupe via a
  shared promise and clean up on rejection (.finally) so transient RPC
  failures don't poison the chain for the process lifetime.
- `resolveToken` short-circuits when the token is already in the stable
  cache, avoiding an unnecessary collateral fetch for stable-only pairs.
- Drop `pricingUnavailableReason` references — that field doesn't exist
  on the SDK's FPMMPoolDetails type and was breaking the build.
- Consolidate duplicated `getTokenSymbol`/`symbolForAddress` into a
  single `tokenSymbolOrAddress` helper; lift duplicated `parseAmount`
  from quote.ts and swap.ts into format.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chapati23 chapati23 merged commit 82dfdeb into main Apr 28, 2026
2 checks passed
@chapati23 chapati23 deleted the worktree-inherited-popping-pillow branch April 28, 2026 07:07
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