Skip to content

fix(bank): add LockedCoins check to SubWei to enforce vesting invariant#3655

Open
Sahil-4555 wants to merge 1 commit into
sei-protocol:mainfrom
Sahil-4555:fix/subwei-locked-coins-check
Open

fix(bank): add LockedCoins check to SubWei to enforce vesting invariant#3655
Sahil-4555 wants to merge 1 commit into
sei-protocol:mainfrom
Sahil-4555:fix/subwei-locked-coins-check

Conversation

@Sahil-4555

Copy link
Copy Markdown

What this fixes

SubWei was not checking locked coins before deducting the balance. SubUnlockedCoins already does this check properly, but SubWei was missing it. This means the wei deduction path was not respecting vesting locks at the keeper level.

This PR adds the locked coins check to SubWei so that it behaves the same way as SubUnlockedCoins. The spendable balance is calculated using the same formula that the EVM keeper uses in GetBalance.

Fixes #3654

@cursor

cursor Bot commented Jun 27, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes core bank deduction logic for wei/EVM transfers; scope is small but incorrect bounds would affect fund availability for vesting accounts.

Overview
SubWei now rejects deductions that exceed spendable balance instead of only comparing against total usei/wei.

Before the rest of the deduction logic, it loads LockedCoins, computes spendable usei (total usei minus locked, floored at zero), and caps the allowed wei debit at spendableUsei * OneUseiInWei + currentWeiBalance. That mirrors SubUnlockedCoins and closes a path where vesting-locked usei could still be consumed when wei spending pulled from the combined balance (including SendCoinsAndWei).

currentUseiBalance is fetched earlier so the same value feeds both the new guard and the existing aggregate-balance path when usei must be debited.

Reviewed by Cursor Bugbot for commit 2132c63. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2132c63. Configure here.

Comment thread sei-cosmos/x/bank/keeper/send.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SubWei does not check LockedCoins before deducting balance

1 participant