From 0e65e73380ba74d0c8792f9da5283934dba7b066 Mon Sep 17 00:00:00 2001 From: Jack Ellis Date: Tue, 19 Mar 2024 10:57:31 +0000 Subject: [PATCH] refactor: remove goerli goerli has been all-but-decomissioned so the decision has been made to remove goerli from nftx.js BREAKING CHANGE: all references to goerli have been removed --- packages/config/src/index.ts | 5 +- packages/constants/src/addresses.ts | 13 ---- packages/constants/src/networks.ts | 1 - packages/constants/src/subgraph.ts | 13 +--- packages/constants/src/ticks.ts | 4 - packages/constants/src/urls.ts | 3 - packages/constants/src/values.ts | 3 +- .../assets/fetchUserHoldings/fetchErc1155s.ts | 77 ------------------- .../assets/fetchUserHoldings/fetchErc721s.ts | 77 ------------------- packages/queue/src/constants.ts | 1 - packages/react/src/contexts/nftx.tsx | 4 +- .../src/prices/__tests__/premiums.test.ts | 2 +- 12 files changed, 8 insertions(+), 195 deletions(-) diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index ef0e224d..f79bc471 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -24,7 +24,7 @@ export interface Config { * @example * ERC721_SUBGRAPH: { * [Network.Mainnet]: 'https://my-subgraph-url.com', - * [Network.Goerli]: ['https://try-me-first.com', 'https://try-me-second.com'] + * [Network.Sepolia]: ['https://try-me-first.com', 'https://try-me-second.com'] * } */ subgraph: { @@ -124,7 +124,6 @@ const defaultConfig: Config = { }, contracts: { ethPrice: { - [Network.Goerli]: '2500000000', // $2.5k [Network.Sepolia]: '2000000000', // $2k }, }, @@ -138,13 +137,11 @@ const defaultConfig: Config = { source: 'api', requiredBlockNumber: { [Network.Mainnet]: 0, - [Network.Goerli]: 0, [Network.Sepolia]: 0, [Network.Arbitrum]: 0, }, apiBlockNumber: { [Network.Mainnet]: 0, - [Network.Goerli]: 0, [Network.Sepolia]: 0, [Network.Arbitrum]: 0, }, diff --git a/packages/constants/src/addresses.ts b/packages/constants/src/addresses.ts index f5ac6a7b..c65e609a 100644 --- a/packages/constants/src/addresses.ts +++ b/packages/constants/src/addresses.ts @@ -27,7 +27,6 @@ export const ARTBLOCK_COLLECTIONS = [ export const WETH_TOKEN = { [Network.Mainnet]: a('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), [Network.Arbitrum]: a('0x82af49447d8a07e3bd95bd0d56f35241523fbab1'), - [Network.Goerli]: a('0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6'), [Network.Sepolia]: a('0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14'), }; @@ -35,7 +34,6 @@ export const WETH_TOKEN = { export const USDC = { [Network.Mainnet]: a('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), [Network.Arbitrum]: a('0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'), - [Network.Goerli]: a('0x2f3a40a3db8a7e3d09b0adfefbce4f6f81927557'), [Network.Sepolia]: a('0x2C032Aa43D119D7bf4Adc42583F1f94f3bf3023a'), }; @@ -46,7 +44,6 @@ export const OPENSEA_COLLECTION = a( /** Zap specifically for creating new vaults - CreateVaultZap */ export const CREATE_VAULT_ZAP = { [Network.Mainnet]: a('0x56dab32697B4A313f353DA0CE42B5113eD8E6f74'), - [Network.Goerli]: a('0xc6464CC63bC20b64e1633A0293C2C9b202F4f1b6'), [Network.Sepolia]: a('0xD80b916470F8e79FD8d09874cb159CbB8D13d8da'), [Network.Arbitrum]: a('0xF9E891AB1ECa89B7A4B3cBD45aEBFDF3Ec38946F'), }; @@ -54,7 +51,6 @@ export const CREATE_VAULT_ZAP = { /** Perform buy/sell/swaps - MarketplaceUniversalRouterZap */ export const MARKETPLACE_ZAP = { [Network.Mainnet]: a('0x293A0c49c85F1D8851C665Ac3cE1f1DC2a79bE3d'), - [Network.Goerli]: a('0x0be2D766Eef4b6a72F1fAe2e49619F013d647B8A'), [Network.Sepolia]: a('0xd88a3B9D0Fb2d39ec8394CfFD983aFBB2D4a6410'), [Network.Arbitrum]: a('0xf56296B3010a59Ef7F0915569DD44E1302b9Ca40'), }; @@ -62,7 +58,6 @@ export const MARKETPLACE_ZAP = { /** Stake NFTs or vTokens for xNFTs - NFTXInventoryStakingV3Upgradable */ export const INVENTORY_STAKING = { [Network.Mainnet]: a('0x889f313e2a3FDC1c9a45bC6020A8a18749CD6152'), - [Network.Goerli]: a('0xEf771a17e6970d8B4b208a76e94F175277554230'), [Network.Sepolia]: a('0xfBFf0635f7c5327FD138E1EBa72BD9877A6a7C1C'), [Network.Arbitrum]: a('0xe39a7E67d3E3b6eAF58BC02C4E80C3688847d155'), }; @@ -70,7 +65,6 @@ export const INVENTORY_STAKING = { /** AMM Router - nftxUniversalRouter */ export const NFTX_ROUTER = { [Network.Mainnet]: a('0x250d62a67254A46c0De472d2c9215E1d890cC90f'), - [Network.Goerli]: a('0xF7c4FC5C2e30258e1E4d1197fc63aeDE371508f3'), [Network.Sepolia]: a('0x12156cCA1958B6591CC49EaE03a5553458a4b424'), [Network.Arbitrum]: a('0x4529ad73b2cc8d4db0b0deba90de165e35c4b628'), }; @@ -78,7 +72,6 @@ export const NFTX_ROUTER = { /** Staking / Liquidity / Pools - NftxRouter */ export const POOL_ROUTER = { [Network.Mainnet]: a('0x70A741A12262d4b5Ff45C0179c783a380EebE42a'), - [Network.Goerli]: a('0x8E16cdd0D9A15d2d0EFeA531660e8DbD0F6eE12D'), [Network.Sepolia]: a('0x441b7DE4340AAa5aA86dB4DA43d9Badf7B2DAA66'), [Network.Arbitrum]: a('0x52731751Dede22827ad47109f5e9697d75a3ef4d'), }; @@ -86,7 +79,6 @@ export const POOL_ROUTER = { /** NonfungiblePositionManager */ export const NONFUNGIBLE_POSITION_MANAGER = { [Network.Mainnet]: a('0x26387fcA3692FCac1C1e8E4E2B22A6CF0d4b71bF'), - [Network.Goerli]: a('0xDa9411C5455a1bfDb527d0988c0A2764E2a104be'), [Network.Sepolia]: a('0xA9bCC1e29d3460177875f68fDCC0264D22c40BF0'), [Network.Arbitrum]: a('0x8AD238377531547838370B9C4aC346b9Ed5466Ea'), }; @@ -94,7 +86,6 @@ export const NONFUNGIBLE_POSITION_MANAGER = { /** The permit2 contract, needs an approval signature because the UniversalRouter only transfers tokens from user via Permit2 */ export const PERMIT2 = { [Network.Mainnet]: a('0x000000000022d473030f116ddee9f6b43ac78ba3'), - [Network.Goerli]: a('0x000000000022d473030f116ddee9f6b43ac78ba3'), [Network.Sepolia]: a('0x000000000022d473030f116ddee9f6b43ac78ba3'), [Network.Arbitrum]: a('0x000000000022d473030f116ddee9f6b43ac78ba3'), }; @@ -103,14 +94,12 @@ export const PERMIT2 = { export const ENS_REGISTRAR = { [Network.Mainnet]: a('0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85'), [Network.Arbitrum]: a('0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85'), - [Network.Goerli]: a('0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85'), [Network.Sepolia]: a('0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85'), }; /** UniswapV3FactoryUpgradeable */ export const AMM_FACTORY = { [Network.Mainnet]: a('0xa70e10beB02fF9a44007D9D3695d4b96003db101'), - [Network.Goerli]: a('0xf25081B098c5929A26F562aa2502795fE89BC73f'), [Network.Sepolia]: a('0xDD2dce9C403f93c10af1846543870D065419E70b'), [Network.Arbitrum]: a('0xF4D0512FB47319B0CE9144EF582862e2921CaBF8'), }; @@ -118,7 +107,6 @@ export const AMM_FACTORY = { /** NFTXVaultFactoryUpgradableV3 */ export const VAULT_FACTORY = { [Network.Mainnet]: a('0xC255335bc5aBd6928063F5788a5E420554858f01'), - [Network.Goerli]: a('0x1d552A0e6c2f680872C4a88b1e7def05F1858dF0'), [Network.Sepolia]: a('0x31C56CaF49125043e80B4d3C7f8734f949d8178C'), [Network.Arbitrum]: a('0x4dEeb9D2Bff2e9C35ce1f013DcC4582F891cb711'), }; @@ -127,6 +115,5 @@ export const VAULT_FACTORY = { export const NFTX_FEE_DISTRIBUTOR = { [Network.Mainnet]: a('0xF4d96C5094FCD9eC24E612585e723b58F89e21fe'), [Network.Sepolia]: a('0x66EF5B4b6ee05639194844CE4867515665F14fED'), - [Network.Goerli]: a('0xA8076Ec5Dbb95165e14624Ff43dE2290e78A6905'), [Network.Arbitrum]: a('0x0d50970C7848ebbE52661e70057D7D063B7de886'), }; diff --git a/packages/constants/src/networks.ts b/packages/constants/src/networks.ts index b23e1e2a..9d5a5ca6 100644 --- a/packages/constants/src/networks.ts +++ b/packages/constants/src/networks.ts @@ -1,6 +1,5 @@ export enum Network { Mainnet = 1, Arbitrum = 42_161, - Goerli = 5, Sepolia = 11_155_111, } diff --git a/packages/constants/src/subgraph.ts b/packages/constants/src/subgraph.ts index 8cc4561f..4f1aa966 100644 --- a/packages/constants/src/subgraph.ts +++ b/packages/constants/src/subgraph.ts @@ -20,8 +20,6 @@ export const ERC721_SUBGRAPH = { 'https://gateway-arbitrum.network.thegraph.com/api/49f332ad234c93d2f07d2c085f1ca6d6/subgraphs/id/CBf1FtUKFnipwKVm36mHyeMtkuhjmh4KHzY3uWNNq5ow', [Network.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/nftx-project/721-arbitrum-data-nexus', - [Network.Goerli]: - 'https://api.thegraph.com/subgraphs/name/nftx-project/eip721-looksrare-goerli', [Network.Sepolia]: 'https://api.thegraph.com/subgraphs/name/nftx-project/721-sepolia-data-nexus', }; @@ -31,8 +29,6 @@ export const ERC1155_SUBGRAPH = { 'https://gateway-arbitrum.network.thegraph.com/api/49f332ad234c93d2f07d2c085f1ca6d6/subgraphs/id/5C6JRVzKcE9AVbT7S71EycV8eEGcfkJB9gGsyTbHMVmN', [Network.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/nftx-project/1155-arbitrum-data-nexus', - [Network.Goerli]: - 'https://api.thegraph.com/subgraphs/name/nftx-project/eip1155-looksrare-goerli', [Network.Sepolia]: 'https://api.thegraph.com/subgraphs/name/nftx-project/1155-sepolia-data-nexus', }; @@ -40,9 +36,8 @@ export const ERC1155_SUBGRAPH = { export const NFTX_SUBGRAPH = { [Network.Mainnet]: 'https://graph-proxy.nftx.xyz/nftx-indexer/subgraphs/id/QmTzyQKcTsLq1jLXM4gcEyu9XkRLX7wbJJ5mY4SCHRXgii', - [Network.Arbitrum]: `${SHARED_ROOT}/nftx-project/nftx-v2-arbitrum`, - [Network.Goerli]: - 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-vaults-goerli', + [Network.Arbitrum]: + 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-vaults-arbitrum', [Network.Sepolia]: 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-vaults-sepolia', }; @@ -50,8 +45,8 @@ export const NFTX_SUBGRAPH = { export const NFTX_UNISWAP_SUBGRAPH = { [Network.Mainnet]: 'https://graph-proxy.nftx.xyz/nftx-indexer/subgraphs/id/QmTqJsUzqsmSzkvDeSGDmGYCcVu8v3Tr3j3MqNsTZvVCMm', - [Network.Goerli]: - 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-amm-goerli', [Network.Sepolia]: 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-amm-sepolia', + [Network.Arbitrum]: + 'https://api.thegraph.com/subgraphs/name/nftx-project/nftx-v3-amm-arbitrum', }; diff --git a/packages/constants/src/ticks.ts b/packages/constants/src/ticks.ts index 91df720f..00a06541 100644 --- a/packages/constants/src/ticks.ts +++ b/packages/constants/src/ticks.ts @@ -7,26 +7,22 @@ import { Network } from './networks'; // 0.0001 ETH export const RFBR_MIN_PRICE = { [Network.Mainnet]: 100000000000000n, - [Network.Goerli]: 100000000000000n, [Network.Sepolia]: 100000000000000n, [Network.Arbitrum]: 100000000000000n, }; // 10,000 ETH export const RFBR_MAX_PRICE = { [Network.Mainnet]: 10000000000000000000000n, - [Network.Goerli]: 10000000000000000000000n, [Network.Sepolia]: 10000000000000000000000n, [Network.Arbitrum]: 10000000000000000000000n, }; export const RFBR_MIN_TICK = { [Network.Mainnet]: -92160, - [Network.Goerli]: -92160, [Network.Sepolia]: -92160, [Network.Arbitrum]: -92160, }; export const RFBR_MAX_TICK = { [Network.Mainnet]: 92100, - [Network.Goerli]: 92100, [Network.Sepolia]: 92100, [Network.Arbitrum]: 92100, }; diff --git a/packages/constants/src/urls.ts b/packages/constants/src/urls.ts index 87ad4c67..32eb8891 100644 --- a/packages/constants/src/urls.ts +++ b/packages/constants/src/urls.ts @@ -2,7 +2,6 @@ import { Network } from './networks'; export const NFTX_ROUTER_URL = { [Network.Mainnet]: 'https://api.nftx.xyz/v3/eth-mainnet/quote', - [Network.Goerli]: 'https://api.nftx.xyz/v3/eth-goerli/quote', [Network.Sepolia]: 'https://api.nftx.xyz/v3/eth-sepolia/quote', [Network.Arbitrum]: 'https://api.nftx.xyz/v3/arbitrum-one/quote', }; @@ -10,14 +9,12 @@ export const NFTX_ROUTER_URL = { export const NFTX_APR_URL = { [Network.Mainnet]: 'https://data.nftx.xyz/vaultaprs', [Network.Arbitrum]: 'https://data.nftx.xyz/vaultaprs', - [Network.Goerli]: 'https://data.nftx.xyz/vaultaprs', }; export const NFTX_API_URL = 'https://api-v3.nftx.xyz'; export const RESERVOIR_URL = { [Network.Mainnet]: 'https://api.reservoir.tools', - [Network.Goerli]: 'https://api-goerli.reservoir.tools', [Network.Arbitrum]: 'https://api-arbitrum.reservoir.tools', [Network.Sepolia]: 'https://api-sepolia.reservoir.tools', }; diff --git a/packages/constants/src/values.ts b/packages/constants/src/values.ts index e7adf85e..805b6349 100644 --- a/packages/constants/src/values.ts +++ b/packages/constants/src/values.ts @@ -8,6 +8,5 @@ export const MaxUint256 = export const PREMIUM_DURATION = { [Network.Mainnet]: 36000, // 10 hours [Network.Arbitrum]: 36000, // 10 hours - [Network.Goerli]: 36000, // 10 hours - [Network.Sepolia]: 3600, // 1 hour + [Network.Sepolia]: 36000, // 1 hour }; diff --git a/packages/core/src/assets/fetchUserHoldings/fetchErc1155s.ts b/packages/core/src/assets/fetchUserHoldings/fetchErc1155s.ts index 1fe99867..dce2f83d 100644 --- a/packages/core/src/assets/fetchUserHoldings/fetchErc1155s.ts +++ b/packages/core/src/assets/fetchUserHoldings/fetchErc1155s.ts @@ -62,75 +62,6 @@ const fetchErc1155sMainnet = async ({ const fetchErc1155sSepolia = fetchErc1155sMainnet; -const fetchErc1155sGoerli = async ({ - lastId, - network, - userAddress, - querySubgraph, -}: { - network: number; - lastId: string; - userAddress: Address; - querySubgraph: QuerySubgraph; -}) => { - let holdings: Array = []; - let nextId: string | undefined; - type Response = { - owners: { - id: Address; - totalTokens: string; - tokens: { - tokenID: `${number}`; - collection: { id: Address }; - }[]; - }[]; - }; - - const query = gql`{ - owners( - where: { - id: "${userAddress}" - } - ) { - id - totalTokens - tokens( - first: 1000 - orderBy: tokenID - where: { - tokenID_gt: "${lastId}" - } - ) { - tokenID - collection { - id - } - } - } - }`; - - const data = await querySubgraph({ - url: getChainConstant(config.subgraph.ERC1155_SUBGRAPH, network), - query, - }); - - if (data?.owners?.[0]?.tokens?.length) { - holdings = data.owners[0].tokens.map((x) => { - return { - assetAddress: x.collection.id, - tokenId: BigInt(x.tokenID).toString() as TokenId, - quantity: 1n, - }; - }); - } - if (data?.owners?.[0]?.tokens?.length === 1000) { - nextId = - data.owners?.[0].tokens[data.owners?.[0].tokens.length - 1].tokenID; - } - - return [holdings, nextId] as const; -}; - const fetchErc1155sArbitrum = fetchErc1155sMainnet; export const makeFetchErc1155s = @@ -160,14 +91,6 @@ export const makeFetchErc1155s = querySubgraph, }); break; - case Network.Goerli: - [holdings, nextId] = await fetchErc1155sGoerli({ - lastId, - network, - userAddress, - querySubgraph, - }); - break; case Network.Sepolia: [holdings, nextId] = await fetchErc1155sSepolia({ lastId, diff --git a/packages/core/src/assets/fetchUserHoldings/fetchErc721s.ts b/packages/core/src/assets/fetchUserHoldings/fetchErc721s.ts index defb1f6a..f417053d 100644 --- a/packages/core/src/assets/fetchUserHoldings/fetchErc721s.ts +++ b/packages/core/src/assets/fetchUserHoldings/fetchErc721s.ts @@ -52,75 +52,6 @@ const fetchErc721sMainnet = async ({ const fetchErc721sSepolia = fetchErc721sMainnet; -const fetchErc721sGoerli = async ({ - lastId, - network, - userAddress, - querySubgraph, -}: { - network: number; - lastId: string; - userAddress: Address; - querySubgraph: QuerySubgraph; -}) => { - let holdings: Array = []; - let nextId: string | undefined; - type Response = { - owners: { - id: Address; - totalTokens: string; - tokens: { - tokenID: `${number}`; - collection: { id: Address }; - }[]; - }[]; - }; - - const query = gql`{ - owners( - where: { - id: "${userAddress}" - } - ) { - id - totalTokens - tokens( - first: 1000 - orderBy: tokenID - where: { - tokenID_gt: "${lastId}" - } - ) { - tokenID - collection { - id - } - } - } - }`; - - const data = await querySubgraph({ - url: getChainConstant(config.subgraph.ERC721_SUBGRAPH, network), - query, - }); - - if (data?.owners?.[0]?.tokens?.length) { - holdings = data.owners[0].tokens.map((x) => { - return { - assetAddress: x.collection.id, - tokenId: BigInt(x.tokenID).toString() as TokenId, - quantity: 1n, - }; - }); - } - if (data?.owners?.[0]?.tokens?.length === 1000) { - nextId = - data.owners?.[0].tokens[data.owners?.[0].tokens.length - 1].tokenID; - } - - return [holdings, nextId] as const; -}; - const fetchErc721sArbitrum = fetchErc721sMainnet; export const makeFetchErc721s = @@ -150,14 +81,6 @@ export const makeFetchErc721s = querySubgraph, }); break; - case Network.Goerli: - [holdings, nextId] = await fetchErc721sGoerli({ - lastId, - network, - userAddress, - querySubgraph, - }); - break; case Network.Sepolia: [holdings, nextId] = await fetchErc721sSepolia({ lastId, diff --git a/packages/queue/src/constants.ts b/packages/queue/src/constants.ts index b0e80fd4..d4c9e36f 100644 --- a/packages/queue/src/constants.ts +++ b/packages/queue/src/constants.ts @@ -8,7 +8,6 @@ if (!BULLMQ_REDIS_URI) { export const NETWORK_QUEUE_NAMES = { [Network.Mainnet]: 'indexer-workers-mainnet', - [Network.Goerli]: 'indexer-workers-goerli', [Network.Sepolia]: 'indexer-workers-sepolia', [Network.Arbitrum]: 'indexer-workers-arbitrum', }; diff --git a/packages/react/src/contexts/nftx.tsx b/packages/react/src/contexts/nftx.tsx index 280b3516..5f3a56c7 100644 --- a/packages/react/src/contexts/nftx.tsx +++ b/packages/react/src/contexts/nftx.tsx @@ -9,15 +9,13 @@ import * as core from 'nftx.js'; import { EventsProvider } from './events'; import { Network, Provider, Signer } from 'nftx.js'; import { createPublicClient, http } from 'viem'; -import { arbitrum, mainnet, goerli, sepolia } from 'viem/chains'; +import { arbitrum, mainnet, sepolia } from 'viem/chains'; const getDefaultProvider = (network: number) => { const chain = (() => { switch (network) { case Network.Arbitrum: return arbitrum; - case Network.Goerli: - return goerli; case Network.Sepolia: return sepolia; case Network.Mainnet: diff --git a/packages/utils/src/prices/__tests__/premiums.test.ts b/packages/utils/src/prices/__tests__/premiums.test.ts index 4e9011ab..eabd1fa9 100644 --- a/packages/utils/src/prices/__tests__/premiums.test.ts +++ b/packages/utils/src/prices/__tests__/premiums.test.ts @@ -17,7 +17,7 @@ beforeEach(() => { holding, vTokenToEth, now, - network: Network.Goerli, + network: Network.Sepolia, }); });