fix(morpho): Fix withdraw to use dynamic token decimals#1090
Open
Kubudak90 wants to merge 3 commits intocoinbase:mainfrom
Open
fix(morpho): Fix withdraw to use dynamic token decimals#1090Kubudak90 wants to merge 3 commits intocoinbase:mainfrom
Kubudak90 wants to merge 3 commits intocoinbase:mainfrom
Conversation
…rdcoded 18 The MorphoActionProvider.withdraw() function was using Web3.to_wei(assets, 'ether') which hardcodes 18 decimals. This caused incorrect amounts for tokens with different decimals (e.g., USDC with 6 decimals). Changes: - Added token_address field to MorphoWithdrawSchema - Updated withdraw() to fetch token decimals dynamically (matching deposit behavior) - Updated description to say 'whole units' instead of 'atomic units' - Added examples for both WETH and USDC in the description - Updated tests to include token_address and added test for non-18 decimal tokens Fixes coinbase#946
🟡 Heimdall Review Status
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The withdraw action was using atomic units (wei) while deposit used whole units (e.g., 1.5 WETH). This inconsistency would confuse users. Changes: - Updated WithdrawSchema to accept decimal values like DepositSchema - Added tokenAddress parameter to withdraw for fetching decimals - Updated withdraw function to parse decimal amounts to atomic units - Updated description to clarify whole units vs atomic units - Updated tests to match new behavior This makes the Morpho provider consistent with Moonwell and other action providers that use whole units for both deposit and withdraw.
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
Fixes #946
The MorphoActionProvider.withdraw() function was using Web3.to_wei(assets, 'ether') which hardcodes 18 decimals. This caused incorrect amounts for tokens with different decimals (e.g., USDC with 6 decimals would be off by 12 orders of magnitude).
Changes
Testing
Bug Details
Before this fix:
After this fix: