Skip to content

Commit

Permalink
Merge pull request #24 from TLX-Protocol/add-burn-exclusion
Browse files Browse the repository at this point in the history
🚀  Add Exclusion for Burned TLX
  • Loading branch information
chase-manning authored Sep 25, 2024
2 parents e47734e + 12cdb91 commit d7872ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions functions/src/__tests__/supply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).toBeLessThanOrEqual(MAX_SUPPLY);
});

test("getMaxSupply should return MAX_SUPPLY", async () => {
Expand Down
1 change: 1 addition & 0 deletions functions/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
22 changes: 18 additions & 4 deletions functions/src/supply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Airdrop,
AmmDistributor,
Bonding,
Burn,
GenesisLocker,
MAX_SUPPLY,
OPTIMISM_RPC,
Expand All @@ -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 () => {
Expand Down

0 comments on commit d7872ff

Please sign in to comment.