Fix Maya CACAO source swaps (below min limit / Invalid publicAddress)#465
Merged
Conversation
Contributor
Author
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3e8b1c0. Configure here.
3e8b1c0 to
bf81347
Compare
Contributor
Author
peachbits
approved these changes
Jun 23, 2026
peachbits
left a comment
Contributor
There was a problem hiding this comment.
This is fine. I would have preferred to see the getNodeLimitUnits to be passed into makeThorchainBasedPlugin as an opt to avoid another instance of the common code asking itself what it is but we can clean up if we add another clone later.
Swapping CACAO (Maya Protocol native asset) to BTC failed at any amount. Two distinct bugs in the shared Thorchain/Maya plugin code were responsible: 1. The native RUNE/CACAO deposit branch was gated on a source wallet pluginId of 'cacao', but the Maya chain's pluginId is 'mayachain' (CACAO is only the currency code). CACAO sources never matched the deposit branch and fell through to the UTXO path, throwing 'Invalid publicAddress' once an amount cleared the min check. 2. Mayanode expresses quote amounts in each asset's native precision (CACAO is 1e10, BTC is 1e8), whereas Thornode normalizes everything to THOR_LIMIT_UNITS (1e8). Using 1e8 for CACAO under-scaled the amount sent to Mayanode by 100x, so normal amounts came back below the min limit. Quote conversions and the deposit's coin decimals now use each asset's native multiplier for Maya; Thorchain is unchanged (its multiplier resolves to THOR_LIMIT_UNITS). Verified end to end on the iOS simulator: a 942 CACAO -> BTC swap now builds a correct quote and executes to the success scene.
bf81347 to
d57b048
Compare
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.




CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Fixes Maya Protocol swaps from CACAO (e.g. CACAO → BTC), which failed at every amount with "amount is below the min limit" (and, at large amounts, an
Invalid publicAddresscore log). Maya CACAO → BTC works on the Maya website, so this was an Edge-side plugin bug.There were two distinct root causes in the shared Thorchain/Maya plugin code (
src/swap/defi/thorchain/thorchainCommon.ts):Wrong pluginId for the native deposit branch. The RUNE/CACAO
MakeTxDepositpath was gated onfromWallet.currencyInfo.pluginId === 'cacao', but the Maya chain's pluginId ismayachain(CACAOis only the currency code, confirmed inedge-currency-accountbasedmayachainInfo.ts). CACAO sources never matched the deposit branch, fell through to the UTXO path, leftpublicAddressnull, and threwInvalid publicAddressonce an amount cleared the (broken) min check. The GUI surfaces that thrown error as the generic "below min limit" message.Wrong amount precision for Mayanode quotes. Mayanode expresses quote amounts in each asset's native precision (CACAO is 1e10, BTC is 1e8), whereas Thornode normalizes everything to
THOR_LIMIT_UNITS(1e8). Using 1e8 for CACAO under-scaled the amount sent to Mayanode by 100×, so any normal amount came back below Maya's minimum. A newgetNodeLimitUnitshelper resolves the correct multiplier per asset for Maya (the asset's native multiplier) while leaving Thorchain onTHOR_LIMIT_UNITS. The deposit coindecimalslikewise now uses the source asset's native multiplier (a no-op for RUNE, since its native multiplier already equals 1e8).Thorchain (RUNE) behavior is unchanged: for every RUNE/Thorchain asset the new helper resolves to the existing
THOR_LIMIT_UNITS.Testing
Verified end to end on the iOS simulator with the funded
edge-fundsMAYAChain wallet:tsc+ eslint + jest (verify-repo.sh) pass./quote/swapcall) and the swap executes through the confirm slider to the "Congratulations! Your exchange is being processed!" success scene.Screenshots attached below.
Asana: https://app.asana.com/0/1215088146871429/1215734647159265
Note
Medium Risk
Touches shared quote and tx-building logic for all Maya swaps and max-quote paths; Thorchain is gated on pluginId but any Maya precision mistake could mis-quote or mis-build deposits.
Overview
Fixes Maya Protocol swaps when CACAO is the source (e.g. CACAO → BTC), which previously failed with “below min limit” or
Invalid publicAddress.The shared Thorchain/Maya plugin now treats native CACAO/RUNE deposits with wallet pluginId
mayachaininstead of the non-existentcacao, so CACAO uses theMakeTxDepositpath instead of falling through to UTXO handling.For
mayaprotocolquotes, amounts sent to Mayanode and converted back usegetNodeLimitUnits(per-asset native multipliers via exportedgetTokenMultiplier) instead of universalTHOR_LIMIT_UNITS(1e8)—fixing ~100× under-scaling for CACAO (1e10). Depositdecimalsand max-quote probe amounts follow the same multipliers (e.g. ~1000 CACAO for max seeds on Maya).Thorchain/RUNE behavior is unchanged when the helper resolves to 1e8.
Reviewed by Cursor Bugbot for commit d57b048. Bugbot is set up for automated code reviews on this repo. Configure here.