All files / src/NetworkInfo/DbSyncNetworkInfoProvider queries.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 0/0
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 9336x       36x                 36x           36x             36x                                                                                                                 36x               36x  
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,
    committee_max_term_length,
    gov_action_lifetime,
    drep_activity,
    pvt_motion_no_confidence,
    pvt_committee_normal,
    pvt_committee_no_confidence,
    pvt_hard_fork_initiation,
    pvtpp_security_group,
    dvt_motion_no_confidence,
    dvt_committee_normal,
    dvt_committee_no_confidence,
    dvt_update_to_constitution,
    dvt_hard_fork_initiation,
    dvt_p_p_network_group,
    dvt_p_p_economic_group,
    dvt_p_p_technical_group,
    dvt_p_p_gov_group,
    dvt_treasury_withdrawal
    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;