-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
107 distribution quality tiers (#113)
Adds quality tier bonus to distribution contract
- Loading branch information
Showing
11 changed files
with
6,531 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,5 +93,3 @@ sw.* | |
|
||
# warp cache | ||
cache/ | ||
|
||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
{ | ||
"families": [ | ||
{ | ||
"fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
}, | ||
{ | ||
"fingerprint": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
}, | ||
{ | ||
"fingerprint": "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
}, | ||
{ | ||
"fingerprint": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
}, | ||
{ | ||
"fingerprint": "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
}, | ||
{ | ||
"fingerprint": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", | ||
"add": [ | ||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" | ||
] | ||
} | ||
], | ||
"relays": [ | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
"nickname": "B109-test-relay-1" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", | ||
"nickname": "B109-test-relay-2" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", | ||
"nickname": "B109-test-relay-3" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", | ||
"nickname": "B109-test-relay-4" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE", | ||
"nickname": "B109-test-relay-5" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"fingerprint": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", | ||
"nickname": "B109-test-relay-6" | ||
} | ||
], | ||
"scores": [ | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"score": "1000", | ||
"fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
}, | ||
{ | ||
"address": "0xB109188f495c61659804b054C7Bc9f10435D9095", | ||
"score": "1000", | ||
"fingerprint": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import { readFileSync } from 'fs' | ||
|
||
const resultsPath = | ||
`${__dirname}/../../test/e2e/data/results_quality_bonuses.csv` | ||
const resultsCSVBuffer = readFileSync(resultsPath) | ||
const resultsCSV = resultsCSVBuffer.toString() | ||
const results = resultsCSV.split('\r\n') | ||
results.shift() // NB: get rid of header in csv | ||
const rewards = [] | ||
|
||
let baseNetworkScore = 0 | ||
let baseActualDistributedTokens = 0 | ||
|
||
let familyMultiplierNetworkScore = 0 | ||
let familyMultiplierActualDistributedTokens = 0 | ||
|
||
let qualityBonusNetworkScore = 0 | ||
let qualityBonusActualDistributedTokens = 0 | ||
|
||
let hwBonusNetworkScore = 0 | ||
let hwBonusActualDistributedTokens = 0 | ||
|
||
let hwBonusNetworkScoreWithFamilyMultiplier = 0 | ||
let hwBonusActualDistributedTokensWithFamilyMultiplier = 0 | ||
|
||
let totalNetworkScore = 0 | ||
let totalActualDistributedTokens = 0 | ||
|
||
for (const result of results) { | ||
const [ | ||
r1, | ||
r2, | ||
address, | ||
|
||
baseScore, | ||
basePercentShare, | ||
baseReward, | ||
|
||
familyMultiplierScore, | ||
familyMultiplierPercentShare, | ||
familyMultiplierReward, | ||
|
||
qualityBonusScore, | ||
qualityBonusPercentShare, | ||
qualityBonusReward, | ||
|
||
qualityBonusScoreWithFamilyMultiplier, | ||
qualityBonusPercentShareWithFamilyMultiplier, | ||
qualityBonusRewardWithFamilyMultiplier, | ||
|
||
hwBonusScore, | ||
hwBonusPercentShare, | ||
hwBonusReward, | ||
|
||
hwBonusScoreWithFamilyMultiplier, | ||
hwBonusPercentShareWithFamilyMultiplier, | ||
hwBonusRewardWithFamilyMultiplier, | ||
|
||
totalReward, | ||
totalRewardWithFamilyMultiplier | ||
] = result.split(',') | ||
|
||
baseNetworkScore += Number.parseInt(baseScore) | ||
baseActualDistributedTokens += Number.parseInt(baseReward) | ||
|
||
familyMultiplierNetworkScore += Number.parseInt(familyMultiplierScore) | ||
familyMultiplierActualDistributedTokens += Number.parseInt(familyMultiplierReward) | ||
|
||
qualityBonusNetworkScore += Number.parseInt(qualityBonusScore) | ||
qualityBonusActualDistributedTokens += Number.parseInt(qualityBonusReward) | ||
|
||
hwBonusNetworkScore += Number.parseInt(hwBonusScore) | ||
hwBonusActualDistributedTokens += Number.parseInt(hwBonusReward) | ||
|
||
hwBonusNetworkScoreWithFamilyMultiplier += Number.parseInt(hwBonusScoreWithFamilyMultiplier) | ||
hwBonusActualDistributedTokensWithFamilyMultiplier += Number.parseInt(hwBonusRewardWithFamilyMultiplier) | ||
|
||
totalNetworkScore += | ||
Number.parseInt(baseScore) | ||
+ Number.parseInt(hwBonusScoreWithFamilyMultiplier) | ||
+ Number.parseInt(qualityBonusScore) | ||
totalActualDistributedTokens += Number.parseInt(totalReward) | ||
|
||
rewards.push({ | ||
address, | ||
|
||
baseScore, | ||
basePercentShare, | ||
baseReward, | ||
|
||
familyMultiplierScore, | ||
familyMultiplierPercentShare, | ||
familyMultiplierReward, | ||
|
||
qualityBonusScore, | ||
qualityBonusPercentShare, | ||
qualityBonusReward, | ||
|
||
hwBonusScore, | ||
hwBonusPercentShare, | ||
hwBonusReward, | ||
|
||
hwBonusScoreWithFamilyMultiplier, | ||
hwBonusPercentShareWithFamilyMultiplier, | ||
hwBonusRewardWithFamilyMultiplier, | ||
|
||
totalReward | ||
}) | ||
} | ||
|
||
const output = { | ||
baseNetworkScore: baseNetworkScore.toString(), | ||
baseActualDistributedTokens: baseActualDistributedTokens.toString(), | ||
|
||
familyMultiplierNetworkScore: familyMultiplierNetworkScore.toString(), | ||
familyMultiplierActualDistributedTokens: | ||
familyMultiplierActualDistributedTokens.toString(), | ||
|
||
qualityBonusNetworkScore: qualityBonusNetworkScore.toString(), | ||
qualityBonusActualDistributedTokens: | ||
qualityBonusActualDistributedTokens.toString(), | ||
|
||
hwBonusNetworkScore: hwBonusNetworkScore.toString(), | ||
hwBonusActualDistributedTokens: hwBonusActualDistributedTokens.toString(), | ||
|
||
hwBonusNetworkScoreWithFamilyMultiplier: | ||
hwBonusNetworkScoreWithFamilyMultiplier.toString(), | ||
hwBonusActualDistributedTokensWithFamilyMultiplier: | ||
hwBonusActualDistributedTokensWithFamilyMultiplier.toString(), | ||
|
||
totalNetworkScore: totalNetworkScore.toString(), | ||
totalActualDistributedTokens: totalActualDistributedTokens.toString(), | ||
|
||
rewards | ||
} | ||
|
||
console.log(JSON.stringify(output, undefined, 2)) |
Oops, something went wrong.