fix: enable Solana swaps via Chainflip with correct decimals#91
Merged
0xApotheosis merged 4 commits intodevelopfrom Jan 27, 2026
Merged
fix: enable Solana swaps via Chainflip with correct decimals#910xApotheosis merged 4 commits intodevelopfrom
0xApotheosis merged 4 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8dd02bb to
a5140fe
Compare
a5140fe to
7b580e2
Compare
- Remove outdated blocking logic that prevented SOL→BTC, SOL→ETH, and ETH→SOL pairs from fetching quotes - Add getChainflipAssetId helper to map token/chain combinations to correct Chainflip asset identifiers (e.g., ETH on any chain maps to Eth.Eth since Chainflip only supports ETH on Ethereum mainnet) Chainflip now supports all these pairs and returns valid quotes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7b580e2 to
62a9de6
Compare
SOL → ETH swaps were failing because the amount calculation used the destination token's decimals instead of the source token's native decimals. Added getChainflipDecimals helper to return correct decimals for each asset (SOL=9, BTC=8, ETH=18, USDT=6). Co-Authored-By: Claude <noreply@anthropic.com>
JavaScript's Number type can produce scientific notation (1e+18) for large numbers when converted to string, which the Chainflip API may not parse correctly. Using BigInt ensures the amount is formatted as a proper integer string (1000000000000000000). Co-Authored-By: Claude <noreply@anthropic.com>
For Chainflip swaps (Solana involved), use getChainflipDecimals for the destination token. For THORChain swaps, use the existing decimals lookup. This fixes the output showing in scientific notation. Co-Authored-By: Claude <noreply@anthropic.com>
Merged
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
Root Cause
Multiple issues were preventing Solana swaps from working:
fromToken.decimals[toToken.symbol]which looked up decimals based on the destination token instead of using the source token's native decimals10 ** 18can produce1e+18when stringified, which Chainflip couldn't parseChanges
1. Remove blocking logic
Removed the if-block that blocked SOL↔ETH and SOL→BTC pairs - Chainflip now supports these.
2. Add
getChainflipAssetIdhelperMaps token/chain combinations to correct Chainflip asset identifiers:
Sol.SolBtc.BtcEth.EthUsdt.Eth3. Add
getChainflipDecimalshelperReturns correct native decimals for Chainflip assets:
4. Use BigInt for amount formatting
Ensures the amount is formatted as a proper integer string (e.g.,
"1000000000") instead of scientific notation ("1e+9").5. Fix output display decimals
Use
getChainflipDecimals(toToken)for Chainflip swaps to correctly format the received amount.Test Plan
🤖 Generated with Claude Code