Skip to content

Commit

Permalink
fix totalMkrDelegated, cleanup, add to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Jul 12, 2024
1 parent 3dd8215 commit 2861219
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ The following configuration values can be added to the `.env` file:

- Set `GASLESS_WEBHOOK_URL` for sending gasless vote requests to discord

- Set `USE_PRIVATE_SUBGRAPH` to `true` to connect to the subgraph privately

**Optional** Set `DEFENDER_API_KEY_MAINNET` and/or `DEFENDER_API_KEY_TESTNET` to a valid OpenZeppelin Defender Relay key (used for gasless poll voting)
**Optional** Set `DEFENDER_API_SECRET_MAINNET` and/or`DEFENDER_API_SECRET_TESTNET` to a valid OpenZeppelin Defender Relay secret
**Optional** Set `ALCHEMY_ARBITRUM_KEY` to a valid Alchemy API key for the arbitrum network
Expand Down
5 changes: 3 additions & 2 deletions modules/delegates/api/fetchDelegationMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { gqlRequest } from 'modules/gql/gqlRequest';
import { allDelegations } from 'modules/gql/queries/subgraph/allDelegations';
import { SupportedNetworks } from 'modules/web3/constants/networks';
import { networkNameToChainId } from 'modules/web3/helpers/chain';
import { BigNumberWAD } from 'modules/web3/constants/numbers';
import { BigNumberJS } from 'lib/bigNumberJs';

interface DelegationMetrics {
totalMkrDelegated: number;
Expand All @@ -25,8 +27,7 @@ export async function fetchDelegationMetrics(
query: allDelegations
});
const delegations = res.delegations;

const totalMkrDelegated = delegations.reduce((acc, cur) => acc + Number(cur.amount), 0);
const totalMkrDelegated = delegations.reduce((acc, cur) => acc.plus(new BigNumberJS(cur.amount).div(BigNumberWAD)), new BigNumberJS(0)).toNumber();
const delegatorCount = delegations.filter(d => Number(d.amount) > 0).length;

return {
Expand Down
21 changes: 0 additions & 21 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ import { useVotedProposals } from 'modules/executive/hooks/useVotedProposals';
import { fetchLandingPageData } from 'modules/home/api/fetchLandingPageData';
import { LandingPageData } from 'modules/home/api/fetchLandingPageData';
import { useLandingPageDelegates } from 'modules/gql/hooks/useLandingPageDelegates';
import { fetchDelegationMetrics } from 'modules/delegates/api/fetchDelegationMetrics';
import { fetchChainDelegates } from 'modules/delegates/api/fetchChainDelegates';

const LandingPage = ({
proposals,
Expand Down Expand Up @@ -134,25 +132,6 @@ const LandingPage = ({
}
}, []);


useEffect(() => {
const fetchMetrics = async () => {
const metrics = await fetchDelegationMetrics(SupportedNetworks.TENDERLY);
console.log('metrics', metrics);
};

fetchMetrics();
}, []);

useEffect(() => {
const fetchDelegates = async () => {
const chainDelegates = await fetchChainDelegates(SupportedNetworks.TENDERLY);
console.log('chainDelegates', chainDelegates);
};

fetchDelegates();
}, []);

return (
<div>
{delegates.length === 0 && delegatesInfo.length === 0 && polls.length === 0 && (
Expand Down

0 comments on commit 2861219

Please sign in to comment.