Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Following the README's install instructions did not work —
npm install -g mento-cli404'd, and the existing published@mento-protocol/mento-cli@0.1.0install 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
@mento-protocol/cli(binary staysmento); bump to3.0.0to match the v3 SDK rewrite.prepack: tsc+files: ["bin", "dist"]so the npm tarball ships a pre-builtdist/.Installing from sourcesection explains thenpm pack && npm install -g <tarball>path that avoids the Volta-symlink bug seen withnpm install -g ..Token resolution (real bug)
resolveTokenonly consulted the SDK'sgetCachedTokens(stable tokens). Any command resolving a collateral asset by symbol or address —CELO,USDC,axlUSDC,USD₮,axlEUROC— failed withToken not found(quote / swap /routes --from/--to/trading status <pair>) or rendered raw addresses instead of symbols (pools,trading limits,routestables, mermaid graph).prefetchTokens(mento, chainId)fetchesmento.tokens.getCollateralAssets()once per chain. Concurrent first-callers share an in-flight promise; the entry is cleared via.finallyso a transient RPC failure doesn't poison the chain for the process lifetime.resolveTokenshort-circuits when the symbol is already in the stable cache (e.g.USDm → USDCpairs no longer wait on a collateral fetch).tokenSymbolOrAddresshelper replaces three near-identical copies ofgetTokenSymbol/symbolForAddressacrosspools.ts,trading.ts,routes.ts.Misc cleanup
pricingUnavailableReasonreferences inpools.ts— field doesn't exist on the SDK'sFPMMPoolDetails, was breaking the build.parseAmountfromquote.ts+swap.tsintoformat.ts.USDm CELO(no direct route exists on-chain) toUSDm USDC(real FPMM pool); removed deaddocs/PRD.mdlink.Test plan
npm installfrom clean tree,npm pack,npm install -g ./mento-protocol-cli-3.0.0.tgz— installs cleanly via Voltamento --version→3.0.0mento info→ mainnet contract addressesmento tokens/mento tokens --collateral/mento tokens --allmento quote USDm USDC 100→ real on-chain quote (was previously failing)mento pools→ symbols resolve correctly (USDm, axlUSDC, USDC etc.) instead of raw addressesmento routes --from USDm --to USDC→ renders the routemento trading status USDm USDC→ ✓ Tradablenpm publish --access public --dry-runlooks 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/swapand 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: addsfiles+prepackbuild so tarballs includebin/anddist/, setspublishConfig.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+ asyncresolveToken/resolveTokenSyncand a sharedtokenSymbolOrAddresshelper, then wiring these intoquote,swap,routes,pools, andtrading(including mermaid graph output) so collateral symbols resolve and display correctly. Also centralizes decimal parsing viaparseAmountinlib/formatand removes references to a non-existentpricingUnavailableReasonfield in pool details.Reviewed by Cursor Bugbot for commit c560d59. Bugbot is set up for automated code reviews on this repo. Configure here.