Skip to content

Conversation

@micaelae
Copy link
Member

@micaelae micaelae commented Oct 27, 2025

Explanation

References

Fixes #6616

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Moves stablecoin config to a top-level CAIP asset list and updates slippage, selectors, validators, and CAIP formatting accordingly.

  • Feature flags/config:
    • Add stablecoins: CaipAssetType[] to platform config and default config; remove chain-level stablecoins.
    • Update PlatformConfigSchema to validate top-level CAIP stablecoins list.
  • Slippage:
    • Refactor getDefaultSlippagePercentage to take srcAssetId, destAssetId, and global stablecoins (CAIP); adjust logic for cross-chain, Solana, and EVM stablecoin pairs.
    • Export getDefaultSlippagePercentage and BRIDGE_DEFAULT_SLIPPAGE from index.
  • Selectors/exports:
    • Remove selectDefaultSlippagePercentage selector and its exports/usages.
  • CAIP formatters:
    • formatAddressToAssetId now always returns a CAIP asset ID; lowercases EVM addresses and uses erc20: vs non‑EVM token:.
    • Improve error messages and deprecate formatAddressToCaipReference in JSDoc; add explicit throws docs.
  • Tests:
    • Update slippage tests to use CAIP asset IDs and new getDefaultSlippagePercentage API.
    • Adjust expectations per updated schemas and utilities.

Written by Cursor Bugbot for commit 80f2735. This will update automatically on new commits. Configure here.

@micaelae micaelae requested a review from a team as a code owner October 27, 2025 18:59
@micaelae micaelae marked this pull request as draft October 27, 2025 18:59
// Non-EVM assets
return CaipAssetTypeStruct.create(
`${formatChainIdToCaip(chainId)}/erc20:${addressOrAssetId}`,
`${formatChainIdToCaip(chainId)}/token:${addressOrAssetId}`,
Copy link

Choose a reason for hiding this comment

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

Bug: Refactored Function Lacks Validation

The refactored formatAddressToAssetId function removes validation and always returns a CaipAssetType, even for invalid inputs. The old implementation returned undefined when addressOrAssetId was not a valid hex string (after checking for native addresses and Solana). The new implementation will create a "token:" type asset for ANY non-hex string input in the final fallthrough case, which could create invalid CAIP asset types for malformed or invalid addresses. This changes the function's contract (return type changed from CaipAssetType | undefined to CaipAssetType) without proper validation, potentially masking errors.

Fix in Cursor Fix in Web

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.

2 participants