Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions crates/primitives-currency-swap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "primitives-currency-swap"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
frame-support = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }

[features]
default = ["std"]
std = ["frame-support/std"]
try-runtime = ["frame-support/try-runtime"]
23 changes: 23 additions & 0 deletions crates/primitives-currency-swap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Currency swap related primitives.

// Either generate code at stadard mode, or `no_std`, based on the `std` feature presence.
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{sp_runtime::DispatchError, traits::Currency};

/// Currency swap interface.
pub trait CurrencySwap<AccountIdFrom, AccountIdTo> {
/// The currency type balances send from.
type From: Currency<AccountIdFrom>;

/// The currency type balances send to.
type To: Currency<AccountIdTo>;

/// A possible error happens during the actual swap logic.
type Error: Into<DispatchError>;

/// The actual swap logic.
fn swap(
imbalance: <Self::From as Currency<AccountIdFrom>>::NegativeImbalance,
) -> Result<<Self::To as Currency<AccountIdTo>>::NegativeImbalance, Self::Error>;
}