-
Notifications
You must be signed in to change notification settings - Fork 41
feat(node): [NET-1455] Autostaker plugin #3086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
fd73f95
to
6f23cee
Compare
if ((sponsorships.length) > 0 && (availableBalance >= STAKE_AMOUNT)) { | ||
const targetSponsorship = sample(sponsorships)! | ||
logger.info(`Stake ${formatEther(STAKE_AMOUNT)} to ${targetSponsorship.id}`) | ||
await _operatorContractUtils.stake( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "what" to do should be separated from the "when", like it is in the simulator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. put "what to do with the sponsorships from thegraph" into a separate strategies directory
// @ts-expect-error private | ||
const queryResult = streamrClient.theGraphClient.queryEntities((lastId: string, pageSize: number) => { | ||
return { | ||
query: ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How we should query the possible sponsorships, which we could stake to? Now we use projectedInsolvency_gt and spotAPY_gt fllters, but maybe these are not optimall.
remainingWei_gt: "0"
is same as the projectedInsolvency, and clearer IMO. It's a good way to select only "active" sponsorships.
There might not need to be hard cutoffs for other this, just order by totalPayoutWeiPerSec
desc should be fine, take some reasonable maximum number, e.g. 100.
# Do not merge this manual test to main | ||
|
||
NODE_PRIVATE_KEY="1111111111111111111111111111111111111111111111111111111111111111" | ||
OWNER_PRIVATE_KEY="2222222222222222222222222222222222222222222222222222222222222222" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wouldn't like to require that operators provide their private key for this plugin. What other possibilities there are? The nodes can nowadays vote and flag behalf of the operator, so maybe they could also stake/unstake if that kind of permission could be added?
Nodes do node things; there's another role that can be used for staking/unstaking: CONTROLLER_ROLE. This is added by operator calling operatorContract.grantRole("0x7b765e0e932d348852a6f810bfa1ab891e259123f02db8cdcde614c570223357", controllerAddress)
(where that hex mush can be read from operatorContract.CONTROLLER_ROLE()
)
This is probably preferable as a key management mechanism, so that the autostaker would be run with a private key of this kind of "controller".
There's revokeRole
for removing that role.
…3087) Added a method which provides a client for querying The Graph. All entities of the Streamr graph can be queried using this client, e.g.: - `Stream` - `StreamPermission` - `Operator` - `Sponsorship` - `Stake` - `Vote` - ... This method is currently internal, but it can be made public if needed. Needed in #3086.
WIP. Requesting a review for some early feedback about the approach (see e.g. the "open questions" section).
Currently this just stakes 10000 tokens to some random active sponsorship until it runs out of tokens. It should get the list of actions (stakes and unstakes) from a separate module.
Also logging and error handling could be improved.
Open questions
projectedInsolvency_gt
andspotAPY_gt
fllters, but maybe these are not optimall.SDK features needed
StreamrClient#getTheGraphClient()
so that we don't need to use client's private variable?Development
autostaker-manual-test.sh
script for manual testing. Do not merge that to main, but instead implement some proper tests for this.