w3sandbox/staking/stakecalc2.py

57 lines
1.4 KiB
Python
Raw Normal View History

class StakingPool:
def __init__(self):
# TODO: Add mutex
# self.mutex = None
self.fee_rate = 0.03
self.share_pct = 0.6
self.community_pct = 0.3
self.developer_pct = 0.1
self.contract_fund = 0.0
self.community_fund = 0.0
self.developer_fund = 0.0
self.user_balances = {}
def deposit(self, user: str, amount: float):
# Calculate fee
# Distribute fee
# TODO: Handle edge case where pool has no initial users == Community funds gets the reward
# 1. Community funds
# 2. Developer funds
# 3. Reward stakers
# Update user_balances with new deposit
pass
def withdraw(self, user: str):
# Fetch amount from user_balances
# Remove user from pool to prevent self-reward leaving a hanging balance
# Calculate fee
# Distribute fee
# TODO: User needs to be removed from the pool first to avoid hanging balances after rewarding stakers
# 1. Community funds
# 2. Developer funds
# 3. Reward stakers
pass
def __distribute_reward(self, amount):
# # # #
# Lock user_balances mutex
# # # #
# Get total staked amount
# Determine distribution amongst users
# Update self.user_balances
# # # #
# Unlock user_balances mutex
# # # #
pass