import { Mutable } from 'src/common/utils/types';
import { BLOCKCHAIN_NAME } from 'src/core/blockchain/models/blockchain-name';
import { AlgebraTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/algebra-trade-providers';
import { BridgersTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/bridgers-trade-providers';
import { izumiTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/izumi-trade-providers';
import { pancakeRouterProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/pancake-router-providers';
import { syncSwapTradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/sync-swap-trade-providers';
import { UniswapV2TradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/uniswap-v2-trade-providers';
import { UniswapV3TradeProviders } from 'src/features/on-chain/calculation-manager/constants/trade-providers/uniswap-v3-trade-providers';
import { OnChainTypedTradeProviders } from 'src/features/on-chain/calculation-manager/models/on-chain-typed-trade-provider';

import { vooiTradeProviders } from './vooi-trade-providers';

export const typedTradeProviders: OnChainTypedTradeProviders = [
    ...UniswapV2TradeProviders,
    ...UniswapV3TradeProviders,
    ...AlgebraTradeProviders,
    ...BridgersTradeProviders,
    // ...CurveTradeProviders, Removed because hack
    ...pancakeRouterProviders,
    ...izumiTradeProviders,
    ...vooiTradeProviders,
    ...syncSwapTradeProviders
].reduce(
    (acc, ProviderClass) => {
        const provider = new ProviderClass();
        acc[provider.blockchain][provider.type] = provider;
        return acc;
    },
    Object.values(BLOCKCHAIN_NAME).reduce(
        (acc, blockchain) => ({
            ...acc,
            [blockchain]: {}
        }),
        {} as Mutable<OnChainTypedTradeProviders>
    )
);
