Skip to content

Commit

Permalink
fixes after reading tzkt documentation
Browse files Browse the repository at this point in the history
delegatedBalance is deprecated, need to sum up `own` and `external`
instead

also made a note that `currentDelegatedBalance` of delegators is also
deprecated
  • Loading branch information
nicolasochem committed Jun 4, 2024
1 parent 16d6147 commit e12e343
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tzkt/tzkt_reward_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_rewards_for_cycle_map(self, cycle, rewards_type) -> RewardProviderModel:
address=self.baking_address, cycle=cycle, fetch_delegators=True
)

delegate_staking_balance = split["delegatedBalance"]
delegate_staking_balance = split["ownDelegatedBalance"] + split["externalDelegatedBalance"]

# calculate estimated rewards
num_blocks = split["blocks"] + split["missedBlocks"] + split["futureBlocks"]
Expand Down Expand Up @@ -72,6 +72,8 @@ def get_rewards_for_cycle_map(self, cycle, rewards_type) -> RewardProviderModel:
delegators_balances = {
item["address"]: {
"staking_balance": item["delegatedBalance"],
# FIXME: current_balance is deprecated and no longer accurate
# Instead, tzkt provides a boolean "empty" that can be used.
"current_balance": item["currentDelegatedBalance"],
}
for item in split["delegators"]
Expand Down

0 comments on commit e12e343

Please sign in to comment.