From 59921f67b905af4586a15409a99b378b7a8b082a Mon Sep 17 00:00:00 2001 From: Chase Manning Date: Wed, 25 Sep 2024 11:05:31 +0100 Subject: [PATCH 1/4] :wrench: add burn address --- functions/src/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/src/constants.ts b/functions/src/constants.ts index 2515b2b..40356dd 100644 --- a/functions/src/constants.ts +++ b/functions/src/constants.ts @@ -19,6 +19,7 @@ export const ZapSwap = "0x461aB832D11A7B18CC444B7C92a1E2B8877A327A"; export const VelodromePool = "0x6eA20Dbc05f58ED607c374e545BFb402d5796770"; export const AmmDistributor = "0x9d27E96B3564e51422C1f0592f42b3934f2bd056"; export const VelodromeVoterAutomation = "0x3B413D27d373bC04e196b59E117E07842258007d"; +export const Burn = "0x000000000000000000000000000000000000dEaD"; // Endpoints export const OPTIMISM_RPC = "https://mainnet.optimism.io/"; From d832ef67a2acc4ea10e80ca2d04de0a558dc047d Mon Sep 17 00:00:00 2001 From: Chase Manning Date: Wed, 25 Sep 2024 11:05:41 +0100 Subject: [PATCH 2/4] :rocket: add support for excluding burned TLX --- functions/src/supply.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/functions/src/supply.ts b/functions/src/supply.ts index b5e0c71..6d15f5c 100644 --- a/functions/src/supply.ts +++ b/functions/src/supply.ts @@ -3,6 +3,7 @@ import { Airdrop, AmmDistributor, Bonding, + Burn, GenesisLocker, MAX_SUPPLY, OPTIMISM_RPC, @@ -22,18 +23,31 @@ const locker = new Contract(GenesisLocker, lockerAbi, provider); export const getCirculatingSupply = async () => { const EXCLUDED_ADDRESSES = [Airdrop, Bonding, GenesisLocker, Vesting, AmmDistributor, VelodromeVoterAutomation]; - const [airdropBalance, bondingBalance, genesisLockerBalance, vestingBalance, ammBalance, voterBalance, totalStaked] = - await Promise.all([...EXCLUDED_ADDRESSES.map((address) => tlx.balanceOf(address)), locker.totalStaked()]); + const [ + airdropBalance, + bondingBalance, + genesisLockerBalance, + vestingBalance, + ammBalance, + voterBalance, + totalStaked, + totalSupply, + ] = await Promise.all([ + ...EXCLUDED_ADDRESSES.map((address) => tlx.balanceOf(address)), + locker.totalStaked(), + getTotalSupply(), + ]); const lockedAmount = genesisLockerBalance - totalStaked; const totalExcluded = airdropBalance + bondingBalance + lockedAmount + vestingBalance + ammBalance + voterBalance; - return MAX_SUPPLY - bigintToNumber(totalExcluded); + return totalSupply - bigintToNumber(totalExcluded); }; export const getTotalSupply = async () => { - return Promise.resolve(MAX_SUPPLY); + const burn = await tlx.balanceOf(Burn); + return MAX_SUPPLY - bigintToNumber(burn); }; export const getMaxSupply = async () => { From 968e554e66385d2fab4baed18b2103e598bfdf7c Mon Sep 17 00:00:00 2001 From: Chase Manning Date: Wed, 25 Sep 2024 11:05:57 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=85=20fix=20tests=20for=20burned=20tl?= =?UTF-8?q?x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/src/__tests__/supply.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/src/__tests__/supply.test.ts b/functions/src/__tests__/supply.test.ts index 328f785..a484a5a 100644 --- a/functions/src/__tests__/supply.test.ts +++ b/functions/src/__tests__/supply.test.ts @@ -9,9 +9,9 @@ describe("Supply Functions", () => { expect(circulatingSupply).toBeLessThan(MAX_SUPPLY); }); - test("getTotalSupply should return MAX_SUPPLY", async () => { + test("getTotalSupply should return total supply", async () => { const totalSupply = await getTotalSupply(); - expect(totalSupply).toBe(MAX_SUPPLY); + expect(totalSupply).toBeLessThan(MAX_SUPPLY); }); test("getMaxSupply should return MAX_SUPPLY", async () => { From 12cdb91635c024c2eb64b1b5eacb5db807d17624 Mon Sep 17 00:00:00 2001 From: Chase Manning Date: Wed, 25 Sep 2024 11:07:43 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=E2=9C=85=20fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/src/__tests__/supply.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/__tests__/supply.test.ts b/functions/src/__tests__/supply.test.ts index a484a5a..7d21b6f 100644 --- a/functions/src/__tests__/supply.test.ts +++ b/functions/src/__tests__/supply.test.ts @@ -11,7 +11,7 @@ describe("Supply Functions", () => { test("getTotalSupply should return total supply", async () => { const totalSupply = await getTotalSupply(); - expect(totalSupply).toBeLessThan(MAX_SUPPLY); + expect(totalSupply).toBeLessThanOrEqual(MAX_SUPPLY); }); test("getMaxSupply should return MAX_SUPPLY", async () => {