From 6cc04c3ac247e996f1f005086551a82f6786ff54 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 14 Aug 2023 21:07:53 +0100 Subject: [PATCH 1/4] chore: updating proposals --- scripts/proposals/proposal_03_calculate_LP.js | 12 ++-- ...05_change_fractions_and_manage_products.js | 64 +++++++++++++++++++ 2 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 scripts/proposals/proposal_05_change_fractions_and_manage_products.js diff --git a/scripts/proposals/proposal_03_calculate_LP.js b/scripts/proposals/proposal_03_calculate_LP.js index 468578c2..10135a34 100644 --- a/scripts/proposals/proposal_03_calculate_LP.js +++ b/scripts/proposals/proposal_03_calculate_LP.js @@ -66,8 +66,8 @@ async function main() { console.log("Initial priceLP", priceLP.toString()); // Estimate the average ETH amount of swaps the last number of days - const numDays = 7; - console.log("Last number of days:", numDays); + const numDays = 2; + console.log("Last number of days to compute the average swap volume:", numDays); const numBlocksBack = Math.floor((3600 * 24 * numDays) / 12); // Get events @@ -234,13 +234,13 @@ async function main() { // Get effective bond const effectiveBond = ethers.BigNumber.from(await tokenomics.effectiveBond()); - // Vesting is 7 days - const vesting = 3600 * 24 * 7; + // One day time + const oneDay = 3600 * 24; // Price LP for OLAS price of corresponding prices const pricesLP = [pricesOLASIncrease[0]]; - const supplies = ["1000000" + "0".repeat(18)]; - const vestings = [vesting]; + const supplies = ["100000" + "0".repeat(18)]; + const vestings = [28 * oneDay]; const numPrices = pricesLP.length; const targets = new Array(numPrices).fill(depositoryTwoAddress); diff --git a/scripts/proposals/proposal_05_change_fractions_and_manage_products.js b/scripts/proposals/proposal_05_change_fractions_and_manage_products.js new file mode 100644 index 00000000..0e155f13 --- /dev/null +++ b/scripts/proposals/proposal_05_change_fractions_and_manage_products.js @@ -0,0 +1,64 @@ +/*global process*/ + +const { ethers } = require("hardhat"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const providerName = parsedData.providerName; + + const provider = await ethers.providers.getDefaultProvider(providerName); + const signers = await ethers.getSigners(); + + // EOA address + const EOA = signers[0]; + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Get all the necessary contract addresses + const tokenomicsProxyAddress = parsedData.tokenomicsProxyAddress; + const depositoryTwoAddress = parsedData.depositoryTwoAddress; + + // Get contract instances + const tokenomics = await ethers.getContractAt("Tokenomics", tokenomicsProxyAddress); + const depository = await ethers.getContractAt("Depository", depositoryTwoAddress); + + const AddressZero = "0x" + "0".repeat(40); + + // Proposal preparation + console.log("Proposal 5. Change tokenomics top-up and bonding fractions, close old products and create new ones"); + const targets = [depositoryTwoAddress, tokenomicsProxyAddress]; + const values = [0, 0]; + const callDatas = [ + depository.interface.encodeFunctionData("close", [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]), + tokenomics.interface.encodeFunctionData("changeIncentiveFractions", [83, 17, 95, 4, 1]) + ]; + + // Additional products to create with depository contract + const vesting = 3600 * 24 * 7; + const pricesLP = ["248552225555891292658","239199446069592728050","229846666583294163442","220493887096995598809","211141107610697034201"]; + const supplies = ["200000000000000000000000","300000000000000000000000","400000000000000000000000","400000000000000000000000","500000000000000000000000"]; + + for (let i = 0; i < pricesLP.length; i++) { + targets.push(depositoryTwoAddress); + values.push(0); + callDatas.push(depository.interface.encodeFunctionData("create", [parsedData.OLAS_ETH_PairAddress, pricesLP[i], supplies[i], vesting])); + } + + const description = "Change tokenomics top-up and bonding fractions, close old products and create new ones"; + + // Proposal details + console.log("targets:", targets); + console.log("values:", values); + console.log("call datas:", callDatas); + console.log("description:", description); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From df50fe753e51067bf6d3fa8f4036a43a36e4347c Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Mon, 14 Aug 2023 21:12:18 +0100 Subject: [PATCH 2/4] chore: updating proposals --- ...cts.js => proposal_06_change_fractions_and_manage_products.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/proposals/{proposal_05_change_fractions_and_manage_products.js => proposal_06_change_fractions_and_manage_products.js} (100%) diff --git a/scripts/proposals/proposal_05_change_fractions_and_manage_products.js b/scripts/proposals/proposal_06_change_fractions_and_manage_products.js similarity index 100% rename from scripts/proposals/proposal_05_change_fractions_and_manage_products.js rename to scripts/proposals/proposal_06_change_fractions_and_manage_products.js From 847bc0dbe4742ea50d180206ba3628c3e1b8f176 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 17 Aug 2023 18:14:31 +0100 Subject: [PATCH 3/4] chore: updating proposal scripts --- scripts/proposals/proposal_03_calculate_LP.js | 40 ++++++------------- ...06_change_fractions_and_manage_products.js | 13 +++--- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/scripts/proposals/proposal_03_calculate_LP.js b/scripts/proposals/proposal_03_calculate_LP.js index 10135a34..149f5015 100644 --- a/scripts/proposals/proposal_03_calculate_LP.js +++ b/scripts/proposals/proposal_03_calculate_LP.js @@ -9,22 +9,8 @@ async function main() { const globalsFile = "globals.json"; const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); let parsedData = JSON.parse(dataFromJSON); - const useLedger = parsedData.useLedger; - const derivationPath = parsedData.derivationPath; const providerName = parsedData.providerName; - let EOA; - const provider = await ethers.providers.getDefaultProvider(providerName); - const signers = await ethers.getSigners(); - - if (useLedger) { - EOA = new LedgerSigner(provider, derivationPath); - } else { - EOA = signers[0]; - } - // EOA address - const deployer = await EOA.getAddress(); - console.log("EOA is:", deployer); // Get all the necessary contract addresses const depositoryTwoAddress = parsedData.depositoryTwoAddress; @@ -62,11 +48,11 @@ async function main() { priceOLAS = ethers.BigNumber.from(Math.floor(priceOLAS * 100)); // Get current LP price - let priceLP = ethers.BigNumber.from(await depository.getCurrentPriceLP(tokenAddress)); + let priceLP = ethers.BigNumber.from(await depository.getCurrentPriceLP(tokenAddress)).mul(2); console.log("Initial priceLP", priceLP.toString()); // Estimate the average ETH amount of swaps the last number of days - const numDays = 2; + const numDays = 7; console.log("Last number of days to compute the average swap volume:", numDays); const numBlocksBack = Math.floor((3600 * 24 * numDays) / 12); @@ -142,9 +128,8 @@ async function main() { // Swap to get upper bound prices let priceCompare; let targetPrice = Number(priceOLAS); - let pcStep = 20; - let targetPcStep = Math.floor((targetPrice * pcStep) / 100); - let totalPriceIncrease = 200; + let pcStep = 5; + let numSteps = 10; const pricesOLASIncrease = new Array(); const pricesLPIncrease = new Array(); @@ -152,7 +137,7 @@ async function main() { // to the desired value. const condition = true; while (condition) { - targetPrice += targetPcStep; + targetPrice += pcStep; pricesOLASIncrease.push(targetPrice); while (condition) { //console.log("targetPrice", targetPrice); @@ -174,8 +159,8 @@ async function main() { pricesLPIncrease.push(priceLP); // Decrease the total price increase as we reached the new price, and break when we found all prices - totalPriceIncrease -= pcStep; - if (totalPriceIncrease == 0) { + numSteps -= 1; + if (numSteps == 0) { break; } } @@ -190,16 +175,15 @@ async function main() { // Swap to get lower bound prices targetPrice = Number(priceOLAS); - pcStep = 20; - targetPcStep = Math.floor((targetPrice * pcStep) / 100); - let totalPriceDecrease = 80; + pcStep = 5; + numSteps = 10; const pricesOLASDecrease = new Array(); const pricesLPDecrease = new Array(); // We need to iteratively swap by adding average ETH into the pool each time such that the price of OLAS increases // to the desired value. while (condition) { - targetPrice -= targetPcStep; + targetPrice -= pcStep; pricesOLASDecrease.push(targetPrice); while (condition) { //console.log("targetPrice", targetPrice); @@ -221,8 +205,8 @@ async function main() { pricesLPDecrease.push(priceLP); // Decrease the total price increase as we reached the new price, and break when we found all prices - totalPriceDecrease -= pcStep; - if (totalPriceDecrease == 0) { + numSteps -= 1; + if (numSteps == 0 || targetPrice <= pcStep) { break; } } diff --git a/scripts/proposals/proposal_06_change_fractions_and_manage_products.js b/scripts/proposals/proposal_06_change_fractions_and_manage_products.js index 0e155f13..8a1e47e3 100644 --- a/scripts/proposals/proposal_06_change_fractions_and_manage_products.js +++ b/scripts/proposals/proposal_06_change_fractions_and_manage_products.js @@ -33,18 +33,21 @@ async function main() { const values = [0, 0]; const callDatas = [ depository.interface.encodeFunctionData("close", [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]), - tokenomics.interface.encodeFunctionData("changeIncentiveFractions", [83, 17, 95, 4, 1]) + tokenomics.interface.encodeFunctionData("changeIncentiveFractions", [83, 17, 90, 8, 2]) ]; // Additional products to create with depository contract - const vesting = 3600 * 24 * 7; - const pricesLP = ["248552225555891292658","239199446069592728050","229846666583294163442","220493887096995598809","211141107610697034201"]; - const supplies = ["200000000000000000000000","300000000000000000000000","400000000000000000000000","400000000000000000000000","500000000000000000000000"]; + const oneDay = 3600 * 24; + const pricesLP = ["185491475634516176834","171739930293108999394","159606213815396784008","149090326201379530672", + "140504866934837734890", "133345477624551759418", "125737933372879003894", "119271520758957161698", "113565862570202595056"]; + const supplies = ["100000" + "0".repeat(18), "100000" + "0".repeat(18), "100000" + "0".repeat(18), "100000" + "0".repeat(18), + "100000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18)]; + const vestings = [28 * oneDay, 28 * oneDay, 21 * oneDay, 21 * oneDay, 14 * oneDay, 14 * oneDay, 7 * oneDay, 7 * oneDay, 7 * oneDay] for (let i = 0; i < pricesLP.length; i++) { targets.push(depositoryTwoAddress); values.push(0); - callDatas.push(depository.interface.encodeFunctionData("create", [parsedData.OLAS_ETH_PairAddress, pricesLP[i], supplies[i], vesting])); + callDatas.push(depository.interface.encodeFunctionData("create", [parsedData.OLAS_ETH_PairAddress, pricesLP[i], supplies[i], vestings[i]])); } const description = "Change tokenomics top-up and bonding fractions, close old products and create new ones"; From 0b5ea298c228a179b7302f19b3333800fddd27fd Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 17 Aug 2023 18:16:46 +0100 Subject: [PATCH 4/4] chore: linter --- .../proposal_06_change_fractions_and_manage_products.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/proposals/proposal_06_change_fractions_and_manage_products.js b/scripts/proposals/proposal_06_change_fractions_and_manage_products.js index 8a1e47e3..b49f5808 100644 --- a/scripts/proposals/proposal_06_change_fractions_and_manage_products.js +++ b/scripts/proposals/proposal_06_change_fractions_and_manage_products.js @@ -42,7 +42,7 @@ async function main() { "140504866934837734890", "133345477624551759418", "125737933372879003894", "119271520758957161698", "113565862570202595056"]; const supplies = ["100000" + "0".repeat(18), "100000" + "0".repeat(18), "100000" + "0".repeat(18), "100000" + "0".repeat(18), "100000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18), "150000" + "0".repeat(18)]; - const vestings = [28 * oneDay, 28 * oneDay, 21 * oneDay, 21 * oneDay, 14 * oneDay, 14 * oneDay, 7 * oneDay, 7 * oneDay, 7 * oneDay] + const vestings = [28 * oneDay, 28 * oneDay, 21 * oneDay, 21 * oneDay, 14 * oneDay, 14 * oneDay, 7 * oneDay, 7 * oneDay, 7 * oneDay]; for (let i = 0; i < pricesLP.length; i++) { targets.push(depositoryTwoAddress);