88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
"""
|
|
CONCEPT HODLJENNER.COM
|
|
A community-driven staking project for the Etherum token $JENNER designed to encourage and reward the community by
|
|
holding onto the token.
|
|
|
|
Dedicated $JENNER HODLERS (not holders) can stake some of their $JENNER to the pool. When doing so, 3% of the total
|
|
staked amount will be shared amongst the stakers already in the pool.
|
|
|
|
A staker can exit the pool at any time they wish. They will be given back their INITIAL STAKE (minus fees) plus
|
|
their share of the Fee rewards.
|
|
"""
|
|
|
|
|
|
class StakingContract:
|
|
def __init__(self):
|
|
self.rewards_pct = 0.6
|
|
self.community_pct = 0.3
|
|
self.developer_pct = 0.1
|
|
|
|
self.balances = {
|
|
"stakes": 0.0,
|
|
"reward": 0.0,
|
|
"developer": 0.0,
|
|
"community": 0.0,
|
|
}
|
|
|
|
self.users = {}
|
|
|
|
def deposit(self, user: str, amount: float):
|
|
stake, reward, community, developer = self.calc_fee(amount)
|
|
print('--- DEPOSIT ---')
|
|
print(f'user address: {user}')
|
|
print(f'staked amount: {stake}')
|
|
print(f'reward amount: {reward}')
|
|
print(f'community amount: {community}')
|
|
print(f'developer amount: {developer}')
|
|
print('')
|
|
|
|
self.balances['stakes'] += stake
|
|
self.balances['reward'] += reward
|
|
self.balances['developer'] += developer
|
|
self.balances['community'] += community
|
|
|
|
if user in self.users.keys():
|
|
self.users[user] += stake
|
|
else:
|
|
self.users[user] = stake
|
|
|
|
def withdraw(self, user: str):
|
|
pass
|
|
|
|
def calc_fee(self, amount):
|
|
fee = amount * 0.03
|
|
stake_amount = amount - fee
|
|
|
|
rewards = fee * self.rewards_pct
|
|
community = fee * self.community_pct
|
|
developer = fee * self.developer_pct
|
|
|
|
return stake_amount, rewards, community, developer
|
|
|
|
def show_stats(self):
|
|
print('--- POOL STATS ---')
|
|
for k, v in self.balances.items():
|
|
print(f'{k}: {v}')
|
|
print('')
|
|
print('--- USERS IN POOL ---')
|
|
for k, v in self.users.items():
|
|
print(f'{k}: {v}')
|
|
print('')
|
|
|
|
|
|
def main():
|
|
pool = StakingContract()
|
|
pool.show_stats()
|
|
pool.deposit("user1", 1000)
|
|
pool.deposit("user2", 200000)
|
|
pool.deposit("user3", 90283)
|
|
pool.show_stats()
|
|
|
|
user = pool.withdraw("user1")
|
|
pool.show_stats()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|