Skip to content

Commit

Permalink
Update the tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypan authored and Jay Pan committed Jan 2, 2025
1 parent ddff786 commit 0553e84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/apr_v2_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

URL = 'wss://docker-test.peaq.network'
URL = 'wss://mpfn1.peaq.network'
# URL = 'wss://wss-async.agung.peaq.network'
INFLAITON_PERCENTAGE = 0.035
COLLATR_DELEGATOR_PERCENTAGE = 0.40
TOTAL_ISSUANCE_NUMBER = 4.2 * 10 ** 9 * 10 ** 18
Expand Down Expand Up @@ -35,12 +36,12 @@
for k, v in in_candidate_pool.items():
print(f'collator: {k}')
print(f' collator total: {v["total"]}')
# commission_rate = v['commission'] / 10000000
commission_rate = 0.1
# commission_rate = v['commission'] / 1000000
commission_rate = 0.0
print(f' commission rate: {commission_rate}')
for delegator in v['delegators']:
print(f' delegator: {delegator["owner"]}')
print(f' delegator stake: {delegator["amount"]}')
print(f' delegator apr: {(INFLAITON_PERCENTAGE * COLLATR_DELEGATOR_PERCENTAGE * TOTAL_ISSUANCE_NUMBER * (1 - commission_rate) * delegator["amount"] / total_staking_number / delegator["amount"] * 100)}')
print(f' delegator apr: {(INFLAITON_PERCENTAGE * COLLATR_DELEGATOR_PERCENTAGE * TOTAL_ISSUANCE_NUMBER * (1 - commission_rate) / total_staking_number * 100)}') # noqa
print(f' sum: {total_staking_number}')
print(f' collator apr: {(INFLAITON_PERCENTAGE * COLLATR_DELEGATOR_PERCENTAGE * TOTAL_ISSUANCE_NUMBER * (v["stake"] + commission_rate * sum([delegator["amount"] for delegator in v["delegators"]])) / total_staking_number / v["stake"] * 100)}')
print(f' collator apr: {(INFLAITON_PERCENTAGE * COLLATR_DELEGATOR_PERCENTAGE * TOTAL_ISSUANCE_NUMBER * (v["stake"] + commission_rate * sum([delegator["amount"] for delegator in v["delegators"]])) / total_staking_number / v["stake"] * 100)}') # noqa
4 changes: 4 additions & 0 deletions tools/stress/stress_token_economy_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def calculate_total_staking_ratio(staking_info, collator_block_info):

for collator_addr, collator_stake_info in staking_info.items():
staking_ratio = {}
if collator_addr not in collator_block_info:
continue
block_generated_num = float(collator_block_info[collator_addr])
commission = float(collator_stake_info['commission']) / 10 ** 6

Expand All @@ -153,6 +155,8 @@ def calculate_total_staking_ratio(staking_info, collator_block_info):
def caculate_total_staking_num(staking_info, collator_block_info):
total_staking_num = 0
for collator_addr, collator_stake_info in staking_info.items():
if collator_addr not in collator_block_info:
continue
block_generated_num = collator_block_info[collator_addr]
total_staking_num += block_generated_num * collator_stake_info['stake']
for delegator_info in collator_stake_info['delegators']:
Expand Down

0 comments on commit 0553e84

Please sign in to comment.