Skip to content

Commit

Permalink
Enable USDT and cleanup for Across (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xh3rman authored Jan 14, 2025
1 parent a33c570 commit 6ee5a01
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 77 deletions.
77 changes: 9 additions & 68 deletions crates/gem_evm/src/across/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,81 +78,22 @@ impl AcrossDeployment {
HashMap::from([
(
Chain::Ethereum,
vec![
ACX_ETH_ASSET_ID.into(),
DAI_ETH_ASSET_ID.into(),
USDC_ETH_ASSET_ID.into(),
USDT_ETH_ASSET_ID.into(),
USDC_E_ETH_ASSET_ID.into(),
WBTC_ETH_ASSET_ID.into(),
WETH_ETH_ASSET_ID.into(),
],
),
(
Chain::Optimism,
vec![
ACX_OP_ASSET_ID.into(),
DAI_OP_ASSET_ID.into(),
USDT_OP_ASSET_ID.into(),
USDC_OP_ASSET_ID.into(),
USDC_E_OP_ASSET_ID.into(),
WBTC_OP_ASSET_ID.into(),
WETH_OP_ASSET_ID.into(),
],
vec![USDC_ETH_ASSET_ID.into(), USDT_ETH_ASSET_ID.into(), WETH_ETH_ASSET_ID.into()],
),
(Chain::Optimism, vec![USDT_OP_ASSET_ID.into(), USDC_OP_ASSET_ID.into(), WETH_OP_ASSET_ID.into()]),
(
Chain::Polygon,
vec![
ACX_POLYGON_ASSET_ID.into(),
DAI_POLYGON_ASSET_ID.into(),
USDC_POLYGON_ASSET_ID.into(),
USDC_E_POLYGON_ASSET_ID.into(),
USDT_POLYGON_ASSET_ID.into(),
WBTC_POLYGON_ASSET_ID.into(),
WETH_POLYGON_ASSET_ID.into(),
],
vec![USDC_POLYGON_ASSET_ID.into(), USDT_POLYGON_ASSET_ID.into(), WETH_POLYGON_ASSET_ID.into()],
),
(
Chain::Arbitrum,
vec![
ACX_ARB_ASSET_ID.into(),
DAI_ARB_ASSET_ID.into(),
USDT_ARB_ASSET_ID.into(),
USDC_ARB_ASSET_ID.into(),
USDC_E_ARB_ASSET_ID.into(),
WBTC_ARB_ASSET_ID.into(),
WETH_ARB_ASSET_ID.into(),
],
),
(
Chain::Base,
vec![WETH_BASE_ASSET_ID.into(), USDC_BASE_ASSET_ID.into(), USDC_E_BASE_ASSET_ID.into()],
),
(
Chain::Linea,
vec![
DAI_LINEA_ASSET_ID.into(),
USDC_E_LINEA_ASSET_ID.into(),
USDT_LINEA_ASSET_ID.into(),
WBTC_LINEA_ASSET_ID.into(),
WETH_LINEA_ASSET_ID.into(),
],
),
(
Chain::ZkSync,
vec![
DAI_ZKSYNC_ASSET_ID.into(),
WBTC_ZKSYNC_ASSET_ID.into(),
WETH_ZKSYNC_ASSET_ID.into(),
USDC_E_ZKSYNC_ASSET_ID.into(),
USDT_ZKSYNC_ASSET_ID.into(),
],
),
(
Chain::World,
vec![WBTC_WORLD_ASSET_ID.into(), WETH_WORLD_ASSET_ID.into(), USDC_E_WORLD_ASSET_ID.into()],
vec![USDT_ARB_ASSET_ID.into(), USDC_ARB_ASSET_ID.into(), WETH_ARB_ASSET_ID.into()],
),
(Chain::Blast, vec![WBTC_BLAST_ASSET_ID.into(), WETH_BLAST_ASSET_ID.into()]),
(Chain::Base, vec![WETH_BASE_ASSET_ID.into(), USDC_BASE_ASSET_ID.into()]),
(Chain::Linea, vec![USDT_LINEA_ASSET_ID.into(), WETH_LINEA_ASSET_ID.into()]),
(Chain::ZkSync, vec![WETH_ZKSYNC_ASSET_ID.into(), USDT_ZKSYNC_ASSET_ID.into()]),
(Chain::World, vec![WETH_WORLD_ASSET_ID.into()]),
(Chain::Blast, vec![WETH_BLAST_ASSET_ID.into()]),
])
}

Expand Down
18 changes: 10 additions & 8 deletions gemstone/src/swapper/across/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ impl Across {
pub fn is_supported_pair(from_asset: &AssetId, to_asset: &AssetId) -> bool {
let from = weth_address::normalize_asset(from_asset).unwrap();
let to = weth_address::normalize_asset(to_asset).unwrap();
debug_println!("from: {:?}, to: {:?}", from, to);
let asset_mappings = AcrossDeployment::asset_mappings();
for mapping in asset_mappings.iter() {
if mapping.set.contains(&from) && mapping.set.contains(&to) {
return true;
}
}
false

AcrossDeployment::asset_mappings()
.into_iter()
.any(|x| x.set.contains(&from) && x.set.contains(&to))
}

pub fn get_rate_model(from_asset: &AssetId, to_asset: &AssetId, token_config: &TokenConfig) -> RateModel {
Expand Down Expand Up @@ -250,6 +246,12 @@ impl GemSwapProvider for Across {
SwapChainAsset::Assets(Chain::Ethereum, vec![ETHEREUM_USDC.id.clone()]),
SwapChainAsset::Assets(Chain::Base, vec![BASE_USDC.id.clone()]),
SwapChainAsset::Assets(Chain::Optimism, vec![OPTIMISM_USDC.id.clone()]),
// USDT
SwapChainAsset::Assets(Chain::Arbitrum, vec![ARBITRUM_USDT.id.clone()]),
SwapChainAsset::Assets(Chain::Ethereum, vec![ETHEREUM_USDT.id.clone()]),
SwapChainAsset::Assets(Chain::Linea, vec![LINEA_USDT.id.clone()]),
SwapChainAsset::Assets(Chain::Optimism, vec![OPTIMISM_USDT.id.clone()]),
SwapChainAsset::Assets(Chain::ZkSync, vec![ZKSYNC_USDT.id.clone()]),
]
}

Expand Down
1 change: 0 additions & 1 deletion gemstone/src/swapper/universal_router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ impl GemSwapProvider for UniswapV3 {
if !self.support_chain(&request.from_asset.chain) {
return Err(SwapperError::NotSupportedChain);
}

let wallet_address: Address = request.wallet_address.as_str().parse().map_err(SwapperError::from)?;

// Check deployment and weth contract
Expand Down

0 comments on commit 6ee5a01

Please sign in to comment.