Skip to content
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

Fix history amounts, and expiration dates, increase page limit #923

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/delegates/api/fetchDelegatedTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/gql/queries/subgraph/allDelegations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { gql } from 'graphql-request';

export const allDelegations = gql`
{
delegations {
delegations(first: 1000) {
delegator
delegate {
id
Expand Down
2 changes: 1 addition & 1 deletion modules/gql/queries/subgraph/delegateHistoryArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/gql/queries/subgraph/delegatorHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions modules/web3/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}`
Expand Down
Loading