-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #649 from Prop-House/offchain
Promote offchain to prod
- Loading branch information
Showing
3 changed files
with
598 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
packages/prop-house-communities/src/_strategies/nounsDelegatedVotes.ts
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,34 @@ | ||
import { StrategyFactory, _Strategy } from '../types/_Strategy'; | ||
import { BaseArgs } from '../actions/execStrategy'; | ||
import NounsABI from '../abi/NounsABI.json'; | ||
import { parseBlockTag } from '../utils/parseBlockTag'; | ||
import { Contract } from 'ethers'; | ||
import BigNumber from 'bignumber.js'; | ||
|
||
export interface nounsDelegatedVotesStratArgs extends BaseArgs { | ||
multiplier: number; | ||
blockTag?: number; | ||
} | ||
|
||
/** | ||
* Calculates number of delegate votes for NounsDAO | ||
*/ | ||
export const nounsDelegatedVotes: StrategyFactory<nounsDelegatedVotesStratArgs> = ( | ||
params: nounsDelegatedVotesStratArgs, | ||
): _Strategy => { | ||
return async () => { | ||
const { account, blockTag, provider, multiplier } = params; | ||
const _contract = new Contract( | ||
'0x9C8fF314C9Bc7F6e59A9d9225Fb22946427eDC03', | ||
NounsABI, | ||
provider, | ||
); | ||
const balance = await _contract.getCurrentVotes(account, { | ||
blockTag: parseBlockTag(blockTag), | ||
}); | ||
|
||
const parsedBal = new BigNumber(balance.toString()).toNumber(); | ||
|
||
return parsedBal * multiplier; | ||
}; | ||
}; |
Oops, something went wrong.