This repository was archived by the owner on Aug 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 828
[hedgey-locked] Strategy for hedgey vesting and lockup contracts #1698
Open
nerfZael
wants to merge
1
commit into
snapshot-labs:master
Choose a base branch
from
agentcoinorg:nerfzael/hedgey-locked
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 hidden or 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 @@ | ||
| # hedgey-locked | ||
|
|
||
| This strategy calls the lockedBalances function on Hedgey Lockup and Vesting contracts | ||
|
|
||
| It can also apply a multiplier to the value returned | ||
|
|
||
| Here is an example of parameters: | ||
|
|
||
| ```json | ||
| { | ||
| "contracts": ["0xce7ac66e78aae01d899eb90b63d1f20be2e9c4b1", "0x24f4BC74C00412422C9D2A7c78033fc8Aea8Da18"], | ||
| "token": "0xE13FB676E9bdd7AFda91495eC4e027FC63212FC3", | ||
| "symbol": "TACO", | ||
| "decimals": 18, | ||
| "multiplier": 10 | ||
| } | ||
| ``` |
This file contains hidden or 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,27 @@ | ||
| [ | ||
| { | ||
| "name": "Example voting based on hedgey vesting token with a multiplier", | ||
| "strategy": { | ||
| "name": "hedgey-locked", | ||
| "params": { | ||
| "contracts": [ | ||
| "0x73cD8626b3cD47B009E68380720CFE6679A3Ec3D", | ||
| "0x1bb64AF7FE05fc69c740609267d2AbE3e119Ef82" | ||
| ], | ||
| "token": "0x04E69Ff14A86E1ca9a155A8563E95887973EE175", | ||
| "symbol": "AITV", | ||
| "decimals": 18, | ||
| "multiplier": 1 | ||
| } | ||
| }, | ||
| "network": "1", | ||
| "addresses": [ | ||
| "0xe90a6EaBEe9162b23edAe465f55327F95d15ae11", | ||
| "0xBE54EBB0A14317256f32Aee3Df8a894793960E78", | ||
| "0xF0138A76223d93192C9c903520f1cf95c9094065", | ||
| "0xDC13Ab880e2AB7b5544a7b927769B5CEc6d62a0b", | ||
| "0xe31D847B47465cC2745319dAc9E0c6ac711cA10b" | ||
| ], | ||
| "snapshot": 21844600 | ||
| } | ||
| ] |
This file contains hidden or 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,48 @@ | ||
| import { BigNumber, BigNumberish } from '@ethersproject/bignumber'; | ||
| import { formatUnits } from '@ethersproject/units'; | ||
| import { Multicaller } from '../../utils'; | ||
|
|
||
| export const author = 'agentcoinorg'; | ||
| export const version = '1.0.0'; | ||
|
|
||
| const abi = [ | ||
| 'function lockedBalances(address holder, address token) view returns (uint256 lockedBalance)' | ||
| ]; | ||
|
|
||
| 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 }); | ||
|
|
||
| for (const contract of options.contracts) { | ||
| for (const address of addresses) { | ||
| multi.call(contract + "/" + address, contract, 'lockedBalances', [address, options.token]); | ||
| } | ||
| } | ||
|
|
||
| const result: Record<string, BigNumberish> = await multi.execute(); | ||
|
|
||
| const scores: Record<string, BigNumber> = | ||
| Object.entries(result).reduce((acc, [path, value]) => { | ||
| const [_, address] = path.split('/'); | ||
| const score = BigNumber.from(value).mul(options.multiplier); | ||
| return { | ||
| ...acc, | ||
| [address]: acc[address] ? acc[address].add(score) : score | ||
| }; | ||
| }, {}); | ||
|
|
||
| return Object.fromEntries( | ||
| Object.entries(scores).map(([address, score]) => [ | ||
| address, | ||
| parseFloat(formatUnits(score.toString(), options.decimals)) | ||
| ]) | ||
| ); | ||
| } | ||
This file contains hidden or 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,49 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$ref": "#/definitions/Strategy", | ||
| "definitions": { | ||
| "Strategy": { | ||
| "title": "Strategy", | ||
| "type": "object", | ||
| "properties": { | ||
| "symbol": { | ||
| "type": "string", | ||
| "title": "Symbol", | ||
| "examples": ["e.g. UNI"], | ||
| "maxLength": 16 | ||
| }, | ||
| "contracts": { | ||
| "type": "array", | ||
| "title": "Hedgey Contract addresses", | ||
| "items": { | ||
| "type": "string", | ||
| "examples": ["e.g. 0xCe7Ac66E78aAE01d899eb90b63D1f20bE2E9c4B1"], | ||
| "pattern": "^0x[a-fA-F0-9]{40}$", | ||
| "minLength": 42, | ||
| "maxLength": 42 | ||
| } | ||
| }, | ||
| "token": { | ||
| "type": "string", | ||
| "title": "Token Contract address", | ||
| "examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"], | ||
| "pattern": "^0x[a-fA-F0-9]{40}$", | ||
| "minLength": 42, | ||
| "maxLength": 42 | ||
| }, | ||
| "decimals": { | ||
| "type": "number", | ||
| "title": "Decimals", | ||
| "examples": ["e.g. 18"] | ||
| }, | ||
| "multiplier": { | ||
| "type": "number", | ||
| "title": "Multiplier", | ||
| "examples": ["e.g. 1"] | ||
| } | ||
| }, | ||
| "required": ["contracts", "token", "decimals", "multiplier"], | ||
| "additionalProperties": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
May face memory issues if someone pass too many contracts. could you throw an error if someone pass contracts above a limit