From f2c3898d04b08e07519885a1a2171f808273dd3f Mon Sep 17 00:00:00 2001 From: agatha Date: Mon, 3 Jun 2024 00:25:18 -0400 Subject: [PATCH] update deposit function --- staking/stakecalc2.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/staking/stakecalc2.py b/staking/stakecalc2.py index 25beef8..6231233 100644 --- a/staking/stakecalc2.py +++ b/staking/stakecalc2.py @@ -17,16 +17,26 @@ class StakingPool: def stake(self, user: str, amount: float): # Calculate fee + total_fee = amount * self.fee_rate # Distribute fee # TODO: Handle edge case where pool has no initial users == Community funds gets the reward # 1. Community funds + community_fee = total_fee * self.community_pct + # 2. Developer funds + developer_fee = total_fee * self.developer_pct + # 3. Reward stakers + reward_amount = total_fee - community_fee - developer_fee + self.__distribute_reward(reward_amount) # Deposit amount minus fee to contract_fund (wallet) # 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): # Fetch amount from user_balances