Skip to content

Commit

Permalink
Merge pull request #649 from Prop-House/offchain
Browse files Browse the repository at this point in the history
Promote offchain to prod
  • Loading branch information
cryptoseneca authored Oct 17, 2023
2 parents 224664a + 725221d commit 027fe94
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/prop-house-communities/src/_strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { validEnsAndMinBal, validEnsAndMinBalStratArgs } from './validEnsAndMinB
import { thankApe, thankApeStratArgs } from './thankApe';
import { minimumBalance, minimumBalanceStratArgs } from './minimumBalance';
import { balanceOfErc1155, balanceOfErc1155StratArgs } from './balanceOfErc1155';
import { nounsDelegatedVotes, nounsDelegatedVotesStratArgs } from './nounsDelegatedVotes';

export const StrategyNames = [
'balanceOfErc721',
Expand All @@ -14,6 +15,7 @@ export const StrategyNames = [
'thankApe',
'minimumBalance',
'balanceOfErc1155',
'nounsDelegatedVotes',
] as const;

export type StrategyName = typeof StrategyNames[number];
Expand All @@ -25,7 +27,8 @@ export type StrategyPayload =
| validEnsAndMinBalStratArgs
| thankApeStratArgs
| minimumBalanceStratArgs
| balanceOfErc1155StratArgs;
| balanceOfErc1155StratArgs
| nounsDelegatedVotesStratArgs;

export const _strategies = {
balanceOfErc721: balanceOfErc721,
Expand All @@ -35,4 +38,5 @@ export const _strategies = {
thankApe: thankApe,
minimumBalance: minimumBalance,
balanceOfErc1155: balanceOfErc1155,
nounsDelegatedVotes: nounsDelegatedVotes,
};
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;
};
};
Loading

0 comments on commit 027fe94

Please sign in to comment.