Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove estimate spend function #46

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions contracts/ChildChainGaugeInjectorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -413,23 +413,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
Loading