You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MaintenancePoolService.deposit creates a second escrow when it loses the first-deposit race, which is the orphaned escrow #275 was meant to prevent #781
The race-loser branch (src/maintenance-pool/maintenance-pool.service.ts:89-100):
if(updateResult.affected===0){// Another request won the race — top up the winner's escrow instead.constexistingPool=awaitthis.findOne(id);awaitthis.escrowService.fund({ amount,asset: pool.asset, funderAddress,maintenancePoolId: pool.id});awaitthis.poolRepo.increment({ id },'balance',Number(amount));returnthis.findOne(id);}
The comment says "top up the winner's escrow instead" — and the code calls escrowService.fund again, which creates a newEscrow row (and a new on-chain fund) rather than depositing into the existing one. existingPool is fetched and never used, so the winner's escrowId is read and discarded.
Why it matters: the loser has already created one escrow before the conditional update ran (:77-82), so this branch creates a second. The pool ends up pointing at the winner's escrow while two further escrow rows exist with maintenancePoolId set and nothing referencing them — orphans, which is precisely what #275's lock was added to avoid. pool.balance is incremented for money that is locked in an escrow the pool will never withdraw from.
The non-race path has the same shape: subsequent deposits call escrowService.fund (:103-108), creating a new escrow per deposit, while the contract's model is repeated deposit() calls against one pool. So a pool with twelve monthly deposits has twelve escrow rows and pool.escrowId pointing at the first.
Fix: add a deposit path to EscrowService that invokes the pool contract's deposit(pool_id, sponsor, token, amount) against the existing escrow row instead of calling fund, and have both branches here use it. Then pool.escrowId is the single escrow for the pool's lifetime, which is what poolWithdraw already assumes.
I analyzed "MaintenancePoolService.deposit creates a second escrow when it loses the first-deposit race, which is the orphaned escrow #275 was meant to prevent" in MergeFi/backend and have a concrete technical roadmap to resolve it.
I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.
I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.
@Umubioghenemaro has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
I’m interested in contributing to this issue. I’ll begin by reviewing the existing architecture and related code, then implement the requested changes while following the project’s existing conventions. I’ll include appropriate tests and keep the PR focused, documented, and easy to review.
Congratulations, @maikNeta! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @maikNeta: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
😎 @maikNeta: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.
Activity
guptakumarranjeet150 commentedon Nov 12, 2026
Hi team,
I analyzed "MaintenancePoolService.deposit creates a second escrow when it loses the first-deposit race, which is the orphaned escrow #275 was meant to prevent" in MergeFi/backend and have a concrete technical roadmap to resolve it.
I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.
I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.
Thank you!
Umubioghenemaro commentedon Nov 19, 2026
@Umubioghenemaro has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Umubioghenemaro to this issue.
maikNeta commentedon Nov 19, 2026
@maikNeta has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @maikNeta to this issue.
drips-wave commentedon Nov 19, 2026
Congratulations, @maikNeta! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @maikNeta: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
fix(backend): no default encryption key, single pool escrow, shared p…
drips-wave commentedon Nov 20, 2026
This issue has been completed by @maikNeta as part of the Stellar Wave Program's 11th Wave 🥳
😎 @maikNeta: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.