Class: Sorare::Rewards::Supply::ComputeForQuality

Inherits:
Object
  • Object
show all
Includes:
Interactor
Defined in:
lib/sorare/rewards/interactors/supply/compute_for_quality.rb

Overview

ComputeForQuality computes the rewardable supply for a given quality between the divisions of a league

Instance Method Summary collapse

Instance Method Details

#callObject



15
16
17
# File 'lib/sorare/rewards/interactors/supply/compute_for_quality.rb', line 15

def call
  context.quality_supply = total_supply.zero? ? 0 : quality_supply
end

#quality_supplyObject



19
20
21
22
23
# File 'lib/sorare/rewards/interactors/supply/compute_for_quality.rb', line 19

def quality_supply
  plain, extra = (tier_supply.to_f * rewardable).divmod(total_supply)

  plain + remaining_supply(plain, extra)
end

#remaining_supply(plain, extra) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/sorare/rewards/interactors/supply/compute_for_quality.rb', line 25

def remaining_supply(plain, extra)
  reward_probability = randomizer.rand
  return 0 if rewarded.sum + plain >= rewardable
  return 0 if extra.zero?
  return 0 if reward_probability > (extra.to_f / total_supply)

  1
end