diff --git a/zenlink-protocol/rpc/Cargo.toml b/zenlink-protocol/rpc/Cargo.toml index 8004aa8..c45d79a 100644 --- a/zenlink-protocol/rpc/Cargo.toml +++ b/zenlink-protocol/rpc/Cargo.toml @@ -3,6 +3,7 @@ name = "zenlink-protocol-rpc" version = "0.4.0" authors = ["Zenlink Developers"] edition = "2018" +license = "GPL-3.0-only" [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] diff --git a/zenlink-protocol/rpc/README.md b/zenlink-protocol/rpc/README.md index 5c33988..c7cfa8e 100644 --- a/zenlink-protocol/rpc/README.md +++ b/zenlink-protocol/rpc/README.md @@ -541,3 +541,7 @@ } } ``` + +## License + +[GPL-v3](LICENSE) diff --git a/zenlink-protocol/rpc/runtime-api/Cargo.toml b/zenlink-protocol/rpc/runtime-api/Cargo.toml index 02f2a4e..02196ec 100644 --- a/zenlink-protocol/rpc/runtime-api/Cargo.toml +++ b/zenlink-protocol/rpc/runtime-api/Cargo.toml @@ -3,6 +3,7 @@ name = "zenlink-protocol-runtime-api" version = "0.4.0" authors = ["Zenlink Developers"] edition = "2018" +license = "GPL-3.0-only" [dependencies] # alias "parity-scale-code" to "codec" diff --git a/zenlink-protocol/src/README.md b/zenlink-protocol/src/README.md new file mode 100644 index 0000000..65ca6f0 --- /dev/null +++ b/zenlink-protocol/src/README.md @@ -0,0 +1,100 @@ +## Zenlink Protocol v0.4.0 Overview +![zenlink protocol](./docs/zenlink-protocol-v0.4.0.png) + +`Zenlink Protocol` mainly consists of two parts: assets and asset operations, +namely `Zenlink Assets` and `Zenlink Actions`. +Through the `UAI`(unified asset identifier) and `MultiAssetsHandler` interfaces, +`Zenlink` can perform `Swap` and `Transfer By XCM` any asset on the chain. + +## Zenlink Protocol v0.4.0 Features +- Based on the `newest` XCM design +- Based on `FRAMEv2` +- Swap exchange fee `configurable` +- `Compatible` Polkadot XCMP cross-chain asset processing +- Zenlink Protocol registration whitelist-XCM `trust collection management` +- Through Transfer-By-XCM, `assets can flow freely` between parachains +- ZenlinkMultiAssets adapter comes with `LIQUIDITY` and `Foreign` asset processing, which can `adapt to various native assets such as NATIVE/LOCAL/RESERVE` +- Provide LocalAssetHandler, OtherAssetHandler and other traits to `support locally defined assets such as LOCAL and RESERVE` +- Under the control of MultiAssetsHandler, `assets can swap freely` + +## UAI v0.1.0 + +- UAI v0.1.0 definition + +```rust +pub struct AssetId { + pub chain_id: u32, // ParaId + pub asset_type: u8, // Asset types supported by Zenlink Assets + pub asset_index: u32, // the index number of the asset +} +``` + +- UAI v0.1.0 asset type + +`asset_type` currently only supports the following values: + +```rust +/// Native currency, the most basic asset on each parachain +pub const NATIVE: u8 = 0; +/// Swap module asset, LP token generated by Zenlink DEX +pub const LIQUIDITY: u8 = 1; +/// Other asset type on this chain, other asset modules on this chain +pub const LOCAL: u8 = 2; +/// Reserved for future, reserved asset type +pub const RESERVED: u8 = 3; +``` + +In the current version of UAI, `Zenlink Assets` supports up to four locally defined assets of `Native/LIQUIDITY/LOCAL/RESERVED`. +When these four assets are transferred across chains, a cross-chain mapping asset category `Foreign` will be generated inside `ZenlinkProtocol`. + +- `Before and after the cross-chain asset transfer, the UAI of the asset has not changed`. + +## MultiAssetsHandler + +The trait is defined as follows +```rust +pub trait MultiAssetsHandler { + fn balance_of(asset_id: AssetId, who: &AccountId) -> AssetBalance; + fn total_supply(asset_id: AssetId) -> AssetBalance; + fn is_exists(asset_id: AssetId) -> bool; + fn transfer( + asset_id: AssetId, + origin: &AccountId, + target: &AccountId, + amount: AssetBalance, + ) -> DispatchResult { + let withdrawn = Self::withdraw(asset_id, origin, amount)?; + let _ = Self::deposit(asset_id, target, withdrawn)?; + Ok(()) + } + fn deposit( + asset_id: AssetId, + target: &AccountId, + amount: AssetBalance, + ) -> Result; + + fn withdraw( + asset_id: AssetId, + origin: &AccountId, + amount: AssetBalance, + ) -> Result; +} + +``` + +- `is_exists` is a unified access interface for `Zenlink Actions` +- `balance_of`, `total_supply`, `transfer` are `Zenlink Swap Action` access interface +- `deposit`, `withdraw` are `Zenlink Transfer-By-XCM Action` access interface +- `MultiAssetsHandler` can operate in addition to the four native defined assets identified by `UAI`, +as well as the `cross-chain mapping asset Foreign` inside `ZenlinkProtocol`. + + +## Swap and Transfer-By-XCM +- Four native defined assets (`NATIVE/LIQUIDITY/LOCAL/RESERVED`) and cross-chain mapping assets (`Foreign`) can be exchanged through `MultiAssetsHandler`. +- Four native defined assets (`NATIVE/LIQUIDITY/LOCAL/RESERVED`) Cross-chain asset transfer through `Transfer-By-XCM`, and a mapped asset `Foreign` is generated +on the target parachain, Also through the `Transfer-By-XCM` cross-chain transfer back to the original definition chain of the asset. + + +## License + +[GPL-v3](LICENSE) diff --git a/zenlink-protocol/src/docs/zenlink-protocol-v0.4.0.png b/zenlink-protocol/src/docs/zenlink-protocol-v0.4.0.png new file mode 100644 index 0000000..1992609 Binary files /dev/null and b/zenlink-protocol/src/docs/zenlink-protocol-v0.4.0.png differ diff --git a/zenlink-protocol/src/transfer/mod.rs b/zenlink-protocol/src/transfer/mod.rs index 5ac447b..545b3ee 100644 --- a/zenlink-protocol/src/transfer/mod.rs +++ b/zenlink-protocol/src/transfer/mod.rs @@ -1,3 +1,6 @@ +// Copyright 2020-2021 Zenlink +// Licensed under GPL-3.0. + use super::*; impl Pallet {