Skip to content

Commit

Permalink
fix boosting delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
timotejvesel committed Oct 6, 2023
1 parent f7ee3f0 commit 78d352a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/services/CalculatingRewardsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class CalculatingRewardsService {

if (node.group === 1) {
let [selfDelegations, normalDelegations, delegators] = await this.nodeGroup1Data(delegations, node, boostingAddresses, addressBinder);
let virtualBoost = BigInt(boostingFactor) * selfDelegations > BigInt(10e6) * GWEI ? BigInt(boostingFactor) * selfDelegations - BigInt(10e6) * GWEI : BigInt(0);
let virtualBoost = BigInt(boostingFactor) * selfDelegations > BigInt(10e6) * GWEI ? BigInt(boostingFactor) * selfDelegations - BigInt(10e6) * GWEI : BigInt(0);
node.boostDelegations = virtualBoost < BigInt(5e6) * GWEI ? virtualBoost : BigInt(5e6) * GWEI;
node.boost = node.selfBond + node.boostDelegations;
node.BEB = selfDelegations;
Expand Down Expand Up @@ -255,8 +255,8 @@ export class CalculatingRewardsService {
}


public async getBoostingAddresses(fnlFile: string) {
return JSON.parse(fs.readFileSync(fnlFile, 'utf8'));
public async getBoostingAddresses(boostingFile: string) {
return JSON.parse(fs.readFileSync(boostingFile, 'utf8'));
}

public async getActiveStakes(vpBlock: number, path1: string, path2: string) {
Expand Down Expand Up @@ -466,6 +466,10 @@ export class CalculatingRewardsService {
if (node.pChainAddress.includes(delegation.inputAddresses[0])) {
selfDelegations += delegation.weight;
}
// boosting delegation
else if (boostingAddresses.includes(delegation.inputAddresses[0])) {
// do nothing
}
// regular delegation
else {
regularDelegations += delegation.weight;
Expand Down Expand Up @@ -501,7 +505,7 @@ export class CalculatingRewardsService {
if (node.pChainAddress.includes(delegation.inputAddresses[0])) {
selfDelegations += delegation.weight;
}
// FNL delegation (boosting)
// boosting delegation
else if (boostingAddresses.includes(delegation.inputAddresses[0])) {
boost += delegation.weight;
}
Expand Down

0 comments on commit 78d352a

Please sign in to comment.