diff --git a/apps/scripts/src/config/tokens.ts b/apps/scripts/src/config/tokens.ts index 2ba22d25e..7a6cfd3d2 100644 --- a/apps/scripts/src/config/tokens.ts +++ b/apps/scripts/src/config/tokens.ts @@ -25,7 +25,7 @@ const EMPTY_MAP: TokenConfig["wrappedDetails"] = new Map(); export const DEVNET_SWIMUSD: TokenConfig = { isDisabled: !isPoolRestructureEnabled(), id: "devnet-swimusd", - projectId: TokenProjectId.SwimLpSolanaUsdcUsdt, + projectId: TokenProjectId.SwimUsd, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "5ctnNpb7h1SyPqZ8t8m2kCykrtDGVZBtZgYWv6UAeDhr", // TODO: Update diff --git a/apps/ui/package.json b/apps/ui/package.json index a87d9fba5..883903dea 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -34,6 +34,11 @@ "last 1 safari version" ] }, + "jest": { + "moduleNameMapper": { + "!!url-loader!.+\\.svg": "/src/__mocks__/base64Mock.ts" + } + }, "engines": { "node": "^16" }, @@ -51,13 +56,13 @@ "@solana/spl-token": "^0.3.5", "@solana/web3.js": "^1.62.0", "@swim-io/aptos": "^0.40.0", - "@swim-io/core": "^0.40.0", - "@swim-io/evm": "^0.40.0", + "@swim-io/core": "workspace:^", + "@swim-io/evm": "workspace:^", "@swim-io/evm-contracts": "^0.40.0", "@swim-io/pool-math": "^0.40.0", - "@swim-io/solana": "^0.40.0", + "@swim-io/solana": "workspace:^", "@swim-io/solana-contracts": "^0.40.0", - "@swim-io/token-projects": "^0.40.0", + "@swim-io/token-projects": "workspace:^", "@swim-io/utils": "^0.40.0", "@swim-io/wormhole": "^0.40.0", "bn.js": "^5.2.1", diff --git a/apps/ui/src/__mocks__/base64Mock.ts b/apps/ui/src/__mocks__/base64Mock.ts new file mode 100644 index 000000000..ad3e322ef --- /dev/null +++ b/apps/ui/src/__mocks__/base64Mock.ts @@ -0,0 +1,2 @@ +const dataUrl = "base64"; +export default dataUrl; diff --git a/apps/ui/src/components/AddForm.tsx b/apps/ui/src/components/AddForm.tsx index 5d1287552..af68f3d2c 100644 --- a/apps/ui/src/components/AddForm.tsx +++ b/apps/ui/src/components/AddForm.tsx @@ -13,7 +13,6 @@ import { EuiText, } from "@elastic/eui"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { filterMap, isEachNotNull, isNotNull } from "@swim-io/utils"; import type Decimal from "decimal.js"; import type { FormEvent, ReactElement } from "react"; @@ -21,13 +20,14 @@ import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import shallow from "zustand/shallow.js"; +import type { EcosystemId, PoolSpec, TokenConfig } from "../config"; import { DISABLED_ECOSYSTEMS, ECOSYSTEMS, ECOSYSTEM_IDS, + getTokenProject, isEcosystemEnabled, } from "../config"; -import type { EcosystemId, PoolSpec, TokenConfig } from "../config"; import { selectConfig } from "../core/selectors"; import { useEnvironment, useNotification } from "../core/store"; import { captureAndWrapException } from "../errors"; @@ -86,7 +86,7 @@ const TokenAddPanel = ({ onBlur, }: TokenAddPanelProps): ReactElement => { const { t } = useTranslation(); - const tokenProject = TOKEN_PROJECTS_BY_ID[tokenConfig.projectId]; + const tokenProject = getTokenProject(tokenConfig.projectId); const balance = useUserBalanceAmount(tokenConfig, ecosystemId); return ( { const ecosystem = ECOSYSTEMS[ecosystemId]; return { @@ -499,7 +499,7 @@ export const AddForm = ({ } }; - const lpTokenProject = TOKEN_PROJECTS_BY_ID[lpToken.projectId]; + const lpTokenProject = getTokenProject(lpToken.projectId); const receiveLabel = poolSpec.isStakingPool ? t("add_token_form.choose_receive_tokens_on", { tokenSymbol: lpTokenProject.symbol, diff --git a/apps/ui/src/components/EuiFieldIntlNumber.tsx b/apps/ui/src/components/EuiFieldIntlNumber.tsx index af5383757..6d5f64ec0 100644 --- a/apps/ui/src/components/EuiFieldIntlNumber.tsx +++ b/apps/ui/src/components/EuiFieldIntlNumber.tsx @@ -2,6 +2,7 @@ /* eslint-disable react/prop-types */ import { EuiFieldNumber } from "@elastic/eui"; +import type { Override } from "@swim-io/utils"; import escapeStringRegexp from "escape-string-regexp"; import type { ComponentProps } from "react"; import { forwardRef, useCallback } from "react"; @@ -17,7 +18,6 @@ const MappedEuiFieldNumber = forwardRef< return ; }); -type Override = Omit & U; type Props = Override< Omit, "customInput" | "onChange">, { diff --git a/apps/ui/src/components/PoolListItem.tsx b/apps/ui/src/components/PoolListItem.tsx index 369bab1de..efdc3138d 100644 --- a/apps/ui/src/components/PoolListItem.tsx +++ b/apps/ui/src/components/PoolListItem.tsx @@ -8,7 +8,6 @@ import { EuiTitle, EuiToolTip, } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { chunks } from "@swim-io/utils"; import Decimal from "decimal.js"; import type { ReactElement } from "react"; @@ -17,6 +16,7 @@ import { useNavigate } from "react-router-dom"; import { atomicToCurrencyString } from "../amounts"; import type { PoolSpec, TokenConfig } from "../config"; +import { getTokenProject } from "../config"; import { i18next } from "../i18n"; import { TokenIcon } from "./TokenIcon"; @@ -92,7 +92,7 @@ export const PoolListItem = ({ style={{ margin: flexItemMargin }} > { const ecosystem = ECOSYSTEMS[ecosystemId]; const lpBalance = userLpBalances[ecosystemId]; @@ -396,7 +395,7 @@ export const RemoveForm = ({ ); return { value: id, - text: `${TOKEN_PROJECTS_BY_ID[tokenConfig.projectId].displayName} (${ + text: `${getTokenProject(tokenConfig.projectId).displayName} (${ ECOSYSTEMS[tokenConfig.nativeEcosystemId].displayName })`, }; @@ -642,7 +641,7 @@ export const RemoveForm = ({ } }; - const lpTokenProject = TOKEN_PROJECTS_BY_ID[lpToken.projectId]; + const lpTokenProject = getTokenProject(lpToken.projectId); const maximumLpBurnLabel = poolSpec.isStakingPool ? t("remove_token_form.max_required_lp_tokens", { tokenSymbol: lpTokenProject.symbol, @@ -814,7 +813,7 @@ export const RemoveForm = ({ prepend={ } diff --git a/apps/ui/src/components/SwapForm/SwapForm.tsx b/apps/ui/src/components/SwapForm/SwapForm.tsx index e71d75a38..bfb74ed37 100644 --- a/apps/ui/src/components/SwapForm/SwapForm.tsx +++ b/apps/ui/src/components/SwapForm/SwapForm.tsx @@ -8,7 +8,6 @@ import { } from "@elastic/eui"; import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { defaultIfError, isEachNotNull } from "@swim-io/utils"; import type Decimal from "decimal.js"; import type { FormEvent, ReactElement, ReactNode } from "react"; @@ -16,6 +15,7 @@ import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import shallow from "zustand/shallow.js"; +import { getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment, useNotification } from "../../core/store"; import { captureAndWrapException } from "../../errors"; @@ -110,7 +110,7 @@ export const SwapForm = ({ maxSlippageFraction }: Props): ReactElement => { const isLargeSwap = useIsLargeSwap(fromToken, toToken, inputAmount); const isSmallEthSwap = - TOKEN_PROJECTS_BY_ID[fromToken.projectId].isStablecoin && + getTokenProject(fromToken.projectId).isStablecoin && [fromToken.nativeEcosystemId, toToken.nativeEcosystemId].includes( EvmEcosystemId.Ethereum, ) && diff --git a/apps/ui/src/components/SwapFormV2/SwapFormV2.tsx b/apps/ui/src/components/SwapFormV2/SwapFormV2.tsx index 30ad0f39c..72b6ac257 100644 --- a/apps/ui/src/components/SwapFormV2/SwapFormV2.tsx +++ b/apps/ui/src/components/SwapFormV2/SwapFormV2.tsx @@ -8,7 +8,6 @@ import { } from "@elastic/eui"; import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { defaultIfError } from "@swim-io/utils"; import Decimal from "decimal.js"; import type { FormEvent, ReactElement, ReactNode } from "react"; @@ -16,7 +15,7 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; import shallow from "zustand/shallow.js"; -import { getTokenDetailsForEcosystem } from "../../config"; +import { getTokenDetailsForEcosystem, getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment, useNotification } from "../../core/store"; import { captureAndWrapException } from "../../errors"; @@ -109,7 +108,7 @@ export const SwapFormV2 = ({ maxSlippageFraction }: Props): ReactElement => { maxSlippageFraction, ); const isSmallEthSwap = - TOKEN_PROJECTS_BY_ID[fromTokenConfig.projectId].isStablecoin && + getTokenProject(fromTokenConfig.projectId).isStablecoin && [fromTokenOption.ecosystemId, toTokenOption.ecosystemId].includes( EvmEcosystemId.Ethereum, ) && diff --git a/apps/ui/src/components/TokenIcon.tsx b/apps/ui/src/components/TokenIcon.tsx index b2b61a417..5e20b17e1 100644 --- a/apps/ui/src/components/TokenIcon.tsx +++ b/apps/ui/src/components/TokenIcon.tsx @@ -1,12 +1,11 @@ import { EuiIcon } from "@elastic/eui"; import type { TokenProject } from "@swim-io/token-projects"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type { ComponentProps, ReactElement } from "react"; import { Fragment } from "react"; import { Trans } from "react-i18next"; import type { EcosystemId, TokenConfig } from "../config"; -import { ECOSYSTEMS } from "../config"; +import { ECOSYSTEMS, getTokenProject } from "../config"; import { useIntlListSeparators } from "../hooks"; import type { Amount } from "../models/amount"; @@ -117,7 +116,7 @@ export const TokenConfigIcon = ({ ecosystem, }: TokenConfigIconProps): ReactElement => ( ); @@ -125,5 +124,5 @@ export const TokenConfigIcon = ({ export const TokenSearchConfigIcon = ({ token, }: Pick): ReactElement => ( - + ); diff --git a/apps/ui/src/components/TokenSearchModal.tsx b/apps/ui/src/components/TokenSearchModal.tsx index 06577f061..1b7bc1648 100644 --- a/apps/ui/src/components/TokenSearchModal.tsx +++ b/apps/ui/src/components/TokenSearchModal.tsx @@ -9,14 +9,18 @@ import { EuiSelectable, } from "@elastic/eui"; import type { EuiSelectableOption } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { useCallback } from "react"; import type { ReactElement } from "react"; import { useTranslation } from "react-i18next"; import shallow from "zustand/shallow.js"; import type { EcosystemId, TokenConfig } from "../config"; -import { ECOSYSTEM_LIST, isEcosystemEnabled, isSwimUsd } from "../config"; +import { + ECOSYSTEM_LIST, + getTokenProject, + isEcosystemEnabled, + isSwimUsd, +} from "../config"; import { selectConfig } from "../core/selectors"; import { useEnvironment } from "../core/store"; import { useUserBalanceAmount } from "../hooks"; @@ -88,7 +92,7 @@ export const TokenSearchModal = ({ ); const options = filteredTokens.map((token) => { - const tokenProject = TOKEN_PROJECTS_BY_ID[token.projectId]; + const tokenProject = getTokenProject(token.projectId); return { label: `${tokenProject.symbol}`, searchableLabel: `${tokenProject.symbol} ${tokenProject.displayName}`, diff --git a/apps/ui/src/components/molecules/AddTransfer.tsx b/apps/ui/src/components/molecules/AddTransfer.tsx index 352f79491..daedc2c33 100644 --- a/apps/ui/src/components/molecules/AddTransfer.tsx +++ b/apps/ui/src/components/molecules/AddTransfer.tsx @@ -1,10 +1,10 @@ import { EuiLoadingSpinner, EuiText } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { filterMap } from "@swim-io/utils"; import type { VFC } from "react"; import { useTranslation } from "react-i18next"; import type { EcosystemId, TokenConfig } from "../../config"; +import { getTokenProject } from "../../config"; import { useIntlListFormatter } from "../../hooks"; import type { Amount } from "../../models"; @@ -29,11 +29,11 @@ export const AddTransfer: VFC = ({ const listFormatter = useIntlListFormatter(); const nonZeroInputTokens = filterMap( (amount: Amount) => !amount.isZero(), - (amount) => TOKEN_PROJECTS_BY_ID[amount.tokenConfig.projectId].symbol, + (amount) => getTokenProject(amount.tokenConfig.projectId).symbol, fromAmounts, ); const inputTokenNames = listFormatter.format(nonZeroInputTokens); - const outputTokenName = TOKEN_PROJECTS_BY_ID[toToken.projectId].symbol; + const outputTokenName = getTokenProject(toToken.projectId).symbol; return ( diff --git a/apps/ui/src/components/molecules/ClaimSwimUsdOnSolana.tsx b/apps/ui/src/components/molecules/ClaimSwimUsdOnSolana.tsx index 3590727b0..88252ed46 100644 --- a/apps/ui/src/components/molecules/ClaimSwimUsdOnSolana.tsx +++ b/apps/ui/src/components/molecules/ClaimSwimUsdOnSolana.tsx @@ -1,9 +1,9 @@ import { EuiLoadingSpinner, EuiText } from "@elastic/eui"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type { VFC } from "react"; import { useTranslation } from "react-i18next"; +import { getTokenProject } from "../../config"; import { useSwimUsd } from "../../hooks"; import { TxEcosystemList } from "./TxList"; @@ -30,7 +30,7 @@ export const ClaimSwimUsdOnSolana: VFC = ({ {isLoading && } {t("recent_interactions.claim_token_on_solana", { - tokenName: TOKEN_PROJECTS_BY_ID[swimUsd.projectId].displayName, + tokenName: getTokenProject(swimUsd.projectId).displayName, })} diff --git a/apps/ui/src/components/molecules/RemoveTransfer.tsx b/apps/ui/src/components/molecules/RemoveTransfer.tsx index 8eb4041da..e104fad11 100644 --- a/apps/ui/src/components/molecules/RemoveTransfer.tsx +++ b/apps/ui/src/components/molecules/RemoveTransfer.tsx @@ -1,10 +1,10 @@ import { EuiLoadingSpinner, EuiText } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { filterMap } from "@swim-io/utils"; import type { VFC } from "react"; import { useTranslation } from "react-i18next"; import type { EcosystemId, TokenConfig } from "../../config"; +import { getTokenProject } from "../../config"; import { useIntlListFormatter } from "../../hooks"; import type { Amount } from "../../models"; @@ -29,11 +29,11 @@ export const RemoveTransfer: VFC = ({ const listFormatter = useIntlListFormatter(); const nonZeroOutputTokens = filterMap( (amount: Amount) => !amount.isZero(), - (amount) => TOKEN_PROJECTS_BY_ID[amount.tokenConfig.projectId].symbol, + (amount) => getTokenProject(amount.tokenConfig.projectId).symbol, toAmounts, ); const outputTokenNames = listFormatter.format(nonZeroOutputTokens); - const inputTokenName = TOKEN_PROJECTS_BY_ID[fromToken.projectId].symbol; + const inputTokenName = getTokenProject(fromToken.projectId).symbol; return ( diff --git a/apps/ui/src/components/molecules/SwapTransfer.tsx b/apps/ui/src/components/molecules/SwapTransfer.tsx index 776f4e381..181f1936a 100644 --- a/apps/ui/src/components/molecules/SwapTransfer.tsx +++ b/apps/ui/src/components/molecules/SwapTransfer.tsx @@ -1,10 +1,9 @@ import { EuiLoadingSpinner, EuiText } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type { VFC } from "react"; import { useTranslation } from "react-i18next"; import type { EcosystemId, TokenConfig } from "../../config"; -import { ECOSYSTEMS } from "../../config"; +import { ECOSYSTEMS, getTokenProject } from "../../config"; import { TxEcosystemList } from "./TxList"; @@ -30,9 +29,8 @@ export const SwapTransfer: VFC = ({ {isLoading && } {t("recent_interactions.swap_token_from_x_to_y", { - fromTokenName: - TOKEN_PROJECTS_BY_ID[fromToken.projectId].displayName, - toTokenName: TOKEN_PROJECTS_BY_ID[toToken.projectId].displayName, + fromTokenName: getTokenProject(fromToken.projectId).displayName, + toTokenName: getTokenProject(toToken.projectId).displayName, ecosystemName: ECOSYSTEMS[ecosystemId].displayName, })} diff --git a/apps/ui/src/components/molecules/Transfer/Transfer.tsx b/apps/ui/src/components/molecules/Transfer/Transfer.tsx index 09ec7e22d..cdcc85d42 100644 --- a/apps/ui/src/components/molecules/Transfer/Transfer.tsx +++ b/apps/ui/src/components/molecules/Transfer/Transfer.tsx @@ -1,10 +1,9 @@ import { EuiLoadingSpinner, EuiText } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type { VFC } from "react"; import { useTranslation } from "react-i18next"; import type { EcosystemId, TokenConfig } from "../../../config"; -import { ECOSYSTEMS } from "../../../config"; +import { ECOSYSTEMS, getTokenProject } from "../../../config"; import { TxList } from "../TxList"; interface Props { @@ -32,7 +31,7 @@ export const Transfer: VFC = ({ {isLoading && } {t("recent_interactions.transfer_token_from_x_to_y", { - tokenName: TOKEN_PROJECTS_BY_ID[token.projectId].displayName, + tokenName: getTokenProject(token.projectId).displayName, fromEcosystemName: ECOSYSTEMS[from].displayName, toEcosystemName: ECOSYSTEMS[to].displayName, })} diff --git a/apps/ui/src/config/chains.ts b/apps/ui/src/config/chains.ts index bf88b329d..5bd511967 100644 --- a/apps/ui/src/config/chains.ts +++ b/apps/ui/src/config/chains.ts @@ -2,8 +2,14 @@ import type { AptosChainConfig } from "@swim-io/aptos"; import { APTOS_ECOSYSTEM_ID, aptos } from "@swim-io/aptos"; import { Env } from "@swim-io/core"; import type { EvmChainConfig } from "@swim-io/evm"; +import { EvmEcosystemId } from "@swim-io/evm"; +import type { SolanaChainConfig } from "@swim-io/solana"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import type { ReadonlyRecord } from "@swim-io/utils"; + +import type { EcosystemId } from "./ecosystem"; +import { Protocol } from "./ecosystem"; import { - EvmEcosystemId, acala, aurora, avalanche, @@ -12,13 +18,8 @@ import { fantom, karura, polygon, -} from "@swim-io/evm"; -import type { SolanaChainConfig } from "@swim-io/solana"; -import { SOLANA_ECOSYSTEM_ID, solana } from "@swim-io/solana"; -import type { ReadonlyRecord } from "@swim-io/utils"; - -import type { EcosystemId } from "./ecosystem"; -import { Protocol } from "./ecosystem"; + solana, +} from "./ecosystems"; export const enum EvmChainId { EthereumMainnet = 1, diff --git a/apps/ui/src/config/ecosystems/acala.ts b/apps/ui/src/config/ecosystems/acala.ts new file mode 100644 index 000000000..c94b3ff1b --- /dev/null +++ b/apps/ui/src/config/ecosystems/acala.ts @@ -0,0 +1,74 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { acala as acalaFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...acalaFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-acala-ausd", + projectId: TokenProjectIdV1.Ausd, + nativeDetails: { + address: "0x0000000000000000000000000000000000000000", // TODO: Update + decimals: 6, // TODO: Update + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "11111111111111111111111111111112", // TODO: Update + decimals: 6, // TODO: Update + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...acalaFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-acala-ausd", + projectId: TokenProjectIdV1.Ausd, + nativeDetails: { + address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", + decimals: 12, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "BbdPh2Nvpp7XftBHWENJu5dpC5gF5FtCSyFLTU4qNr7g", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-acala-lp-ausd", + projectId: TokenProjectIdV2.SwimLpAcalaAusd, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const acala = assertType>()({ + ...acalaFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/aurora.ts b/apps/ui/src/config/ecosystems/aurora.ts new file mode 100644 index 000000000..0f2c48059 --- /dev/null +++ b/apps/ui/src/config/ecosystems/aurora.ts @@ -0,0 +1,152 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { aurora as auroraFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...auroraFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-aurora-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "9Y8pJhF8AQGBGL5PTd12P4w82n2qAADTmWakkXSatdAu", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-aurora-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x4988a896b1227218e4A686fdE5EabdcAbd91571f", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "GFhej2oJ1NPLbzSX3D3B9jzYaidff6NoBAUNmu6dLXwU", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-aurora-usn", + projectId: TokenProjectIdV1.Usn, + nativeDetails: { + address: "0x5183e1B1091804BC2602586919E6880ac1cf2896", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "3NDmtc2xKMpm8wCiaALey2y3EGhBkUNuXJ9m3JcjnHMM", + decimals: 8, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...auroraFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-aurora-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "B3qmqCvzbni27z5TRrt1uBYMczUCjCjui7piGAZifSTU", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-aurora-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "BaTEf2Mnrf9wePKb9g9BtSPkrZmmBnR6K9Q1ZxDKmWoh", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-aurora-usn", + projectId: TokenProjectIdV1.Usn, + nativeDetails: { + address: "0x0000000000000000000000000000000000000000", // TODO: Update + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "11111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-aurora-lp-usdc-usdt", + projectId: TokenProjectIdV2.SwimLpAuroraUsdcUsdt, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + { + id: "testnet-aurora-lp-usn", + projectId: TokenProjectIdV2.SwimLpAuroraUsn, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const aurora = assertType>()( + { + ...auroraFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, + } as const, +); diff --git a/apps/ui/src/config/ecosystems/avalanche.ts b/apps/ui/src/config/ecosystems/avalanche.ts new file mode 100644 index 000000000..400230c7a --- /dev/null +++ b/apps/ui/src/config/ecosystems/avalanche.ts @@ -0,0 +1,110 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { avalanche as avalancheFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...avalancheFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-avalanche-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "FHfba3ov5P3RjaiLVgh8FTv4oirxQDoVXuoUUDvHuXax", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-avalanche-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "Kz1csQA91WUGcQ2TB3o5kdGmWmMGp8eJcDEyHzNDVCX", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...avalancheFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-avalanche-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "2t6pVTufn9A4b37oLmex3YMjm3smp1G9tPd9HpAFSeka", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-avalanche-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "9ibet2CuBX1a4HpbzH9auxxtyUvkSKVy39jWtZY5Bfor", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-avalanche-lp-usdc-usdt", + projectId: TokenProjectIdV2.SwimLpAvalancheUsdcUsdt, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const avalanche = assertType< + EvmEcosystemConfigV1 +>()({ + ...avalancheFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/bnb.ts b/apps/ui/src/config/ecosystems/bnb.ts new file mode 100644 index 000000000..943589e21 --- /dev/null +++ b/apps/ui/src/config/ecosystems/bnb.ts @@ -0,0 +1,218 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { bnb as bnbFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...bnbFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-bnb-busd", + projectId: TokenProjectIdV1.Busd, + nativeDetails: { + address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2", + decimals: 8, + }, + ], + ]), + }, + { + id: "mainnet-bnb-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x55d398326f99059ff775485246999027b3197955", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "8qJSyQprMC57TWKaYEmetUR3UUiTP2M3hXdcvFhkZdmv", + decimals: 8, + }, + ], + ]), + }, + { + id: "mainnet-bnb-gst", + projectId: TokenProjectIdV1.Gst, + nativeDetails: { + address: "0x4a2c860cec6471b9f5f5a336eb4f38bb21683c98", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "GDuUFXEhUm4jG71vPxYRX3VxUMJ5etGvHTR1iKwTdb6p", + decimals: 8, + }, + ], + ]), + }, + { + id: "mainnet-bnb-gmt", + projectId: TokenProjectIdV1.Gmt, + nativeDetails: { + address: "0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "7dzFD8xQ3FDmVLxwn75UA9WhVnBsUdRAexASVvpXX3Bo", + decimals: 8, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...bnbFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-bnb-busd", + projectId: TokenProjectIdV1.Busd, + nativeDetails: { + address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "6KTvgrkLoPJdB3Grv4ZBUGt6JiLdVnKzJNo4HvLEgm6d", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-bnb-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x98529E942FD121d9C470c3d4431A008257E0E714", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "4dr6ogcLsaFf2RDF4LJU1CvNtNKxonVqQvM6vuGdVR1e", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-bnb-gst", + projectId: TokenProjectIdV1.Gst, + nativeDetails: { + address: "0x73160078948280B8680e5F1eB2964698928E8cd7", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "6oAiihJq1urtb6P8ARjwA6TFoduSoVGxaMb8gEMm5cR6", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-bnb-gmt", + projectId: TokenProjectIdV1.Gmt, + nativeDetails: { + address: "0x1F65D61D01E3f10b34B855287b32D7bfbEA088D0", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "GE2tiQBCoPjCABkoTXa9jTSV8zCVZo8shyiBh8v52hDz", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-bnb-lp-busd-usdt", + projectId: TokenProjectIdV2.SwimLpBnbBusdUsdt, + nativeDetails: { + address: "0x57FCF9B276d3E7D698112D9b87e6f410B1B5d78d", // TODO: Update + decimals: 6, + }, + }, + ], + pools: [], +}; + +const localnet: EvmChainConfigV1 = { + ...bnbFromSdk.chains[Env.Local], + tokens: [ + { + id: "local-bnb-busd", + projectId: TokenProjectIdV1.Busd, + nativeDetails: { + address: "0xCeeFD27e0542aFA926B87d23936c79c276A48277", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "4X3Fu7ZcRSf7dvKEwwQ8b5xb2jQg2NPNkWs1gDGf1WMg", + decimals: 8, + }, + ], + ]), + }, + { + id: "local-bnb-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x988B6CFBf3332FF98FFBdED665b1F53a61f92612", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "9idXDPGb5jfwaf5fxjiMacgUcwpy3ZHfdgqSjAV5XLDr", + decimals: 8, + }, + ], + ]), + }, + ], + pools: [], +}; + +export const bnb = assertType>()({ + ...bnbFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + [Env.Local]: localnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/ethereum.ts b/apps/ui/src/config/ecosystems/ethereum.ts new file mode 100644 index 000000000..6681b42e3 --- /dev/null +++ b/apps/ui/src/config/ecosystems/ethereum.ts @@ -0,0 +1,152 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { ethereum as ethereumFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...ethereumFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-ethereum-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-ethereum-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0xdac17f958d2ee523a2206206994597c13d831ec7", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...ethereumFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-ethereum-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x45B167CF5b14007Ca0490dCfB7C4B870Ec0C0Aa6", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-ethereum-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "8Cfyi1mYXqKATUkMPvb9BMXikdbppJst6E7eQJkKjAtf", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-ethereum-lp-usdc-usdt", + projectId: TokenProjectIdV2.SwimLpEthereumUsdcUsdt, + nativeDetails: { + address: "0xf3eb1180A64827A602A7e02883b7299191527073", // TODO: Update + decimals: 6, + }, + }, + ], + pools: [], +}; + +const localnet: EvmChainConfigV1 = { + ...ethereumFromSdk.chains[Env.Local], + tokens: [ + { + id: "local-ethereum-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0xFcCeD5E997E7fb1D0594518D3eD57245bB8ed17E", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "Ep9cMbgyG46b6PVvJNypopc6i8TFzvUVmGiT4MA1PhSb", + decimals: 6, + }, + ], + ]), + }, + { + id: "local-ethereum-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0xdAA71FBBA28C946258DD3d5FcC9001401f72270F", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "9AGDY4Xa9wDfRZc2LHeSS9iAdH6Bhw6VnMd2t7tkJhYv", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +export const ethereum = assertType< + EvmEcosystemConfigV1 +>()({ + ...ethereumFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + [Env.Local]: localnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/fantom.ts b/apps/ui/src/config/ecosystems/fantom.ts new file mode 100644 index 000000000..e78bf6fc7 --- /dev/null +++ b/apps/ui/src/config/ecosystems/fantom.ts @@ -0,0 +1,76 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { fantom as fantomFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...fantomFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-fantom-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "Dnr8fDaswHtYMSKbtR9e8D5EadyxqyJwE98xp17ZxE2E", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...fantomFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-fantom-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "9uJH6SjzmoqdiZXjcwYKuRevbYh5tR449FU5pg4rpden", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-fantom-lp-usdc", + projectId: TokenProjectIdV2.SwimLpFantomUsdc, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const fantom = assertType>()( + { + ...fantomFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, + } as const, +); diff --git a/apps/ui/src/config/ecosystems/index.ts b/apps/ui/src/config/ecosystems/index.ts new file mode 100644 index 000000000..0e49d5543 --- /dev/null +++ b/apps/ui/src/config/ecosystems/index.ts @@ -0,0 +1,9 @@ +export { acala } from "./acala"; +export { aurora } from "./aurora"; +export { avalanche } from "./avalanche"; +export { bnb } from "./bnb"; +export { ethereum } from "./ethereum"; +export { fantom } from "./fantom"; +export { karura } from "./karura"; +export { polygon } from "./polygon"; +export { solana } from "./solana"; diff --git a/apps/ui/src/config/ecosystems/karura.ts b/apps/ui/src/config/ecosystems/karura.ts new file mode 100644 index 000000000..bd145e751 --- /dev/null +++ b/apps/ui/src/config/ecosystems/karura.ts @@ -0,0 +1,118 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { karura as karuraFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...karuraFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-karura-ausd", + projectId: TokenProjectIdV1.Ausd, + nativeDetails: { + address: "0x0000000000000000000100000000000000000081", + decimals: 12, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "3sEvyXzC2vAPqF7uprB2vRaL1X1FbqQqmPxhwVi53GYF", + decimals: 8, + }, + ], + ]), + }, + { + id: "mainnet-karura-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x0000000000000000000500000000000000000007", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "E942z7FnS7GpswTvF5Vggvo7cMTbvZojjLbFgsrDVff1", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...karuraFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-karura-ausd", + projectId: TokenProjectIdV1.Ausd, + nativeDetails: { + address: "0x074370ca8Fea9e8f1C5eE23f34CBdcD3FB7a66aD", + decimals: 12, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "BRpsJtEUyCPQPRP4DAavXU5KmBqfgKQmX7fwnpVvUUMG", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-karura-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x535d5e3b1ff7de526fe180e654a41350903c328d", + decimals: 18, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "AnYj8Rbkfd8FYmoiyv6iDS3Tje7PzhPWyE5VZVDh9pzD", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-karura-lp-usdt", + projectId: TokenProjectIdV2.SwimLpKaruraUsdt, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + { + id: "testnet-karura-lp-ausd", + projectId: TokenProjectIdV2.SwimLpKaruraAusd, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const karura = assertType>()( + { + ...karuraFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, + } as const, +); diff --git a/apps/ui/src/config/ecosystems/polygon.ts b/apps/ui/src/config/ecosystems/polygon.ts new file mode 100644 index 000000000..e9b12edea --- /dev/null +++ b/apps/ui/src/config/ecosystems/polygon.ts @@ -0,0 +1,110 @@ +import { Env } from "@swim-io/core"; +import type { EvmEcosystemId } from "@swim-io/evm"; +import { polygon as polygonFromSdk } from "@swim-io/evm"; +import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; +import { assertType } from "@swim-io/utils"; + +import { TokenProjectIdV1 } from "../tokenProjects"; + +import type { EvmChainConfigV1, EvmEcosystemConfigV1 } from "./types"; + +const mainnet: EvmChainConfigV1 = { + ...polygonFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-polygon-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "E2VmbootbVCBkMNNxKQgCLMS1X3NoGMaYAsufaAsf7M", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-polygon-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "5goWRao6a3yNC4d6UjMdQxonkCMvKBwdpubU3qhfcdf1", + decimals: 6, + }, + ], + ]), + }, + ], + pools: [], +}; + +const testnet: EvmChainConfigV1 = { + ...polygonFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-polygon-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "0x0a0d7cEA57faCBf5DBD0D3b5169Ab00AC8Cf7dd1", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "D5YvMW5U3HUpD1EstYbKmmZsLdmCPgUj44JqBmNY7fUM", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-polygon-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "0x2Ac9183EC64F71AfB73909c7C028Db14d35FAD2F", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + SOLANA_ECOSYSTEM_ID, + { + address: "2otzQWyoydNp4Ws1kV8J8WVYiun6wmuFMMbicgdoEULn", + decimals: 6, + }, + ], + ]), + }, + { + id: "testnet-polygon-lp-usdc-usdt", + projectId: TokenProjectIdV2.SwimLpPolygonUsdcUsdt, + nativeDetails: { + address: "0x1111111111111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + }, + ], + pools: [], +}; + +export const polygon = assertType< + EvmEcosystemConfigV1 +>()({ + ...polygonFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/solana.ts b/apps/ui/src/config/ecosystems/solana.ts new file mode 100644 index 000000000..950db0af5 --- /dev/null +++ b/apps/ui/src/config/ecosystems/solana.ts @@ -0,0 +1,573 @@ +import type { TokenDetails } from "@swim-io/core"; +import { Env } from "@swim-io/core"; +import { SOLANA_ECOSYSTEM_ID, solana as solanaFromSdk } from "@swim-io/solana"; +import { assertType } from "@swim-io/utils"; + +import type { EcosystemId } from "../ecosystem"; +import { TokenProjectIdV1 } from "../tokenProjects"; + +import { bnb } from "./bnb"; +import { ethereum } from "./ethereum"; +import type { SolanaChainConfigV1, SolanaEcosystemConfigV1 } from "./types"; + +const EMPTY_MAP: ReadonlyMap = new Map(); +const BNB_ECOSYSTEM_ID = bnb.id; +const ETHEREUM_ECOSYSTEM_ID = ethereum.id; + +const mainnet: SolanaChainConfigV1 = { + ...solanaFromSdk.chains[Env.Mainnet], + tokens: [ + { + id: "mainnet-solana-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x41f7B8b9b897276b7AAE926a9016935280b44E97", + decimals: 6, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x91Ca579B0D47E5cfD5D0862c21D5659d39C8eCf0", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-solana-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x1CDD2EaB61112697626F7b4bB0e23Da4FeBF7B7C", + decimals: 6, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x49d5cC521F75e13fa8eb4E89E9D381352C897c96", + decimals: 6, + }, + ], + ]), + }, + { + id: "mainnet-solana-gst", + projectId: TokenProjectIdV1.Gst, + nativeDetails: { + address: "AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-gmt", + projectId: TokenProjectIdV1.Gmt, + nativeDetails: { + address: "7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-hexapool", + projectId: TokenProjectIdV1.SwimUsdV1, + nativeDetails: { + address: "BJUH9GJLaMSLV1E7B3SQLCy9eCfyr6zsrwGcpS2MkqR1", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x01F369bF2d5a62CE60B0a2E92143CD623BeCb0fB", + decimals: 8, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0xF78479d516A12b9cFb000951D19f67B4fE0B065d", + decimals: 8, + }, + ], + ]), + }, + { + id: "mainnet-solana-lp-meta-avalanche-usdc", + projectId: TokenProjectIdV1.SwimAvalancheUsdcLp, + nativeDetails: { + address: "DKwsWeqHrB8R1u2DFMHKtq4iqaQNgPgUbHTJyXPqkTzK", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-avalanche-usdt", + projectId: TokenProjectIdV1.SwimAvalancheUsdtLp, + nativeDetails: { + address: "5rwvDmUbcnZTwZ4Zywev2wnDbyDDD2vcsGU2Xmy7aRNS", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-polygon-usdc", + projectId: TokenProjectIdV1.SwimPolygonUsdcLp, + nativeDetails: { + address: "ANFojEXhiEQQoovhBs77XmBQuqbe59UBygRWViyf4945", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-polygon-usdt", + projectId: TokenProjectIdV1.SwimPolygonUsdtLp, + nativeDetails: { + address: "2Nx6L79dHHgHcJtNfZWukQkWZvf5h4bps34zuh1gjtdP", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-gst", + projectId: TokenProjectIdV1.SwimSolanaGstBinanceGstLp, + nativeDetails: { + address: "8YYBkTNhpY9mFdCdZWM6mHNf8J6A9hGfimb33LEiiZ3x", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-gmt", + projectId: TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp, + nativeDetails: { + address: "2x7MjgopLXd3qETGLpY19cyZjHvVnGkrwVjTkJnBza4A", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-aurora-usdc", + projectId: TokenProjectIdV1.SwimAuroraUsdcLp, + nativeDetails: { + address: "9qRe2nBrR2rTXxRaV1PZN9hZnqq3UXgoFWTbP6NE3MEu", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-aurora-usdt", + projectId: TokenProjectIdV1.SwimAuroraUsdtLp, + nativeDetails: { + address: "4XPDxtGbcM7bAPKZxALd2s862n3WoG4xPPvyCPVULKAb", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-aurora-usn", + projectId: TokenProjectIdV1.SwimAuroraUsnLp, + nativeDetails: { + address: "3eXCU7YoiCq3rZ6787pPFJE7TXBsKuTZ49wH2kFnuTeF", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-fantom-usdc", + projectId: TokenProjectIdV1.SwimFantomUsdcLp, + nativeDetails: { + address: "J5ifGexAQTg76TresJhJSqTPJLT6BNxrV5rwNJTTz4Cx", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-karura-ausd", + projectId: TokenProjectIdV1.SwimKaruraAusdLp, + nativeDetails: { + address: "8vzXSNVAX4fymEFahJFh1ypzDBFv3QMVaZ4GtJWHrRjU", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-karura-usdt", + projectId: TokenProjectIdV1.SwimKaruraUsdtLp, + nativeDetails: { + address: "2sXvitirRSjgTTNzGNWAFZWSqEx87kDoTJvqG9JSyivh", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-meta-acala-ausd", + projectId: TokenProjectIdV1.SwimAcalaAusdLp, + nativeDetails: { + address: "11111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-swim", + projectId: TokenProjectIdV1.Swim, + nativeDetails: { + address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "mainnet-solana-lp-swimlake", + projectId: TokenProjectIdV1.XSwim, + nativeDetails: { + address: "SwiMNJ49SxkqMaVWLGGVRH25kE5dBnD2RQoiQUnKtMC", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + ], + pools: [], +}; + +const testnet: SolanaChainConfigV1 = { + ...solanaFromSdk.chains[Env.Testnet], + tokens: [ + { + id: "testnet-solana-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "6iSRgpK4oiqJZuhpLsTecW3n9xBKUq9N3VPQN7RinYwq", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "8VbikoRxEoyYzTDzDcPTSsGk2E5mM7fK1WrVpKrVd75M", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-gst", + projectId: TokenProjectIdV1.Gst, + nativeDetails: { + address: "FYxTtPiGxNSDouZQftVRHFqraFJyLvNbTXzZj8X2gKQP", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-gmt", + projectId: TokenProjectIdV1.Gmt, + nativeDetails: { + address: "3xsNPBpf7UAKpJsLTqiPqHT3ZBKPDndj1rJFM7xaSJcV", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-hexapool", + projectId: TokenProjectIdV1.SwimUsdV1, + nativeDetails: { + address: "5ctnNpb7h1SyPqZ8t8m2kCykrtDGVZBtZgYWv6UAeDhr", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x4DF39C514Eb1747bb4D89cA9Ee35718611590935", + decimals: 8, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x84252522366DB2eA1dAaDe5E2C55CD90a50aC46e", + decimals: 8, + }, + ], + ]), + }, + { + id: "testnet-solana-swim", + projectId: TokenProjectIdV1.Swim, + nativeDetails: { + address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-swimlake", + projectId: TokenProjectIdV1.XSwim, + nativeDetails: { + address: "A8UVBwvj1XcdP5okoMqkjhCQGLaqQ8iJDYnNxAMbsNNF", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-avalanche-usdc", + projectId: TokenProjectIdV1.SwimAvalancheUsdcLp, + nativeDetails: { + address: "DU15RXzuPWTLC4tbAcQvtXbDkHFrY8u6CxgTdhz2Mt8c", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-avalanche-usdt", + projectId: TokenProjectIdV1.SwimAvalancheUsdtLp, + nativeDetails: { + address: "D6PuZckpEcBhVcpfgjgbWnARhFD3ApHhvnxBGWR6MW5Z", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-polygon-usdc", + projectId: TokenProjectIdV1.SwimPolygonUsdcLp, + nativeDetails: { + address: "6WBFbyA3XJ3T2BeqA9JbyZFfj3KTCRtnC8MJANBsVNrz", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-polygon-usdt", + projectId: TokenProjectIdV1.SwimPolygonUsdtLp, + nativeDetails: { + address: "HH3RwS94BWhR4bKeNYGvr2CfSLRQ2Kq6EYSDTKgGLgET", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-gst", + projectId: TokenProjectIdV1.SwimSolanaGstBinanceGstLp, + nativeDetails: { + address: "BM3sXSfRg1yKzf2AbTA5QV76MdnKHi9M8D7VCGzDEYM1", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-gmt", + projectId: TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp, + nativeDetails: { + address: "5VUZL2JcvbmjuT1DzDyWJ4mwtEH8unKyuQj3k38j8Ngs", + decimals: 9, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-aurora-usdc", + projectId: TokenProjectIdV1.SwimAuroraUsdcLp, + nativeDetails: { + address: "AQiHPuuBPsq4MLLjLv2WHRFbrNB1JHZeR4mQGVJTwVHn", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-aurora-usdt", + projectId: TokenProjectIdV1.SwimAuroraUsdtLp, + nativeDetails: { + address: "utXdXdUMaS5qrBDDUg5btQMGL2CedouzmMPbYMJPEZD", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-aurora-usn", + projectId: TokenProjectIdV1.SwimAuroraUsnLp, + nativeDetails: { + address: "11111111111111111111111111111111", // TODO: Update + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-fantom-usdc", + projectId: TokenProjectIdV1.SwimFantomUsdcLp, + nativeDetails: { + address: "4hmRgsk3hSdK1gXV7rg1pStwYtntKmbcFQyKqsZ4USis", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-karura-ausd", + projectId: TokenProjectIdV1.SwimKaruraAusdLp, + nativeDetails: { + address: "4idDPnTYR4J9YhXmayKZYW8QBrASuuiTAxfkWUeaL3ap", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-karura-usdt", + projectId: TokenProjectIdV1.SwimKaruraUsdtLp, + nativeDetails: { + address: "882uzB9euTbBQJ6MrGrvxjXSTQi23VBQZcLcTH4E5Xow", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "testnet-solana-lp-meta-acala-ausd", + projectId: TokenProjectIdV1.SwimAcalaAusdLp, + nativeDetails: { + address: "BTbHtbUtDX5WAUSxPgELzy9VsbMbKAVFQ2hykNrD3X7L", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + ], + pools: [ + { + id: "two-pool", + displayName: "Two Pool", + ecosystemId: SOLANA_ECOSYSTEM_ID, + address: "EGm6UfAJ6LFy8WRxE2YjjJzwUbZ1ZFiuG2rP6YudKKBB", + contract: "8VNVtWUae4qMe535i4yL1gD3VTo8JhcfFEygaozBq8aM", + governanceFeeAccount: "FN9strke8tiDYmRNH3LFtg9zjJpTsxgTPHUegsQsUiai", + lpTokenId: "swimUSD", + tokenIds: ["testnet-solana-usdc", "testnet-solana-usdt"], + tokenAccounts: new Map([ + ["testnet-solana-usdc", "49fm8MaATyD4BwaqxXmjASGuR3WLg8PL1SvMiYpyTdrx"], + ["testnet-solana-usdt", "849M4dvrdoUqsn7t6eVWWNos8Q8RfLJxRTzQC46KGoYE"], + ]), + feeDecimals: 6, + isStableSwap: true, + isStakingPool: false, + }, + ], +}; + +const localnet: SolanaChainConfigV1 = { + ...solanaFromSdk.chains[Env.Local], + tokens: [ + { + id: "local-solana-usdc", + projectId: TokenProjectIdV1.Usdc, + nativeDetails: { + address: "USCAD1T3pV246XwC5kBFXpEjuudS1zT1tTNYhxby9vy", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x81681EC304dcfe2Ddad462E7e968C49A848410c3", + decimals: 6, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x04C5Bf0f72FC1a9F50Ff3228C6285491ad00e13E", + decimals: 6, + }, + ], + ]), + }, + { + id: "local-solana-usdt", + projectId: TokenProjectIdV1.Usdt, + nativeDetails: { + address: "USTPJc7bSkXxRPP1ZdxihfxtfgWNrcRPrE4KEC6EK23", + decimals: 6, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0xa22915e82eb27fb64988Efa3d2749838174ccCBE", + decimals: 6, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x23F55d75CFBe4334031dc7a19bf030613E966b2B", + decimals: 6, + }, + ], + ]), + }, + { + id: "local-solana-lp-hexapool", + projectId: TokenProjectIdV1.SwimUsdV1, + nativeDetails: { + address: "LPTufpWWSucDqq1hib8vxj1uJxTh2bkE7ZTo65LH4J2", + decimals: 8, + }, + wrappedDetails: new Map([ + [ + ETHEREUM_ECOSYSTEM_ID, + { + address: "0x56cd8686e818c0C29983eA32fa6938618b35923f", + decimals: 8, + }, + ], + [ + BNB_ECOSYSTEM_ID, + { + address: "0x7231BBdaB2F3814664f6E1f072A5ae0525709431", + decimals: 8, + }, + ], + ]), + }, + { + id: "local-solana-swim", + projectId: TokenProjectIdV1.Swim, + nativeDetails: { + address: "SWMPqjB9AAtpCbatAEEGK67wNBCN1HDW6VypX7E5r9g", + decimals: 6, + }, + wrappedDetails: EMPTY_MAP, + }, + { + id: "local-solana-lp-swimlake", + projectId: TokenProjectIdV1.XSwim, + nativeDetails: { + address: "xSwy12tTsuYwM2Hd7ceNmvDftgxJ2ZSTycjzAfrNwPW", + decimals: 8, + }, + wrappedDetails: EMPTY_MAP, + }, + ], + pools: [], +}; + +export const solana = assertType()({ + ...solanaFromSdk, + chains: { + [Env.Mainnet]: mainnet, + [Env.Testnet]: testnet, + [Env.Local]: localnet, + }, +} as const); diff --git a/apps/ui/src/config/ecosystems/types.ts b/apps/ui/src/config/ecosystems/types.ts new file mode 100644 index 000000000..b5a9fb77b --- /dev/null +++ b/apps/ui/src/config/ecosystems/types.ts @@ -0,0 +1,40 @@ +import type { Env } from "@swim-io/core"; +import type { + EvmChainConfig, + EvmEcosystemConfig, + EvmEcosystemId, +} from "@swim-io/evm"; +import type { SolanaChainConfig, SolanaEcosystemConfig } from "@swim-io/solana"; +import type { Override, ReadonlyRecord } from "@swim-io/utils"; + +import type { TokenConfig } from "../tokens"; + +export type EvmChainConfigV1 = + Override< + EvmChainConfig, + { + readonly tokens: readonly Omit[]; + } + >; + +export type EvmEcosystemConfigV1 = + Override< + EvmEcosystemConfig, + { + readonly chains: Partial>>; + } + >; + +export type SolanaChainConfigV1 = Override< + SolanaChainConfig, + { + readonly tokens: readonly Omit[]; + } +>; + +export type SolanaEcosystemConfigV1 = Override< + SolanaEcosystemConfig, + { + readonly chains: Partial>; + } +>; diff --git a/apps/ui/src/config/index.ts b/apps/ui/src/config/index.ts index 14ddfff90..b528cf031 100644 --- a/apps/ui/src/config/index.ts +++ b/apps/ui/src/config/index.ts @@ -15,6 +15,7 @@ export * from "./chains"; export * from "./ecosystem"; export * from "./i18n"; export * from "./pools"; +export * from "./tokenProjects"; export * from "./tokens"; export * from "./utils"; export * from "./wormhole"; diff --git a/apps/ui/src/config/tokenProjects.ts b/apps/ui/src/config/tokenProjects.ts new file mode 100644 index 000000000..3664ab432 --- /dev/null +++ b/apps/ui/src/config/tokenProjects.ts @@ -0,0 +1,277 @@ +import type { + TokenProjectId as TokenProjectIdV2, + TokenProject as TokenProjectV2, +} from "@swim-io/token-projects"; +import { TOKEN_PROJECTS_BY_ID as TOKEN_PROJECTS_BY_ID_V2 } from "@swim-io/token-projects"; +import type { Override, ReadonlyRecord } from "@swim-io/utils"; +import { assertType } from "@swim-io/utils"; + +/* eslint-disable import/no-unresolved, import/no-webpack-loader-syntax */ +// prefix with `!!` to overwrite webpack loader and use url-loader to output base64 instead +import AUSD_SVG from "!!url-loader!../images/tokens/ausd.svg"; +import BUSD_SVG from "!!url-loader!../images/tokens/busd.svg"; +import GMT_SVG from "!!url-loader!../images/tokens/gmt.svg"; +import GST_SVG from "!!url-loader!../images/tokens/gst.svg"; +import LP_ACALA_AUSD_SVG from "!!url-loader!../images/tokens/lp_acala_ausd.svg"; +import LP_AURORA_USDC_SVG from "!!url-loader!../images/tokens/lp_aurora_usdc.svg"; +import LP_AURORA_USDT_SVG from "!!url-loader!../images/tokens/lp_aurora_usdt.svg"; +import LP_AURORA_USN_SVG from "!!url-loader!../images/tokens/lp_aurora_usn.svg"; +import LP_AVALANCHE_USDC_SVG from "!!url-loader!../images/tokens/lp_avalanche_usdc.svg"; +import LP_AVALANCHE_USDT_SVG from "!!url-loader!../images/tokens/lp_avalanche_usdt.svg"; +import LP_FANTOM_USDC_SVG from "!!url-loader!../images/tokens/lp_fantom_usdc.svg"; +import LP_GMT_SVG from "!!url-loader!../images/tokens/lp_gmt.svg"; +import LP_GST_SVG from "!!url-loader!../images/tokens/lp_gst.svg"; +import LP_KARURA_AUSD_SVG from "!!url-loader!../images/tokens/lp_karura_ausd.svg"; +import LP_KARURA_USDT_SVG from "!!url-loader!../images/tokens/lp_karura_usdt.svg"; +import LP_POLYGON_USDC_SVG from "!!url-loader!../images/tokens/lp_polygon_usdc.svg"; +import LP_POLYGON_USDT_SVG from "!!url-loader!../images/tokens/lp_polygon_usdt.svg"; +import SWIM_TOKEN_SVG from "!!url-loader!../images/tokens/swim.svg"; +import SWIM_USD_SVG from "!!url-loader!../images/tokens/swim_usd.svg"; +import USDC_SVG from "!!url-loader!../images/tokens/usdc.svg"; +import USDT_SVG from "!!url-loader!../images/tokens/usdt.svg"; +import USN_SVG from "!!url-loader!../images/tokens/usn.svg"; +import XSWIM_TOKEN_SVG from "!!url-loader!../images/tokens/xswim.svg"; +/* eslint-enable import/no-unresolved, import/no-webpack-loader-syntax */ + +export enum TokenProjectIdV1 { + Ausd = "ausd-v1", + Busd = "busd-v1", + Gmt = "gmt-v1", + Gst = "gst-v1", + Swim = "swim-v1", + SwimAcalaAusdLp = "swim-acala-ausd-lp-v1", + SwimAuroraUsdcLp = "swim-aurora-usdc-lp-v1", + SwimAuroraUsdtLp = "swim-aurora-usdt-lp-v1", + SwimAuroraUsnLp = "swim-aurora-usn-lp-v1", + SwimAvalancheUsdcLp = "swim-avalanche-usdc-lp-v1", + SwimAvalancheUsdtLp = "swim-avalanche-usdt-lp-v1", + SwimFantomUsdcLp = "swim-fantom-usdc-lp-v1", + SwimKaruraAusdLp = "swim-karura-ausd-lp-v1", + SwimKaruraUsdtLp = "swim-karura-usdt-lp-v1", + SwimPolygonUsdcLp = "swim-polygon-usdc-lp-v1", + SwimPolygonUsdtLp = "swim-polygon-usdt-lp-v1", + SwimSolanaGmtBinanceGmtLp = "swim-solana-gmt-binance-gst-lp-v1", + SwimSolanaGstBinanceGstLp = "swim-solana-gst-binance-gst-lp-v1", + SwimUsdV1 = "swim-usd-v1", + Usdc = "usdc-v1", + Usdt = "usdt-v1", + Usn = "usn-v1", + XSwim = "xswim-v1", +} +// Make sure no name collision with v2 +assertType>()(TokenProjectIdV1); + +export type TokenProjectV1 = Override< + TokenProjectV2, + { + readonly id: TokenProjectIdV1; + readonly tokenNumber?: never; + } +>; + +export const TOKEN_PROJECTS_BY_ID_V1: ReadonlyRecord< + TokenProjectIdV1, + TokenProjectV1 +> = { + [TokenProjectIdV1.Usdc]: { + id: TokenProjectIdV1.Usdc, + symbol: "USDC", + displayName: "USD Coin", + icon: USDC_SVG, + isStablecoin: true, + isLp: false, + }, + [TokenProjectIdV1.Usdt]: { + id: TokenProjectIdV1.Usdt, + symbol: "USDT", + displayName: "Tether USD", + icon: USDT_SVG, + isStablecoin: true, + isLp: false, + }, + [TokenProjectIdV1.Usn]: { + id: TokenProjectIdV1.Usn, + symbol: "USN", + displayName: "USN", + icon: USN_SVG, + isStablecoin: true, + isLp: false, + }, + [TokenProjectIdV1.Busd]: { + id: TokenProjectIdV1.Busd, + symbol: "BUSD", + displayName: "Binance USD", + icon: BUSD_SVG, + isStablecoin: true, + isLp: false, + }, + [TokenProjectIdV1.Ausd]: { + id: TokenProjectIdV1.Ausd, + symbol: "aUSD", + displayName: "Acala USD", + icon: AUSD_SVG, + isStablecoin: true, + isLp: false, + }, + [TokenProjectIdV1.Gst]: { + id: TokenProjectIdV1.Gst, + symbol: "GST", + displayName: "Green Satoshi Token", + icon: GST_SVG, + isStablecoin: false, + isLp: false, + }, + [TokenProjectIdV1.Gmt]: { + id: TokenProjectIdV1.Gmt, + symbol: "GMT", + displayName: "STEPN", + icon: GMT_SVG, + isStablecoin: false, + isLp: false, + }, + [TokenProjectIdV1.SwimUsdV1]: { + id: TokenProjectIdV1.SwimUsdV1, + symbol: "swimUSD", + displayName: "swimUSD (Swim Hexapool LP)", + icon: SWIM_USD_SVG, + isStablecoin: true, + isLp: true, + }, + [TokenProjectIdV1.Swim]: { + id: TokenProjectIdV1.Swim, + symbol: "SWIM", + displayName: "Swim Protocol Token", + icon: SWIM_TOKEN_SVG, + isStablecoin: false, + isLp: false, + }, + [TokenProjectIdV1.XSwim]: { + id: TokenProjectIdV1.XSwim, + symbol: "xSWIM", + displayName: "xSWIM (SwimLake LP)", + icon: XSWIM_TOKEN_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAvalancheUsdcLp]: { + id: TokenProjectIdV1.SwimAvalancheUsdcLp, + symbol: "SWIM-AVALANCHE-USDC-LP", + displayName: "Avalanche USDC LP", + icon: LP_AVALANCHE_USDC_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAvalancheUsdtLp]: { + id: TokenProjectIdV1.SwimAvalancheUsdtLp, + symbol: "SWIM-AVALANCHE-USDT-LP", + displayName: "Avalanche USDT LP", + icon: LP_AVALANCHE_USDT_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimPolygonUsdcLp]: { + id: TokenProjectIdV1.SwimPolygonUsdcLp, + symbol: "SWIM-POLYGON-USDC-LP", + displayName: "Polygon USDC LP", + icon: LP_POLYGON_USDC_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimPolygonUsdtLp]: { + id: TokenProjectIdV1.SwimPolygonUsdtLp, + symbol: "SWIM-POLYGON-USDT-LP", + displayName: "Polygon USDT LP", + icon: LP_POLYGON_USDT_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimSolanaGstBinanceGstLp]: { + id: TokenProjectIdV1.SwimSolanaGstBinanceGstLp, + symbol: "solaGST-binaGST", + displayName: "Swim Solana GST Binance GST LP", + icon: LP_GST_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp]: { + id: TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp, + symbol: "solaGMT-binaGMT", + displayName: "Swim Solana GMT Binance GMT LP", + icon: LP_GMT_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAuroraUsdcLp]: { + id: TokenProjectIdV1.SwimAuroraUsdcLp, + symbol: "SWIM-AURORA-USDC-LP", + displayName: "Aurora USDC LP", + icon: LP_AURORA_USDC_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAuroraUsdtLp]: { + id: TokenProjectIdV1.SwimAuroraUsdtLp, + symbol: "SWIM-AURORA-USDT-LP", + displayName: "Aurora USDT LP", + icon: LP_AURORA_USDT_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAuroraUsnLp]: { + id: TokenProjectIdV1.SwimAuroraUsnLp, + symbol: "SWIM-AURORA-USN-LP", + displayName: "Aurora USN LP", + icon: LP_AURORA_USN_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimFantomUsdcLp]: { + id: TokenProjectIdV1.SwimFantomUsdcLp, + symbol: "SWIM-FANTOM-USDC-LP", + displayName: "Fantom USDC LP", + icon: LP_FANTOM_USDC_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimKaruraAusdLp]: { + id: TokenProjectIdV1.SwimKaruraAusdLp, + symbol: "SWIM-KARURA-AUSD-LP", + displayName: "Karura AUSD LP", + icon: LP_KARURA_AUSD_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimKaruraUsdtLp]: { + id: TokenProjectIdV1.SwimKaruraUsdtLp, + symbol: "SWIM-KARURA-USDT-LP", + displayName: "Karura USDT LP", + icon: LP_KARURA_USDT_SVG, + isStablecoin: false, + isLp: true, + }, + [TokenProjectIdV1.SwimAcalaAusdLp]: { + id: TokenProjectIdV1.SwimAcalaAusdLp, + symbol: "SWIM-ACALA-AUSD-LP", + displayName: "Acala AUSD LP", + icon: LP_ACALA_AUSD_SVG, + isStablecoin: false, + isLp: true, + }, +}; + +export const TOKEN_PROJECTS_V1 = Object.values(TOKEN_PROJECTS_BY_ID_V1); + +export function getTokenProject(projectId: TokenProjectIdV1): TokenProjectV1; +export function getTokenProject(projectId: TokenProjectIdV2): TokenProjectV2; +export function getTokenProject( + projectId: TokenProjectIdV1 | TokenProjectIdV2, +): TokenProjectV1 | TokenProjectV2; +export function getTokenProject( + projectId: TokenProjectIdV1 | TokenProjectIdV2, +): TokenProjectV1 | TokenProjectV2 { + return ( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + TOKEN_PROJECTS_BY_ID_V1[projectId as TokenProjectIdV1] ?? + TOKEN_PROJECTS_BY_ID_V2[projectId as TokenProjectIdV2] + ); +} diff --git a/apps/ui/src/config/tokens.test.ts b/apps/ui/src/config/tokens.test.ts index c65249bc0..e7cd86c2d 100644 --- a/apps/ui/src/config/tokens.test.ts +++ b/apps/ui/src/config/tokens.test.ts @@ -41,7 +41,7 @@ const generateSuite = (env: Env): void => { // NOTE: We may have to rethink this test if eg tokens on Ethereum/BNB can be deployed at the same address it("does not specify an address more than once", () => { const allAddresses = tokens.flatMap((token) => - [token.nativeDetails, ...token.wrappedDetails.values()].map( + [token.nativeDetails, ...(token.wrappedDetails?.values() ?? [])].map( (details) => details.address, ), ); @@ -80,7 +80,7 @@ const generateSuite = (env: Env): void => { it("does not specify token details for any token’s native Wormhole ecosystem", () => { const nativeEcosystemDetails = tokens.map((token) => - token.wrappedDetails.get(token.nativeEcosystemId), + token.wrappedDetails?.get(token.nativeEcosystemId), ); expect(nativeEcosystemDetails.some(Boolean)).toBe(false); }); diff --git a/apps/ui/src/config/tokens.ts b/apps/ui/src/config/tokens.ts index 04c43e65a..68ed8942e 100644 --- a/apps/ui/src/config/tokens.ts +++ b/apps/ui/src/config/tokens.ts @@ -5,28 +5,43 @@ import type { } from "@swim-io/core"; import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TokenProjectId } from "@swim-io/token-projects"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; import type { ReadonlyRecord } from "@swim-io/utils"; import type { EcosystemId } from "./ecosystem"; import { isEcosystemEnabled } from "./ecosystem"; import { isPoolRestructureEnabled } from "./pools"; +import { TokenProjectIdV1 } from "./tokenProjects"; -export interface TokenConfig extends CoreTokenConfig { +type CommonTokenConfig = Pick & { readonly isDisabled?: boolean; // TODO: Remove and derive from ChainConfig readonly nativeEcosystemId: EcosystemId; - /** Required for v1 pool support */ - readonly wrappedDetails: ReadonlyMap; -} +}; +export type TokenConfig = CommonTokenConfig & + ( + | { + readonly projectId: TokenProjectIdV1; + readonly wrappedDetails: ReadonlyMap; + } + | { + readonly projectId: Exclude; + readonly wrappedDetails?: never; + } + | { + readonly projectId: TokenProjectIdV2.SwimUsd; + // will be migrate to ChainConfig’s swimUsdDetails + readonly wrappedDetails: ReadonlyMap; + } + ); // NOTE: Use a shared empty map to save memory -const EMPTY_MAP: TokenConfig["wrappedDetails"] = new Map(); +const EMPTY_MAP: ReadonlyMap = new Map(); const MAINNET_TOKENS: readonly TokenConfig[] = [ { id: "mainnet-solana-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", @@ -51,7 +66,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", @@ -76,7 +91,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-gst", - projectId: TokenProjectId.Gst, + projectId: TokenProjectIdV1.Gst, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB", @@ -86,7 +101,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-gmt", - projectId: TokenProjectId.Gmt, + projectId: TokenProjectIdV1.Gmt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx", @@ -96,7 +111,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "BJUH9GJLaMSLV1E7B3SQLCy9eCfyr6zsrwGcpS2MkqR1", @@ -121,7 +136,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-avalanche-usdc", - projectId: TokenProjectId.SwimAvalancheUsdcLp, + projectId: TokenProjectIdV1.SwimAvalancheUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "DKwsWeqHrB8R1u2DFMHKtq4iqaQNgPgUbHTJyXPqkTzK", @@ -131,7 +146,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-avalanche-usdt", - projectId: TokenProjectId.SwimAvalancheUsdtLp, + projectId: TokenProjectIdV1.SwimAvalancheUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "5rwvDmUbcnZTwZ4Zywev2wnDbyDDD2vcsGU2Xmy7aRNS", @@ -141,7 +156,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-polygon-usdc", - projectId: TokenProjectId.SwimPolygonUsdcLp, + projectId: TokenProjectIdV1.SwimPolygonUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "ANFojEXhiEQQoovhBs77XmBQuqbe59UBygRWViyf4945", @@ -151,7 +166,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-polygon-usdt", - projectId: TokenProjectId.SwimPolygonUsdtLp, + projectId: TokenProjectIdV1.SwimPolygonUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "2Nx6L79dHHgHcJtNfZWukQkWZvf5h4bps34zuh1gjtdP", @@ -161,7 +176,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-gst", - projectId: TokenProjectId.SwimSolanaGstBinanceGstLp, + projectId: TokenProjectIdV1.SwimSolanaGstBinanceGstLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "8YYBkTNhpY9mFdCdZWM6mHNf8J6A9hGfimb33LEiiZ3x", @@ -171,7 +186,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-gmt", - projectId: TokenProjectId.SwimSolanaGmtBinanceGmtLp, + projectId: TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "2x7MjgopLXd3qETGLpY19cyZjHvVnGkrwVjTkJnBza4A", @@ -181,7 +196,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-aurora-usdc", - projectId: TokenProjectId.SwimAuroraUsdcLp, + projectId: TokenProjectIdV1.SwimAuroraUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "9qRe2nBrR2rTXxRaV1PZN9hZnqq3UXgoFWTbP6NE3MEu", @@ -191,7 +206,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-aurora-usdt", - projectId: TokenProjectId.SwimAuroraUsdtLp, + projectId: TokenProjectIdV1.SwimAuroraUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "4XPDxtGbcM7bAPKZxALd2s862n3WoG4xPPvyCPVULKAb", @@ -202,7 +217,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_AURORA_USN, id: "mainnet-solana-lp-meta-aurora-usn", - projectId: TokenProjectId.SwimAuroraUsnLp, + projectId: TokenProjectIdV1.SwimAuroraUsnLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "3eXCU7YoiCq3rZ6787pPFJE7TXBsKuTZ49wH2kFnuTeF", @@ -212,7 +227,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-fantom-usdc", - projectId: TokenProjectId.SwimFantomUsdcLp, + projectId: TokenProjectIdV1.SwimFantomUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "J5ifGexAQTg76TresJhJSqTPJLT6BNxrV5rwNJTTz4Cx", @@ -223,7 +238,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_KARURA_AUSD, id: "mainnet-solana-lp-meta-karura-ausd", - projectId: TokenProjectId.SwimKaruraAusdLp, + projectId: TokenProjectIdV1.SwimKaruraAusdLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "8vzXSNVAX4fymEFahJFh1ypzDBFv3QMVaZ4GtJWHrRjU", @@ -233,7 +248,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-solana-lp-meta-karura-usdt", - projectId: TokenProjectId.SwimKaruraUsdtLp, + projectId: TokenProjectIdV1.SwimKaruraUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "2sXvitirRSjgTTNzGNWAFZWSqEx87kDoTJvqG9JSyivh", @@ -244,7 +259,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !isEcosystemEnabled(EvmEcosystemId.Acala), id: "mainnet-solana-lp-meta-acala-ausd", - projectId: TokenProjectId.SwimAcalaAusdLp, + projectId: TokenProjectIdV1.SwimAcalaAusdLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "11111111111111111111111111111111", // TODO: Update @@ -254,7 +269,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-ethereum-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", @@ -272,7 +287,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-ethereum-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0xdac17f958d2ee523a2206206994597c13d831ec7", @@ -290,7 +305,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-bnb-busd", - projectId: TokenProjectId.Busd, + projectId: TokenProjectIdV1.Busd, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", @@ -308,7 +323,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-bnb-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x55d398326f99059ff775485246999027b3197955", @@ -326,7 +341,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-bnb-gst", - projectId: TokenProjectId.Gst, + projectId: TokenProjectIdV1.Gst, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x4a2c860cec6471b9f5f5a336eb4f38bb21683c98", @@ -344,7 +359,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-bnb-gmt", - projectId: TokenProjectId.Gmt, + projectId: TokenProjectIdV1.Gmt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1", @@ -362,7 +377,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-avalanche-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Avalanche, nativeDetails: { address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", @@ -380,7 +395,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-avalanche-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Avalanche, nativeDetails: { address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", @@ -398,7 +413,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-polygon-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Polygon, nativeDetails: { address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", @@ -416,7 +431,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-polygon-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Polygon, nativeDetails: { address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", @@ -434,7 +449,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-aurora-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802", @@ -452,7 +467,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-aurora-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x4988a896b1227218e4A686fdE5EabdcAbd91571f", @@ -471,7 +486,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_AURORA_USN, id: "mainnet-aurora-usn", - projectId: TokenProjectId.Usn, + projectId: TokenProjectIdV1.Usn, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x5183e1B1091804BC2602586919E6880ac1cf2896", @@ -489,7 +504,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-fantom-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Fantom, nativeDetails: { address: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", @@ -508,7 +523,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_KARURA_AUSD, id: "mainnet-karura-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x0000000000000000000100000000000000000081", @@ -526,7 +541,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ }, { id: "mainnet-karura-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x0000000000000000000500000000000000000007", @@ -545,7 +560,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !isEcosystemEnabled(EvmEcosystemId.Acala), id: "mainnet-acala-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Acala, nativeDetails: { address: "0x0000000000000000000000000000000000000000", // TODO: Update @@ -564,7 +579,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: true, id: "mainnet-solana-swim", - projectId: TokenProjectId.Swim, + projectId: TokenProjectIdV1.Swim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", @@ -575,7 +590,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: true, id: "mainnet-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, + projectId: TokenProjectIdV1.XSwim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "SwiMNJ49SxkqMaVWLGGVRH25kE5dBnD2RQoiQUnKtMC", @@ -588,7 +603,7 @@ const MAINNET_TOKENS: readonly TokenConfig[] = [ export const TESTNET_SWIMUSD: TokenConfig = { isDisabled: !isPoolRestructureEnabled(), id: "testnet-swimusd", - projectId: TokenProjectId.SwimLpSolanaUsdcUsdt, + projectId: TokenProjectIdV2.SwimUsd, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "3ngTtoyP9GFybFifX1dr7gCFXFiM2Wr6NfXn6EuU7k6C", // TODO: Update @@ -658,121 +673,111 @@ export const TESTNET_TOKENS_FOR_RESTRUCTURE: readonly TokenConfig[] = [ { isDisabled: !isPoolRestructureEnabled(), id: "testnet-ethereum-lp-usdc-usdt", - projectId: TokenProjectId.SwimLpEthereumUsdcUsdt, + projectId: TokenProjectIdV2.SwimLpEthereumUsdcUsdt, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0xee525c4cEB776D9e770D2Fd81fc91d6418657955", // TODO: Update decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-bnb-lp-busd-usdt", - projectId: TokenProjectId.SwimLpBnbBusdUsdt, + projectId: TokenProjectIdV2.SwimLpBnbBusdUsdt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x976943205ef791A1cf676A880c07458C91F241d7", // TODO: Update decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-avalanche-lp-usdc-usdt", - projectId: TokenProjectId.SwimLpAvalancheUsdcUsdt, + projectId: TokenProjectIdV2.SwimLpAvalancheUsdcUsdt, nativeEcosystemId: EvmEcosystemId.Avalanche, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-polygon-lp-usdc-usdt", - projectId: TokenProjectId.SwimLpPolygonUsdcUsdt, + projectId: TokenProjectIdV2.SwimLpPolygonUsdcUsdt, nativeEcosystemId: EvmEcosystemId.Polygon, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-aurora-lp-usdc-usdt", - projectId: TokenProjectId.SwimLpAuroraUsdcUsdt, + projectId: TokenProjectIdV2.SwimLpAuroraUsdcUsdt, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled() || !process.env.REACT_APP_ENABLE_AURORA_USN, id: "testnet-aurora-lp-usn", - projectId: TokenProjectId.SwimLpAuroraUsn, + projectId: TokenProjectIdV2.SwimLpAuroraUsn, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-fantom-lp-usdc", - projectId: TokenProjectId.SwimLpFantomUsdc, + projectId: TokenProjectIdV2.SwimLpFantomUsdc, nativeEcosystemId: EvmEcosystemId.Fantom, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-karura-lp-usdt", - projectId: TokenProjectId.SwimLpKaruraUsdt, + projectId: TokenProjectIdV2.SwimLpKaruraUsdt, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled() || !process.env.REACT_APP_ENABLE_KARURA_AUSD, id: "testnet-karura-lp-ausd", - projectId: TokenProjectId.SwimLpKaruraAusd, + projectId: TokenProjectIdV2.SwimLpKaruraAusd, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { isDisabled: !isPoolRestructureEnabled(), id: "testnet-acala-lp-ausd", - projectId: TokenProjectId.SwimLpAcalaAusd, + projectId: TokenProjectIdV2.SwimLpAcalaAusd, nativeEcosystemId: EvmEcosystemId.Acala, nativeDetails: { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ]; export const TESTNET_TOKENS: readonly TokenConfig[] = [ { id: "testnet-solana-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "2w7wsGofEAvLiWXZgJySXZ4gofEhm8jQ9rtwXr1zbzUc", @@ -782,7 +787,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "DznJzVAjPHBvyyqXEQgPWTonF2nhwoSoutPNbXjmsUvY", @@ -792,7 +797,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-usdc-v2", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "6iSRgpK4oiqJZuhpLsTecW3n9xBKUq9N3VPQN7RinYwq", @@ -802,7 +807,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-usdt-v2", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "8VbikoRxEoyYzTDzDcPTSsGk2E5mM7fK1WrVpKrVd75M", @@ -812,7 +817,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-gst", - projectId: TokenProjectId.Gst, + projectId: TokenProjectIdV1.Gst, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "FYxTtPiGxNSDouZQftVRHFqraFJyLvNbTXzZj8X2gKQP", @@ -822,7 +827,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-gmt", - projectId: TokenProjectId.Gmt, + projectId: TokenProjectIdV1.Gmt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "3xsNPBpf7UAKpJsLTqiPqHT3ZBKPDndj1rJFM7xaSJcV", @@ -832,7 +837,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "5ctnNpb7h1SyPqZ8t8m2kCykrtDGVZBtZgYWv6UAeDhr", @@ -857,7 +862,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-swim", - projectId: TokenProjectId.Swim, + projectId: TokenProjectIdV1.Swim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", @@ -867,7 +872,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, + projectId: TokenProjectIdV1.XSwim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "A8UVBwvj1XcdP5okoMqkjhCQGLaqQ8iJDYnNxAMbsNNF", @@ -877,7 +882,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-avalanche-usdc", - projectId: TokenProjectId.SwimAvalancheUsdcLp, + projectId: TokenProjectIdV1.SwimAvalancheUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "DU15RXzuPWTLC4tbAcQvtXbDkHFrY8u6CxgTdhz2Mt8c", @@ -887,7 +892,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-avalanche-usdt", - projectId: TokenProjectId.SwimAvalancheUsdtLp, + projectId: TokenProjectIdV1.SwimAvalancheUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "D6PuZckpEcBhVcpfgjgbWnARhFD3ApHhvnxBGWR6MW5Z", @@ -897,7 +902,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-polygon-usdc", - projectId: TokenProjectId.SwimPolygonUsdcLp, + projectId: TokenProjectIdV1.SwimPolygonUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "6WBFbyA3XJ3T2BeqA9JbyZFfj3KTCRtnC8MJANBsVNrz", @@ -907,7 +912,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-polygon-usdt", - projectId: TokenProjectId.SwimPolygonUsdtLp, + projectId: TokenProjectIdV1.SwimPolygonUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "HH3RwS94BWhR4bKeNYGvr2CfSLRQ2Kq6EYSDTKgGLgET", @@ -917,7 +922,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-gst", - projectId: TokenProjectId.SwimSolanaGstBinanceGstLp, + projectId: TokenProjectIdV1.SwimSolanaGstBinanceGstLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "BM3sXSfRg1yKzf2AbTA5QV76MdnKHi9M8D7VCGzDEYM1", @@ -927,7 +932,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-gmt", - projectId: TokenProjectId.SwimSolanaGmtBinanceGmtLp, + projectId: TokenProjectIdV1.SwimSolanaGmtBinanceGmtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "5VUZL2JcvbmjuT1DzDyWJ4mwtEH8unKyuQj3k38j8Ngs", @@ -937,7 +942,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-aurora-usdc", - projectId: TokenProjectId.SwimAuroraUsdcLp, + projectId: TokenProjectIdV1.SwimAuroraUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "AQiHPuuBPsq4MLLjLv2WHRFbrNB1JHZeR4mQGVJTwVHn", @@ -947,7 +952,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-aurora-usdt", - projectId: TokenProjectId.SwimAuroraUsdtLp, + projectId: TokenProjectIdV1.SwimAuroraUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "utXdXdUMaS5qrBDDUg5btQMGL2CedouzmMPbYMJPEZD", @@ -958,7 +963,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_AURORA_USN, id: "testnet-solana-lp-meta-aurora-usn", - projectId: TokenProjectId.SwimAuroraUsnLp, + projectId: TokenProjectIdV1.SwimAuroraUsnLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "11111111111111111111111111111111", // TODO: Update @@ -968,7 +973,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-fantom-usdc", - projectId: TokenProjectId.SwimFantomUsdcLp, + projectId: TokenProjectIdV1.SwimFantomUsdcLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "4hmRgsk3hSdK1gXV7rg1pStwYtntKmbcFQyKqsZ4USis", @@ -978,7 +983,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-karura-ausd", - projectId: TokenProjectId.SwimKaruraAusdLp, + projectId: TokenProjectIdV1.SwimKaruraAusdLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "4idDPnTYR4J9YhXmayKZYW8QBrASuuiTAxfkWUeaL3ap", @@ -988,7 +993,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-solana-lp-meta-karura-usdt", - projectId: TokenProjectId.SwimKaruraUsdtLp, + projectId: TokenProjectIdV1.SwimKaruraUsdtLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "882uzB9euTbBQJ6MrGrvxjXSTQi23VBQZcLcTH4E5Xow", @@ -999,7 +1004,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !isEcosystemEnabled(EvmEcosystemId.Acala), id: "testnet-solana-lp-meta-acala-ausd", - projectId: TokenProjectId.SwimAcalaAusdLp, + projectId: TokenProjectIdV1.SwimAcalaAusdLp, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "BTbHtbUtDX5WAUSxPgELzy9VsbMbKAVFQ2hykNrD3X7L", @@ -1009,7 +1014,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-ethereum-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0x45B167CF5b14007Ca0490dCfB7C4B870Ec0C0Aa6", @@ -1027,7 +1032,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-ethereum-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", @@ -1045,7 +1050,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-bnb-busd", - projectId: TokenProjectId.Busd, + projectId: TokenProjectIdV1.Busd, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", @@ -1063,7 +1068,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-bnb-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x98529E942FD121d9C470c3d4431A008257E0E714", @@ -1081,7 +1086,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-bnb-gst", - projectId: TokenProjectId.Gst, + projectId: TokenProjectIdV1.Gst, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x73160078948280B8680e5F1eB2964698928E8cd7", @@ -1099,7 +1104,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-bnb-gmt", - projectId: TokenProjectId.Gmt, + projectId: TokenProjectIdV1.Gmt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x1F65D61D01E3f10b34B855287b32D7bfbEA088D0", @@ -1117,7 +1122,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-avalanche-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Avalanche, nativeDetails: { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", @@ -1135,7 +1140,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-avalanche-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Avalanche, nativeDetails: { address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", @@ -1153,7 +1158,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-polygon-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Polygon, nativeDetails: { address: "0x0a0d7cEA57faCBf5DBD0D3b5169Ab00AC8Cf7dd1", @@ -1171,7 +1176,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-polygon-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Polygon, nativeDetails: { address: "0x2Ac9183EC64F71AfB73909c7C028Db14d35FAD2F", @@ -1189,7 +1194,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-aurora-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", @@ -1207,7 +1212,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-aurora-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", @@ -1226,7 +1231,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !process.env.REACT_APP_ENABLE_AURORA_USN, id: "testnet-aurora-usn", - projectId: TokenProjectId.Usn, + projectId: TokenProjectIdV1.Usn, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "0x0000000000000000000000000000000000000000", // TODO: Update @@ -1244,7 +1249,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-fantom-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Fantom, nativeDetails: { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", @@ -1262,7 +1267,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-karura-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x074370ca8Fea9e8f1C5eE23f34CBdcD3FB7a66aD", @@ -1280,7 +1285,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ }, { id: "testnet-karura-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "0x535d5e3b1ff7de526fe180e654a41350903c328d", @@ -1299,7 +1304,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ { isDisabled: !isEcosystemEnabled(EvmEcosystemId.Acala), id: "testnet-acala-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Acala, nativeDetails: { address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", @@ -1322,7 +1327,7 @@ export const TESTNET_TOKENS: readonly TokenConfig[] = [ const LOCAL_TOKENS: readonly TokenConfig[] = [ { id: "local-solana-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "USCAD1T3pV246XwC5kBFXpEjuudS1zT1tTNYhxby9vy", @@ -1347,7 +1352,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-solana-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "USTPJc7bSkXxRPP1ZdxihfxtfgWNrcRPrE4KEC6EK23", @@ -1372,7 +1377,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "LPTufpWWSucDqq1hib8vxj1uJxTh2bkE7ZTo65LH4J2", @@ -1397,7 +1402,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-solana-swim", - projectId: TokenProjectId.Swim, + projectId: TokenProjectIdV1.Swim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "SWMPqjB9AAtpCbatAEEGK67wNBCN1HDW6VypX7E5r9g", @@ -1407,7 +1412,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, + projectId: TokenProjectIdV1.XSwim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "xSwy12tTsuYwM2Hd7ceNmvDftgxJ2ZSTycjzAfrNwPW", @@ -1417,7 +1422,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-ethereum-usdc", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0xFcCeD5E997E7fb1D0594518D3eD57245bB8ed17E", @@ -1435,7 +1440,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-ethereum-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Ethereum, nativeDetails: { address: "0xdAA71FBBA28C946258DD3d5FcC9001401f72270F", @@ -1453,7 +1458,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-bnb-busd", - projectId: TokenProjectId.Busd, + projectId: TokenProjectIdV1.Busd, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0xCeeFD27e0542aFA926B87d23936c79c276A48277", @@ -1471,7 +1476,7 @@ const LOCAL_TOKENS: readonly TokenConfig[] = [ }, { id: "local-bnb-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Bnb, nativeDetails: { address: "0x988B6CFBf3332FF98FFBdED665b1F53a61f92612", diff --git a/apps/ui/src/config/utils.ts b/apps/ui/src/config/utils.ts index 51bf32561..abcff5186 100644 --- a/apps/ui/src/config/utils.ts +++ b/apps/ui/src/config/utils.ts @@ -1,6 +1,6 @@ import type { Env, TokenDetails } from "@swim-io/core"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TokenProjectId } from "@swim-io/token-projects"; +import { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; import { deduplicate } from "@swim-io/utils"; import type { Ecosystem, EcosystemId } from "./ecosystem"; @@ -15,7 +15,7 @@ export const getTokenDetailsForEcosystem = ( ): TokenDetails | null => tokenConfig.nativeEcosystemId === ecosystemId ? tokenConfig.nativeDetails - : tokenConfig.wrappedDetails.get(ecosystemId) ?? null; + : tokenConfig.wrappedDetails?.get(ecosystemId) ?? null; export const getSolanaTokenDetails = ( tokenConfig: TokenConfig, @@ -55,5 +55,7 @@ export const hasTokenEcosystem = ( ): boolean => getPoolTokenEcosystems(pool, env).some(({ id }) => id === ecosystemId); -export const isSwimUsd = (token: TokenConfig) => - token.projectId === TokenProjectId.SwimLpSolanaUsdcUsdt; +export const isSwimUsd = ( + token: TokenConfig, +): token is TokenConfig & { readonly projectId: TokenProjectIdV2.SwimUsd } => + token.projectId === TokenProjectIdV2.SwimUsd; diff --git a/apps/ui/src/core/selectors/__snapshots__/swapTokenOptions.test.ts.snap b/apps/ui/src/core/selectors/__snapshots__/swapTokenOptions.test.ts.snap index fb69a2b9c..980afad69 100644 --- a/apps/ui/src/core/selectors/__snapshots__/swapTokenOptions.test.ts.snap +++ b/apps/ui/src/core/selectors/__snapshots__/swapTokenOptions.test.ts.snap @@ -11,7 +11,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map {}, }, }, @@ -24,7 +24,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map {}, }, }, @@ -37,7 +37,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map { "solana" => Object { "address": "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", @@ -55,7 +55,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map { "solana" => Object { "address": "8Cfyi1mYXqKATUkMPvb9BMXikdbppJst6E7eQJkKjAtf", @@ -73,7 +73,7 @@ Array [ "decimals": 18, }, "nativeEcosystemId": "bnb", - "projectId": "busd", + "projectId": "busd-v1", "wrappedDetails": Map { "solana" => Object { "address": "6KTvgrkLoPJdB3Grv4ZBUGt6JiLdVnKzJNo4HvLEgm6d", @@ -91,7 +91,7 @@ Array [ "decimals": 18, }, "nativeEcosystemId": "bnb", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map { "solana" => Object { "address": "4dr6ogcLsaFf2RDF4LJU1CvNtNKxonVqQvM6vuGdVR1e", @@ -110,7 +110,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "swim-lp-solana-usdc-usdt", + "projectId": "swim-usd", "wrappedDetails": Map { "acala" => Object { "address": "0x1111111111111111111111111111111111111111", @@ -157,7 +157,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "swim-lp-solana-usdc-usdt", + "projectId": "swim-usd", "wrappedDetails": Map { "acala" => Object { "address": "0x1111111111111111111111111111111111111111", @@ -204,7 +204,7 @@ Array [ "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "swim-lp-solana-usdc-usdt", + "projectId": "swim-usd", "wrappedDetails": Map { "acala" => Object { "address": "0x1111111111111111111111111111111111111111", diff --git a/apps/ui/src/hooks/evm/useRegisterErc20Token.ts b/apps/ui/src/hooks/evm/useRegisterErc20Token.ts index cbaf73635..580f35690 100644 --- a/apps/ui/src/hooks/evm/useRegisterErc20Token.ts +++ b/apps/ui/src/hooks/evm/useRegisterErc20Token.ts @@ -2,7 +2,11 @@ import type { EvmEcosystemId } from "@swim-io/evm"; import { useTranslation } from "react-i18next"; import type { TokenConfig } from "../../config"; -import { ECOSYSTEMS, getTokenDetailsForEcosystem } from "../../config"; +import { + ECOSYSTEMS, + getTokenDetailsForEcosystem, + getTokenProject, +} from "../../config"; import { useNotification } from "../../core/store"; import { captureException } from "../../errors"; @@ -43,7 +47,7 @@ export const useRegisterErc20Token = ( } await wallet.registerToken( tokenDetails, - tokenConfig.projectId, + getTokenProject(tokenConfig.projectId), evmChainId, ); } catch (error) { diff --git a/apps/ui/src/hooks/interaction/__snapshots__/useCreateInteractionStateV2.test.ts.snap b/apps/ui/src/hooks/interaction/__snapshots__/useCreateInteractionStateV2.test.ts.snap index 523290309..9176724f9 100644 --- a/apps/ui/src/hooks/interaction/__snapshots__/useCreateInteractionStateV2.test.ts.snap +++ b/apps/ui/src/hooks/interaction/__snapshots__/useCreateInteractionStateV2.test.ts.snap @@ -236,7 +236,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map { "solana" => Object { "address": "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", @@ -255,7 +255,7 @@ Object { "decimals": 18, }, "nativeEcosystemId": "bnb", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map { "solana" => Object { "address": "4dr6ogcLsaFf2RDF4LJU1CvNtNKxonVqQvM6vuGdVR1e", @@ -308,7 +308,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map { "solana" => Object { "address": "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", @@ -327,7 +327,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map { "solana" => Object { "address": "8Cfyi1mYXqKATUkMPvb9BMXikdbppJst6E7eQJkKjAtf", @@ -382,7 +382,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map { "solana" => Object { "address": "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", @@ -401,7 +401,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map {}, }, "value": "1000", @@ -466,7 +466,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map {}, }, "value": "1000", @@ -480,7 +480,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "ethereum", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map { "solana" => Object { "address": "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", @@ -548,7 +548,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdc", + "projectId": "usdc-v1", "wrappedDetails": Map {}, }, "value": "1000", @@ -562,7 +562,7 @@ Object { "decimals": 6, }, "nativeEcosystemId": "solana", - "projectId": "usdt", + "projectId": "usdt-v1", "wrappedDetails": Map {}, }, "value": "1000", diff --git a/apps/ui/src/hooks/interaction/useCrossChainEvmToEvmSwapInteractionMutation.ts b/apps/ui/src/hooks/interaction/useCrossChainEvmToEvmSwapInteractionMutation.ts index 981822b5e..454d067c2 100644 --- a/apps/ui/src/hooks/interaction/useCrossChainEvmToEvmSwapInteractionMutation.ts +++ b/apps/ui/src/hooks/interaction/useCrossChainEvmToEvmSwapInteractionMutation.ts @@ -9,6 +9,7 @@ import { isEvmEcosystemId, } from "@swim-io/evm"; import { Routing__factory } from "@swim-io/evm-contracts"; +import { isTokenProjectId } from "@swim-io/token-projects"; import { useMutation } from "react-query"; import shallow from "zustand/shallow.js"; @@ -63,24 +64,35 @@ export const useCrossChainEvmToEvmSwapInteractionMutation = () => { ) { throw new Error(`${fromEcosystem} wallet not found`); } + const fromTokenSpec = fromTokenData.tokenConfig; - const toTokenSpec = toTokenData.tokenConfig; const fromChainConfig = EVM_ECOSYSTEMS[fromEcosystem].chains[env] ?? null; if (fromChainConfig === null) { throw new Error(`${fromEcosystem} chain config not found`); } - const toChainConfig = EVM_ECOSYSTEMS[toEcosystem].chains[env] ?? null; - if (toChainConfig === null) { - throw new Error(`${toEcosystem} chain config not found`); + if (!isTokenProjectId(fromTokenSpec.projectId)) { + throw new Error( + `Unsupported token project: ${fromTokenSpec.projectId}`, + ); } const fromTokenDetails = getTokenDetails( fromChainConfig, fromTokenSpec.projectId, ); + + const toTokenSpec = toTokenData.tokenConfig; + const toChainConfig = EVM_ECOSYSTEMS[toEcosystem].chains[env] ?? null; + if (toChainConfig === null) { + throw new Error(`${toEcosystem} chain config not found`); + } + if (!isTokenProjectId(toTokenSpec.projectId)) { + throw new Error(`Unsupported token project: ${toTokenSpec.projectId}`); + } const toTokenDetails = getTokenDetails( toChainConfig, toTokenSpec.projectId, ); + await wallet.switchNetwork(fromChainConfig.chainId); const fromEvmClient = getEvmClient(fromEcosystem); const fromRouting = Routing__factory.connect( diff --git a/apps/ui/src/hooks/swim/useGetSwapFormErrorsV2.ts b/apps/ui/src/hooks/swim/useGetSwapFormErrorsV2.ts index 8d2d48c65..cb4929140 100644 --- a/apps/ui/src/hooks/swim/useGetSwapFormErrorsV2.ts +++ b/apps/ui/src/hooks/swim/useGetSwapFormErrorsV2.ts @@ -1,9 +1,8 @@ -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { isNotNull } from "@swim-io/utils"; import type Decimal from "decimal.js"; import { useTranslation } from "react-i18next"; -import { DISABLED_ECOSYSTEMS, ECOSYSTEMS } from "../../config"; +import { DISABLED_ECOSYSTEMS, ECOSYSTEMS, getTokenProject } from "../../config"; import type { TokenOption } from "../../models"; import { isValidSlippageFraction } from "../../models"; import { @@ -71,7 +70,7 @@ export const useGetSwapFormErrorsV2 = ( ...errors, `Insufficient funds for ${ ECOSYSTEMS[fromTokenOption.ecosystemId].displayName - } ${TOKEN_PROJECTS_BY_ID[fromToken.projectId].displayName}`, + } ${getTokenProject(fromToken.projectId).displayName}`, ]; } diff --git a/apps/ui/src/hooks/swim/useIsLargeSwap.ts b/apps/ui/src/hooks/swim/useIsLargeSwap.ts index 390f84820..814074483 100644 --- a/apps/ui/src/hooks/swim/useIsLargeSwap.ts +++ b/apps/ui/src/hooks/swim/useIsLargeSwap.ts @@ -1,8 +1,8 @@ import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import shallow from "zustand/shallow.js"; import type { TokenConfig } from "../../config"; +import { getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment } from "../../core/store"; import type { Amount } from "../../models"; @@ -28,12 +28,12 @@ export const useIsLargeSwap = ( const outputPoolUsdValue = pools[pools.length - 1].poolUsdValue; const outputAmount = useSwapOutputAmountEstimate(inputAmount, toToken); return ( - (TOKEN_PROJECTS_BY_ID[fromToken.projectId].isStablecoin && + (getTokenProject(fromToken.projectId).isStablecoin && inputPoolUsdValue !== null && inputAmount .toHuman(SOLANA_ECOSYSTEM_ID) .gt(inputPoolUsdValue.mul(0.1))) || - (TOKEN_PROJECTS_BY_ID[toToken.projectId].isStablecoin && + (getTokenProject(toToken.projectId).isStablecoin && outputPoolUsdValue !== null && outputAmount !== null && outputAmount.toHuman(SOLANA_ECOSYSTEM_ID).gt(outputPoolUsdValue.mul(0.1))) diff --git a/apps/ui/src/hooks/swim/useIsLargeSwapV2.ts b/apps/ui/src/hooks/swim/useIsLargeSwapV2.ts index 641eca92b..e8c9e5097 100644 --- a/apps/ui/src/hooks/swim/useIsLargeSwapV2.ts +++ b/apps/ui/src/hooks/swim/useIsLargeSwapV2.ts @@ -1,8 +1,8 @@ -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type Decimal from "decimal.js"; import shallow from "zustand/shallow.js"; import { sum } from "../../amounts"; +import { getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment } from "../../core/store"; import type { TokenOption } from "../../models"; @@ -36,10 +36,10 @@ export const useIsLargeSwapV2 = ( const inputBalance = sum(poolBalances[0]); const outputBalance = sum(poolBalances[poolBalances.length - 1]); return ( - (TOKEN_PROJECTS_BY_ID[fromTokenOption.tokenConfig.projectId].isStablecoin && + (getTokenProject(fromTokenOption.tokenConfig.projectId).isStablecoin && inputBalance !== null && inputAmount.gt(inputBalance.mul(0.1))) || - (TOKEN_PROJECTS_BY_ID[toTokenOption.tokenConfig.projectId].isStablecoin && + (getTokenProject(toTokenOption.tokenConfig.projectId).isStablecoin && outputBalance !== null && minimumOutputAmount !== null && minimumOutputAmount.gt(outputBalance.mul(0.1))) diff --git a/apps/ui/src/hooks/swim/usePoolUsdValues.ts b/apps/ui/src/hooks/swim/usePoolUsdValues.ts index 9d8448ed9..5d677cdf8 100644 --- a/apps/ui/src/hooks/swim/usePoolUsdValues.ts +++ b/apps/ui/src/hooks/swim/usePoolUsdValues.ts @@ -1,9 +1,9 @@ -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { findOrThrow } from "@swim-io/utils"; -import type { PoolSpec, TokenConfig } from "config"; import Decimal from "decimal.js"; import shallow from "zustand/shallow.js"; +import type { PoolSpec, TokenConfig } from "../../config"; +import { getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment } from "../../core/store"; import { isSolanaPool } from "../../models"; @@ -29,14 +29,14 @@ export const usePoolUsdValues = (poolSpecs: readonly PoolSpec[]) => { if ( poolTokens.some( (tokenConfig) => - !TOKEN_PROJECTS_BY_ID[tokenConfig.projectId].isStablecoin && + !getTokenProject(tokenConfig.projectId).isStablecoin && !prices.get(tokenConfig.id), ) ) { return new Decimal(0); } return poolTokens.reduce((sum, tokenConfig, i) => { - const price = TOKEN_PROJECTS_BY_ID[tokenConfig.projectId].isStablecoin + const price = getTokenProject(tokenConfig.projectId).isStablecoin ? new Decimal(1) : prices.get(tokenConfig.id) ?? new Decimal(1); return sum.add(poolBalances[i].mul(price)); diff --git a/apps/ui/src/hooks/swim/useSwapTokensContext.ts b/apps/ui/src/hooks/swim/useSwapTokensContext.ts index c6d16dbb1..06b94c97b 100644 --- a/apps/ui/src/hooks/swim/useSwapTokensContext.ts +++ b/apps/ui/src/hooks/swim/useSwapTokensContext.ts @@ -1,9 +1,9 @@ -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { findOrThrow } from "@swim-io/utils"; import { useNavigate, useParams } from "react-router-dom"; import shallow from "zustand/shallow.js"; import type { TokenConfig } from "../../config"; +import { getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment } from "../../core/store"; @@ -28,7 +28,7 @@ interface SwapTokensContext { const convertTokenConfigToUrlParam = (token: TokenConfig): string => `${token.nativeEcosystemId}-${ - TOKEN_PROJECTS_BY_ID[token.projectId].symbol + getTokenProject(token.projectId).symbol }`.toLowerCase(); export const useSwapTokensContext = (): SwapTokensContext => { @@ -47,7 +47,7 @@ export const useSwapTokensContext = (): SwapTokensContext => { return ( tokens.find((token) => { return ( - TOKEN_PROJECTS_BY_ID[token.projectId].symbol.toLowerCase() === + getTokenProject(token.projectId).symbol.toLowerCase() === projectSymbol && token.nativeEcosystemId.toLowerCase() === ecosystemId ); diff --git a/apps/ui/src/images/tokens/lp_acala_ausd.svg b/apps/ui/src/images/tokens/lp_acala_ausd.svg new file mode 100644 index 000000000..56d29cbb7 --- /dev/null +++ b/apps/ui/src/images/tokens/lp_acala_ausd.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/token-projects/images/lp_aurora_usdc.svg b/apps/ui/src/images/tokens/lp_aurora_usdc.svg similarity index 100% rename from packages/token-projects/images/lp_aurora_usdc.svg rename to apps/ui/src/images/tokens/lp_aurora_usdc.svg diff --git a/packages/token-projects/images/lp_aurora_usdt.svg b/apps/ui/src/images/tokens/lp_aurora_usdt.svg similarity index 100% rename from packages/token-projects/images/lp_aurora_usdt.svg rename to apps/ui/src/images/tokens/lp_aurora_usdt.svg diff --git a/packages/token-projects/images/lp_aurora_usn.svg b/apps/ui/src/images/tokens/lp_aurora_usn.svg similarity index 100% rename from packages/token-projects/images/lp_aurora_usn.svg rename to apps/ui/src/images/tokens/lp_aurora_usn.svg diff --git a/packages/token-projects/images/lp_avalanche_usdc.svg b/apps/ui/src/images/tokens/lp_avalanche_usdc.svg similarity index 100% rename from packages/token-projects/images/lp_avalanche_usdc.svg rename to apps/ui/src/images/tokens/lp_avalanche_usdc.svg diff --git a/packages/token-projects/images/lp_avalanche_usdt.svg b/apps/ui/src/images/tokens/lp_avalanche_usdt.svg similarity index 100% rename from packages/token-projects/images/lp_avalanche_usdt.svg rename to apps/ui/src/images/tokens/lp_avalanche_usdt.svg diff --git a/apps/ui/src/images/tokens/lp_fantom_usdc.svg b/apps/ui/src/images/tokens/lp_fantom_usdc.svg new file mode 100644 index 000000000..b1e9920db --- /dev/null +++ b/apps/ui/src/images/tokens/lp_fantom_usdc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/ui/src/images/tokens/lp_karura_ausd.svg b/apps/ui/src/images/tokens/lp_karura_ausd.svg new file mode 100644 index 000000000..b81b40247 --- /dev/null +++ b/apps/ui/src/images/tokens/lp_karura_ausd.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/ui/src/images/tokens/lp_karura_usdt.svg b/apps/ui/src/images/tokens/lp_karura_usdt.svg new file mode 100644 index 000000000..e8657faab --- /dev/null +++ b/apps/ui/src/images/tokens/lp_karura_usdt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/token-projects/images/lp_polygon_usdc.svg b/apps/ui/src/images/tokens/lp_polygon_usdc.svg similarity index 100% rename from packages/token-projects/images/lp_polygon_usdc.svg rename to apps/ui/src/images/tokens/lp_polygon_usdc.svg diff --git a/packages/token-projects/images/lp_polygon_usdt.svg b/apps/ui/src/images/tokens/lp_polygon_usdt.svg similarity index 100% rename from packages/token-projects/images/lp_polygon_usdt.svg rename to apps/ui/src/images/tokens/lp_polygon_usdt.svg diff --git a/apps/ui/src/models/amount.test.ts b/apps/ui/src/models/amount.test.ts index cb413b7f8..4eb2b93e0 100644 --- a/apps/ui/src/models/amount.test.ts +++ b/apps/ui/src/models/amount.test.ts @@ -1,10 +1,10 @@ import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TokenProjectId } from "@swim-io/token-projects"; import BN from "bn.js"; import Decimal from "decimal.js"; import type { TokenConfig } from "../config"; +import { TokenProjectIdV1 } from "../config"; import { Amount } from "./amount"; @@ -31,7 +31,7 @@ const staticMethodConstructionCases: readonly StaticMethodConstructionCase[] = [ describe("Amount", () => { const defaultNonStablecoinTokenConfig: TokenConfig = { id: "test-token", - projectId: TokenProjectId.Swim, + projectId: TokenProjectIdV1.Swim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "xxx", decimals: 8 }, wrappedDetails: new Map([ @@ -40,7 +40,7 @@ describe("Amount", () => { }; const defaultStablecoinTokenConfig: TokenConfig = { id: "test-stablecoin", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "xxx", decimals: 8 }, wrappedDetails: new Map([ diff --git a/apps/ui/src/models/amount.ts b/apps/ui/src/models/amount.ts index 01ce3fd9e..7dd4ef4e3 100644 --- a/apps/ui/src/models/amount.ts +++ b/apps/ui/src/models/amount.ts @@ -1,10 +1,9 @@ import type { TokenDetails } from "@swim-io/core"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import BN from "bn.js"; import Decimal from "decimal.js"; import type { EcosystemId, TokenConfig } from "../config"; -import { getTokenDetailsForEcosystem } from "../config"; +import { getTokenDetailsForEcosystem, getTokenProject } from "../config"; import { fallbackLanguageIfNotSupported, i18next } from "../i18n"; export class Amount { @@ -114,7 +113,7 @@ export class Amount { i18next.resolvedLanguage, ); const numberFormatter = new Intl.NumberFormat(language, { - ...(TOKEN_PROJECTS_BY_ID[this.tokenConfig.projectId].isStablecoin + ...(getTokenProject(this.tokenConfig.projectId).isStablecoin ? { minimumFractionDigits: 2, maximumFractionDigits: 2, diff --git a/apps/ui/src/models/crossEcosystem/atomicString.test.ts b/apps/ui/src/models/crossEcosystem/atomicString.test.ts index a08cd0e2f..d26c75c00 100644 --- a/apps/ui/src/models/crossEcosystem/atomicString.test.ts +++ b/apps/ui/src/models/crossEcosystem/atomicString.test.ts @@ -1,9 +1,9 @@ import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TokenProjectId } from "@swim-io/token-projects"; import Decimal from "decimal.js"; import type { TokenConfig } from "../../config"; +import { TokenProjectIdV1 } from "../../config"; import { atomicStringToHumanDecimal, @@ -12,7 +12,7 @@ import { const defaultStablecoinTokenConfig: TokenConfig = { id: "test-stablecoin", - projectId: TokenProjectId.Usdc, + projectId: TokenProjectIdV1.Usdc, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "xxx", decimals: 8 }, wrappedDetails: new Map([ diff --git a/apps/ui/src/models/swim/utils.ts b/apps/ui/src/models/swim/utils.ts index 4b01038d6..f9fa96aaa 100644 --- a/apps/ui/src/models/swim/utils.ts +++ b/apps/ui/src/models/swim/utils.ts @@ -2,13 +2,12 @@ import { APTOS_ECOSYSTEM_ID } from "@swim-io/aptos"; import { EvmEcosystemId } from "@swim-io/evm"; import type { TokenAccount } from "@swim-io/solana"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import type { ReadonlyRecord } from "@swim-io/utils"; import { filterMap, findOrThrow } from "@swim-io/utils"; import Decimal from "decimal.js"; import type { EcosystemId, PoolSpec, TokenConfig } from "../../config"; -import { getTokenDetailsForEcosystem } from "../../config"; +import { getTokenDetailsForEcosystem, getTokenProject } from "../../config"; import { Amount } from "../amount"; import type { InteractionSpec, InteractionSpecV2 } from "./interaction"; @@ -188,7 +187,7 @@ export const getPoolUsdValue = ( poolTokenAccounts: readonly TokenAccount[], ): Decimal | null => tokens.every( - (tokenConfig) => TOKEN_PROJECTS_BY_ID[tokenConfig.projectId].isStablecoin, + (tokenConfig) => getTokenProject(tokenConfig.projectId).isStablecoin, ) ? poolTokenAccounts.reduce((acc, account) => { const tokenConfig = tokens.find( diff --git a/apps/ui/src/models/wormhole/solana.test.ts b/apps/ui/src/models/wormhole/solana.test.ts index 19934d10e..3098bca0b 100644 --- a/apps/ui/src/models/wormhole/solana.test.ts +++ b/apps/ui/src/models/wormhole/solana.test.ts @@ -4,10 +4,9 @@ import { Env } from "@swim-io/core"; import { EvmEcosystemId } from "@swim-io/evm"; import type { SolanaTx } from "@swim-io/solana"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TokenProjectId } from "@swim-io/token-projects"; import type { TokenConfig } from "../../config"; -import { CHAINS, Protocol, TOKENS } from "../../config"; +import { CHAINS, Protocol, TOKENS, TokenProjectIdV1 } from "../../config"; import { parsedSwimSwapTx, parsedWormholePostVaaTxs, @@ -29,7 +28,7 @@ describe("models - Wormhole utils", () => { "Ex4QfU1vD5dtFQYHJrs6XwLaRzy2C5yZKhQSNJJXQg5e"; const token: TokenConfig = { id: "test-token", - projectId: TokenProjectId.Swim, + projectId: TokenProjectIdV1.Swim, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "xxx", decimals: 8 }, wrappedDetails: new Map([ diff --git a/apps/ui/src/pages/PoolPage.tsx b/apps/ui/src/pages/PoolPage.tsx index d7716d9ef..dea2275ad 100644 --- a/apps/ui/src/pages/PoolPage.tsx +++ b/apps/ui/src/pages/PoolPage.tsx @@ -15,7 +15,6 @@ import { EuiToolTip, } from "@elastic/eui"; import { EvmEcosystemId } from "@swim-io/evm"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { defaultIfError } from "@swim-io/utils"; import Decimal from "decimal.js"; import type { ReactElement } from "react"; @@ -35,7 +34,11 @@ import { SlippageButton } from "../components/SlippageButton"; import { StatList } from "../components/StatList"; import { TokenConfigIcon, TokenIcon } from "../components/TokenIcon"; import type { PoolSpec } from "../config"; -import { getSolanaTokenDetails, getTokenDetailsForEcosystem } from "../config"; +import { + getSolanaTokenDetails, + getTokenDetailsForEcosystem, + getTokenProject, +} from "../config"; import { selectConfig } from "../core/selectors"; import { useEnvironment } from "../core/store"; import { @@ -174,13 +177,13 @@ export const PoolPageInner = ({ const userLpBalances = useUserLpBalances(lpToken, userLpTokenAccount); const userLpStats = [ lpToken.nativeEcosystemId, - ...(poolSpec.isLegacyPool ? lpToken.wrappedDetails.keys() : []), + ...(poolSpec.isLegacyPool ? lpToken.wrappedDetails?.keys() ?? [] : []), ].map((ecosystemId) => { const userLpBalance = userLpBalances[ecosystemId]; return { title: ( ), diff --git a/apps/ui/src/pages/PoolsPage.tsx b/apps/ui/src/pages/PoolsPage.tsx index d46f1128d..f081b0403 100644 --- a/apps/ui/src/pages/PoolsPage.tsx +++ b/apps/ui/src/pages/PoolsPage.tsx @@ -17,7 +17,7 @@ import { } from "@elastic/eui"; import { EvmEcosystemId } from "@swim-io/evm"; import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana"; -import { TOKEN_PROJECTS_BY_ID, TokenProjectId } from "@swim-io/token-projects"; +import type { TokenProjectId as TokenProjectIdV2 } from "@swim-io/token-projects"; import { deduplicate, filterMap, findOrThrow, sortBy } from "@swim-io/utils"; import type { ReadonlyRecord } from "@swim-io/utils"; import Decimal from "decimal.js"; @@ -29,7 +29,9 @@ import shallow from "zustand/shallow.js"; import { atomicToTvlString } from "../amounts"; import { PoolListItem } from "../components/PoolListItem"; import { + TokenProjectIdV1, getPoolTokenEcosystems, + getTokenProject, hasTokenEcosystem, isEcosystemEnabled, } from "../config"; @@ -39,7 +41,7 @@ import { useEnvironment } from "../core/store"; import { usePoolUsdValues, useTitle } from "../hooks"; type EcosystemSelectType = EcosystemId | "all"; -type TokenProjectSelectType = TokenProjectId | "all"; +type TokenProjectSelectType = TokenProjectIdV1 | TokenProjectIdV2 | "all"; const PoolsPage = (): ReactElement => { const { t } = useTranslation(); @@ -173,7 +175,7 @@ const PoolsPage = (): ReactElement => { tokenConfigs={[ { id: "placeholder-aurora-native-usn", - projectId: TokenProjectId.Usn, + projectId: TokenProjectIdV1.Usn, nativeEcosystemId: EvmEcosystemId.Aurora, nativeDetails: { address: "", @@ -183,7 +185,7 @@ const PoolsPage = (): ReactElement => { }, { id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "", @@ -207,7 +209,7 @@ const PoolsPage = (): ReactElement => { tokenConfigs={[ { id: "placeholder-karura-native-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "", @@ -217,7 +219,7 @@ const PoolsPage = (): ReactElement => { }, { id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "", @@ -236,7 +238,7 @@ const PoolsPage = (): ReactElement => { tokenConfigs={[ { id: "placeholder-karura-native-usdt", - projectId: TokenProjectId.Usdt, + projectId: TokenProjectIdV1.Usdt, nativeEcosystemId: EvmEcosystemId.Karura, nativeDetails: { address: "", @@ -246,7 +248,7 @@ const PoolsPage = (): ReactElement => { }, { id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "", @@ -270,7 +272,7 @@ const PoolsPage = (): ReactElement => { tokenConfigs={[ { id: "placeholder-acala-native-ausd", - projectId: TokenProjectId.Ausd, + projectId: TokenProjectIdV1.Ausd, nativeEcosystemId: EvmEcosystemId.Acala, nativeDetails: { address: "", @@ -280,7 +282,7 @@ const PoolsPage = (): ReactElement => { }, { id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, + projectId: TokenProjectIdV1.SwimUsdV1, nativeEcosystemId: SOLANA_ECOSYSTEM_ID, nativeDetails: { address: "", @@ -416,7 +418,7 @@ function useTokenProjectFilter() { deduplicate( (project) => project.id, tokens - .map((token) => TOKEN_PROJECTS_BY_ID[token.projectId]) + .map((token) => getTokenProject(token.projectId)) .filter((project) => project.symbol !== "SWIM" && !project.isLp), ), "displayName", @@ -455,7 +457,7 @@ function useFilteredPools( const projectsPerPool: ReadonlyRecord< PoolSpec["id"], - readonly TokenProjectId[] + readonly (TokenProjectIdV1 | TokenProjectIdV2)[] > = useMemo(() => { return pools.reduce( (accumulator, pool) => ({ diff --git a/apps/ui/src/pages/SwapPage/SwapPage.tsx b/apps/ui/src/pages/SwapPage/SwapPage.tsx index 2b69c4ea7..21dca7be2 100644 --- a/apps/ui/src/pages/SwapPage/SwapPage.tsx +++ b/apps/ui/src/pages/SwapPage/SwapPage.tsx @@ -9,7 +9,6 @@ import { EuiSpacer, EuiTitle, } from "@elastic/eui"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; import { defaultIfError } from "@swim-io/utils"; import Decimal from "decimal.js"; import type { ReactElement } from "react"; @@ -21,7 +20,7 @@ import { MultiConnectButton } from "../../components/ConnectButton"; import { RecentInteractions } from "../../components/RecentInteractions"; import { SlippageButton } from "../../components/SlippageButton"; import { SwapForm } from "../../components/SwapForm"; -import { ECOSYSTEMS } from "../../config"; +import { ECOSYSTEMS, getTokenProject } from "../../config"; import { selectConfig } from "../../core/selectors"; import { useEnvironment } from "../../core/store"; import { useSwapTokensContext, useTitle } from "../../hooks"; @@ -35,10 +34,9 @@ const SwapPage = (): ReactElement => { const { fromToken, toToken } = useSwapTokensContext(); const fromEcosystemName = ECOSYSTEMS[fromToken.nativeEcosystemId].displayName; - const fromTokenProjectId = - TOKEN_PROJECTS_BY_ID[fromToken.projectId].displayName; + const fromTokenProjectId = getTokenProject(fromToken.projectId).displayName; const toEcosystemName = ECOSYSTEMS[toToken.nativeEcosystemId].displayName; - const toTokenProjectId = TOKEN_PROJECTS_BY_ID[toToken.projectId].displayName; + const toTokenProjectId = getTokenProject(toToken.projectId).displayName; useTitle( t("swap_page.title", { fromEcosystemName, diff --git a/packages/core/src/chain.ts b/packages/core/src/chain.ts index d8d90e0e0..7df2da8e9 100644 --- a/packages/core/src/chain.ts +++ b/packages/core/src/chain.ts @@ -19,7 +19,8 @@ export interface ChainConfig { export const getTokenDetails = ( chainConfig: ChainConfig, - tokenProjectId: TokenProjectId, + /** @todo to be removed: legacy v1 token project id */ + tokenProjectId: TokenProjectId | `${string}-v1`, ): TokenDetails => tokenProjectId === TokenProjectId.SwimUsd ? chainConfig.swimUsdDetails diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 312808b33..7df0cb55f 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -17,7 +17,8 @@ export interface WrappedTokenInfo { export interface InitiatePortalTransferParams { readonly wallet: Wallet; readonly interactionId: string; - readonly tokenProjectId: TokenProjectId; + /** @todo to be removed: legacy v1 token project id */ + readonly tokenProjectId: TokenProjectId | `${string}-v1`; /** Standardized Wormhole format, ie 32 bytes */ readonly targetAddress: Uint8Array; readonly targetChainId: ChainId; diff --git a/packages/core/src/token.ts b/packages/core/src/token.ts index 3fcacd0ed..d6eb35ba1 100644 --- a/packages/core/src/token.ts +++ b/packages/core/src/token.ts @@ -13,8 +13,7 @@ export interface TokenDetails { export interface TokenConfig { readonly id: string; /** The ID of the token project to which this token belongs */ - readonly projectId: TokenProjectId; + /** @todo to be removed: legacy v1 token project id */ + readonly projectId: TokenProjectId | `${string}-v1`; readonly nativeDetails: TokenDetails; - /** A map from ecosystem ID to token details for a Wormhole-wrapped version of the token */ - readonly wrappedDetails: ReadonlyMap; } diff --git a/packages/evm/src/ecosystems/acala.ts b/packages/evm/src/ecosystems/acala.ts index 6364fc690..5485fadf0 100644 --- a/packages/evm/src/ecosystems/acala.ts +++ b/packages/evm/src/ecosystems/acala.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const acalaChainId = assertType()({ [Env.Mainnet]: 787, [Env.Testnet]: 597, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0x0000000000000000000000000000000000000000", // TODO: Update decimals: 6, // TODO: Update }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "11111111111111111111111111111112", // TODO: Update - decimals: 6, // TODO: Update - }, - ], - ]), }, ], pools: [], @@ -74,15 +62,6 @@ const testnet: EvmChainConfig = { address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", decimals: 12, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "BbdPh2Nvpp7XftBHWENJu5dpC5gF5FtCSyFLTU4qNr7g", - decimals: 8, - }, - ], - ]), }, { id: "testnet-acala-lp-ausd", @@ -91,7 +70,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/ecosystems/aurora.ts b/packages/evm/src/ecosystems/aurora.ts index aa51b9ac2..2e744ed82 100644 --- a/packages/evm/src/ecosystems/aurora.ts +++ b/packages/evm/src/ecosystems/aurora.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const auroraChainId = assertType()({ [Env.Mainnet]: 1313161554, [Env.Testnet]: 1313161555, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "9Y8pJhF8AQGBGL5PTd12P4w82n2qAADTmWakkXSatdAu", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-aurora-usdt", @@ -56,15 +44,6 @@ const mainnet: EvmChainConfig = { address: "0x4988a896b1227218e4A686fdE5EabdcAbd91571f", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "GFhej2oJ1NPLbzSX3D3B9jzYaidff6NoBAUNmu6dLXwU", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-aurora-usn", @@ -73,15 +52,6 @@ const mainnet: EvmChainConfig = { address: "0x5183e1B1091804BC2602586919E6880ac1cf2896", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "3NDmtc2xKMpm8wCiaALey2y3EGhBkUNuXJ9m3JcjnHMM", - decimals: 8, - }, - ], - ]), }, ], pools: [], @@ -108,15 +78,6 @@ const testnet: EvmChainConfig = { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "B3qmqCvzbni27z5TRrt1uBYMczUCjCjui7piGAZifSTU", - decimals: 6, - }, - ], - ]), }, { id: "testnet-aurora-usdt", @@ -125,15 +86,6 @@ const testnet: EvmChainConfig = { address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "BaTEf2Mnrf9wePKb9g9BtSPkrZmmBnR6K9Q1ZxDKmWoh", - decimals: 6, - }, - ], - ]), }, { id: "testnet-aurora-usn", @@ -142,15 +94,6 @@ const testnet: EvmChainConfig = { address: "0x0000000000000000000000000000000000000000", // TODO: Update decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "11111111111111111111111111111111", // TODO: Update - decimals: 8, - }, - ], - ]), }, { id: "testnet-aurora-lp-usdc-usdt", @@ -159,7 +102,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { id: "testnet-aurora-lp-usn", @@ -168,7 +110,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/ecosystems/avalanche.ts b/packages/evm/src/ecosystems/avalanche.ts index bdf1b88c6..c0d1f3449 100644 --- a/packages/evm/src/ecosystems/avalanche.ts +++ b/packages/evm/src/ecosystems/avalanche.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const avalancheChainId = assertType()({ [Env.Mainnet]: 43114, // C-Chain [Env.Testnet]: 43113, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "FHfba3ov5P3RjaiLVgh8FTv4oirxQDoVXuoUUDvHuXax", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-avalanche-usdt", @@ -56,15 +44,6 @@ const mainnet: EvmChainConfig = { address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "Kz1csQA91WUGcQ2TB3o5kdGmWmMGp8eJcDEyHzNDVCX", - decimals: 6, - }, - ], - ]), }, ], pools: [], @@ -91,15 +70,6 @@ const testnet: EvmChainConfig = { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "2t6pVTufn9A4b37oLmex3YMjm3smp1G9tPd9HpAFSeka", - decimals: 6, - }, - ], - ]), }, { id: "testnet-avalanche-usdt", @@ -108,15 +78,6 @@ const testnet: EvmChainConfig = { address: "0x489dDcd070b6c4e0373FBB5d529Cc06328E048c3", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "9ibet2CuBX1a4HpbzH9auxxtyUvkSKVy39jWtZY5Bfor", - decimals: 6, - }, - ], - ]), }, { id: "testnet-avalanche-lp-usdc-usdt", @@ -125,7 +86,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/ecosystems/bnb.ts b/packages/evm/src/ecosystems/bnb.ts index a93e233a3..7d33e02b0 100644 --- a/packages/evm/src/ecosystems/bnb.ts +++ b/packages/evm/src/ecosystems/bnb.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const bnbChainId = assertType()({ [Env.Mainnet]: 56, [Env.Testnet]: 97, @@ -40,15 +37,6 @@ const mainnet: EvmChainConfig = { address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2", - decimals: 8, - }, - ], - ]), }, { id: "mainnet-bnb-usdt", @@ -57,15 +45,6 @@ const mainnet: EvmChainConfig = { address: "0x55d398326f99059ff775485246999027b3197955", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "8qJSyQprMC57TWKaYEmetUR3UUiTP2M3hXdcvFhkZdmv", - decimals: 8, - }, - ], - ]), }, { id: "mainnet-bnb-gst", @@ -74,15 +53,6 @@ const mainnet: EvmChainConfig = { address: "0x4a2c860cec6471b9f5f5a336eb4f38bb21683c98", decimals: 8, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "GDuUFXEhUm4jG71vPxYRX3VxUMJ5etGvHTR1iKwTdb6p", - decimals: 8, - }, - ], - ]), }, { id: "mainnet-bnb-gmt", @@ -91,15 +61,6 @@ const mainnet: EvmChainConfig = { address: "0x3019bf2a2ef8040c242c9a4c5c4bd4c81678b2a1", decimals: 8, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "7dzFD8xQ3FDmVLxwn75UA9WhVnBsUdRAexASVvpXX3Bo", - decimals: 8, - }, - ], - ]), }, ], pools: [], @@ -126,15 +87,6 @@ const testnet: EvmChainConfig = { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "6KTvgrkLoPJdB3Grv4ZBUGt6JiLdVnKzJNo4HvLEgm6d", - decimals: 8, - }, - ], - ]), }, { id: "testnet-bnb-usdt", @@ -143,15 +95,6 @@ const testnet: EvmChainConfig = { address: "0x98529E942FD121d9C470c3d4431A008257E0E714", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "4dr6ogcLsaFf2RDF4LJU1CvNtNKxonVqQvM6vuGdVR1e", - decimals: 8, - }, - ], - ]), }, { id: "testnet-bnb-gst", @@ -160,15 +103,6 @@ const testnet: EvmChainConfig = { address: "0x73160078948280B8680e5F1eB2964698928E8cd7", decimals: 8, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "6oAiihJq1urtb6P8ARjwA6TFoduSoVGxaMb8gEMm5cR6", - decimals: 8, - }, - ], - ]), }, { id: "testnet-bnb-gmt", @@ -177,15 +111,6 @@ const testnet: EvmChainConfig = { address: "0x1F65D61D01E3f10b34B855287b32D7bfbEA088D0", decimals: 8, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "GE2tiQBCoPjCABkoTXa9jTSV8zCVZo8shyiBh8v52hDz", - decimals: 8, - }, - ], - ]), }, { id: "testnet-bnb-lp-busd-usdt", @@ -194,7 +119,6 @@ const testnet: EvmChainConfig = { address: "0x57FCF9B276d3E7D698112D9b87e6f410B1B5d78d", // TODO: Update decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], @@ -221,15 +145,6 @@ const localnet: EvmChainConfig = { address: "0xCeeFD27e0542aFA926B87d23936c79c276A48277", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "4X3Fu7ZcRSf7dvKEwwQ8b5xb2jQg2NPNkWs1gDGf1WMg", - decimals: 8, - }, - ], - ]), }, { id: "local-bnb-usdt", @@ -238,15 +153,6 @@ const localnet: EvmChainConfig = { address: "0x988B6CFBf3332FF98FFBdED665b1F53a61f92612", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "9idXDPGb5jfwaf5fxjiMacgUcwpy3ZHfdgqSjAV5XLDr", - decimals: 8, - }, - ], - ]), }, ], pools: [], diff --git a/packages/evm/src/ecosystems/ethereum.ts b/packages/evm/src/ecosystems/ethereum.ts index 778fa30c1..6ca751983 100644 --- a/packages/evm/src/ecosystems/ethereum.ts +++ b/packages/evm/src/ecosystems/ethereum.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const ethereumChainId = assertType()({ [Env.Mainnet]: 1, [Env.Testnet]: 5, @@ -40,15 +37,6 @@ const mainnet: EvmChainConfig = { address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-ethereum-usdt", @@ -57,15 +45,6 @@ const mainnet: EvmChainConfig = { address: "0xdac17f958d2ee523a2206206994597c13d831ec7", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1", - decimals: 6, - }, - ], - ]), }, ], pools: [], @@ -92,15 +71,6 @@ const testnet: EvmChainConfig = { address: "0x45B167CF5b14007Ca0490dCfB7C4B870Ec0C0Aa6", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "7Lf95y8NuCU5RRC95oUtbBtckPAtbr9ubTgrCiyZ1kEf", - decimals: 6, - }, - ], - ]), }, { id: "testnet-ethereum-usdt", @@ -109,15 +79,6 @@ const testnet: EvmChainConfig = { address: "0x996f42BdB0CB71F831C2eFB05Ac6d0d226979e5B", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "8Cfyi1mYXqKATUkMPvb9BMXikdbppJst6E7eQJkKjAtf", - decimals: 6, - }, - ], - ]), }, { id: "testnet-ethereum-lp-usdc-usdt", @@ -126,7 +87,6 @@ const testnet: EvmChainConfig = { address: "0xf3eb1180A64827A602A7e02883b7299191527073", // TODO: Update decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], @@ -153,15 +113,6 @@ const localnet: EvmChainConfig = { address: "0xFcCeD5E997E7fb1D0594518D3eD57245bB8ed17E", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "Ep9cMbgyG46b6PVvJNypopc6i8TFzvUVmGiT4MA1PhSb", - decimals: 6, - }, - ], - ]), }, { id: "local-ethereum-usdt", @@ -170,15 +121,6 @@ const localnet: EvmChainConfig = { address: "0xdAA71FBBA28C946258DD3d5FcC9001401f72270F", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "9AGDY4Xa9wDfRZc2LHeSS9iAdH6Bhw6VnMd2t7tkJhYv", - decimals: 6, - }, - ], - ]), }, ], pools: [], diff --git a/packages/evm/src/ecosystems/fantom.ts b/packages/evm/src/ecosystems/fantom.ts index 3d6ec4a49..c99862cae 100644 --- a/packages/evm/src/ecosystems/fantom.ts +++ b/packages/evm/src/ecosystems/fantom.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const fantomChainId = assertType()({ [Env.Mainnet]: 250, [Env.Testnet]: 4002, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "Dnr8fDaswHtYMSKbtR9e8D5EadyxqyJwE98xp17ZxE2E", - decimals: 6, - }, - ], - ]), }, ], pools: [], @@ -74,15 +62,6 @@ const testnet: EvmChainConfig = { address: "0x92934a8b10DDF85e81B65Be1D6810544744700dC", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "9uJH6SjzmoqdiZXjcwYKuRevbYh5tR449FU5pg4rpden", - decimals: 6, - }, - ], - ]), }, { id: "testnet-fantom-lp-usdc", @@ -91,7 +70,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/ecosystems/karura.ts b/packages/evm/src/ecosystems/karura.ts index 1ec6d55d5..cedeb5a95 100644 --- a/packages/evm/src/ecosystems/karura.ts +++ b/packages/evm/src/ecosystems/karura.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const karuraChainId = assertType()({ [Env.Mainnet]: 686, [Env.Testnet]: 596, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0x0000000000000000000100000000000000000081", decimals: 12, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "3sEvyXzC2vAPqF7uprB2vRaL1X1FbqQqmPxhwVi53GYF", - decimals: 8, - }, - ], - ]), }, { id: "mainnet-karura-usdt", @@ -56,15 +44,6 @@ const mainnet: EvmChainConfig = { address: "0x0000000000000000000500000000000000000007", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "E942z7FnS7GpswTvF5Vggvo7cMTbvZojjLbFgsrDVff1", - decimals: 6, - }, - ], - ]), }, ], pools: [], @@ -91,15 +70,6 @@ const testnet: EvmChainConfig = { address: "0x074370ca8Fea9e8f1C5eE23f34CBdcD3FB7a66aD", decimals: 12, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "BRpsJtEUyCPQPRP4DAavXU5KmBqfgKQmX7fwnpVvUUMG", - decimals: 8, - }, - ], - ]), }, { id: "testnet-karura-usdt", @@ -108,15 +78,6 @@ const testnet: EvmChainConfig = { address: "0x535d5e3b1ff7de526fe180e654a41350903c328d", decimals: 18, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "AnYj8Rbkfd8FYmoiyv6iDS3Tje7PzhPWyE5VZVDh9pzD", - decimals: 8, - }, - ], - ]), }, { id: "testnet-karura-lp-usdt", @@ -125,7 +86,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, { id: "testnet-karura-lp-ausd", @@ -134,7 +94,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/ecosystems/polygon.ts b/packages/evm/src/ecosystems/polygon.ts index 75b806415..facb3c97f 100644 --- a/packages/evm/src/ecosystems/polygon.ts +++ b/packages/evm/src/ecosystems/polygon.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -10,9 +10,6 @@ import type { } from "../protocol"; import { EVM_PROTOCOL, EvmEcosystemId } from "../protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const SOLANA_ECOSYSTEM_ID = "solana"; - export const polygonChainId = assertType()({ [Env.Mainnet]: 137, [Env.Testnet]: 80001, @@ -39,15 +36,6 @@ const mainnet: EvmChainConfig = { address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "E2VmbootbVCBkMNNxKQgCLMS1X3NoGMaYAsufaAsf7M", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-polygon-usdt", @@ -56,15 +44,6 @@ const mainnet: EvmChainConfig = { address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "5goWRao6a3yNC4d6UjMdQxonkCMvKBwdpubU3qhfcdf1", - decimals: 6, - }, - ], - ]), }, ], pools: [], @@ -91,15 +70,6 @@ const testnet: EvmChainConfig = { address: "0x0a0d7cEA57faCBf5DBD0D3b5169Ab00AC8Cf7dd1", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "D5YvMW5U3HUpD1EstYbKmmZsLdmCPgUj44JqBmNY7fUM", - decimals: 6, - }, - ], - ]), }, { id: "testnet-polygon-usdt", @@ -108,15 +78,6 @@ const testnet: EvmChainConfig = { address: "0x2Ac9183EC64F71AfB73909c7C028Db14d35FAD2F", decimals: 6, }, - wrappedDetails: new Map([ - [ - SOLANA_ECOSYSTEM_ID, - { - address: "2otzQWyoydNp4Ws1kV8J8WVYiun6wmuFMMbicgdoEULn", - decimals: 6, - }, - ], - ]), }, { id: "testnet-polygon-lp-usdc-usdt", @@ -125,7 +86,6 @@ const testnet: EvmChainConfig = { address: "0x1111111111111111111111111111111111111111", // TODO: Update decimals: 8, }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/evm/src/walletAdapters/EvmWalletAdapter.ts b/packages/evm/src/walletAdapters/EvmWalletAdapter.ts index e2ee95028..295f1272f 100644 --- a/packages/evm/src/walletAdapters/EvmWalletAdapter.ts +++ b/packages/evm/src/walletAdapters/EvmWalletAdapter.ts @@ -1,6 +1,5 @@ import type { TokenDetails } from "@swim-io/core"; -import type { TokenProjectId } from "@swim-io/token-projects"; -import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects"; +import type { TokenProject } from "@swim-io/token-projects"; import { sleep } from "@swim-io/utils"; import type { Signer } from "ethers"; import { ethers } from "ethers"; @@ -29,7 +28,7 @@ export interface EvmWalletAdapter extends EventEmitter { readonly switchNetwork: (chainId: number) => Promise; readonly registerToken: ( tokenDetails: TokenDetails, - projectId: TokenProjectId, + tokenProject: Pick, chainId: number, ) => Promise; readonly isUnlocked: () => Promise; @@ -190,7 +189,8 @@ export class EvmWeb3WalletAdapter public async registerToken( tokenDetails: TokenDetails, - projectId: TokenProjectId, + /** compatible with both TokenProjectV1 and TokenProjectV2 */ + tokenProject: Pick, chainId: number, ): Promise { if (!this.walletProvider) { @@ -206,9 +206,9 @@ export class EvmWeb3WalletAdapter type: "ERC20", // Initially only supports ERC20, but eventually more! options: { address: tokenDetails.address, // The address that the token is at. - symbol: TOKEN_PROJECTS_BY_ID[projectId].symbol, // A ticker symbol or shorthand, up to 5 chars. + symbol: tokenProject.symbol, // A ticker symbol or shorthand, up to 5 chars. decimals: tokenDetails.decimals, // The number of decimals in the token - image: TOKEN_PROJECTS_BY_ID[projectId].icon, // A string url of the token logo + image: tokenProject.icon, // A string url of the token logo }, })) as boolean; return wasAdded; diff --git a/packages/solana/src/ecosystem.ts b/packages/solana/src/ecosystem.ts index ddc6cdecd..b44192230 100644 --- a/packages/solana/src/ecosystem.ts +++ b/packages/solana/src/ecosystem.ts @@ -1,4 +1,4 @@ -import type { GasToken, TokenDetails } from "@swim-io/core"; +import type { GasToken } from "@swim-io/core"; import { Env } from "@swim-io/core"; import { TokenProjectId } from "@swim-io/token-projects"; import { assertType } from "@swim-io/utils"; @@ -6,10 +6,6 @@ import { assertType } from "@swim-io/utils"; import type { SolanaChainConfig, SolanaEcosystemConfig } from "./protocol"; import { SOLANA_ECOSYSTEM_ID, SOLANA_PROTOCOL } from "./protocol"; -const EMPTY_MAP: ReadonlyMap = new Map(); -const BNB_ECOSYSTEM_ID = "bnb"; -const ETHEREUM_ECOSYSTEM_ID = "ethereum"; - /** Adapted from @solana/spl-token-registry ENV */ export enum SolanaChainId { MainnetBeta = 101, @@ -41,22 +37,6 @@ const mainnet: SolanaChainConfig = { address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", decimals: 6, }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x41f7B8b9b897276b7AAE926a9016935280b44E97", - decimals: 6, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x91Ca579B0D47E5cfD5D0862c21D5659d39C8eCf0", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-solana-usdt", @@ -65,22 +45,6 @@ const mainnet: SolanaChainConfig = { address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", decimals: 6, }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x1CDD2EaB61112697626F7b4bB0e23Da4FeBF7B7C", - decimals: 6, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x49d5cC521F75e13fa8eb4E89E9D381352C897c96", - decimals: 6, - }, - ], - ]), }, { id: "mainnet-solana-gst", @@ -89,7 +53,6 @@ const mainnet: SolanaChainConfig = { address: "AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB", decimals: 9, }, - wrappedDetails: EMPTY_MAP, }, { id: "mainnet-solana-gmt", @@ -98,166 +61,6 @@ const mainnet: SolanaChainConfig = { address: "7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx", decimals: 9, }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, - nativeDetails: { - address: "BJUH9GJLaMSLV1E7B3SQLCy9eCfyr6zsrwGcpS2MkqR1", - decimals: 8, - }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x01F369bF2d5a62CE60B0a2E92143CD623BeCb0fB", - decimals: 8, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0xF78479d516A12b9cFb000951D19f67B4fE0B065d", - decimals: 8, - }, - ], - ]), - }, - { - id: "mainnet-solana-lp-meta-avalanche-usdc", - projectId: TokenProjectId.SwimAvalancheUsdcLp, - nativeDetails: { - address: "DKwsWeqHrB8R1u2DFMHKtq4iqaQNgPgUbHTJyXPqkTzK", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-avalanche-usdt", - projectId: TokenProjectId.SwimAvalancheUsdtLp, - nativeDetails: { - address: "5rwvDmUbcnZTwZ4Zywev2wnDbyDDD2vcsGU2Xmy7aRNS", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-polygon-usdc", - projectId: TokenProjectId.SwimPolygonUsdcLp, - nativeDetails: { - address: "ANFojEXhiEQQoovhBs77XmBQuqbe59UBygRWViyf4945", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-polygon-usdt", - projectId: TokenProjectId.SwimPolygonUsdtLp, - nativeDetails: { - address: "2Nx6L79dHHgHcJtNfZWukQkWZvf5h4bps34zuh1gjtdP", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-gst", - projectId: TokenProjectId.SwimSolanaGstBinanceGstLp, - nativeDetails: { - address: "8YYBkTNhpY9mFdCdZWM6mHNf8J6A9hGfimb33LEiiZ3x", - decimals: 9, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-gmt", - projectId: TokenProjectId.SwimSolanaGmtBinanceGmtLp, - nativeDetails: { - address: "2x7MjgopLXd3qETGLpY19cyZjHvVnGkrwVjTkJnBza4A", - decimals: 9, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-aurora-usdc", - projectId: TokenProjectId.SwimAuroraUsdcLp, - nativeDetails: { - address: "9qRe2nBrR2rTXxRaV1PZN9hZnqq3UXgoFWTbP6NE3MEu", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-aurora-usdt", - projectId: TokenProjectId.SwimAuroraUsdtLp, - nativeDetails: { - address: "4XPDxtGbcM7bAPKZxALd2s862n3WoG4xPPvyCPVULKAb", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-aurora-usn", - projectId: TokenProjectId.SwimAuroraUsnLp, - nativeDetails: { - address: "3eXCU7YoiCq3rZ6787pPFJE7TXBsKuTZ49wH2kFnuTeF", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-fantom-usdc", - projectId: TokenProjectId.SwimFantomUsdcLp, - nativeDetails: { - address: "J5ifGexAQTg76TresJhJSqTPJLT6BNxrV5rwNJTTz4Cx", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-karura-ausd", - projectId: TokenProjectId.SwimKaruraAusdLp, - nativeDetails: { - address: "8vzXSNVAX4fymEFahJFh1ypzDBFv3QMVaZ4GtJWHrRjU", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-karura-usdt", - projectId: TokenProjectId.SwimKaruraUsdtLp, - nativeDetails: { - address: "2sXvitirRSjgTTNzGNWAFZWSqEx87kDoTJvqG9JSyivh", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-meta-acala-ausd", - projectId: TokenProjectId.SwimAcalaAusdLp, - nativeDetails: { - address: "11111111111111111111111111111111", // TODO: Update - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-swim", - projectId: TokenProjectId.Swim, - nativeDetails: { - address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", - decimals: 6, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "mainnet-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, - nativeDetails: { - address: "SwiMNJ49SxkqMaVWLGGVRH25kE5dBnD2RQoiQUnKtMC", - decimals: 6, - }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], @@ -286,7 +89,6 @@ const testnet: SolanaChainConfig = { address: "6iSRgpK4oiqJZuhpLsTecW3n9xBKUq9N3VPQN7RinYwq", decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, { id: "testnet-solana-usdt", @@ -295,7 +97,6 @@ const testnet: SolanaChainConfig = { address: "8VbikoRxEoyYzTDzDcPTSsGk2E5mM7fK1WrVpKrVd75M", decimals: 6, }, - wrappedDetails: EMPTY_MAP, }, { id: "testnet-solana-gst", @@ -304,7 +105,6 @@ const testnet: SolanaChainConfig = { address: "FYxTtPiGxNSDouZQftVRHFqraFJyLvNbTXzZj8X2gKQP", decimals: 9, }, - wrappedDetails: EMPTY_MAP, }, { id: "testnet-solana-gmt", @@ -313,166 +113,6 @@ const testnet: SolanaChainConfig = { address: "3xsNPBpf7UAKpJsLTqiPqHT3ZBKPDndj1rJFM7xaSJcV", decimals: 9, }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, - nativeDetails: { - address: "5ctnNpb7h1SyPqZ8t8m2kCykrtDGVZBtZgYWv6UAeDhr", - decimals: 8, - }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x4DF39C514Eb1747bb4D89cA9Ee35718611590935", - decimals: 8, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x84252522366DB2eA1dAaDe5E2C55CD90a50aC46e", - decimals: 8, - }, - ], - ]), - }, - { - id: "testnet-solana-swim", - projectId: TokenProjectId.Swim, - nativeDetails: { - address: "swimnKEr963p7EbCjsSnBCoYwytuZHPm3zbq6fKLHXb", - decimals: 6, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, - nativeDetails: { - address: "A8UVBwvj1XcdP5okoMqkjhCQGLaqQ8iJDYnNxAMbsNNF", - decimals: 6, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-avalanche-usdc", - projectId: TokenProjectId.SwimAvalancheUsdcLp, - nativeDetails: { - address: "DU15RXzuPWTLC4tbAcQvtXbDkHFrY8u6CxgTdhz2Mt8c", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-avalanche-usdt", - projectId: TokenProjectId.SwimAvalancheUsdtLp, - nativeDetails: { - address: "D6PuZckpEcBhVcpfgjgbWnARhFD3ApHhvnxBGWR6MW5Z", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-polygon-usdc", - projectId: TokenProjectId.SwimPolygonUsdcLp, - nativeDetails: { - address: "6WBFbyA3XJ3T2BeqA9JbyZFfj3KTCRtnC8MJANBsVNrz", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-polygon-usdt", - projectId: TokenProjectId.SwimPolygonUsdtLp, - nativeDetails: { - address: "HH3RwS94BWhR4bKeNYGvr2CfSLRQ2Kq6EYSDTKgGLgET", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-gst", - projectId: TokenProjectId.SwimSolanaGstBinanceGstLp, - nativeDetails: { - address: "BM3sXSfRg1yKzf2AbTA5QV76MdnKHi9M8D7VCGzDEYM1", - decimals: 9, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-gmt", - projectId: TokenProjectId.SwimSolanaGmtBinanceGmtLp, - nativeDetails: { - address: "5VUZL2JcvbmjuT1DzDyWJ4mwtEH8unKyuQj3k38j8Ngs", - decimals: 9, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-aurora-usdc", - projectId: TokenProjectId.SwimAuroraUsdcLp, - nativeDetails: { - address: "AQiHPuuBPsq4MLLjLv2WHRFbrNB1JHZeR4mQGVJTwVHn", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-aurora-usdt", - projectId: TokenProjectId.SwimAuroraUsdtLp, - nativeDetails: { - address: "utXdXdUMaS5qrBDDUg5btQMGL2CedouzmMPbYMJPEZD", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-aurora-usn", - projectId: TokenProjectId.SwimAuroraUsnLp, - nativeDetails: { - address: "11111111111111111111111111111111", // TODO: Update - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-fantom-usdc", - projectId: TokenProjectId.SwimFantomUsdcLp, - nativeDetails: { - address: "4hmRgsk3hSdK1gXV7rg1pStwYtntKmbcFQyKqsZ4USis", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-karura-ausd", - projectId: TokenProjectId.SwimKaruraAusdLp, - nativeDetails: { - address: "4idDPnTYR4J9YhXmayKZYW8QBrASuuiTAxfkWUeaL3ap", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-karura-usdt", - projectId: TokenProjectId.SwimKaruraUsdtLp, - nativeDetails: { - address: "882uzB9euTbBQJ6MrGrvxjXSTQi23VBQZcLcTH4E5Xow", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "testnet-solana-lp-meta-acala-ausd", - projectId: TokenProjectId.SwimAcalaAusdLp, - nativeDetails: { - address: "BTbHtbUtDX5WAUSxPgELzy9VsbMbKAVFQ2hykNrD3X7L", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, }, ], pools: [ @@ -519,22 +159,6 @@ const localnet: SolanaChainConfig = { address: "USCAD1T3pV246XwC5kBFXpEjuudS1zT1tTNYhxby9vy", decimals: 6, }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x81681EC304dcfe2Ddad462E7e968C49A848410c3", - decimals: 6, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x04C5Bf0f72FC1a9F50Ff3228C6285491ad00e13E", - decimals: 6, - }, - ], - ]), }, { id: "local-solana-usdt", @@ -543,64 +167,6 @@ const localnet: SolanaChainConfig = { address: "USTPJc7bSkXxRPP1ZdxihfxtfgWNrcRPrE4KEC6EK23", decimals: 6, }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0xa22915e82eb27fb64988Efa3d2749838174ccCBE", - decimals: 6, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x23F55d75CFBe4334031dc7a19bf030613E966b2B", - decimals: 6, - }, - ], - ]), - }, - { - id: "local-solana-lp-hexapool", - projectId: TokenProjectId.SwimUsd, - nativeDetails: { - address: "LPTufpWWSucDqq1hib8vxj1uJxTh2bkE7ZTo65LH4J2", - decimals: 8, - }, - wrappedDetails: new Map([ - [ - ETHEREUM_ECOSYSTEM_ID, - { - address: "0x56cd8686e818c0C29983eA32fa6938618b35923f", - decimals: 8, - }, - ], - [ - BNB_ECOSYSTEM_ID, - { - address: "0x7231BBdaB2F3814664f6E1f072A5ae0525709431", - decimals: 8, - }, - ], - ]), - }, - { - id: "local-solana-swim", - projectId: TokenProjectId.Swim, - nativeDetails: { - address: "SWMPqjB9AAtpCbatAEEGK67wNBCN1HDW6VypX7E5r9g", - decimals: 6, - }, - wrappedDetails: EMPTY_MAP, - }, - { - id: "local-solana-lp-swimlake", - projectId: TokenProjectId.XSwim, - nativeDetails: { - address: "xSwy12tTsuYwM2Hd7ceNmvDftgxJ2ZSTycjzAfrNwPW", - decimals: 8, - }, - wrappedDetails: EMPTY_MAP, }, ], pools: [], diff --git a/packages/solana/src/wormhole.ts b/packages/solana/src/wormhole.ts index 087db56df..e743bbff5 100644 --- a/packages/solana/src/wormhole.ts +++ b/packages/solana/src/wormhole.ts @@ -17,7 +17,7 @@ import type { VersionedTransactionResponse, } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js"; -import type { WrappedTokenInfo } from "@swim-io/core/types"; +import type { WrappedTokenInfo } from "@swim-io/core"; import { createMemoIx, createTx } from "./utils"; diff --git a/packages/token-projects/images/lp_gmt.svg b/packages/token-projects/images/lp_gmt.svg deleted file mode 100644 index 0900b51a5..000000000 --- a/packages/token-projects/images/lp_gmt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/token-projects/images/lp_gst.svg b/packages/token-projects/images/lp_gst.svg deleted file mode 100644 index 22b4a48db..000000000 --- a/packages/token-projects/images/lp_gst.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/token-projects/images/sol.svg b/packages/token-projects/images/sol.svg deleted file mode 100644 index 8797740c5..000000000 --- a/packages/token-projects/images/sol.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/token-projects/images/swim.svg b/packages/token-projects/images/swim.svg deleted file mode 100644 index ff8ec695e..000000000 --- a/packages/token-projects/images/swim.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/token-projects/images/xswim.svg b/packages/token-projects/images/xswim.svg deleted file mode 100644 index 17de89231..000000000 --- a/packages/token-projects/images/xswim.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/token-projects/src/projects.ts b/packages/token-projects/src/projects.ts index d68a68e94..8c40d53be 100644 --- a/packages/token-projects/src/projects.ts +++ b/packages/token-projects/src/projects.ts @@ -5,51 +5,23 @@ import BUSD_SVG from "./images/busd"; import GMT_SVG from "./images/gmt"; import GST_SVG from "./images/gst"; import LP_ACALA_AUSD_SVG from "./images/lp_acala_ausd"; -import LP_AURORA_USDC_SVG from "./images/lp_aurora_usdc"; -import LP_AURORA_USDT_SVG from "./images/lp_aurora_usdt"; -import LP_AURORA_USN_SVG from "./images/lp_aurora_usn"; -import LP_AVALANCHE_USDC_SVG from "./images/lp_avalanche_usdc"; -import LP_AVALANCHE_USDT_SVG from "./images/lp_avalanche_usdt"; import LP_FANTOM_USDC_SVG from "./images/lp_fantom_usdc"; -import LP_GMT_SVG from "./images/lp_gmt"; -import LP_GST_SVG from "./images/lp_gst"; import LP_KARURA_AUSD_SVG from "./images/lp_karura_ausd"; import LP_KARURA_USDT_SVG from "./images/lp_karura_usdt"; -import LP_POLYGON_USDC_SVG from "./images/lp_polygon_usdc"; -import LP_POLYGON_USDT_SVG from "./images/lp_polygon_usdt"; -import SWIM_TOKEN_SVG from "./images/swim"; import SWIM_USD_SVG from "./images/swim_usd"; import USDC_SVG from "./images/usdc"; import USDT_SVG from "./images/usdt"; import USN_SVG from "./images/usn"; -import XSWIM_TOKEN_SVG from "./images/xswim"; export enum TokenProjectId { Ausd = "ausd", Busd = "busd", Gmt = "gmt", Gst = "gst", - Swim = "swim", - SwimAcalaAusdLp = "swim-acala-ausd-lp", - SwimAuroraUsdcLp = "swim-aurora-usdc-lp", - SwimAuroraUsdtLp = "swim-aurora-usdt-lp", - SwimAuroraUsnLp = "swim-aurora-usn-lp", - SwimAvalancheUsdcLp = "swim-avalanche-usdc-lp", - SwimAvalancheUsdtLp = "swim-avalanche-usdt-lp", - SwimFantomUsdcLp = "swim-fantom-usdc-lp", - SwimKaruraAusdLp = "swim-karura-ausd-lp", - SwimKaruraUsdtLp = "swim-karura-usdt-lp", - SwimPolygonUsdcLp = "swim-polygon-usdc-lp", - SwimPolygonUsdtLp = "swim-polygon-usdt-lp", - SwimSolanaGmtBinanceGmtLp = "swim-solana-gmt-binance-gst-lp", - SwimSolanaGstBinanceGstLp = "swim-solana-gst-binance-gst-lp", SwimUsd = "swim-usd", Usdc = "usdc", Usdt = "usdt", Usn = "usn", - XSwim = "xswim", - // V2 - SwimLpSolanaUsdcUsdt = "swim-lp-solana-usdc-usdt", SwimLpEthereumUsdcUsdt = "swim-lp-ethereum-usdc-usdt", SwimLpBnbBusdUsdt = "swim-lp-bnb-busd-usdt", SwimLpAvalancheUsdcUsdt = "swim-lp-avalanche-usdc-usdt", @@ -62,21 +34,32 @@ export enum TokenProjectId { SwimLpAcalaAusd = "swim-lp-acala-ausd", } +export const isTokenProjectId = (id: string): id is TokenProjectId => { + return Object.values(TokenProjectId).includes(id as TokenProjectId); +}; + /** * A token project incorporates one or more tokens. For example USDT has deployments on several * different chains, which are technically independent tokens but share many features. Note that * these are not wrapped versions of some single original token. */ -export interface TokenProject { +export type TokenProject = { readonly id: TokenProjectId; readonly symbol: string; readonly displayName: string; - /** URL of an icon for the token */ + /** absolute url or base64 of an icon for the token */ readonly icon: string; readonly isStablecoin: boolean; - readonly isLp: boolean; - readonly tokenNumber: number | null; -} +} & ( + | { + readonly isLp: boolean; + readonly tokenNumber: number; + } + | { + readonly isLp: true; + readonly tokenNumber: null; + } +); export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< TokenProjectId, @@ -147,152 +130,6 @@ export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< }, [TokenProjectId.SwimUsd]: { id: TokenProjectId.SwimUsd, - symbol: "swimUSD", - displayName: "swimUSD (Swim Hexapool LP)", - icon: SWIM_USD_SVG, - isStablecoin: true, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.Swim]: { - id: TokenProjectId.Swim, - symbol: "SWIM", - displayName: "Swim Protocol Token", - icon: SWIM_TOKEN_SVG, - isStablecoin: false, - isLp: false, - tokenNumber: null, - }, - [TokenProjectId.XSwim]: { - id: TokenProjectId.XSwim, - symbol: "xSWIM", - displayName: "xSWIM (SwimLake LP)", - icon: XSWIM_TOKEN_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAvalancheUsdcLp]: { - id: TokenProjectId.SwimAvalancheUsdcLp, - symbol: "SWIM-AVALANCHE-USDC-LP", - displayName: "Avalanche USDC LP", - icon: LP_AVALANCHE_USDC_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAvalancheUsdtLp]: { - id: TokenProjectId.SwimAvalancheUsdtLp, - symbol: "SWIM-AVALANCHE-USDT-LP", - displayName: "Avalanche USDT LP", - icon: LP_AVALANCHE_USDT_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimPolygonUsdcLp]: { - id: TokenProjectId.SwimPolygonUsdcLp, - symbol: "SWIM-POLYGON-USDC-LP", - displayName: "Polygon USDC LP", - icon: LP_POLYGON_USDC_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimPolygonUsdtLp]: { - id: TokenProjectId.SwimPolygonUsdtLp, - symbol: "SWIM-POLYGON-USDT-LP", - displayName: "Polygon USDT LP", - icon: LP_POLYGON_USDT_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimSolanaGstBinanceGstLp]: { - id: TokenProjectId.SwimSolanaGstBinanceGstLp, - symbol: "solaGST-binaGST", - displayName: "Swim Solana GST Binance GST LP", - icon: LP_GST_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimSolanaGmtBinanceGmtLp]: { - id: TokenProjectId.SwimSolanaGmtBinanceGmtLp, - symbol: "solaGMT-binaGMT", - displayName: "Swim Solana GMT Binance GMT LP", - icon: LP_GMT_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAuroraUsdcLp]: { - id: TokenProjectId.SwimAuroraUsdcLp, - symbol: "SWIM-AURORA-USDC-LP", - displayName: "Aurora USDC LP", - icon: LP_AURORA_USDC_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAuroraUsdtLp]: { - id: TokenProjectId.SwimAuroraUsdtLp, - symbol: "SWIM-AURORA-USDT-LP", - displayName: "Aurora USDT LP", - icon: LP_AURORA_USDT_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAuroraUsnLp]: { - id: TokenProjectId.SwimAuroraUsnLp, - symbol: "SWIM-AURORA-USN-LP", - displayName: "Aurora USN LP", - icon: LP_AURORA_USN_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimFantomUsdcLp]: { - id: TokenProjectId.SwimFantomUsdcLp, - symbol: "SWIM-FANTOM-USDC-LP", - displayName: "Fantom USDC LP", - icon: LP_FANTOM_USDC_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimKaruraAusdLp]: { - id: TokenProjectId.SwimKaruraAusdLp, - symbol: "SWIM-KARURA-AUSD-LP", - displayName: "Karura AUSD LP", - icon: LP_KARURA_AUSD_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimKaruraUsdtLp]: { - id: TokenProjectId.SwimKaruraUsdtLp, - symbol: "SWIM-KARURA-USDT-LP", - displayName: "Karura USDT LP", - icon: LP_KARURA_USDT_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - [TokenProjectId.SwimAcalaAusdLp]: { - id: TokenProjectId.SwimAcalaAusdLp, - symbol: "SWIM-ACALA-AUSD-LP", - displayName: "Acala AUSD LP", - icon: LP_ACALA_AUSD_SVG, - isStablecoin: false, - isLp: true, - tokenNumber: null, - }, - // V2 - // TODO: Reassign swimUSD to this token - [TokenProjectId.SwimLpSolanaUsdcUsdt]: { - id: TokenProjectId.SwimLpSolanaUsdcUsdt, symbol: "swimUSDv2", // TODO: update displayName: "swimUSD (v2)", // TODO: update icon: SWIM_USD_SVG, // TODO: update @@ -358,7 +195,7 @@ export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< id: TokenProjectId.SwimLpFantomUsdc, symbol: "SWIM-LP-FANTOM-USDC", displayName: "Fantom USDC Pool LP", - icon: SWIM_USD_SVG, // TODO: update + icon: LP_FANTOM_USDC_SVG, isStablecoin: false, isLp: true, tokenNumber: null, @@ -367,7 +204,7 @@ export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< id: TokenProjectId.SwimLpKaruraUsdt, symbol: "SWIM-LP-KARURA-USDT", displayName: "Karura USDT Pool LP", - icon: SWIM_USD_SVG, // TODO: update + icon: LP_KARURA_USDT_SVG, isStablecoin: false, isLp: true, tokenNumber: null, @@ -376,7 +213,7 @@ export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< id: TokenProjectId.SwimLpKaruraAusd, symbol: "SWIM-LP-KARURA-AUSD", displayName: "Karura AUSD Pool LP", - icon: SWIM_USD_SVG, // TODO: update + icon: LP_KARURA_AUSD_SVG, isStablecoin: false, isLp: true, tokenNumber: null, @@ -385,7 +222,7 @@ export const TOKEN_PROJECTS_BY_ID: ReadonlyRecord< id: TokenProjectId.SwimLpAcalaAusd, symbol: "SWIM-LP-ACALA-AUSD", displayName: "Acala AUSD Pool LP", - icon: SWIM_USD_SVG, // TODO: update + icon: LP_ACALA_AUSD_SVG, isStablecoin: false, isLp: true, tokenNumber: null, diff --git a/packages/utils/src/collections.ts b/packages/utils/src/collections.ts index edc94a0d4..a1377250e 100644 --- a/packages/utils/src/collections.ts +++ b/packages/utils/src/collections.ts @@ -27,16 +27,24 @@ export const deduplicate = ( ).values(), ]; -export const findOrThrow = ( +export function findOrThrow( + searchables: readonly T[], + condition: (element: T, index: number, array: readonly T[]) => element is S, +): S; +export function findOrThrow( + searchables: readonly T[], + condition: (element: T, index: number, array: readonly T[]) => boolean, +): T; +export function findOrThrow( searchables: readonly T[], condition: (element: T, index: number, array: readonly T[]) => boolean, -): T => { +): T { const result = searchables.find(condition); if (result === undefined) { throw new Error("Not found"); } return result; -}; +} export const chunks = ( array: readonly T[], diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts index 38e6f77d3..d915077ac 100644 --- a/packages/utils/src/types.ts +++ b/packages/utils/src/types.ts @@ -5,5 +5,8 @@ export const assertType = () => { return (input: U): U => input; }; +/** Override existing field types */ +export type Override = Omit & U; + /** Get union type of object values */ export type ValueOf> = T[keyof T]; diff --git a/yarn.lock b/yarn.lock index 9170f8b16..2ade8ad9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7426,27 +7426,7 @@ __metadata: languageName: node linkType: hard -"@swim-io/evm@npm:^0.40.0": - version: 0.40.0 - resolution: "@swim-io/evm@npm:0.40.0" - dependencies: - "@swim-io/core": ^0.40.0 - "@swim-io/evm-contracts": ^0.40.0 - "@swim-io/token-projects": ^0.40.0 - "@swim-io/utils": ^0.40.0 - graphql: ^16.6.0 - graphql-request: ^4.3.0 - moralis: ^1.8.0 - peerDependencies: - "@certusone/wormhole-sdk": ^0.6.2 - decimal.js: ^10.3.1 - ethers: ^5.6.9 - eventemitter3: ^4.0.7 - checksum: ba65ee3dcf51c9a4c1e329a7597b41c4226028f2fc76afd57c9e8185b20e04ef5563d47cdf017ec9aa122e148162408b16d544a167c6953b251a77fc83cebdfb - languageName: node - linkType: hard - -"@swim-io/evm@workspace:packages/evm": +"@swim-io/evm@workspace:^, @swim-io/evm@workspace:packages/evm": version: 0.0.0-use.local resolution: "@swim-io/evm@workspace:packages/evm" dependencies: @@ -7972,14 +7952,14 @@ __metadata: "@storybook/node-logger": ^6.5.10 "@storybook/react": ^6.5.10 "@swim-io/aptos": ^0.40.0 - "@swim-io/core": ^0.40.0 + "@swim-io/core": "workspace:^" "@swim-io/eslint-config": "workspace:^" - "@swim-io/evm": ^0.40.0 + "@swim-io/evm": "workspace:^" "@swim-io/evm-contracts": ^0.40.0 "@swim-io/pool-math": ^0.40.0 - "@swim-io/solana": ^0.40.0 + "@swim-io/solana": "workspace:^" "@swim-io/solana-contracts": ^0.40.0 - "@swim-io/token-projects": ^0.40.0 + "@swim-io/token-projects": "workspace:^" "@swim-io/tsconfig": "workspace:^" "@swim-io/utils": ^0.40.0 "@swim-io/wormhole": ^0.40.0