Skip to content

Commit 8da3671

Browse files
authored
Merge pull request #2 from gear-foundation/do-refactor
update
2 parents 5c4130d + 2985275 commit 8da3671

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/calculators/circulation-supply.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import {
33
AIRDROP_POOL,
44
DEVELOPER_PROJECTS_GRANTS_POOL,
55
FOUNDATION_AND_ECOSYSTEM_DEVELOPMENT_POOL,
6-
INFLATION_OFFSETTING_POOL,
6+
INITIAL_BALANCE_INFLATION_OFFSETTING_POOL,
77
EDUCATION_BOOTCAMP_PR_EVENT_POOL,
88
PROTOCOL_DEVELOPMENT_POOL,
99
PROTOCOL_RESERVE_POOL,
1010
VALIDATOR_INCENTIVES_POOL,
1111
MARKET_POOL,
1212
CUSTODY,
13+
AIRDROP_3RD_PARTY_1,
14+
DECIMALS,
1315
} from '../consts.js';
1416
import { totalSupply } from './total-supply.js';
1517

@@ -41,7 +43,7 @@ export async function totalVesting() {
4143
const locked = withType.unwrap()[0].locked.toBigInt();
4244
result += locked;
4345
}
44-
const totalVesting = result / BigInt(10 ** 12);
46+
const totalVesting = result / BigInt(10 ** DECIMALS);
4547
return Number(totalVesting);
4648
}
4749

@@ -59,7 +61,7 @@ export async function totalStaking() {
5961
total += withType.amount.toBigInt();
6062
}
6163
}
62-
const totalStaking = total / BigInt(10 ** 12);
64+
const totalStaking = total / BigInt(10 ** DECIMALS);
6365
return Number(totalStaking);
6466
}
6567

@@ -69,7 +71,7 @@ export async function totalStaking() {
6971
// return [poolAddr, ...deriveAddr(poolAddr)];
7072
// }
7173

72-
// Circulation Supply = Total Supply - (Vesting + Pools);
74+
// Circulation Supply = Total Supply - (Vesting + Staking + Pools);
7375
export async function circulationSupply() {
7476
const addresses = [
7577
EDUCATION_BOOTCAMP_PR_EVENT_POOL,
@@ -79,10 +81,11 @@ export async function circulationSupply() {
7981
VALIDATOR_INCENTIVES_POOL,
8082
DEVELOPER_PROJECTS_GRANTS_POOL,
8183
AIRDROP_POOL,
82-
INFLATION_OFFSETTING_POOL,
8384
MARKET_POOL,
85+
AIRDROP_3RD_PARTY_1,
8486
...CUSTODY,
8587
];
88+
// INFLATION_OFFSETTING_POOL;
8689

8790
const [supply, vesting, staking, pools] = await Promise.all([
8891
totalSupply(),
@@ -91,7 +94,11 @@ export async function circulationSupply() {
9194
getBalances(addresses),
9295
]);
9396

94-
const total = pools.reduce((accumulator, current) => accumulator + current, 0) + vesting + staking;
97+
const total =
98+
pools.reduce((accumulator, current) => accumulator + current, 0) +
99+
vesting +
100+
staking +
101+
INITIAL_BALANCE_INFLATION_OFFSETTING_POOL;
95102

96103
return supply - total;
97104
}

src/calculators/total-supply.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { DECIMALS } from '../consts.js';
12
import { api } from '../node.js';
23

34
export async function totalSupply() {
45
const total = await api.query.balances.totalIssuance();
56

6-
const bigint = total.toBigInt() / BigInt(10 ** 12);
7+
const bigint = total.toBigInt() / BigInt(10 ** DECIMALS);
78
return Number(bigint);
89
}

src/consts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const MARKET_POOL = 'kGmHNw32YQrY9SFArgjFKgrgysZN13Th29ZPoPT6hJ7uhhtrs';
1010

1111
export const INITIAL_BALANCE_INFLATION_OFFSETTING_POOL = 1_000_000_000;
1212

13+
export const AIRDROP_3RD_PARTY_1 = 'kGfgqjRznfuto8Q7oxAine8ZFjDCkpcYB6XVcNCw5QHw1z6xd';
14+
1315
// Custody accounts
1416

1517
export const CUSTODY = [
@@ -24,3 +26,5 @@ export const CUSTODY = [
2426
'kGga7DgxzLLTqn9WjtEZW5pkxYVnBPS4Rt6xK3Adqs1iKN42z',
2527
'kGiVY7G1mJkqaAjKzLnRmwCy5GcvuGQvG5mUtojhVHdLfBd1P',
2628
];
29+
30+
export const DECIMALS = 12;

0 commit comments

Comments
 (0)