MaintenancePoolService.assignReward reports a stale balance in its 'exceeds pool balance' error

Open
#608 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@urielit1313-creator is already working on this.

Since Oct 13, 2026.

  • #624 by @urielit1313-creator — open
  • #650 by @yggdrasilworld — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
22/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
backend

Research direction

Start in MaintenancePoolService.assignReward, at the error thrown when the conditional UPDATE ... WHERE balance >= :amount affects zero rows, and check where pool.balance was read before that update. Fix the message so it does not show a stale balance, either by re-reading the balance or using RETURNING, or by dropping the figure. Two open pull requests (#624 and #650) already target this issue, so compare them before writing a new patch. Done means the error reports a current or omitted balance under concurrent updates, with related issue #274 in mind.

Written by the indexing model from the issue text.

Description

bug good first issue

Problem

When the conditional UPDATE … WHERE balance >= :amount affects 0 rows, the error is Requested reward ${amount} exceeds pool balance ${pool.balance}. pool was read before the update, and under concurrency (exactly the case this guard exists for, #274) the balance shown can be higher than the real one. The message then says something like "exceeds pool balance 500" for a 300 reward.

Suggested fix

Re-read the balance (or RETURNING balance) for the message, or omit the figure.

Related: #274

Dominant language
TypeScript
Stars
2
Forks
90
Avg merge
31m
Merged PRs (30d)
20

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MergeFi/backend

All issues in MergeFi/backend

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.