Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable base on thorchain #8563

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/swapper/src/swappers/ThorchainSwapper/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const sellSupportedChainIds: Record<ChainId, boolean> = {
[KnownChainIds.ThorchainMainnet]: true,
[KnownChainIds.AvalancheMainnet]: true,
[KnownChainIds.BnbSmartChainMainnet]: true,
[KnownChainIds.BaseMainnet]: true,
}

export const buySupportedChainIds: Record<ChainId, boolean> = {
Expand All @@ -30,6 +31,7 @@ export const buySupportedChainIds: Record<ChainId, boolean> = {
[KnownChainIds.ThorchainMainnet]: true,
[KnownChainIds.AvalancheMainnet]: true,
[KnownChainIds.BnbSmartChainMainnet]: true,
[KnownChainIds.BaseMainnet]: true,
}

export const THORCHAIN_SUPPORTED_CHAIN_IDS: SupportedChainIds = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F": "eip155:43114/erc20:0xfe6b19286885a4f7f55adad09c3cd1f906d2478f",
"AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E": "eip155:43114/erc20:0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
"AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7": "eip155:43114/erc20:0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7",
"BASE.CBBTC-0XCBB7C0000AB88B473B1F5AFD9EF808440EED33BF": "eip155:8453/erc20:0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
"BASE.ETH": "eip155:8453/slip44:60",
"BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"BCH.BCH": "bip122:000000000000000000651ef99cb9fcbe/slip44:145",
"BSC.BNB": "eip155:56/slip44:60",
"BSC.TWT-0X4B0F1812E5DF2A09796481FF14017E6005508003": "eip155:56/bep20:0x4b0f1812e5df2a09796481ff14017e6005508003",
"BSC.USDC-0X8AC76A51CC950D9822D68B83FE1AD97B32CD580D": "eip155:56/bep20:0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"BSC.USDT-0X55D398326F99059FF775485246999027B3197955": "eip155:56/bep20:0x55d398326f99059ff775485246999027b3197955",
"BTC.BTC": "bip122:000000000019d6689c085ae165831e93/slip44:0",
Expand Down
1 change: 1 addition & 0 deletions packages/swapper/src/swappers/ThorchainSwapper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export enum ThorchainChain {
GAIA = 'GAIA',
THOR = 'THOR',
BSC = 'BSC',
BASE = 'BASE',
}

export type ThorEvmTradeQuote = TradeQuote &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const checkOutputTxConfirmations = async (
case ThorchainChain.GAIA: {
return config.REACT_APP_UNCHAINED_COSMOS_HTTP_URL
}
case ThorchainChain.BASE: {
return config.REACT_APP_UNCHAINED_BASE_HTTP_URL
}
case ThorchainChain.BSC:
throw Error(`${latestOutTx.chain} not supported`)
default:
Expand Down
1 change: 1 addition & 0 deletions packages/swapper/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type SwapperConfig = {
REACT_APP_UNCHAINED_ETHEREUM_HTTP_URL: string
REACT_APP_UNCHAINED_AVALANCHE_HTTP_URL: string
REACT_APP_UNCHAINED_BNBSMARTCHAIN_HTTP_URL: string
REACT_APP_UNCHAINED_BASE_HTTP_URL: string
REACT_APP_COWSWAP_BASE_URL: string
REACT_APP_PORTALS_BASE_URL: string
REACT_APP_ZRX_BASE_URL: string
Expand Down
12 changes: 11 additions & 1 deletion scripts/generateTradableThorAssetMap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
ASSET_NAMESPACE,
avalancheAssetId,
avalancheChainId,
baseAssetId,
baseChainId,
bchAssetId,
bchChainId,
binanceAssetId,
Expand Down Expand Up @@ -41,6 +43,7 @@ enum ThorchainChain {
GAIA = 'GAIA',
THOR = 'THOR',
BSC = 'BSC',
BASE = 'BASE',
}

const ChainToChainIdMap: Map<ThorchainChain, ChainId> = new Map([
Expand All @@ -54,6 +57,7 @@ const ChainToChainIdMap: Map<ThorchainChain, ChainId> = new Map([
[ThorchainChain.GAIA, cosmosChainId],
[ThorchainChain.THOR, thorchainChainId],
[ThorchainChain.BSC, bscChainId],
[ThorchainChain.BASE, baseChainId],
])

function assertUnreachable(x: never): never {
Expand Down Expand Up @@ -82,6 +86,8 @@ export const getFeeAssetFromThorchainChain = (chain: ThorchainChain): AssetId |
return cosmosAssetId
case ThorchainChain.BSC:
return bscAssetId
case ThorchainChain.BASE:
return baseAssetId
default:
assertUnreachable(chain)
}
Expand All @@ -93,6 +99,7 @@ export const getTokenStandardFromChainId = (chainId: ChainId): AssetNamespace |
case KnownChainIds.AvalancheMainnet:
case KnownChainIds.PolygonMainnet:
case KnownChainIds.GnosisMainnet:
case KnownChainIds.BaseMainnet:
return ASSET_NAMESPACE.erc20
case KnownChainIds.BnbSmartChainMainnet:
return ASSET_NAMESPACE.bep20
Expand All @@ -111,7 +118,10 @@ export const getAssetIdPairFromPool = (pool: ThornodePoolResponse): AssetIdPair
const [, id] = symbol.split('-')
const chainId = ChainToChainIdMap.get(chain as ThorchainChain)
const isFeeAsset =
chain === symbol || thorchainAsset === 'GAIA.ATOM' || thorchainAsset === 'BSC.BNB'
chain === symbol ||
thorchainAsset === 'GAIA.ATOM' ||
thorchainAsset === 'BSC.BNB' ||
thorchainAsset === 'BASE.ETH'
if (isFeeAsset) {
const assetId = chainId ? getFeeAssetFromThorchainChain(chain as ThorchainChain) : undefined
if (assetId) {
Expand Down