fix: await floating balance promises (valence, sierra-money)#20040
Merged
RohanNero merged 1 commit intoJul 16, 2026
Conversation
Both adapters start an async balance-adding call but return before it
settles, so the balance is absent when the framework reads
api.getBalances() (pending promises are not tracked).
- valence (neutron): getLpTvl unwraps astroport LP shares inside
possibleLpTokens.forEach(async ...) and has no await after the loop,
so the api.add() calls never run before the function returns. Use
await Promise.all(map(...)) instead.
- sierra-money (avax): tvl calls api.sumTokens({ USDC }) without await,
racing the OpenTrade multiCall; the reserve USDC is dropped when the
multiCall wins. Await the call.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo adapter TVL calculations were updated to await asynchronous token summation and LP token processing before continuing. ChangesAsync calculation completion
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
The adapter at projects/sierra-money exports TVL: |
|
The adapter at projects/valence exports TVL: |
Contributor
|
Thanks for the PR |
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.
Two adapters kick off an async balance-adding call but return before it settles. The framework reads
api.getBalances()right afterawait tvl(api), and pending promises are not tracked — so the balance is silently missing. Neither shows up as a spike (the value is just persistently low/flickery), which is why it slips past review.valence (neutron) — deterministic undercount
getLpTvlconverts astroport LP shares into their underlying value:forEachdiscards the returned promises and there is noawaitafter the loop, sogetLpTvlreturns before anyapi.addruns. Since it's the last call in the neutrontvl, the entire astroport-LP underlying value is dropped on every run. Fixed by awaitingPromise.all(map(...)).sierra-money (avax) — race
The reserve-USDC
sumTokensis a floating promise racing the awaited OpenTrademultiCall. When the multiCall wins, the reserve USDC (part of the adapter's stated methodology) is dropped beforegetBalances()is read. Fixed by awaiting the call.Both changes are minimal and leave behavior otherwise unchanged; the try/catch handling in valence is preserved.
Summary by CodeRabbit