Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions subgraph/core/src/SortitionModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,11 @@ import { ensureUser } from "./entities/User";
import { ZERO } from "./utils";

export function handleStakeDelayedAlreadyTransferred(event: StakeDelayedAlreadyTransferred): void {
const jurorAddress = event.params._address.toHexString();
ensureUser(jurorAddress);
const courtID = event.params._courtID.toString();

updateJurorStake(jurorAddress, courtID.toString(), SortitionModule.bind(event.address), event.block.timestamp);

//stake is updated instantly so no delayed amount, set delay amount to zero
updateJurorDelayedStake(jurorAddress, courtID, ZERO);
updateJurorDelayedStake(event.params._address.toHexString(), event.params._courtID.toString(), event.params._amount);
}

export function handleStakeDelayedAlreadyTransferredWithdrawn(event: StakeDelayedAlreadyTransferredWithdrawn): void {
const jurorAddress = event.params._address.toHexString();
ensureUser(jurorAddress);
const courtID = event.params._courtID.toString();

updateJurorStake(jurorAddress, courtID.toString(), SortitionModule.bind(event.address), event.block.timestamp);

updateJurorDelayedStake(jurorAddress, courtID, ZERO);
updateJurorDelayedStake(event.params._address.toHexString(), event.params._courtID.toString(), event.params._amount);
}

export function handleStakeDelayedNotTransferred(event: StakeDelayedNotTransferred): void {
Expand Down
30 changes: 15 additions & 15 deletions subgraph/core/src/entities/JurorTokensPerCourt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ export function updateJurorStake(
const jurorTokens = ensureJurorTokensPerCourt(jurorAddress, courtID);

// TODO: index the sortition module and handle these events there
// const jurorBalance = contract.getJurorBalance(Address.fromString(jurorAddress), BigInt.fromString(courtID));
// const previousStake = jurorTokens.staked;
// const previousTotalStake = juror.totalStake;
// jurorTokens.staked = jurorBalance.value2;
// 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.value2);
// court.numberStakedJurors = court.numberStakedJurors.plus(stakedJurorsDelta);
// updateActiveJurors(activeJurorsDelta, timestamp);
const jurorBalance = contract.getJurorBalance(Address.fromString(jurorAddress), BigInt.fromString(courtID));
const previousStake = jurorTokens.staked;
const previousTotalStake = juror.totalStake;
jurorTokens.staked = jurorBalance.value2;
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.value2);
court.numberStakedJurors = court.numberStakedJurors.plus(stakedJurorsDelta);
updateActiveJurors(activeJurorsDelta, timestamp);
juror.save();
court.save();
}
Expand Down
2 changes: 2 additions & 0 deletions subgraph/core/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ dataSources:
- DisputeKit
- Counter
abis:
- name: SortitionModule
file: ../../contracts/deployments/arbitrumSepoliaDevnet/SortitionModule.json
- name: DisputeKitClassic
file: ../../contracts/deployments/arbitrumSepoliaDevnet/DisputeKitClassic.json
- name: KlerosCore
Expand Down