Skip to content
Snippets Groups Projects
Muharem's avatar
Muharem Ismailov authored
Introduces a swap implementation that allows the exchange of a credit
(aka Negative Imbalance) of one asset for a credit of another asset.

This is particularly useful when a credit swap is required but may not
have sufficient value to meet the ED constraint, hence cannot be
deposited to temp account before. An example use case is when XCM fees
are paid using an asset held in the XCM executor registry and has to be
swapped for native currency.

Additional Updates:
- encapsulates the existing `Swap` trait impl within a transactional
context, since partial storage mutation is possible when an error
occurs;
- supplied `Currency` and `Assets` impls must be implemented over the
same `Balance` type, the `AssetBalance` generic type is dropped. This
helps to avoid numerous type conversion and overflow cases. If those
types are different it should be handled outside of the pallet;
- `Box` asset kind on a pallet level, unbox on a runtime level - here
[why](https://substrate.stackexchange.com/questions/10039/boxed-argument-of-a-dispatchable/10103#10103);
- `path` uses `Vec` now, instead of `BoundedVec` since it is never used
in PoV;
- removes the `Transfer` event due to it's redundancy with the events
emitted by `fungible/s` implementations;
- modifies the `SwapExecuted` event type;

related issue: 
- https://github.com/paritytech/polkadot-sdk/issues/105

related PRs:
- (required for) https://github.com/paritytech/polkadot-sdk/pull/1845
- (caused) https://github.com/paritytech/polkadot-sdk/pull/1717

// DONE make the pallet work only with `fungibles` trait and make it
free from the concept of a `native` asset -
https://github.com/paritytech/polkadot-sdk/issues/1842

---------

Co-authored-by: default avatarjoe petrowski <25483142+joepetrowski@users.noreply.github.com>
5ce04514

NOTE: We have recently made significant changes to our repository structure. In order to streamline our development process and foster better contributions, we have merged three separate repositories Cumulus, Substrate and Polkadot into this repository. Read more about the changes here.

Polkadot SDK

StackExchange

The Polkadot SDK repository provides all the resources needed to start building on the Polkadot network, a multi-chain blockchain platform that enables different blockchains to interoperate and share information in a secure and scalable way. The Polkadot SDK comprises three main pieces of software:

Polkadot

PolkadotForum Polkadot-license

Implementation of a node for the https://polkadot.network in Rust, using the Substrate framework. This directory currently contains runtimes for the Polkadot, Kusama, Westend, and Rococo networks. In the future, these will be relocated to the runtimes repository.

Substrate

SubstrateRustDocs Substrate-license

Substrate is the primary blockchain SDK used by developers to create the parachains that make up the Polkadot network. Additionally, it allows for the development of self-sovereign blockchains that operate completely independently of Polkadot.

Cumulus

CumulusRustDocs Cumulus-license

Cumulus is a set of tools for writing Substrate-based Polkadot parachains.

Upstream Dependencies

Below are the primary upstream dependencies utilized in this project:

Security

The security policy and procedures can be found in docs/contributor/SECURITY.md.

Contributing & Code of Conduct

Ensure you follow our contribution guidelines. In every interaction and contribution, this project adheres to the Contributor Covenant Code of Conduct.

Additional Resources

  • For monitoring upcoming changes and current proposals related to the technical implementation of the Polkadot network, visit the Requests for Comment (RFC) repository. While it's maintained by the Polkadot Fellowship, the RFC process welcomes contributions from everyone.