Skip to content

Commit

Permalink
fix: dispute bot (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes authored Nov 30, 2023
1 parent ec0e41b commit 5547d7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/bot/validity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,23 @@ export async function validateHolders(
// Either the distributed amount is less than what would be distributed since the distrib start and there is no dis in the start tree
// Either it's less than what would be distributed since the startTree update
if (
(!!startTree.rewards[k]?.lastUpdateEpoch &&
changePerDistrib[k].epoch > endTree.rewards[k].lastUpdateEpoch - startTree.rewards[k].lastUpdateEpoch) ||
(!startTree.rewards[k]?.lastUpdateEpoch &&
changePerDistrib[k].epoch > endTree.rewards[k].lastUpdateEpoch - solidityDist?.base?.epochStart / HOUR)
!!startTree.rewards[k]?.lastUpdateEpoch &&
changePerDistrib[k].epoch > (endTree.rewards[k].lastUpdateEpoch - startTree.rewards[k].lastUpdateEpoch) * 1.001 // 0.1% tolerance
) {
overDistributed.push(k);
overDistributed.push(
`Distrib ${k.slice(0, 10)} distributed. Theory ${
endTree.rewards[k].lastUpdateEpoch - startTree.rewards[k].lastUpdateEpoch
}, found ${changePerDistrib[k].epoch} `
);
} else if (
!startTree.rewards[k]?.lastUpdateEpoch &&
changePerDistrib[k].epoch > (endTree.rewards[k].lastUpdateEpoch - solidityDist?.base?.epochStart / HOUR) * 1.001 // 0.1% tolerance
) {
overDistributed.push(
`Distrib ${k.slice(0, 10)} distributed. Theory ${
endTree.rewards[k].lastUpdateEpoch - solidityDist?.base?.epochStart / HOUR
}, found ${changePerDistrib[k].epoch} `
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/helpers/logger/ConsoleLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BigNumber } from 'ethers';

import { DisputeContext } from '../../bot/context';
import { OnChainParams } from '../../providers/on-chain/OnChainProvider';
import { MerklReport } from '../../types/bot';
import { BotError, MerklReport } from '../../types/bot';
import Logger from './Logger';

export default class ConsoleLogger extends Logger {
Expand Down Expand Up @@ -52,7 +52,7 @@ export default class ConsoleLogger extends Logger {

override error = async (context, reason: string, code?: number, report?: MerklReport) => {
const log = (...a) => console.log(chalk.red(...a));
log('[CHECKS ERROR]:', reason);
log('[CHECKS ERROR]:', BotError[code], reason);
};

override success = async (context, reason: string, report?: MerklReport) => {
Expand Down

0 comments on commit 5547d7b

Please sign in to comment.