From 7503a593a0a752fcd8104d81ec4422992a3113b2 Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Tue, 26 Apr 2022 01:01:48 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20update=20script=20to=20?= =?UTF-8?q?include=20past=20periods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/rewards/rewards-period.js | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/rewards/rewards-period.js b/scripts/rewards/rewards-period.js index 531e0e54af..63deb33942 100755 --- a/scripts/rewards/rewards-period.js +++ b/scripts/rewards/rewards-period.js @@ -2,13 +2,13 @@ const fs = require("fs"); -async function createAssetRewardsFile() { - const csv = fs.readFileSync("./pools.csv", "utf-8"); +async function createAssetRewardsFile(periodId, startBlock, endBlock) { + const csv = fs.readFileSync(`./${periodId}.csv`, "utf-8"); const entries = JSON.parse(fs.readFileSync("./entries.json", "utf-8")).result .registry.entries; const lines = csv.split("\r\n").filter((line) => line.split(",")[1] !== ""); - let [, allocation] = lines[0].split('"'); + let [, allocation] = lines[1].split('"'); allocation = `${allocation.trim().split(",").join("")}${"0".repeat(18)}`; const multipliers = lines.slice(1).map((line) => { @@ -30,22 +30,25 @@ async function createAssetRewardsFile() { }; }); - const rewards = [ - { - reward_period_id: "RP_1", - reward_period_start_block: 1, - reward_period_end_block: 100, - reward_period_allocation: allocation, - reward_period_pool_multipliers: multipliers, - reward_period_default_multiplier: "0.0", - }, - ]; + const rewardPeriod = { + reward_period_id: periodId, + reward_period_start_block: startBlock, + reward_period_end_block: endBlock, + reward_period_allocation: allocation, + reward_period_pool_multipliers: multipliers, + reward_period_default_multiplier: "0.0", + }; - fs.writeFileSync("./rewards.json", JSON.stringify(rewards, null, 2)); + return rewardPeriod; } async function start() { - await createAssetRewardsFile(); + const rewardPeriods = [ + await createAssetRewardsFile("RP_2", 6586931, 6687730), + await createAssetRewardsFile("RP_1", 6486131, 6586930), + ]; + + fs.writeFileSync("./rewards.json", JSON.stringify(rewardPeriods, null, 2)); } start();