Skip to content

fix(wasm): lockup eligibility queries count withdrawn locks for incentives #2684

Description

@Unique-Divine

Summary

External report (gist) shows that lockup eligibility queries can return locks that are already withdrawn or no longer actively locked, and incentives uses those query results for epoch accounting and WithdrawRewards.

Code lives in NibiruChain/nibiru-wasm; tracked from this repo for visibility.

Severity / triage

  • Priority: p3 — utility reference contract correctness
  • Nibiru does not deploy or operate lockup / incentives for funded protocol incentive programs (per support ticket #833-daniel526, 2026-07-10)
  • Still worth fixing so reference code is correct if third parties copy or deploy it

Production context

From contracts/README.md:

  • lockup and incentives are Utility reference building blocks, not core-* production contracts
  • Nibiru uses core-* contracts where Wasm is part of production infrastructure (e.g. Treasury / Hot Wallet multisigs)

Problem

LocksByDenomBetween and LocksByDenomAndAddressBetween filter with:

env.block.height + lock.duration_blocks > unlocking_after

They do not:

  • exclude lock.funds_withdrawn == true
  • use the lock's actual end_block lifecycle state

incentives consumes these queries in execute_process_epoch and execute_withdraw_rewards, so withdrawn locks can still count toward total_locked and reward payouts.

Affected code

Proposed fix

  1. Exclude withdrawn locks: !lock.funds_withdrawn
  2. Use actual lifecycle in eligibility checks (end_block / NOT_UNLOCKING_BLOCK_IDENTIFIER) instead of current_height + original_duration
  3. Add or adapt integration regression test (gist provides withdrawn_lock_can_still_receive_incentive_rewards)

Acceptance criteria

  • Lockup query filters exclude withdrawn locks
  • Eligibility uses real end_block state
  • Integration test proves withdrawn lock no longer receives rewards after fix
  • README note under Utility contracts: reference-only, not production-operated by Nibiru

Out of scope

Metadata

Metadata

Assignees

Labels

A-dev-toolsArea: Tools and changes for external developers and builders. NOT end usersS-implStatus: Implementation-ready. Clear and fully specificedprio-p3-lowPriority: Low. Please focus on p2 or higher for now.x: wasmRelates to the wasm module or CosmWasm

Type

No type

Projects

Status
⚡ Building 🧱

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions