|
| 1 | +## Zenlink Protocol v0.4.0 Overview |
| 2 | + |
| 3 | + |
| 4 | +`Zenlink Protocol` mainly consists of two parts: assets and asset operations, |
| 5 | +namely `Zenlink Assets` and `Zenlink Actions`. |
| 6 | +Through the `UAI`(unified asset identifier) and `MultiAssetsHandler` interfaces, |
| 7 | +`Zenlink` can perform `Swap` and `Transfer By XCM` any asset on the chain. |
| 8 | + |
| 9 | +## Zenlink Protocol v0.4.0 Features |
| 10 | +- Based on the `newest` XCM design |
| 11 | +- Based on `FRAMEv2` |
| 12 | +- Swap exchange fee `configurable` |
| 13 | +- `Compatible` Polkadot XCMP cross-chain asset processing |
| 14 | +- Zenlink Protocol registration whitelist-XCM `trust collection management` |
| 15 | +- Through Transfer-By-XCM, `assets can flow freely` between parachains |
| 16 | +- ZenlinkMultiAssets adapter comes with `LIQUIDITY` and `Foreign` asset processing, which can `adapt to various native assets such as NATIVE/LOCAL/RESERVE` |
| 17 | +- Provide LocalAssetHandler, OtherAssetHandler and other traits to `support locally defined assets such as LOCAL and RESERVE` |
| 18 | +- Under the control of MultiAssetsHandler, `assets can swap freely` |
| 19 | + |
| 20 | +## UAI v0.1.0 |
| 21 | + |
| 22 | +- UAI v0.1.0 definition |
| 23 | + |
| 24 | +```rust |
| 25 | +pub struct AssetId { |
| 26 | + pub chain_id: u32, // ParaId |
| 27 | + pub asset_type: u8, // Asset types supported by Zenlink Assets |
| 28 | + pub asset_index: u32, // the index number of the asset |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +- UAI v0.1.0 asset type |
| 33 | + |
| 34 | +`asset_type` currently only supports the following values: |
| 35 | + |
| 36 | +```rust |
| 37 | +/// Native currency, the most basic asset on each parachain |
| 38 | +pub const NATIVE: u8 = 0; |
| 39 | +/// Swap module asset, LP token generated by Zenlink DEX |
| 40 | +pub const LIQUIDITY: u8 = 1; |
| 41 | +/// Other asset type on this chain, other asset modules on this chain |
| 42 | +pub const LOCAL: u8 = 2; |
| 43 | +/// Reserved for future, reserved asset type |
| 44 | +pub const RESERVED: u8 = 3; |
| 45 | +``` |
| 46 | + |
| 47 | +In the current version of UAI, `Zenlink Assets` supports up to four locally defined assets of `Native/LIQUIDITY/LOCAL/RESERVED`. |
| 48 | +When these four assets are transferred across chains, a cross-chain mapping asset category `Foreign` will be generated inside `ZenlinkProtocol`. |
| 49 | + |
| 50 | +- `Before and after the cross-chain asset transfer, the UAI of the asset has not changed`. |
| 51 | + |
| 52 | +## MultiAssetsHandler |
| 53 | + |
| 54 | +The trait is defined as follows |
| 55 | +```rust |
| 56 | +pub trait MultiAssetsHandler<AccountId> { |
| 57 | + fn balance_of(asset_id: AssetId, who: &AccountId) -> AssetBalance; |
| 58 | + fn total_supply(asset_id: AssetId) -> AssetBalance; |
| 59 | + fn is_exists(asset_id: AssetId) -> bool; |
| 60 | + fn transfer( |
| 61 | + asset_id: AssetId, |
| 62 | + origin: &AccountId, |
| 63 | + target: &AccountId, |
| 64 | + amount: AssetBalance, |
| 65 | + ) -> DispatchResult { |
| 66 | + let withdrawn = Self::withdraw(asset_id, origin, amount)?; |
| 67 | + let _ = Self::deposit(asset_id, target, withdrawn)?; |
| 68 | + Ok(()) |
| 69 | + } |
| 70 | + fn deposit( |
| 71 | + asset_id: AssetId, |
| 72 | + target: &AccountId, |
| 73 | + amount: AssetBalance, |
| 74 | + ) -> Result<AssetBalance, DispatchError>; |
| 75 | + |
| 76 | + fn withdraw( |
| 77 | + asset_id: AssetId, |
| 78 | + origin: &AccountId, |
| 79 | + amount: AssetBalance, |
| 80 | + ) -> Result<AssetBalance, DispatchError>; |
| 81 | +} |
| 82 | + |
| 83 | +``` |
| 84 | + |
| 85 | +- `is_exists` is a unified access interface for `Zenlink Actions` |
| 86 | +- `balance_of`, `total_supply`, `transfer` are `Zenlink Swap Action` access interface |
| 87 | +- `deposit`, `withdraw` are `Zenlink Transfer-By-XCM Action` access interface |
| 88 | +- `MultiAssetsHandler` can operate in addition to the four native defined assets identified by `UAI`, |
| 89 | +as well as the `cross-chain mapping asset Foreign` inside `ZenlinkProtocol`. |
| 90 | + |
| 91 | + |
| 92 | +## Swap and Transfer-By-XCM |
| 93 | +- Four native defined assets (`NATIVE/LIQUIDITY/LOCAL/RESERVED`) and cross-chain mapping assets (`Foreign`) can be exchanged through `MultiAssetsHandler`. |
| 94 | +- Four native defined assets (`NATIVE/LIQUIDITY/LOCAL/RESERVED`) Cross-chain asset transfer through `Transfer-By-XCM`, and a mapped asset `Foreign` is generated |
| 95 | +on the target parachain, Also through the `Transfer-By-XCM` cross-chain transfer back to the original definition chain of the asset. |
| 96 | + |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +[GPL-v3](LICENSE) |
0 commit comments