-
Notifications
You must be signed in to change notification settings - Fork 19
Polar path documentation #319
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 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8b58ae5
Draft
ChrisChinchilla 20e26ba
Draft
ChrisChinchilla b085daf
Draft
ChrisChinchilla d01d4fc
Draft
ChrisChinchilla c01a7c9
Update docs/develop/09_polarpath/01_overview.md
ChrisChinchilla 07409a1
Review
ChrisChinchilla fa4866a
Merge branch '3472-polar-path-documentation' of github.com:KILTprotoc…
ChrisChinchilla 8217630
Add versions
ChrisChinchilla d34179b
Fix malformed tag
ChrisChinchilla 023d289
Draft
ChrisChinchilla 50cc0e7
Remove the variable
ChrisChinchilla 4c345df
Rewrite paths to not be broken
ChrisChinchilla c8d903b
Update paths for release
ChrisChinchilla 7e76510
Draft
ChrisChinchilla b27a7f1
Changes from review
ChrisChinchilla 9c1d8f9
Draft
ChrisChinchilla 5f6b95b
Merge branch 'master' into 3472-polar-path-documentation
ChrisChinchilla 03e4986
Remove broken links
ChrisChinchilla c54c480
Change config
ChrisChinchilla 59ad35e
Fix links
ChrisChinchilla 0f4a277
Add disclaimer
ChrisChinchilla cb0f6c4
Update imported file
ChrisChinchilla 2f4b570
Clarify
ChrisChinchilla 2524a17
Fix broken pallet paths
ChrisChinchilla 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
id: what-is-polarpath | ||
title: Overview | ||
--- | ||
|
||
Polar path consists of an `asset-swap` pallet for KILT chain runtimes and extrinisics that let parachain-based chain developers to make their native token accessible on the Ethereum network using [the Snowbridge bridge](https://docs.snowbridge.network) between Polkadot and Ethereum. | ||
|
||
Polar path provides parachains with a solution for creating an ERC-20 wrapper around their native tokens, enabling a trustless conversion of any existing native parachain token (PARA) into a wrapped parachain token (wPARA) on Ethereum while maintaining the trustlessness guarantees Snowbridge provides. | ||
|
||
The pallet enables a configured conversion rate of parachain tokens on the origin chain to an ERC-20 wrapper token on Polkadot's AssetHub. | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Setup | ||
|
||
:::tip Asset Hub | ||
The Polkadot Relay Chain doesn't natively support assets apart from DOT. Instead, parachains support this functionality, and for Polkadot, this parachain is the [Asset Hub](https://wiki.polkadot.network/docs/build-integrate-assets). | ||
::: | ||
|
||
Making a Parachain Token to be usable on Ethereum requires the following steps: | ||
|
||
1. Deploy an ERC-20 contract token to Ethereum with a fixed supply based on the parachain needs. | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. [Disable the token issuer rights](https://ethereum.org/en/guides/how-to-revoke-token-access/) on the ERC-20 contract. | ||
3. [Register the ERC-20 token on Asset Hub](https://wiki.polkadot.network/docs/learn-assets#creation-and-management). | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. The entity holding ERC-20 funds performs a one-time transfer of all tokens from their Ethereum account to the parachain's sovereign account on Asset Hub. | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
5. Parachain governance recognizes the wrapper around the ERC-20 token by pairing the ERC-20 token to the parachain token in the swap pallet and enable the token issuer rights. | ||
|
||
Holders of the token on the parachain can can now switch tokens between it and Ethereum. | ||
|
||
## Use cases | ||
|
||
After setup, the following flows are possible: | ||
|
||
:::tip XCM | ||
Polar path uses Polkadot's [Cross-Consensus Message Format (XCM)](https://wiki.polkadot.network/docs/learn-xcm), a messaging format and language used to communicate between consensus systems. | ||
::: | ||
|
||
### Sending tokens from the parachain to Ethereum | ||
|
||
1. Transmit custom parachain tokens, "PARA", from the parachain to wrapped tokens "wPARAs" on Asset Hub via XCM | ||
2. Send wPARAs from Asset Hub to the ERC-20 contract on Ethereum via Snowbridge | ||
|
||
### Sending tokens from Ethereum to the parachain | ||
|
||
1. Send wPARAs from the ERC-20 contract on Ethereum to Asset Hub via Snowbridge | ||
2. Transmit wPARAs on Asset Hub to PARAs on the parachain via XCM | ||
|
||
## Extrinsics | ||
|
||
Before performing a switch, you first need to create a switch pair between the parachain token and the ERC-20 token using the `setSwitchPair` extrinisc. Then you can use any of the other extriniscs with the switch pair, including performing the switch itself using the `switch` extrinisc. | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
:::tip Remote asset | ||
A remote asset is the identifier of the asset considered to be the other side of the switch pair. For an ERC20 token, this is a [MultiLocation](https://wiki.polkadot.network/docs/learn/xcm/fundamentals/multilocation-summary) (in XCM terms) pointing to an address on one of the many EVM-based deployments. | ||
::: | ||
|
||
### `setSwitchPair` | ||
ChrisChinchilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Create a new switch pair between a parachain token and an ERC-20 token. Returns a result and takes the following parameters: | ||
|
||
- `origin`: Polkadot [Junction](https://wiki.polkadot.network/docs/learn/xcm/fundamentals/multilocation-junctions) defining the | ||
- `reserve_location`: | ||
- `remote_asset_id`: | ||
- `remote_fee`: | ||
- `total_issuance`: A `u128` defining | ||
- `circulating_supply`: A `u128` defining, | ||
|
||
### `removeSwitchPair` | ||
|
||
Remove an existing switch pair. Returns a result and takes the following parameters: | ||
|
||
- `remote_asset_id`: | ||
|
||
### `pauseSwitchPair` | ||
|
||
Pause an existing switch pair. Returns a result and takes the following parameters: | ||
|
||
- `remote_asset_id`: | ||
|
||
### `resumeSwitchPair` | ||
|
||
Resume a paused an existing switch pair. Returns a result and takes the following parameters: | ||
|
||
- `remote_asset_id`: | ||
|
||
### `switch` | ||
|
||
Allow any user with enough parachain asset balance to send them to the [Asset Hub pool account](https://docs.rs/pallet-asset-conversion/latest/pallet_asset_conversion/pallet/struct.Pallet.html#method.create_pool) for a specific switch pair and receive a corresponding amount of remote asset from the parachain's sovereign account on the remote location, to a `MultiLocation` of their choice. | ||
|
||
Returns a result and takes the following parameters: | ||
|
||
- `from`: T::AccountId | ||
- `to`: VersionedMultiLocation | ||
- `amount`: LocalCurrencyBalanceOf |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
WIP. | ||
|
||
# TODO | ||
|
||
Besides the TODOs in the code, the following points must be tackled (ordered by importance): | ||
* [REQUIRED FOR V1] Allow for DOT transfers to KILT to be paid with those DOTs | ||
* [REQUIRED FOR V1] Allow for eKILT transfers to KILT (to be swapped for KILTs) to be paid with those eKILTs | ||
* [REQUIRED FOR V2] Add hook to check the swap parameters (restricting where remote assets can be sent to). | ||
* [REQUIRED FOR V1] Add integrity tests to check invariant that total issuance - remote balance = local pool balance (circulating supply) -> especially useful when adding token ratios, to avoid rounding errors | ||
* [OPTIONAL] Add configurable ratio for local/remote swaps. | ||
* [OPTIONAL] Delegate XCM message composition to a trait Config as well, depending on the destination (choosing which asset to use for payments, what amount, etc). |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"label": "Polar path", | ||
"collapsible": true, | ||
"collapsed": true | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.