Skip to content

Commit

Permalink
added check_stakes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshowlett977 committed Jul 6, 2021
1 parent 70f79a1 commit 230f696
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/staking/check_stakes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from brownie import *

import calendar
import time
import json

def main():
thisNetwork = network.show_active()

DAY = 24 * 60 * 60
TWO_WEEKS = 2 * 7 * DAY

# == Load config =======================================================================================================================
if thisNetwork == "development":
acct = accounts[0]
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "testnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "rsk-mainnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/mainnet_contracts.json')
else:
raise Exception("network not supported")

# load deployed contracts addresses
contracts = json.load(configFile)

staking = Contract.from_abi("Staking", address=contracts['Staking'], abi=Staking.abi, owner=acct)

ts = calendar.timegm(time.gmtime())
lockedTS = staking.timestampToLockDate(ts)

totalAmount = 0
for i in range(1, 79):
lockedTS += TWO_WEEKS
amount = staking.getCurrentStakedUntil(lockedTS)
totalAmount += amount
print(amount / 10**18)

print("totalAmount: ", totalAmount / 10**18)
51 changes: 51 additions & 0 deletions scripts/staking/check_user_stakes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from brownie import *

import calendar
import time
import json
import csv
import math

def main():
thisNetwork = network.show_active()

# == Load config =======================================================================================================================
if thisNetwork == "development":
acct = accounts[0]
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "testnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "rsk-mainnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/mainnet_contracts.json')
else:
raise Exception("network not supported")

# load deployed contracts addresses
contracts = json.load(configFile)

staking = Contract.from_abi("Staking", address=contracts['Staking'], abi=Staking.abi, owner=acct)

DAY = 24 * 60 * 60
TWO_WEEKS = 2 * 7 * DAY
# parse data

ts = calendar.timegm(time.gmtime())
totalLockedAmount = 0
with open('./scripts/staking/processed-list.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
user = row[0]

stakes = staking.getStakes(user)
stakeDates = stakes[0]
stakeAmounts = stakes[1]

userLockedAmount = 0
for index, value in enumerate(stakeDates):
if (int(value) > ts):
userLockedAmount += stakeAmounts[index]

totalLockedAmount += userLockedAmount
print(user + ", " + str(userLockedAmount) + ", " + str(stakeDates) + ", " + str(stakeAmounts))

0 comments on commit 230f696

Please sign in to comment.