From c65b2ef460b3ed5daee602c57da8828bedbcd08d Mon Sep 17 00:00:00 2001 From: tyler17 Date: Fri, 27 Sep 2024 17:24:13 -0700 Subject: [PATCH 1/3] fix issue with delegate history events in delegated to table --- modules/delegates/api/fetchDelegatedTo.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/delegates/api/fetchDelegatedTo.ts b/modules/delegates/api/fetchDelegatedTo.ts index 9c064b087..8cef73e0c 100644 --- a/modules/delegates/api/fetchDelegatedTo.ts +++ b/modules/delegates/api/fetchDelegatedTo.ts @@ -56,7 +56,7 @@ export async function fetchDelegatedTo( // We sum the total of lockAmounts in different events to calculate the current delegated amount if (existing) { existing.lockAmount = utils.formatEther(utils.parseEther(existing.lockAmount).add(lockAmount)); - existing.events.push({ lockAmount, blockTimestamp, hash }); + existing.events.push({ lockAmount: utils.formatEther(lockAmount), blockTimestamp, hash }); } else { const delegatingTo = delegates.find( i => i?.voteDelegate?.toLowerCase() === delegateContractAddress.toLowerCase() @@ -89,7 +89,7 @@ export async function fetchDelegatedTo( isAboutToExpire: !isExpired && isAboutToExpire, lockAmount: utils.formatEther(lockAmount), isRenewed: !!newRenewedContract, - events: [{ lockAmount, blockTimestamp, hash }] + events: [{ lockAmount: utils.formatEther(lockAmount), blockTimestamp, hash }] } as DelegationHistoryWithExpirationDate); } From d2bf13298f6fa96a036c07829deddd601d8a8cbc Mon Sep 17 00:00:00 2001 From: tyler17 Date: Fri, 27 Sep 2024 17:45:10 -0700 Subject: [PATCH 2/3] show expiration date properly in delegated to history --- modules/delegates/api/fetchDelegatedTo.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/delegates/api/fetchDelegatedTo.ts b/modules/delegates/api/fetchDelegatedTo.ts index 8cef73e0c..bd6682324 100644 --- a/modules/delegates/api/fetchDelegatedTo.ts +++ b/modules/delegates/api/fetchDelegatedTo.ts @@ -69,11 +69,11 @@ export async function fetchDelegatedTo( const delegatingToWalletAddress = delegatingTo?.delegate?.toLowerCase(); // Get the expiration date of the delegate - const expirationDate = add(new Date(delegatingTo?.blockTimestamp * 1000), { years: 1 }); + const expirationDate = add(new Date(delegatingTo?.blockTimestamp), { years: 1 }); //only v1 delegate contracts expire - const isAboutToExpire = delegatingTo.version === '1' && isAboutToExpireCheck(expirationDate); - const isExpired = delegatingTo.version === '1' && isExpiredCheck(expirationDate); + const isAboutToExpire = delegatingTo.version !== '2' && isAboutToExpireCheck(expirationDate); + const isExpired = delegatingTo.version !== '2' && isExpiredCheck(expirationDate); // If it has a new owner address, check if it has renewed the contract const newOwnerAddress = getNewOwnerFromPrevious(delegatingToWalletAddress as string, network); From aa718654eb25efad6db8c7702503a317ec3b05f7 Mon Sep 17 00:00:00 2001 From: tyler17 Date: Fri, 27 Sep 2024 21:57:07 -0700 Subject: [PATCH 3/3] fetch up to 1000 entries, and use mainnet subgraph --- modules/gql/queries/subgraph/allDelegations.ts | 2 +- modules/gql/queries/subgraph/delegateHistoryArray.ts | 2 +- modules/gql/queries/subgraph/delegatorHistory.ts | 2 +- modules/web3/constants/networks.ts | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/gql/queries/subgraph/allDelegations.ts b/modules/gql/queries/subgraph/allDelegations.ts index ab04cad64..843618986 100644 --- a/modules/gql/queries/subgraph/allDelegations.ts +++ b/modules/gql/queries/subgraph/allDelegations.ts @@ -7,7 +7,7 @@ import { gql } from 'graphql-request'; export const allDelegations = gql` { - delegations { + delegations(first: 1000) { delegator delegate { id diff --git a/modules/gql/queries/subgraph/delegateHistoryArray.ts b/modules/gql/queries/subgraph/delegateHistoryArray.ts index 87c088484..215ce14ed 100644 --- a/modules/gql/queries/subgraph/delegateHistoryArray.ts +++ b/modules/gql/queries/subgraph/delegateHistoryArray.ts @@ -7,7 +7,7 @@ import { gql } from 'graphql-request'; export const delegateHistoryArray = gql` query delegateHistoryArray($delegates: [String!]!) { - delegates(where: { id_in: $delegates }) { + delegates(first: 1000, where: { id_in: $delegates }) { delegationHistory { amount accumulatedAmount diff --git a/modules/gql/queries/subgraph/delegatorHistory.ts b/modules/gql/queries/subgraph/delegatorHistory.ts index 6db900633..cea74d36c 100644 --- a/modules/gql/queries/subgraph/delegatorHistory.ts +++ b/modules/gql/queries/subgraph/delegatorHistory.ts @@ -8,7 +8,7 @@ import { gql } from 'graphql-request'; export const delegatorHistory = gql` query delegatorHistory($address: String!) { - delegationHistories(where: { delegator: $address }) { + delegationHistories(first: 1000, where: { delegator: $address }) { amount accumulatedAmount delegate { diff --git a/modules/web3/constants/networks.ts b/modules/web3/constants/networks.ts index 291ba8b15..1759fad97 100644 --- a/modules/web3/constants/networks.ts +++ b/modules/web3/constants/networks.ts @@ -17,7 +17,8 @@ import { MAINNET_SPOCK_URL, STAGING_MAINNET_SPOCK_URL, TENDERLY_SPOCK_URL, - TENDERLY_SUBGRAPH_URL + TENDERLY_SUBGRAPH_URL, + MAINNET_SUBGRAPH_URL } from 'modules/gql/gql.constants'; export enum SupportedConnectors { @@ -62,7 +63,7 @@ export const CHAIN_INFO: ChainInfo = { defaultRpc: NodeProviders.ALCHEMY, spockUrl: process.env.NEXT_PUBLIC_VERCEL_ENV === 'development' ? STAGING_MAINNET_SPOCK_URL : MAINNET_SPOCK_URL, - subgraphUrl: TENDERLY_SUBGRAPH_URL, + subgraphUrl: MAINNET_SUBGRAPH_URL, rpcs: { [NodeProviders.INFURA]: `https://mainnet.infura.io/v3/${config.INFURA_KEY}`, [NodeProviders.ALCHEMY]: `https://eth-mainnet.g.alchemy.com/v2/${config.ALCHEMY_KEY}`