fix(compound): Track base asset supply via balanceOf in portfolio and withdraw#959
Draft
RezaRahemtola wants to merge 1 commit intocoinbase:mainfrom
Draft
fix(compound): Track base asset supply via balanceOf in portfolio and withdraw#959RezaRahemtola wants to merge 1 commit intocoinbase:mainfrom
RezaRahemtola wants to merge 1 commit intocoinbase:mainfrom
Conversation
🟡 Heimdall Review Status
|
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.
Description
The Compound action provider is missing base asset (e.g. USDC) supply tracking. In Compound v3 (Comet), base asset and collateral assets are tracked differently:
Comet.balanceOf(account), which earns supply APYComet.collateralBalanceOf(account, asset), which backs borrowsWhen using the
supplyaction on USDC, subsequent calls toget_portfoliowill not detect the supplied amounts andwithdrawalso won't work.This is because texisting code only uses
collateralBalanceOf, so:get_portfolioreturns empty when only base asset is suppliedwithdrawcheckscollateralBalanceOffor balance validation, which returns 0 for the base asset, making base asset withdrawals failThis PR fixes that with the following changes:
constants.ts: add balanceOf to COMET_ABIutils.ts: add getBaseAssetBalance(), update getPortfolioDetailsMarkdown() to show base asset supplycompoundActionProvider.ts: fix withdraw() to detect base vs collateral — base uses balanceOf() and skips health ratio check, collateral path unchangedTests
Will do soon, made this PR for my project at the ETHDenver 2026 hackathon, using a custom action provider with these fixes for now and will improve this PR with broader tests later.
Checklist
A couple of things to include in your PR for completeness: