@cowprotocol/sdk-common package provides shared utilities, types, and helper functions used across the CoW Protocol SDK.
Installation
Address Utilities
Type Definitions
isEvmAddress
Validates if a string is a valid EVM address.address- The address string to validate
isBtcAddress
Validates if a string is a valid Bitcoin address (supports legacy P2PKH/P2SH and Bech32 formats).address- The address string to validate
isSolanaAddress
Validates if a string is a valid Solana address (Base58-encoded Ed25519 public keys).address- The address string to validate
getEvmAddressKey
Normalizes an EVM address to lowercase with 0x prefix.getAddressKey
Gets an address key for any supported blockchain address type.address- The address to convert to a key
Token Utilities
TokenIdentifier
getTokenId
Generates a unique token identifier from chain ID and address.areTokensEqual
Compares two tokens for equality based on chain ID and address.areAddressesEqual
Compares two addresses for equality, handling different blockchain formats.isNativeToken
Checks if a token is the native currency for its chain.isWrappedNativeToken
Checks if a token is the wrapped native currency (e.g., WETH on Ethereum).Math Utilities
percentageToBps
Converts a percentage to basis points (bps).percentage- The percentage to convert (e.g., 0.5 for 50%)
bpsToPercentage
Converts basis points to a percentage.bps- The basis points value
applyPercentage
Applies a percentage to a bigint value.value- The value to apply the percentage topercentage- The percentage to apply (e.g., 1.1 for 110%)
Logging
enableLogging
Enables or disables SDK logging.log
Logs a message if logging is enabled.Type Utilities
Nullish
Utility type for nullable values.ABIs
The package exports contract ABIs for CoW Protocol:GPV2SettlementAbi
ABI for the GPv2 Settlement contract, including:TradeeventsetPreSignature()functioninvalidateOrder()functiondomainSeparator()function