diff --git a/src/evmUtils/evmClients.ts b/src/evmUtils/evmClients.ts index 6d844ac..af2d783 100644 --- a/src/evmUtils/evmClients.ts +++ b/src/evmUtils/evmClients.ts @@ -2,6 +2,7 @@ import { Client, createClient, fallback, http } from "viem" import { arbitrum, aurora, + avalanche, base, bob, bsc, @@ -14,6 +15,8 @@ import { mode, sepolia, } from "viem/chains" +import { entries } from "../utils/objectHelper" +import { KnownChainId } from "../utils/types/knownIds" import { ailayer, berachainTestnet, @@ -24,8 +27,6 @@ import { lorenzo, xLayer, } from "./evmChainInfos" -import { KnownChainId } from "../utils/types/knownIds" -import { entries } from "../utils/objectHelper" type EVMChain = KnownChainId.EVMChain const EVMChain = KnownChainId.EVM @@ -153,6 +154,12 @@ export const defaultEvmClients: Partial> = transport: http(), batch: { multicall: true }, }), + + [EVMChain.Avalanche]: createClient({ + chain: avalanche, + transport: http(), + batch: { multicall: true }, + }), } satisfies Record, Client> export const evmChainIdFromKnownChainId = ( diff --git a/src/stacksUtils/crossContractDataMapping.ts b/src/stacksUtils/crossContractDataMapping.ts index 259d68e..69ad35d 100644 --- a/src/stacksUtils/crossContractDataMapping.ts +++ b/src/stacksUtils/crossContractDataMapping.ts @@ -56,6 +56,8 @@ export function contractAssignedChainIdFromKnownChain( return 15n case KnownChainId.EVM.Base: return 16n + case KnownChainId.EVM.Avalanche: + return 17n case KnownChainId.BRC20.Mainnet: case KnownChainId.BRC20.Testnet: return 1001n @@ -166,6 +168,11 @@ export function contractAssignedChainIdToKnownChain( } assertExclude(resPossibilities, KnownChainId.EVM.Base) + if (chainId === 17n) { + return [KnownChainId.EVM.Avalanche] + } + assertExclude(resPossibilities, KnownChainId.EVM.Avalanche) + if (chainId === 1001n) { return [KnownChainId.BRC20.Mainnet, KnownChainId.BRC20.Testnet] } diff --git a/src/utils/swapHelpers/evmDexAggregatorSwapParametersHelpers.ts b/src/utils/swapHelpers/evmDexAggregatorSwapParametersHelpers.ts index 8420398..43c9cf5 100644 --- a/src/utils/swapHelpers/evmDexAggregatorSwapParametersHelpers.ts +++ b/src/utils/swapHelpers/evmDexAggregatorSwapParametersHelpers.ts @@ -30,6 +30,7 @@ export const possibleSwapOnEVMChains = [ KnownChainId.EVM.Arbitrum, KnownChainId.EVM.Linea, KnownChainId.EVM.BSC, + KnownChainId.EVM.Avalanche, ] satisfies KnownChainId.EVMChain[] export interface EVMDexAggregatorSwapParameters { diff --git a/src/utils/swapHelpers/fetchDexAggregatorPossibleRoutes/fetchKyberSwapPossibleRoutes.ts b/src/utils/swapHelpers/fetchDexAggregatorPossibleRoutes/fetchKyberSwapPossibleRoutes.ts index 2c95972..5d1be3a 100644 --- a/src/utils/swapHelpers/fetchDexAggregatorPossibleRoutes/fetchKyberSwapPossibleRoutes.ts +++ b/src/utils/swapHelpers/fetchDexAggregatorPossibleRoutes/fetchKyberSwapPossibleRoutes.ts @@ -183,6 +183,8 @@ function mapSDKChainIdToKyberChainId( return "base" case KnownChainId.EVM.Linea: return "linea" + case KnownChainId.EVM.Avalanche: + return "avalanche" case KnownChainId.EVM.Sepolia: case KnownChainId.EVM.BSCTestnet: case KnownChainId.EVM.CoreDAOTestnet: diff --git a/src/utils/types/knownIds.ts b/src/utils/types/knownIds.ts index 82ea42b..2f9b3cf 100644 --- a/src/utils/types/knownIds.ts +++ b/src/utils/types/knownIds.ts @@ -348,6 +348,12 @@ export namespace KnownChainId { // export const Bera = chainId("evm-bera") /** Represents the Bera testnet chain ID. */ export const BeraTestnet = chainId("evm-bera-testnet") + + // Avalanche + /** Represents the Avalanche mainnet chain ID. */ + export const Avalanche = chainId("evm-avalanche") + /** Represents the Avalanche testnet chain ID. */ + // export const AvalancheTestnet = chainId("evm-avalanche-testnet") } /** Represents a mainnet EVM-compatible blockchain network. */ export type EVMMainnetChain = (typeof _allKnownEVMMainnetChains)[number] @@ -422,6 +428,7 @@ export const _allKnownEVMMainnetChains = [ KnownChainId.EVM.Manta, KnownChainId.EVM.Linea, KnownChainId.EVM.Base, + KnownChainId.EVM.Avalanche, ] as const export const _allKnownEVMTestnetChains = [ KnownChainId.EVM.Sepolia,