@mallow-labs/mallow-common
v1.2.0
Published
Common utilities, types, token mints, and constants used across the Mallow Labs packages.
Downloads
204
Readme
@mallow-labs/mallow-common
Common utilities, types, token mints, and on-chain constants used across the Mallow Labs packages.
Includes Solana token mint addresses (SOL, USDC, SMORES, XNU, …), shared TypeScript types (auction metadata, market events, listing types, …), Mallow program addresses, and a handful of cross-package helpers (shouldAskForShippingAddress, normalizeErrorMessage, file/IPFS URL helpers, etc.).
Install
pnpm add @mallow-labs/mallow-commonUsage
import {
SOL,
USDC,
SMORES,
XNU,
STORE_CREDIT,
USER_REWARD,
AUTH_KEY,
FEE_ACCOUNT_KEY,
StoreProductCategory,
Tokens,
TokenBySymbol,
formatPrice,
} from "@mallow-labs/mallow-common";
// Look up a known token
const usdc = TokenBySymbol["USDC"];
console.log(usdc.decimals); // 6
// Format an on-chain price for display
const display = formatPrice({
price: { amount: "1500000", currencyMint: USDC },
token: usdc,
});
// 1.5
// Reference well-known accounts
console.log(AUTH_KEY.toBase58()); // AUTH8n3RY3JH38j19r1TrZi88zf5pUnAGh4tFkhcnptZ
console.log(FEE_ACCOUNT_KEY.toBase58()); // MFHHByMGfk84s3GZ8dZHaQQ3gbpQYc2NnQYPg2tRCSxExports
| Group | Notable symbols |
|---|---|
| Token mints (strings) | SOL, USDC, USDC_DEV, USD_STAR, SMORES, BONK, JUP, GUAC, GECKO, WEN, FOXY, XNU, XNU_DEV, STORE_CREDIT, USER_REWARD, ETH, oXTZ, XTZ, MALLOW_SOL, …and more |
| Token metadata | Tokens, TokenBySymbol, TokenByMint, MintBySymbol, SymbolByMint, DecimalsBySymbol, CoinGeckoIdBySymbol, GeckoTerminalPoolBySymbol |
| Price formatting | formatPrice, formatPriceWithSymbol, abbreviateAmount, getBaseTokenForChain |
| Known accounts | AUTH_KEY / AUTH_ADDRESS, FEE_ACCOUNT_KEY / FEE_ACCOUNT_ADDRESS, MALLOW_VALIDATOR_KEY / MALLOW_VALIDATOR_ADDRESS |
| Helpers | getFeeAccountTaggingIx — zero-lamport tagging transfer to the Mallow fee account |
| Enums | StoreProductCategory, MarketSource, MarketEventType, Role, JobStatus, ListingType, EventMode, ExploreSort, and many more |
| Types | Auction / market / event / listing / NFT / user shapes used across the Mallow stack |
| Namespaces | IDLs, Programs — re-exports of program IDs and IDLs |
| Util | normalizeErrorMessage, toIpfsUri, getCDNThumbnailUrl, getFileCategory, getIsLive, getMintsByChain, jsonStringify, shouldAskForShippingAddress, …and more |
Versioning
The 1.x line replaces the long-unmaintained 1.1.0 snapshot that had a stale build output (dist/cjs/index.js) and missing exports. 1.2.0 adopts the current monorepo source as-is.
License
MIT
