-
Notifications
You must be signed in to change notification settings - Fork 758
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
Add RichQuack Staking amount strategy [richquack-staked-amount] #1121
Open
ephdtrg
wants to merge
1
commit into
snapshot-labs:master
Choose a base branch
from
Rock-n-Block:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# richquack-staked-amount | ||
|
||
This strategy returns voting power for RichQuack stakers. | ||
|
||
The voting power is based on the amount of staked tokensbalance, rather than delegated voting power. | ||
|
||
## Params | ||
|
||
- `stakingAddress` - (**Required**, `string`) Address of RichQuack Staking contract | ||
|
||
Here is an example of parameters: | ||
|
||
```json | ||
{ | ||
"stakingAddress": "0x24E1FB7a781d255EdC40e80C89d9289dC61925F2", | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "richquack-staked-amount", | ||
"params": { | ||
"stakingAddress": "0x24E1FB7a781d255EdC40e80C89d9289dC61925F2" | ||
} | ||
}, | ||
"network": "56", | ||
"addresses": [ | ||
"0x8575697851F5A11494a725FF43534e859BF49710", | ||
"0xB4433e91F287a6E116aBaF413E64B4E0697DdCce", | ||
"0x4089bd5C7544de334b0FBc125654cEFBB9B62cDE", | ||
"0xc2d06aD1063d895405f2243D0c79b15e676b9Db0", | ||
"0x523D44c7E7557C724b34BABba2A931410634173B" | ||
], | ||
"snapshot": 27084195 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import { formatUnits } from '@ethersproject/units'; | ||
import { Multicaller } from '../../utils'; | ||
|
||
export const author = 'ephdtrg'; | ||
export const version = '0.1.0'; | ||
|
||
const abi = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: '', | ||
type: 'address' | ||
} | ||
], | ||
name: 'stakeInfo', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: 'level', | ||
type: 'uint256' | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'totalStakedForUser', | ||
type: 'uint256' | ||
} | ||
], | ||
stateMutability: 'view', | ||
type: 'function' | ||
} | ||
]; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
): Promise<Record<string, number>> { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
const multi = new Multicaller(network, provider, abi, { blockTag }); | ||
addresses.forEach((address) => | ||
multi.call(address, options.stakingAddress, 'stakeInfo', [address]) | ||
); | ||
const result: Record<string, BigNumberish> = await multi.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address]) => [ | ||
address, | ||
parseFloat(formatUnits(result[address][0], 18)) | ||
]) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/Strategy", | ||
"definitions": { | ||
"Strategy": { | ||
"title": "Strategy", | ||
"type": "object", | ||
"properties": { | ||
"stakingAddress": { | ||
"type": "string", | ||
"title": "Staking address", | ||
"examples": ["e.g. 0x24E1FB7a781d255EdC40e80C89d9289dC61925F2"], | ||
"pattern": "^0x[a-fA-F0-9]{40}$", | ||
"minLength": 42, | ||
"maxLength": 42 | ||
} | ||
}, | ||
"required": ["stakingAddress"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi @ephdtrg i think contract-call strategy should work for you, can try?
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.
Hi, @ChaituVR ! Thank you for response
Do you mean to use existing contract-call strategy for this workflow, instead of writing new strategy, correct?
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.
Yep @ephdtrg Can use it in your space directly :)
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.
Thank you for suggestion @ChaituVR !
Was not aware of this strategy, will check it out and close this PR if it works as intended :)