Skip to content

Commit

Permalink
feat(@nftx/react): new package
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmellis committed Dec 16, 2022
1 parent 155bdb5 commit 2300d27
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
49 changes: 20 additions & 29 deletions packages/constants/src/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
import { Network } from './networks';

const ROOT = 'https://gateway.thegraph.com/api';
const SHARED_ROOT = 'https://graph-proxy.nftx.xyz/shared';
const PROXY_ROOT = 'https://graph-proxy.nftx.xyz/gateway/api';
const CACHE_PROXY_ROOT = 'https://graph-proxy.nftx.xyz/c/gateway/api';
const GRAPH_API_KEY = '690cf8d6987a151008c2536454bd3d7a';

export const NON_STANDARD_SUBGRAPH = {
[Network.Mainnet]:
'https://thegraph-api.nftx.org/subgraphs/name/0xorg/non-standard-nfts',
[Network.Rinkeby]:
'https://thegraph-api.nftx.org/subgraphs/name/0xorg/non-standard-nfts-rinkeby',
[Network.Mainnet]: `${SHARED_ROOT}/subgraphs/name/0xorg/non-standard-nfts`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/0xorg/non-standard-nfts-rinkeby`,
};

export const ERC721_SUBGRAPH = {
[Network.Mainnet]: `${ROOT}/${GRAPH_API_KEY}/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS`,
[Network.Arbitrum]:
'https://api.thegraph.com/subgraphs/name/quantumlyy/eip721-subgraph-arbitrum',
[Network.Rinkeby]:
'https://api.thegraph.com/subgraphs/name/0xorg/eip721-subgraph-rinkeby',
[Network.Mainnet]: `${PROXY_ROOT}/${GRAPH_API_KEY}/subgraphs/id/AVZ1dGwmRGKsbDAbwvxNmXzeEkD48voB3LfGqj5w7FUS`,
[Network.Arbitrum]: `${SHARED_ROOT}/subgraphs/name/quantumlyy/eip721-subgraph-arbitrum`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/0xorg/eip721-subgraph-rinkeby`,
};

export const ERC1155_SUBGRAPH = {
[Network.Mainnet]: `${ROOT}/${GRAPH_API_KEY}/subgraphs/id/GCQVLurkeZrdMf4t5v5NyeWJY8pHhfE9sinjFMjLYd9C`,
[Network.Arbitrum]:
'https://api.thegraph.com/subgraphs/name/quantumlyy/eip1155-subgraph-arbitrum',
[Network.Rinkeby]:
'https://api.thegraph.com/subgraphs/name/0xorg/eip1155-subgraph-rinkeby',
[Network.Mainnet]: `${PROXY_ROOT}/${GRAPH_API_KEY}/subgraphs/id/GCQVLurkeZrdMf4t5v5NyeWJY8pHhfE9sinjFMjLYd9C`,
[Network.Arbitrum]: `${SHARED_ROOT}/subgraphs/name/quantumlyy/eip1155-subgraph-arbitrum`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/0xorg/eip1155-subgraph-rinkeby`,
};

export const SUSHI_SUBGRAPH = {
[Network.Mainnet]: `${ROOT}/${GRAPH_API_KEY}/subgraphs/id/D7azkFFPFT5H8i32ApXLr34UQyBfxDAfKoCEK4M832M6`,
[Network.Arbitrum]:
'https://api.thegraph.com/subgraphs/name/sushiswap/arbitrum-exchange',
[Network.Rinkeby]:
'https://thegraph-api.nftx.org/subgraphs/name/bilalmir135/sushi-swap-exchange',
[Network.Mainnet]: `${PROXY_ROOT}/${GRAPH_API_KEY}/subgraphs/id/D7azkFFPFT5H8i32ApXLr34UQyBfxDAfKoCEK4M832M6`,
[Network.Arbitrum]: `${SHARED_ROOT}/subgraphs/name/sushiswap/arbitrum-exchange`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/bilalmir135/sushi-swap-exchange`,
};

export const NFTX_SUBGRAPH = {
[Network.Mainnet]: `${ROOT}/${GRAPH_API_KEY}/subgraphs/id/4gZf3atMXjYDh4g48Zr83NFX3rkvZED86VqMNhgEXgLc`,
[Network.Arbitrum]: `https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v2-arbitrum`,
[Network.Rinkeby]: `https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v2-rinkeby`,
[Network.Mainnet]: `${CACHE_PROXY_ROOT}/${GRAPH_API_KEY}/subgraphs/id/4gZf3atMXjYDh4g48Zr83NFX3rkvZED86VqMNhgEXgLc`,
[Network.Arbitrum]: `${SHARED_ROOT}/subgraphs/name/nftx-project/nftx-v2-arbitrum`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/nftx-project/nftx-v2-rinkeby`,
};

export const NFTX_TOKEN_BALANCE_SUBGRAPH = {
[Network.Mainnet]:
'https://api.thegraph.com/subgraphs/name/quantumlyy/nftx-holdings-subgraph-mainnet',
[Network.Arbitrum]:
'https://api.thegraph.com/subgraphs/name/quantumlyy/nftx-holdings-subgraph-arbitrum',
[Network.Rinkeby]:
'https://api.thegraph.com/subgraphs/name/quantumlyy/nftx-holdings-subgraph-rinkeby',
[Network.Mainnet]: `${SHARED_ROOT}/subgraphs/name/quantumlyy/nftx-holdings-subgraph-mainnet`,
[Network.Arbitrum]: `${SHARED_ROOT}/subgraphs/name/quantumlyy/nftx-holdings-subgraph-arbitrum`,
[Network.Rinkeby]: `${SHARED_ROOT}/subgraphs/name/quantumlyy/nftx-holdings-subgraph-rinkeby`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ function fetchVaultActivity({
vaultAddresses?: VaultAddress[];
fromTimestamp?: number;
}) {
return getAll({ network, vaultAddresses, fromTimestamp });
const roundedTimestamp = fromTimestamp
? Math.floor(Math.round(fromTimestamp / 30) * 30)
: undefined;
return getAll({ network, vaultAddresses, fromTimestamp: roundedTimestamp });
}

export default fetchVaultActivity;
10 changes: 7 additions & 3 deletions packages/web3/src/vaults/fetchVaultFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,28 @@ async function fetchVaultFees({
vaultAddresses?: VaultAddress[];
fromTimestamp?: number;
}) {
const roundedTimestamp = fromTimestamp
? Math.floor(Math.round(fromTimestamp / 30) * 30)
: undefined;

if (vaultAddress) {
return fetchSingleVaultFees({
vaultAddress,
fromTimestamp,
fromTimestamp: roundedTimestamp,
network,
});
}
if (vaultAddresses?.length === 1) {
return fetchSingleVaultFees({
vaultAddress: vaultAddresses[0],
fromTimestamp,
fromTimestamp: roundedTimestamp,
network,
});
}
if (vaultAddresses?.length > 1) {
return fetchMultiVaultFees({
vaultAddresses,
fromTimestamp,
fromTimestamp: roundedTimestamp,
network,
});
}
Expand Down

0 comments on commit 2300d27

Please sign in to comment.