From 805cad2d37d31517a92486da7b9fb2931f0298f6 Mon Sep 17 00:00:00 2001 From: Tritium-VLK <11885129+Tritium-VLK@users.noreply.github.com> Date: Thu, 17 Oct 2024 00:12:18 +0200 Subject: [PATCH] Remove estimate spend function Seems wrong, is confusing. --- contracts/ChildChainGaugeInjectorV2.sol | 17 --------------- test/ChildChainGaugeInjectorV2.js | 28 ------------------------- 2 files changed, 45 deletions(-) diff --git a/contracts/ChildChainGaugeInjectorV2.sol b/contracts/ChildChainGaugeInjectorV2.sol index 7c04aea..7a78cf3 100644 --- a/contracts/ChildChainGaugeInjectorV2.sol +++ b/contracts/ChildChainGaugeInjectorV2.sol @@ -409,23 +409,6 @@ KeeperCompatibleInterface } } -/** -* @notice Estimates the spend until a given timestamp -* @param timestamp The timestamp to estimate spend until -* @return spendUntilTimestamp The total amount of tokens required to fulfil all active programs until the given timestamp -*/ - function estimateSpendUntilTimestamp(uint256 timestamp) public view returns (uint256 spendUntilTimestamp) { - address[] memory gauges = getActiveGaugeList(); - for (uint256 i = 0; i < gauges.length; i++) { - Target memory target = GaugeConfigs[gauges[i]]; - for (uint256 j = target.periodNumber; j < target.maxPeriods; j++) { - if (block.timestamp + (j * 604800) <= timestamp) { - spendUntilTimestamp += target.amountPerPeriod; - } - } - } - return spendUntilTimestamp; - } /** * @notice Gets a list of addresses that are ready to inject diff --git a/test/ChildChainGaugeInjectorV2.js b/test/ChildChainGaugeInjectorV2.js index 6d07565..47470f5 100644 --- a/test/ChildChainGaugeInjectorV2.js +++ b/test/ChildChainGaugeInjectorV2.js @@ -208,34 +208,6 @@ describe('ChildChainGaugeInjector', () => { } }); - it("should calculate spend for timestamp correctly", async function () { - const tokenAddress = await token.getAddress(); - const gaugeAddress = await gauge.getAddress(); - const injectorAddress = await injector.getAddress(); - - const weeklyIncentive = toTokenUnits(200, tokenDecimals); - await injector.addRecipients([gauge], weeklyIncentive, 2, 0) - - const currentTime = Math.floor(Date.now() / 1000); - const oneWeekInSeconds = 7 * 24 * 60 * 60; - const timestampOneWeekFromNow = currentTime + oneWeekInSeconds; - - let spend = await injector.estimateSpendUntilTimestamp(timestampOneWeekFromNow) - expect(spend).to.equal(500000000000400000000n); - - await injector.addRecipients([gauge2], weeklyIncentive, 2, 0) - - spend = await injector.estimateSpendUntilTimestamp(timestampOneWeekFromNow) - expect(spend).to.equal(800000000n); - - spend = await injector.estimateSpendUntilTimestamp(timestampOneWeekFromNow * 52) - expect(spend).to.equal(800000000n); - - await injector.removeRecipients([gauge2]) - - spend = await injector.estimateSpendUntilTimestamp(timestampOneWeekFromNow) - expect(spend).to.equal(400000000n); - }); it("should add a recipient and check the gauge list", async function () { const recipients = [GAUGE, GAUGE_2];