Skip to content

Commit

Permalink
fix: alchemy price source chains
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsambugs committed Dec 28, 2024
1 parent ffe06fc commit 2b6966b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
11 changes: 10 additions & 1 deletion src/services/prices/price-sources/alchemy-price-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ export class AlchemyPriceSource implements IPriceSource {
getBulkHistoricalPrices: false,
getChart: false,
};
const entries = Object.entries(ALCHEMY_NETWORKS).map(([chainId]) => [chainId, support]);
const entries = Object.entries(ALCHEMY_NETWORKS)
.filter(
([
_,
{
price: { supported },
},
]) => supported
)
.map(([chainId]) => [chainId, support]);
return Object.fromEntries(entries);
}

Expand Down
9 changes: 8 additions & 1 deletion src/services/providers/provider-sources/alchemy-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ export class AlchemyProviderSource extends BaseHttpProvider {

export function alchemySupportedChains(args?: { onlyFree?: boolean }): ChainId[] {
return Object.entries(ALCHEMY_NETWORKS)
.filter(([_, { onlyPaid }]) => !onlyPaid || !args?.onlyFree)
.filter(
([
_,
{
rpc: { tier },
},
]) => tier === 'free' || !args?.onlyFree
)
.map(([chainId]) => Number(chainId));
}

Expand Down
48 changes: 21 additions & 27 deletions src/shared/alchemy.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { Chains } from '@chains';
import { ChainId } from '@types';

export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; onlyPaid?: true }> = {
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet' },
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia' },
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet' },
// [Chains.OPTIMISM_SEPOLIA.chainId]: { key: 'opt-sepolia' },
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet' },
// [Chains.ARBITRUM_SEPOLIA.chainId]: { key: 'arb-sepolia' },
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet' },
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai' },
[Chains.ASTAR.chainId]: { key: 'astar-mainnet' },
[Chains.BLAST.chainId]: { key: 'blast-mainnet' },
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', onlyPaid: true },
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', onlyPaid: true },
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet' },
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', onlyPaid: true },
[Chains.POLYGON_ZKEVM.chainId]: { key: 'polygonzkevm-mainnet' },
// [Chains.POLYGON_ZKEVM_TESTNET.chainId]: { key: 'polygonzkevm-testnet' },
[Chains.BASE.chainId]: { key: 'base-mainnet' },
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', onlyPaid: true },
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet' },
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', onlyPaid: true },
// [Chains.BASE_SEPOLIA.chainId]: { key: 'base-sepolia' },
// [Chains.ZKSYNC.chainId]: { key: 'zksync-mainnet' },
// [Chains.ZKSYNC_SEPOLIA.chainId]: { key: 'zksync-sepolia' },
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet' },
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet' },
[Chains.LINEA.chainId]: { key: 'linea-mainnet' },
export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; rpc: { tier: 'free' | 'paid' }; price: { supported: boolean } }> = {
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia', rpc: { tier: 'free' }, price: { supported: false } },
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai', rpc: { tier: 'free' }, price: { supported: false } },
[Chains.ASTAR.chainId]: { key: 'astar-mainnet', rpc: { tier: 'free' }, price: { supported: false } },
[Chains.BLAST.chainId]: { key: 'blast-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', rpc: { tier: 'paid' }, price: { supported: true } },
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', rpc: { tier: 'paid' }, price: { supported: true } },
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', rpc: { tier: 'paid' }, price: { supported: true } },
[Chains.POLYGON_ZKEVM.chainId]: { key: 'polygonzkevm-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.BASE.chainId]: { key: 'base-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', rpc: { tier: 'paid' }, price: { supported: true } },
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', rpc: { tier: 'paid' }, price: { supported: true } },
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet', rpc: { tier: 'free' }, price: { supported: false } },
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet', rpc: { tier: 'free' }, price: { supported: false } },
[Chains.LINEA.chainId]: { key: 'linea-mainnet', rpc: { tier: 'free' }, price: { supported: true } },
};

0 comments on commit 2b6966b

Please sign in to comment.