-
Notifications
You must be signed in to change notification settings - Fork 55
/
queries.ts
74 lines (68 loc) · 1.66 KB
/
queries.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
export const findCirculatingSupply = `
SELECT ( utxo + rewards ) as circulating_supply FROM ada_pots ORDER BY id DESC LIMIT 1;
`;
export const findTotalSupply = `
SELECT CAST($1 - reserves AS BIGINT) AS total_supply
FROM ada_pots
ORDER BY ada_pots.block_id DESC
LIMIT 1
`;
// Active stake is the stake snapshot from n-1 epochs, where n = current epoch
// epoch_stake contains records of completed epochs
export const findActiveStake = `
SELECT CAST(COALESCE(SUM(amount), 0) AS BIGINT) as active_stake
FROM epoch_stake
WHERE epoch_stake.epoch_no = (SELECT MAX(no) FROM epoch) - 1
`;
export const findLatestCompleteEpoch = `
SELECT no
FROM public.epoch
ORDER BY no DESC
LIMIT 1
`;
export const findProtocolParams = `
SELECT
min_fee_a,
min_fee_b,
max_tx_size,
key_deposit,
pool_deposit,
protocol_major,
protocol_minor,
min_pool_cost,
coins_per_utxo_size,
max_val_size,
max_collateral_inputs,
max_block_size,
max_bh_size,
optimal_pool_count,
influence,
monetary_expand_rate,
treasury_growth_rate,
decentralisation,
collateral_percent,
price_mem,
price_step,
max_tx_ex_mem,
max_tx_ex_steps,
max_block_ex_mem,
max_block_ex_steps,
max_epoch,
gov_action_deposit,
drep_deposit,
cost_model.costs,
committee_min_size,
FROM epoch_param
LEFT JOIN cost_model
ON cost_model.id = epoch_param.cost_model_id
ORDER BY epoch_no DESC NULLS LAST
LIMIT 1;
`;
const Queries = {
findActiveStake,
findCirculatingSupply,
findLatestCompleteEpoch,
findProtocolParams,
findTotalSupply
};
export default Queries;