Skip to content

Commit

Permalink
Remove estimate spend function
Browse files Browse the repository at this point in the history
Seems wrong, is confusing.
  • Loading branch information
Tritium-VLK committed Oct 16, 2024
1 parent b9b2795 commit 805cad2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
17 changes: 0 additions & 17 deletions contracts/ChildChainGaugeInjectorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions test/ChildChainGaugeInjectorV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 805cad2

Please sign in to comment.