Skip to content

Commit

Permalink
fix ticket-price refs removed
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandemeusy committed Jun 7, 2024
1 parent 4eb5f6d commit 9b81159
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions ct-app/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ async def get_ticket_price(self):
await self.ticket_price.set(price)
self.debug(f"Ticket price: {price}")

self.legacy_model.budget.ticket_price = price
self.sigmoid_model.budget.ticket_price = price

async def start(self):
"""
Start the node.
Expand Down
7 changes: 3 additions & 4 deletions ct-app/core/model/budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ def __init__(
self,
period: float,
distribution_per_period: float,
ticket_price: float,
winning_probability: float,
):
self.period = period
self.distribution_per_period = distribution_per_period
self.ticket_price = ticket_price
self.ticket_price = None
self.winning_probability = winning_probability

@property
Expand Down Expand Up @@ -49,7 +48,8 @@ def distribution_per_period(self, value):
@ticket_price.setter
def ticket_price(self, value):
self._ticket_price = value
TICKET_PRICE.set(value)
if value is not None:
TICKET_PRICE.set(value)

@winning_probability.setter
def winning_probability(self, value):
Expand All @@ -61,7 +61,6 @@ def fromParameters(cls, parameters: Parameters):
return cls(
parameters.period,
parameters.countsInPeriod,
parameters.ticketPrice,
parameters.winningProbability,
)

Expand Down
5 changes: 4 additions & 1 deletion ct-app/core/model/economic_model_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def message_count_for_reward(self, stake: float):
rewards = self.apr / 12 * self.transformed_stake(stake)
denominator = self.budget.ticket_price * self.budget.winning_probability

return round(rewards / denominator * self.economic_model.proportion)
if denominator != 0:
return round(rewards / denominator * self.economic_model.proportion)
else:
return 0

@classmethod
def fromParameters(cls, parameters: Parameters):
Expand Down
1 change: 0 additions & 1 deletion ct-app/scripts/core_production_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ economicModel:
budget:
period: 2628000
countsInPeriod: 365
ticketPrice: 0.03 # deprecated
winningProbability: 1

# =============================================================================
Expand Down
1 change: 0 additions & 1 deletion ct-app/scripts/core_staging_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ economicModel:
budget:
period: 1200
countsInPeriod: 1
ticketPrice: 0.5 # deprecated
winningProbability: 1

# =============================================================================
Expand Down
3 changes: 2 additions & 1 deletion ct-app/test/model/test_economic_model_sigmoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def test_economic_model_message_count_for_reward():
model = EconomicModelSigmoid(
10.0, [Bucket("bucket_1", 1, 1, 1), Bucket("bucket_2", 1, 1, 0.5)], 20.0, 1
)
model.budget = Budget(60, 1, 1, 1)
model.budget = Budget(60, 1, 1)
model.budget.ticket_price = 1

assert model.apr([0.5, 0.25]) == 10
assert model.message_count_for_reward(stake, [0.5, 0.25]) == round(
Expand Down

0 comments on commit 9b81159

Please sign in to comment.