nibiru icon indicating copy to clipboard operation
nibiru copied to clipboard

0stake after undelegating from validator

Open cgilbe27 opened this issue 1 year ago • 6 comments

This is kind of 2 bugs

The first bug is that validators are still displayed as staked to even though they don't have any stake assigned image

As a result of not having anything staked..

When you withdrawal rewards from all current validators you see: image image

cgilbe27 avatar Jan 02 '25 14:01 cgilbe27

Seems solvable client-side with a simple .filter statement where we ignore delegations of amount 0

Unique-Divine avatar Jan 06 '25 07:01 Unique-Divine

This will only solve this issue for our first party client, any other client (explorers will also see this issue, See here: https://nibiru.explorers.guru/account/nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5#:~:text=Time-,Delegations,-Delegations)


image

Rewards have a non-zero amount from the built-in cosmos tx, and it's impossible to make this zero even after claiming

import { setupDistributionExtension, } from "@cosmjs/stargate"

`this.nibiruExtensions = StargateQueryClient.withExtensions(
  tmClient,
  setupDistributionExtension,
  setupGovExtension,
  setupStakingExtension,
  setupIbcExtension,
  setupWasmExtension,
  setupAuthExtension,
  setupNibiruExtension
)`

const resp = await signingClient.nibiruExtensions.distribution.delegationTotalRewards(address)

For my account it's the Nodes.Guru validator "nibivaloper1hvt68he6uvadnk73rjy6hg7a4u2myud5yhj3ae"

Client-side fix here: https://github.com/NibiruChain/web-app/pull/1251

cgilbe27 avatar Jan 06 '25 14:01 cgilbe27

Also related, calling reward withdrawal when most are minimal non-zero numbers image

Raw log: (Note, all validators are returning 0stake here, not 0unibi)

"[{\"msg_index\":0,\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\"},{\"key\":\"sender\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"},{\"key\":\"module\",\"value\":\"distribution\"}]},{\"type\":\"withdraw_rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"0stake\"},{\"key\":\"validator\",\"value\":\"nibivaloper1xwh38k5kulrfglt34qqmnsrrjg788d4azq6e5u\"},{\"key\":\"delegator\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"}]}]},{\"msg_index\":1,\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\"},{\"key\":\"sender\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"},{\"key\":\"module\",\"value\":\"distribution\"}]},{\"type\":\"withdraw_rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"0stake\"},{\"key\":\"validator\",\"value\":\"nibivaloper140l6y2gp3gxvay6qtn70re7z2s0gn57zj8exm0\"},{\"key\":\"delegator\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"}]}]},{\"msg_index\":2,\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\"},{\"key\":\"sender\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"},{\"key\":\"module\",\"value\":\"distribution\"}]},{\"type\":\"withdraw_rewards\",\"attributes\":[{\"key\":\"amount\",\"value\":\"0stake\"},{\"key\":\"validator\",\"value\":\"nibivaloper1hvt68he6uvadnk73rjy6hg7a4u2myud5yhj3ae\"},{\"key\":\"delegator\",\"value\":\"nibi1ytf8uvxjx0guxcj7mxs9x8xw5suters539dxp5\"}]}]}]"

cgilbe27 avatar Jan 06 '25 14:01 cgilbe27

Investigate import { setupDistributionExtension, } from "@cosmjs/stargate"

cgilbe27 avatar Jan 06 '25 18:01 cgilbe27

"/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsRequest"

cgilbe27 avatar Jan 06 '25 18:01 cgilbe27

Initial review by Kevin found partial share amount

cgilbe27 avatar Jan 10 '25 06:01 cgilbe27