-
Notifications
You must be signed in to change notification settings - Fork 46
add ETH and WBTC.e asset specs #1710
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ use itp_types::{ | |
| parentchain::{Hash, ParentchainAssetIdNative}, | ||
| xcm::{ | ||
| Junction::{AccountKey20, GlobalConsensus}, | ||
| Junctions::X2, | ||
| Junctions::{X1, X2}, | ||
| Location, | ||
| NetworkId::Ethereum, | ||
| }, | ||
|
|
@@ -57,23 +57,33 @@ use serde::{Deserialize, Serialize}; | |
| #[repr(u32)] | ||
| #[allow(non_camel_case_types)] | ||
| pub enum AssetId { | ||
| // Tether tokens | ||
| /// USDT Tether, minted natively | ||
| USDT = 10, | ||
| /// USDT Tether, minted on Ethereum | ||
| USDT_E = 11, | ||
|
|
||
| // Circle tokens | ||
| /// USDC Circle, minted natively | ||
| USDC = 20, | ||
| /// USDC Circle, minted on Ethereum | ||
| USDC_E = 21, | ||
|
|
||
| // protocol-issued tokens, wrapped or not | ||
| /// Ethereum ETH, | ||
| ETH = 30, | ||
| /// wrapped ETH | ||
| /// wrapped ETH ERC20 | ||
| WETH = 31, | ||
| /// Bitcoin. just reserving the index. no bridge exists yet | ||
| BTC = 36, | ||
| /// ethereum-wrapped Bitcoin | ||
| WBTC_E = 37, | ||
| } | ||
|
|
||
| const USDC_E_MAINNET_CONTRACT_ADDRESS: [u8; 20] = hex!("a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"); | ||
| const USDT_E_MAINNET_CONTRACT_ADDRESS: [u8; 20] = hex!("dac17f958d2ee523a2206206994597c13d831ec7"); | ||
| const WETH_SEPOLIA_CONTRACT_ADDRESS: [u8; 20] = hex!("fff9976782d46cc05630d1f6ebab18b2324d6b14"); | ||
| const WBTC_E_MAINNET_CONTRACT_ADDRESS: [u8; 20] = hex!("2260fac5e5542a773aa44fbcfedf7c193bc2c599"); | ||
|
|
||
| /// The AssetId type we use on L2 to map all possible locations/instances | ||
| /// This type must contain unique definitions for any token we may want to shield on any shielding target | ||
|
|
@@ -88,6 +98,8 @@ impl std::fmt::Display for AssetId { | |
| AssetId::USDC_E => write!(f, "USDC.e"), | ||
| AssetId::ETH => write!(f, "ETH"), | ||
| AssetId::WETH => write!(f, "WETH"), | ||
| AssetId::BTC => write!(f, "BTC"), | ||
| AssetId::WBTC_E => write!(f, "WBTC.e"), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -104,6 +116,7 @@ impl TryFrom<&str> for AssetId { | |
| "USDC.e" => Ok(AssetId::USDC_E), | ||
| "ETH" => Ok(AssetId::ETH), | ||
| "WETH" => Ok(AssetId::WETH), | ||
| "WBTC.e" => Ok(AssetId::WBTC_E), | ||
| _ => Err(()), | ||
| } | ||
| } | ||
|
|
@@ -128,6 +141,8 @@ impl AssetId { | |
| AssetId::USDC_E => Some(FOREIGN_ASSETS), | ||
| AssetId::ETH => Some(FOREIGN_ASSETS), | ||
| AssetId::WETH => Some(FOREIGN_ASSETS), | ||
| AssetId::BTC => None, | ||
| AssetId::WBTC_E => Some(FOREIGN_ASSETS), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -139,6 +154,8 @@ impl AssetId { | |
| AssetId::USDC_E => 1_000_000, // 6 decimals | ||
| AssetId::ETH => 1_000_000_000_000_000_000, // 18 decimals | ||
| AssetId::WETH => 1_000_000_000_000_000_000, // 18 decimals | ||
| AssetId::BTC => 100_000_000, // 8 decimals | ||
| AssetId::WBTC_E => 100_000_000, // 8 decimals | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -157,16 +174,11 @@ impl AssetId { | |
| AssetId::USDC_E, | ||
| AssetId::WETH, | ||
| AssetId::ETH, | ||
| AssetId::WBTC_E, | ||
| ], | ||
| ASSET_HUB_PASEO_GENESIS_HASH_HEX => vec![ | ||
| AssetId::USDT, | ||
| AssetId::USDT_E, | ||
| AssetId::USDC, | ||
| AssetId::USDC_E, | ||
| AssetId::WETH, | ||
| AssetId::ETH, | ||
| ], | ||
| ASSET_HUB_POLKADOT_GENESIS_HASH_HEX => vec![AssetId::USDT_E, AssetId::USDC_E], | ||
| ASSET_HUB_PASEO_GENESIS_HASH_HEX => vec![AssetId::USDT, AssetId::USDC, AssetId::WETH], | ||
| ASSET_HUB_POLKADOT_GENESIS_HASH_HEX => | ||
| vec![AssetId::USDT_E, AssetId::USDC_E, AssetId::ETH, AssetId::WBTC_E], | ||
| _ => vec![], | ||
| } | ||
| } | ||
|
|
@@ -206,6 +218,21 @@ impl AssetTranslation for AssetId { | |
| } else { | ||
| None | ||
| }, | ||
| AssetId::WBTC_E => | ||
| if matches!( | ||
| genesis_hash.into(), | ||
| ASSET_HUB_POLKADOT_GENESIS_HASH_HEX | ASSET_HUB_LOCAL_TEST_GENESIS_HASH_HEX | ||
| ) { | ||
| Some(Location { | ||
| parents: 2, | ||
| interior: X2(Arc::new([ | ||
| GlobalConsensus(Ethereum { chain_id: ETHEREUM_MAINNET_CHAIN_ID }), | ||
| AccountKey20 { key: WBTC_E_MAINNET_CONTRACT_ADDRESS, network: None }, | ||
| ])), | ||
| }) | ||
| } else { | ||
| None | ||
| }, | ||
| AssetId::WETH => | ||
| if matches!( | ||
| genesis_hash.into(), | ||
|
|
@@ -221,6 +248,20 @@ impl AssetTranslation for AssetId { | |
| } else { | ||
| None | ||
| }, | ||
| AssetId::ETH => | ||
| if matches!( | ||
| genesis_hash.into(), | ||
| ASSET_HUB_POLKADOT_GENESIS_HASH_HEX | ASSET_HUB_LOCAL_TEST_GENESIS_HASH_HEX | ||
| ) { | ||
| Some(Location { | ||
| parents: 2, | ||
| interior: X1(Arc::new([GlobalConsensus(Ethereum { | ||
| chain_id: ETHEREUM_MAINNET_CHAIN_ID, | ||
| })])), | ||
| }) | ||
| } else { | ||
| None | ||
| }, | ||
| _ => None, | ||
| } | ||
| } | ||
|
|
@@ -274,6 +315,14 @@ impl AssetTranslation for AssetId { | |
| | ASSET_HUB_LOCAL_TEST_GENESIS_HASH_HEX | ||
| ) => | ||
| Some(AssetId::USDT_E), | ||
| [GlobalConsensus(Ethereum { chain_id: ETHEREUM_MAINNET_CHAIN_ID }), AccountKey20 { key: contract, network: None }] | ||
| if *contract == WBTC_E_MAINNET_CONTRACT_ADDRESS | ||
| && matches!( | ||
| genesis_hash.into(), | ||
| ASSET_HUB_POLKADOT_GENESIS_HASH_HEX | ||
| | ASSET_HUB_LOCAL_TEST_GENESIS_HASH_HEX | ||
| ) => | ||
| Some(AssetId::WBTC_E), | ||
| [GlobalConsensus(Ethereum { chain_id: ETHEREUM_SEPOLIA_CHAIN_ID }), AccountKey20 { key: contract, network: None }] | ||
| if *contract == WETH_SEPOLIA_CONTRACT_ADDRESS | ||
| && matches!( | ||
|
|
@@ -282,6 +331,9 @@ impl AssetTranslation for AssetId { | |
| | ASSET_HUB_LOCAL_TEST_GENESIS_HASH_HEX | ||
| ) => | ||
| Some(AssetId::WETH), | ||
| [GlobalConsensus(Ethereum { chain_id: ETHEREUM_MAINNET_CHAIN_ID })] | ||
| if matches!(genesis_hash.into(), ASSET_HUB_POLKADOT_GENESIS_HASH_HEX) => | ||
|
||
| Some(AssetId::ETH), | ||
| _ => None, | ||
| } | ||
| } else { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason for removing those assets from Paseo?