Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Add Exclusion for Burned TLX #24

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading