Skip to content

Bug: Withdrawing PNK seems to stake PNK? #1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kemuru opened this issue Nov 7, 2023 · 1 comment · Fixed by #1321
Closed

Bug: Withdrawing PNK seems to stake PNK? #1319

kemuru opened this issue Nov 7, 2023 · 1 comment · Fixed by #1321
Labels
Milestone

Comments

@kemuru
Copy link
Contributor

kemuru commented Nov 7, 2023

Shown in the video. Another thing to note is that balances are not the same in Courts than in Dashboard/MyCourts. Probably because of different hooks giving different balances. Maybe thats the cause of this issue? in my experience the one I used at Dashboard/MyCourts seems to give accurate user balance results (One thing to note is that the query from Courts is a contract call, while the one on Dashboard/MyCourts is a subgraph query)

2023-11-07.18-12-15.mp4

Update: I unstaked everything from all courts via frontend, balance is 0 on Courts, but balance is still existing on Dashboard/MyCourts

2023-11-08.09-51-51.mp4

In the subgraph, this is the only handler modifying the court.stake field:

export function updateJurorStake(jurorAddress: string, courtID: string, contract: KlerosCore, timestamp: BigInt): void {
  const juror = ensureUser(jurorAddress);
  const court = Court.load(courtID);
  if (!court) return;
  const jurorTokens = ensureJurorTokensPerCourt(jurorAddress, courtID);
  const jurorBalance = contract.getJurorBalance(Address.fromString(jurorAddress), BigInt.fromString(courtID));
  const previousStake = jurorTokens.staked;
  const previousTotalStake = juror.totalStake;
  jurorTokens.staked = jurorBalance.value0;
  jurorTokens.locked = jurorBalance.value1;
  jurorTokens.save();
  const stakeDelta = getDelta(previousStake, jurorTokens.staked);
  const newTotalStake = juror.totalStake.plus(stakeDelta);
  juror.totalStake = newTotalStake;
  court.stake = court.stake.plus(stakeDelta);
  updateStakedPNK(stakeDelta, timestamp);
  const activeJurorsDelta = getActivityDelta(previousTotalStake, newTotalStake);
  const stakedJurorsDelta = getActivityDelta(previousStake, jurorBalance.value0);
  court.numberStakedJurors = court.numberStakedJurors.plus(stakedJurorsDelta);
  updateActiveJurors(activeJurorsDelta, timestamp);
  juror.save();
  court.save();
}
@jaybuidl
Copy link
Member

jaybuidl commented Nov 8, 2023

It's caused by #1162
73782d9#diff-473f39afc0e476a5691182ed8dfc5dfa27881820e4e6b6452d06610cd4b8cfe2L1017-L1021
image

Essentially the locked stake is maintained per subcourt anymore, but for the whole arbitrator.

@jaybuidl jaybuidl added Type: Bug 🐛 Package: Web Court web frontend Package: Subgraph Court subgraph labels Nov 8, 2023
@jaybuidl jaybuidl added this to the testnet-2.1 milestone Nov 8, 2023
@jaybuidl jaybuidl linked a pull request Nov 8, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants