mirror of https://github.com/nucypher/nucypher.git
Separated parameter for former hours per period in BaseEconomics
parent
b0a605ab25
commit
98b63da822
|
@ -56,6 +56,7 @@ class BaseEconomics:
|
|||
|
||||
# Period Definition
|
||||
_default_hours_per_period = 24
|
||||
_default_former_hours_per_period = 24
|
||||
|
||||
# Time Constraints
|
||||
_default_minimum_worker_periods = 2
|
||||
|
@ -99,6 +100,7 @@ class BaseEconomics:
|
|||
maximum_rewarded_periods: int,
|
||||
first_phase_supply: int,
|
||||
first_phase_max_issuance: int,
|
||||
former_hours_per_period: int = _default_former_hours_per_period,
|
||||
hours_per_period: int = _default_hours_per_period,
|
||||
minimum_locked_periods: int = _default_minimum_locked_periods,
|
||||
minimum_allowed_locked: int = _default_minimum_allowed_locked,
|
||||
|
@ -142,6 +144,7 @@ class BaseEconomics:
|
|||
:param maximum_rewarded_periods: (kmax) Number of periods beyond which a stake's lock duration
|
||||
no longer increases the subsidy it receives. kmax = reward_saturation * 365 where default reward_saturation = 1.
|
||||
See Equation 8 in Staking Protocol & Economics paper.
|
||||
:param former_hours_per_period: Former hours in single period before migration
|
||||
:param hours_per_period: Hours in single period
|
||||
:param minimum_locked_periods: Min amount of periods during which tokens can be locked
|
||||
:param minimum_allowed_locked: Min amount of tokens that can be locked
|
||||
|
@ -182,11 +185,13 @@ class BaseEconomics:
|
|||
self.lock_duration_coefficient_1 = lock_duration_coefficient_1
|
||||
self.lock_duration_coefficient_2 = lock_duration_coefficient_2
|
||||
self.maximum_rewarded_periods = maximum_rewarded_periods
|
||||
self.former_hours_per_period = former_hours_per_period
|
||||
self.hours_per_period = hours_per_period
|
||||
self.minimum_locked_periods = minimum_locked_periods
|
||||
self.minimum_allowed_locked = minimum_allowed_locked
|
||||
self.maximum_allowed_locked = maximum_allowed_locked
|
||||
self.minimum_worker_periods = minimum_worker_periods
|
||||
self.former_seconds_per_period = former_hours_per_period * 60 * 60 # Former seconds in single period
|
||||
self.seconds_per_period = hours_per_period * 60 * 60 # Seconds in single period
|
||||
|
||||
#
|
||||
|
@ -217,7 +222,7 @@ class BaseEconomics:
|
|||
deploy_parameters = (
|
||||
|
||||
# Period
|
||||
self.hours_per_period, # Former hours in single period
|
||||
self.former_hours_per_period, # Former hours in single period
|
||||
self.hours_per_period, # Hours in single period
|
||||
|
||||
# Coefficients
|
||||
|
@ -462,9 +467,10 @@ class EconomicsFactory:
|
|||
|
||||
# Staking Escrow
|
||||
staking_parameters = list(staking_agent.staking_parameters())
|
||||
staking_parameters.pop(0) # FIXME
|
||||
former_seconds_per_period = staking_parameters.pop(0)
|
||||
seconds_per_period = staking_parameters.pop(0)
|
||||
staking_parameters.insert(6, seconds_per_period // 60 // 60) # hours_per_period
|
||||
staking_parameters.insert(6, former_seconds_per_period // 60 // 60) # former_hours_per_period
|
||||
staking_parameters.insert(7, seconds_per_period // 60 // 60) # hours_per_period
|
||||
minting_coefficient = staking_parameters[0]
|
||||
lock_duration_coefficient_2 = staking_parameters[2]
|
||||
first_phase_total_supply = staking_parameters[4]
|
||||
|
|
|
@ -38,6 +38,7 @@ def token_economics():
|
|||
lock_duration_coefficient_1=4,
|
||||
lock_duration_coefficient_2=8,
|
||||
maximum_rewarded_periods=4,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1,
|
||||
minimum_locked_periods=2,
|
||||
minimum_allowed_locked=100,
|
||||
|
|
|
@ -41,6 +41,7 @@ def test_issuer(testerchain, token, deploy_contract):
|
|||
lock_duration_coefficient_1=10 ** 4,
|
||||
lock_duration_coefficient_2=2 * 10 ** 4,
|
||||
maximum_rewarded_periods=10 ** 4,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1)
|
||||
|
||||
def calculate_first_phase_reward(locked, total_locked, locked_periods):
|
||||
|
@ -59,7 +60,7 @@ def test_issuer(testerchain, token, deploy_contract):
|
|||
|
||||
# Only token contract is allowed in Issuer constructor
|
||||
bad_args = dict(_token=staker,
|
||||
_formerHoursPerPeriod=economics.hours_per_period,
|
||||
_formerHoursPerPeriod=economics.former_hours_per_period,
|
||||
_hoursPerPeriod=economics.hours_per_period,
|
||||
_issuanceDecayCoefficient=economics.issuance_decay_coefficient,
|
||||
_lockDurationCoefficient1=economics.lock_duration_coefficient_1,
|
||||
|
@ -203,6 +204,7 @@ def test_issuance_first_phase(testerchain, token, deploy_contract):
|
|||
lock_duration_coefficient_1=1,
|
||||
lock_duration_coefficient_2=2,
|
||||
maximum_rewarded_periods=1,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1)
|
||||
|
||||
creator = testerchain.client.accounts[0]
|
||||
|
@ -211,7 +213,7 @@ def test_issuance_first_phase(testerchain, token, deploy_contract):
|
|||
# Creator deploys the contract
|
||||
issuer, _ = deploy_contract(contract_name='IssuerMock',
|
||||
_token=token.address,
|
||||
_formerHoursPerPeriod=economics.hours_per_period,
|
||||
_formerHoursPerPeriod=economics.former_hours_per_period,
|
||||
_hoursPerPeriod=economics.hours_per_period,
|
||||
_issuanceDecayCoefficient=economics.issuance_decay_coefficient,
|
||||
_lockDurationCoefficient1=economics.lock_duration_coefficient_1,
|
||||
|
@ -307,6 +309,7 @@ def test_issuance_second_phase(testerchain, token, deploy_contract):
|
|||
lock_duration_coefficient_1=1,
|
||||
lock_duration_coefficient_2=2,
|
||||
maximum_rewarded_periods=1,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1)
|
||||
|
||||
creator = testerchain.client.accounts[0]
|
||||
|
@ -315,7 +318,7 @@ def test_issuance_second_phase(testerchain, token, deploy_contract):
|
|||
# Creator deploys the contract
|
||||
issuer, _ = deploy_contract(contract_name='IssuerMock',
|
||||
_token=token.address,
|
||||
_formerHoursPerPeriod=economics.hours_per_period,
|
||||
_formerHoursPerPeriod=economics.former_hours_per_period,
|
||||
_hoursPerPeriod=economics.hours_per_period,
|
||||
_issuanceDecayCoefficient=economics.issuance_decay_coefficient,
|
||||
_lockDurationCoefficient1=economics.lock_duration_coefficient_1,
|
||||
|
|
|
@ -52,6 +52,7 @@ def token_economics():
|
|||
lock_duration_coefficient_1=4,
|
||||
lock_duration_coefficient_2=8,
|
||||
maximum_rewarded_periods=4,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1,
|
||||
minimum_locked_periods=6,
|
||||
minimum_allowed_locked=200,
|
||||
|
|
|
@ -34,6 +34,7 @@ def token_economics():
|
|||
lock_duration_coefficient_1=4,
|
||||
lock_duration_coefficient_2=8,
|
||||
maximum_rewarded_periods=4,
|
||||
former_hours_per_period=1,
|
||||
hours_per_period=1,
|
||||
minimum_locked_periods=2,
|
||||
minimum_allowed_locked=100,
|
||||
|
|
|
@ -54,7 +54,7 @@ def test_upgrading(testerchain, token, token_economics, deploy_contract):
|
|||
contract_library_v2, _ = deploy_contract(
|
||||
contract_name='StakingEscrowV2Mock',
|
||||
_token=token.address,
|
||||
_formerHoursPerPeriod=token_economics.hours_per_period,
|
||||
_formerHoursPerPeriod=token_economics.former_hours_per_period,
|
||||
_hoursPerPeriod=token_economics.hours_per_period,
|
||||
_issuanceDecayCoefficient=2,
|
||||
_lockDurationCoefficient1=2,
|
||||
|
@ -127,7 +127,7 @@ def test_upgrading(testerchain, token, token_economics, deploy_contract):
|
|||
contract_library_bad, _ = deploy_contract(
|
||||
contract_name='StakingEscrowBad',
|
||||
_token=token.address,
|
||||
_formerHoursPerPeriod=token_economics.hours_per_period,
|
||||
_formerHoursPerPeriod=token_economics.former_hours_per_period,
|
||||
_hoursPerPeriod=token_economics.hours_per_period,
|
||||
_issuanceDecayCoefficient=2,
|
||||
_lockDurationCoefficient1=2,
|
||||
|
|
Loading…
Reference in New Issue