Skip to content

Commit

Permalink
burnt clo calculation updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Germain committed Mar 12, 2024
1 parent 802d6a6 commit da4de83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion huginn_callisto_network_agent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "huginn_callisto_network_agent"
spec.version = '0.1.83'
spec.version = '0.1.84'
spec.authors = ["Nicolas Germain"]
spec.email = ["ngermain@hihouhou.com"]

Expand Down
20 changes: 12 additions & 8 deletions lib/huginn_callisto_network_agent/callisto_network_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,29 +454,33 @@ def get_tx_stats()
dead_address = '0x000000000000000000000000000000000000dead'
internal = true
tx_list = []
burnt_ether = 0
burnt_clo = 0
burnt_type2 = 0
burnt_dead = 0
(interpolated['first_block']..interpolated['last_block']).each do |i|
transactions = get_data(i.to_i,internal)
gas_used = transactions['result']['gasUsed'].to_i(16)
transactions['result']['transactions'].each do |tx|
if !tx.empty?
tx_list << tx
if tx['type'] == "0x2"
gas_price = tx['gasPrice'].to_i(16)
fees = gas_price * gas_used.to_f / 10**18
gas_fee = transactions['result']['baseFeePerGas'].to_i(16)
fees = ( transactions['result']['gasUsed'].to_i(16) * gas_fee.to_f ) / (10 ** 18)
log gas_fee
log fees
else
fees = 0
end
if tx['to'] == dead_address
burnt = tx['value'].to_i(16) / 10**18
burnt = tx['value'].to_i(16).to_f / 10**18
else
burnt = 0
end
end
burnt_ether += fees
burnt_ether += burnt
burnt_type2 += fees
burnt_dead += burnt
end
end
burnt_clo = ( burnt_type2 / tx_list.count ) + burnt_dead
top_tx = most_common_from(tx_list)
top_count = tx_list.count { |hash| hash['from'] == top_tx }
miners_count = tx_list.select { |hash| all_miners.include?(hash['from']) }
Expand All @@ -490,7 +494,7 @@ def get_tx_stats()
active = tx_list.map { |p| p['from'] }.uniq.count
# log "top_count : #{top_count}"
# log "total : #{tx_list.count}"
create_event :payload => { 'total_tx' => "#{tx_list.count}", 'total_active' => "#{active}", 'burnt_clo' => "#{burnt_ether}", 'top_wallet': {'address' => "#{top_tx}", 'percentage' => "#{percentage(top_count.to_i,tx_list.count.to_i)}"}, 'shitty': {'address': 'shitty', 'shitty_percentage' => "#{percentage(shitty_count.count,tx_list.count.to_i)}"}, 'miners': {'address': "miners", 'percentage' => "#{percentage(miners_count.count,tx_list.count.to_i)}"}, 'callosha': {'address': callosha_address, 'percentage' => "#{percentage(callosha_count.count,tx_list.count.to_i)}"}, 'twobears': {'address': twobears_address, 'percentage' => "#{percentage(twobears_count.count,tx_list.count.to_i)}"}, 'vipwarz': {'address': vipwarz_address, 'percentage' => "#{percentage(vipwarz_count.count,tx_list.count.to_i)}"}, 'slotmachine': {'address': slotmachine_address, 'percentage' => "#{percentage(slotmachine_count.count,tx_list.count.to_i)}"}}
create_event :payload => { 'total_tx' => "#{tx_list.count}", 'total_active' => "#{active}", 'burnt_clo' => "#{burnt_clo}", 'top_wallet': {'address' => "#{top_tx}", 'percentage' => "#{percentage(top_count.to_i,tx_list.count.to_i)}"}, 'shitty': {'address': 'shitty', 'shitty_percentage' => "#{percentage(shitty_count.count,tx_list.count.to_i)}"}, 'miners': {'address': "miners", 'percentage' => "#{percentage(miners_count.count,tx_list.count.to_i)}"}, 'callosha': {'address': callosha_address, 'percentage' => "#{percentage(callosha_count.count,tx_list.count.to_i)}"}, 'twobears': {'address': twobears_address, 'percentage' => "#{percentage(twobears_count.count,tx_list.count.to_i)}"}, 'vipwarz': {'address': vipwarz_address, 'percentage' => "#{percentage(vipwarz_count.count,tx_list.count.to_i)}"}, 'slotmachine': {'address': slotmachine_address, 'percentage' => "#{percentage(slotmachine_count.count,tx_list.count.to_i)}"}}

end

Expand Down

0 comments on commit da4de83

Please sign in to comment.