update deposit function

This commit is contained in:
agatha 2024-06-03 00:25:18 -04:00
parent 3a93a7766e
commit f2c3898d04

View File

@ -17,16 +17,26 @@ class StakingPool:
def stake(self, user: str, amount: float): def stake(self, user: str, amount: float):
# Calculate fee # Calculate fee
total_fee = amount * self.fee_rate
# Distribute fee # Distribute fee
# TODO: Handle edge case where pool has no initial users == Community funds gets the reward # TODO: Handle edge case where pool has no initial users == Community funds gets the reward
# 1. Community funds # 1. Community funds
community_fee = total_fee * self.community_pct
# 2. Developer funds # 2. Developer funds
developer_fee = total_fee * self.developer_pct
# 3. Reward stakers # 3. Reward stakers
reward_amount = total_fee - community_fee - developer_fee
self.__distribute_reward(reward_amount)
# Deposit amount minus fee to contract_fund (wallet) # Deposit amount minus fee to contract_fund (wallet)
# Update user_balances with deposit amount # Update user_balances with deposit amount
pass if user not in self.user_balances:
self.user_balances[user] = amount - total_fee
else:
self.user_balances[user] += amount - total_fee
def unstake(self, user: str): def unstake(self, user: str):
# Fetch amount from user_balances # Fetch amount from user_balances