nucypher.blockchain

Submodules

class BaseEconomics(initial_supply: int, total_supply: int, issuance_decay_coefficient: int, lock_duration_coefficient_1: int, lock_duration_coefficient_2: int, maximum_rewarded_periods: int, first_phase_supply: int, first_phase_max_issuance: int, hours_per_period: int = 24, minimum_locked_periods: int = 30, minimum_allowed_locked: int = 15000000000000000000000, maximum_allowed_locked: int = 30000000000000000000000000, minimum_worker_periods: int = 2, hash_algorithm: int = 1, base_penalty: int = 2, penalty_history_coefficient: int = 0, percentage_penalty_coefficient: int = 100000, reward_coefficient: int = 2, worklock_supply: int = NotImplemented, bidding_start_date: int = NotImplemented, bidding_end_date: int = NotImplemented, cancellation_end_date: int = NotImplemented, worklock_boosting_refund_rate: int = NotImplemented, worklock_commitment_duration: int = NotImplemented, worklock_min_allowed_bid: int = NotImplemented)

Bases: object

A representation of a contract deployment set’s constructor parameters, and the calculations used to generate those values from high-level human-understandable parameters.

Formula for staking in one period for the second phase: (totalSupply - currentSupply) * (lockedValue / totalLockedValue) * (k1 + allLockedPeriods) / d / k2

d - Coefficient which modifies the rate at which the maximum issuance decays k1 - Numerator of the locking duration coefficient k2 - Denominator of the locking duration coefficient

if allLockedPeriods > maximum_rewarded_periods then allLockedPeriods = maximum_rewarded_periods kappa * log(2) / halving_delay === (k1 + allLockedPeriods) / d

nunits_per_token = 1000000000000000000
HASH_ALGORITHM_KECCAK256 = 0
HASH_ALGORITHM_SHA256 = 1
HASH_ALGORITHM_RIPEMD160 = 2
property erc20_initial_supply
property erc20_reward_supply
property erc20_total_supply
property staking_deployment_parameters

Cast coefficient attributes to uint256 compatible type for solidity+EVM

property slashing_deployment_parameters

Cast coefficient attributes to uint256 compatible type for solidity+EVM

property worklock_deployment_parameters

0 token - Token contract 1 escrow - Staking Escrow contract … 2 startBidDate - Timestamp when bidding starts 3 endBidDate - Timestamp when bidding will end 4 endCancellationDate - Timestamp when cancellation window will end 5 boostingRefund - Coefficient to boost refund ETH 6 stakingPeriods - Duration of tokens locking 7 minAllowedBid - Minimum allowed ETH amount for bidding

property bidding_duration

Returns the total bidding window duration in seconds.

property cancellation_window_duration

Returns the total cancellation window duration in seconds.

class StandardTokenEconomics(initial_supply: int = 1000000000000000000000000000, first_phase_supply: int = 1829579800000000000000000000, first_phase_duration: int = 5, decay_half_life: int = 2, reward_saturation: int = 1, small_stake_multiplier: decimal.Decimal = Decimal('0.5'), **kwargs)

Bases: nucypher.blockchain.economics.BaseEconomics

Formula for staking in one period for the second phase: (totalSupply - currentSupply) * (lockedValue / totalLockedValue) * (k1 + allLockedPeriods) / d / k2

d - Coefficient which modifies the rate at which the maximum issuance decays k1 - Numerator of the locking duration coefficient k2 - Denominator of the locking duration coefficient

if allLockedPeriods > maximum_rewarded_periods then allLockedPeriods = maximum_rewarded_periods kappa * log(2) / halving_delay === (k1 + allLockedPeriods) / d / k2

…but also…

kappa = small_stake_multiplier + (1 - small_stake_multiplier) * min(T, T1) / T1 where allLockedPeriods == min(T, T1)

Academic Reference:

NuCypher: Mining & Staking Economics - Michael Egorov, MacLane Wilkison, NuCypher <https://github.com/nucypher/mining-paper/blob/master/mining-paper.pdf>

first_phase_final_period()int

Returns final period for first phase, assuming that all stakers locked tokens for more than 365 days.

token_supply_at_period(period: int)int

Returns predicted total supply at specified period, assuming that all stakers locked tokens for more than 365 days.

cumulative_rewards_at_period(period: int)int
rewards_during_period(period: int)int
class EconomicsFactory

Bases: object

classmethod get_economics(registry: nucypher.blockchain.eth.registry.BaseContractRegistry)nucypher.blockchain.economics.BaseEconomics
static retrieve_from_blockchain(registry: nucypher.blockchain.eth.registry.BaseContractRegistry)nucypher.blockchain.economics.BaseEconomics