Skip to content

Commit

Permalink
Add logs with total stake to commit logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruch committed Jun 12, 2024
1 parent c558b36 commit 2a60ea9
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions packages/rewards-calculator/src/rewardBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
getRegistrations,
isCommitted,
lastRewardedBlock,
nextEpoch,
Registrations,
} from "./chain";
import { epochStats } from "./reward";
import { addresses, config, contracts, publicClient } from "./config";
import { Hex, parseAbiItem } from "viem";
import type { Workers } from "./workers";
import { logger } from "./logger";
import { bigSum } from "./utils";

async function firstRegistrationBlock(registrations: Registrations) {
return Math.min(
Expand Down Expand Up @@ -74,16 +74,20 @@ export class RewardBot {
this.index,
);

console.log(
JSON.stringify({
time: new Date(),
type: "rewards_commited",
bot_wallet: this.address,
tx_hash: tx,
from_block: fromBlock,
to_block: toBlock,
}),
);
console.log({
time: new Date(),
type: "rewards_commited",
bot_wallet: this.address,
tx_hash: tx,
from_block: fromBlock,
to_block: toBlock,
totalStake: bigSum(
workers.map(({ totalStake }) => BigInt(totalStake.toString())),
),
capedStake: bigSum(
workers.map(({ stake }) => BigInt(stake.toString())),
),
});
} catch (e: any) {
if (e.message?.includes("Already approved")) {
return;
Expand All @@ -109,16 +113,14 @@ export class RewardBot {
ranges.commitment,
);
if (tx) {
console.log(
JSON.stringify({
time: new Date(),
type: "rewards_approved",
bot_wallet: this.address,
tx_hash: tx,
from_block: ranges.fromBlock,
to_block: ranges.toBlock,
}),
);
console.log({
time: new Date(),
type: "rewards_approved",
bot_wallet: this.address,
tx_hash: tx,
from_block: ranges.fromBlock,
to_block: ranges.toBlock,
});
}
}
} catch (e) {
Expand Down

2 comments on commit 2a60ea9

@github-actions
Copy link

Choose a reason for hiding this comment

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

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.