-
Notifications
You must be signed in to change notification settings - Fork 14
feat: set proposal's strategies fiat value #567
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
Open
wa0x6e
wants to merge
20
commits into
master
Choose a base branch
from
feat-get-proposal-vp-value-from-overlord
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
Show all changes
20 commits
Select commit
Hold shift + click to select a range
84efdb7
feat: set proposal vp value on proposal creation
wa0x6e f7a87bd
Merge branch 'master' into feat-get-proposal-vp-value-from-overlord
wa0x6e ed31f78
feat: set proposal strategies value on proposal creation
wa0x6e 599f9e4
fix: set `cb` column
wa0x6e cb9859b
fix: default last_cb to 1
wa0x6e e589d82
fix: round strategies value up to 9 decimals
wa0x6e 4fb62be
refactor: move precision to a const
wa0x6e 43def63
chore: fix typo
wa0x6e 4510db7
test: fix test
wa0x6e 8a28e02
test: fix tests
wa0x6e 8b8875e
refactor: use entityValue as value logic handler
wa0x6e afed3e3
fix: use randomUUID to generate random number
wa0x6e a2e025c
chore: use consistent logging
wa0x6e ec1028e
fix: handle overlord error
wa0x6e a64a0e6
fix: more precise rounding
wa0x6e adc6257
refactor: DRY json rpc request fetcher
wa0x6e 602555e
refactor: simplify rounding
wa0x6e 3e52e3a
fix: allow customize overlord url via env var
wa0x6e 6589f97
chore: remove white spaces
wa0x6e 61267cf
Merge branch 'master' into feat-get-proposal-vp-value-from-overlord
wa0x6e 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
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
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,26 @@ | ||
import { jsonRpcRequest } from './utils'; | ||
|
||
type Proposal = { | ||
network: string; | ||
strategies: any[]; | ||
start: number; | ||
}; | ||
|
||
const OVERLORD_URL = process.env.OVERLORD_URL ?? 'https://overlord.snapshot.org'; | ||
// Round strategy values to 9 decimal places | ||
const STRATEGIES_VALUE_PRECISION = 9; | ||
|
||
export async function getStrategiesValue(proposal: Proposal): Promise<number[]> { | ||
const result: number[] = await jsonRpcRequest(OVERLORD_URL, 'get_vp_value_by_strategy', { | ||
network: proposal.network, | ||
strategies: proposal.strategies, | ||
snapshot: proposal.start | ||
}); | ||
|
||
// Handle unlikely case where strategies value array length does not match strategies length | ||
if (result.length !== proposal.strategies.length) { | ||
throw new Error('Strategies value length mismatch'); | ||
} | ||
|
||
return result.map(value => parseFloat(value.toFixed(STRATEGIES_VALUE_PRECISION))); | ||
} |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.