From a598f9cf4b1509a5673101b08340af806c125894 Mon Sep 17 00:00:00 2001 From: amateima Date: Mon, 17 Feb 2025 17:51:08 +0200 Subject: [PATCH] fix: stop op rebates when threshold is reached --- src/modules/rewards/services/op-rebate-service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/rewards/services/op-rebate-service.ts b/src/modules/rewards/services/op-rebate-service.ts index 2ae0a4d0..f621bdb1 100644 --- a/src/modules/rewards/services/op-rebate-service.ts +++ b/src/modules/rewards/services/op-rebate-service.ts @@ -161,6 +161,17 @@ export class OpRebateService { return; } + const opRebatesStats = await this.opRewardsStatsRepository.findOne({ where: { id: Not(IsNull()) } }); + const opRebatesThreshold = ethers.utils.parseEther("749000"); + const isOpRebatesThresholdReached = new BigNumber( + opRebatesStats.totalTokenAmount, + ).isGreaterThanOrEqualTo(opRebatesThreshold.toString()); + + if (isOpRebatesThresholdReached) { + this.logger.verbose(`OP rebate rewards threshold reached. Skipping...`); + return; + } + const deposit: PartialDeposit = await this.depositRepository.findOne({ where: { id: depositPrimaryKey }, select: partialDepositKeys,