Skip to content

Commit

Permalink
fix: donation amount calculation for each service
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed Jan 24, 2023
1 parent aed8574 commit 69f5543
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
6 changes: 2 additions & 4 deletions contracts/Tokenomics.sol
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,6 @@ contract Tokenomics is TokenomicsConstants, IErrorsTokenomics {
uint256 numServices = serviceIds.length;
// Loop over service Ids to calculate their partial UCFu-s
for (uint256 i = 0; i < numServices; ++i) {
uint96 amount = uint96(amounts[i]);

// Check if the service owner stakes enough OLAS for its components / agents to get a top-up
// If both component and agent owner top-up fractions are zero, there is no need to call external contract
// functions to check each service owner veOLAS balance
Expand All @@ -721,10 +719,10 @@ contract Tokenomics is TokenomicsConstants, IErrorsTokenomics {
if (numServiceUnits == 0) {
revert ServiceNeverDeployed(serviceIds[i]);
}
// The amount has to be adjusted for the number of units in the service
amount /= uint96(numServiceUnits);
// Record amounts data only if at least one incentive unit fraction is not zero
if (incentiveFlags[unitType] || incentiveFlags[unitType + 2]) {
// The amount has to be adjusted for the number of units in the service
uint96 amount = uint96(amounts[i] / numServiceUnits);
// Accumulate amounts for each unit Id
for (uint256 j = 0; j < numServiceUnits; ++j) {
// Get the last epoch number the incentives were accumulated for
Expand Down
21 changes: 10 additions & 11 deletions test/Tokenomics.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe("Tokenomics", async () => {
expect(topUp).to.greaterThan(0);
});

it("Changing maxBond values", async function () {
it.only("Changing maxBond values", async function () {
// Take a snapshot of the current state of the blockchain
const snapshot = await helpers.takeSnapshot();

Expand Down Expand Up @@ -654,7 +654,6 @@ describe("Tokenomics", async () => {
expect((nextMaxBond.div(nextMaxBondFraction).div(2)).mul(initMaxBondFraction)).to.equal(initMaxBond);
// Restore the state of the blockchain back to before changing maxBond-related parameters
snapshotInternal.restore();
return;

// Move to the epoch before changing the year
// OLAS starting time
Expand Down Expand Up @@ -686,15 +685,15 @@ describe("Tokenomics", async () => {

snapshotInternal.restore();

// let snapshotInternal = await helpers.takeSnapshot();
// // Try to change the epoch length now such that the next epoch will immediately have the year change
// await tokenomics.changeTokenomicsParameters(0, 0, 2 * epochLen, 0, 0, 0);
// // Move to the end of epoch and check the updated epoch length
// await helpers.time.increase(epochLen);
// await tokenomics.checkpoint();
// expect(await tokenomics.epochLen()).to.equal(2 * epochLen);
// // Restore the state of the blockchain back to the time half of the epoch before one epoch left for the current year
// snapshotInternal.restore();
// let snapshotInternal = await helpers.takeSnapshot();
// // Try to change the epoch length now such that the next epoch will immediately have the year change
// await tokenomics.changeTokenomicsParameters(0, 0, 2 * epochLen, 0, 0, 0);
// // Move to the end of epoch and check the updated epoch length
// await helpers.time.increase(epochLen);
// await tokenomics.checkpoint();
// expect(await tokenomics.epochLen()).to.equal(2 * epochLen);
// // Restore the state of the blockchain back to the time half of the epoch before one epoch left for the current year
// snapshotInternal.restore();

// const nextEffectiveBond = ethers.BigNumber.from(await tokenomics.effectiveBond());
// // Changing the epoch length to 10
Expand Down

0 comments on commit 69f5543

Please sign in to comment.