Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Staker rewards script: Calculating operator assets #628

Merged
merged 15 commits into from
Dec 3, 2020

Conversation

lukasz-zimnoch
Copy link
Member

@lukasz-zimnoch lukasz-zimnoch commented Dec 1, 2020

Depends on: #625
Depends on: keep-network/tbtc.js#114
Refs: #602

This pull request introduces additional parameters to the staker rewards script. Those parameters are related with operator assets and are defined as follows:

  • keepStaked: it's the value of the operator's activeStake checked at the interval end block
  • ethBonded: it's the sum of all operator bonds active at the interval start block
  • ethUnbonded: it's the value of the operator's availableUnbondedValue checked at the interval start block
  • ethTotal: it's the sum of ethBonded and ethUnbonded

Implemented a stub of the assets calculator
and added computations of the KEEP staked
parameter.
@lukasz-zimnoch lukasz-zimnoch changed the title Staker rewards script - Assets part Staker rewards script - assets part Dec 1, 2020
Base automatically changed from staker-rewards-inspector to master December 1, 2020 15:57
# Conflicts:
#	staker-rewards/lib/context.js
#	staker-rewards/lib/contract-helper.js
#	staker-rewards/rewards.js
Added some logic which determines the starting
and ending blocks for the given interval. The
interval blockspan is needed for calculating
the KEEP staked and ETH under management values
at correct points of the timeline.
The keep staked value for given operator should
be checked at interval end block according to
the rewards specification.
Implemented calculations of the ETH unbonded
and total values and passed the outcomes
to the output table.
Added support of the `toBlock` parameter
to the `getPastEvents` function. This parameter
will add new filtering capabilities while
fetching past events.
@lukasz-zimnoch lukasz-zimnoch changed the title Staker rewards script - assets part Staker rewards script: Calulating operator assets Dec 2, 2020
@lukasz-zimnoch lukasz-zimnoch changed the title Staker rewards script: Calulating operator assets Staker rewards script: Calculating operator assets Dec 2, 2020
Implemented calculations of the ETH bonded
parameter basing on `Bond*` events emitted
by the bonding contract.
@lukasz-zimnoch lukasz-zimnoch marked this pull request as ready for review December 2, 2020 14:43
@pdyraga pdyraga requested a review from nkuba December 2, 2020 15:04
Copy link
Member

@pdyraga pdyraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run this script with

ETH_HOSTNAME="..." node --experimental-json-modules rewards.js 1600041600 1606821119

and all eth* values for all operators are 0 in the table rendered.

(EDIT: which is correct because nothing was bonded at 1600041600).

staker-rewards/lib/assets-calculator.js Outdated Show resolved Hide resolved
staker-rewards/lib/assets-calculator.js Outdated Show resolved Hide resolved
staker-rewards/lib/assets-calculator.js Outdated Show resolved Hide resolved
staker-rewards/lib/assets-calculator.js Outdated Show resolved Hide resolved
staker-rewards/lib/assets-calculator.js Outdated Show resolved Hide resolved
staker-rewards/rewards.js Outdated Show resolved Hide resolved
# Conflicts:
#	staker-rewards/lib/context.js
#	staker-rewards/rewards.js
There should be no dependency on
`KeepRandomBeaconOperator` contract in the
staker rewards script. The true `operator`
contract in this context should be the
`BondedECDSAKeepFactory` contract.
The address of the sanctioned application can
be hardcoded in the context.js file. This
way we can avoid a dependency on
`@keep-network/tbtc` package.
Floating point numbers which represent some
of the operator assets, should be rounded
only in the presentation layer. This way
we keep the precise value for rewards
calculations.
@pdyraga pdyraga added this to the solidity/v1.4.0 milestone Dec 3, 2020
@pdyraga
Copy link
Member

pdyraga commented Dec 3, 2020

Let's make sure we use adjust keepStake value displayed to be /1e18, same as eth* parameters:
image

@pdyraga
Copy link
Member

pdyraga commented Dec 3, 2020

Tested locally with the most recent mainnet data. Works as expected.

@pdyraga pdyraga merged commit c553088 into master Dec 3, 2020
@pdyraga pdyraga deleted the staker-rewards-calculations branch December 3, 2020 15:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants