From 14f29d3bea99fc93c1d8d7f05351195d0dc960f0 Mon Sep 17 00:00:00 2001 From: jipstavenuiter Date: Mon, 6 Nov 2023 15:24:04 +0100 Subject: [PATCH] fix parse allowlist csv tests --- frontend/lib/parsing.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/lib/parsing.ts b/frontend/lib/parsing.ts index 6daccd78..8315f860 100644 --- a/frontend/lib/parsing.ts +++ b/frontend/lib/parsing.ts @@ -61,14 +61,19 @@ export function parseAllowlistCsv( const csvTotalPercentage = 1.0 - addTotalPercentage; // 75 - const percentageBigInt = BigInt(Math.floor(csvTotalPercentage * 100)); // convert percentage to BigInt - const creatorSupply = (csvTotalSupply * 100n) / percentageBigInt; // calculate total supply + const csvTotalPercentageBigInt = BigInt(Math.floor(csvTotalPercentage * 100)); // convert percentage to BigInt + const addTotalPercentageBigInt = BigInt(Math.floor(addTotalPercentage * 100)); // convert percentage to BigInt + const creatorSupply = + (((csvTotalSupply * 100n) / csvTotalPercentageBigInt) * + addTotalPercentageBigInt) / + 100n; + const totalSupply = csvTotalSupply + creatorSupply; // calculate total supply // TODO risk over overflow on units - casting bigint to number const data = csvData.concat( add.map((x) => ({ address: x.address.trim().toLowerCase(), - units: creatorSupply, + units: (totalSupply * BigInt(Math.floor(x.percentage * 100))) / 100n, })), );