diff --git a/Cargo.lock b/Cargo.lock
index b8f4efacf..38e1f8d1f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7929,6 +7929,7 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"serai-coins-primitives",
+ "serai-genesis-liquidity-primitives",
"serai-in-instructions-primitives",
"serai-primitives",
"serai-signals-primitives",
@@ -8127,6 +8128,39 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "serai-genesis-liquidity-pallet"
+version = "0.1.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "parity-scale-codec",
+ "scale-info",
+ "serai-coins-pallet",
+ "serai-dex-pallet",
+ "serai-genesis-liquidity-primitives",
+ "serai-primitives",
+ "serai-validator-sets-pallet",
+ "serai-validator-sets-primitives",
+ "sp-application-crypto",
+ "sp-core",
+ "sp-std",
+]
+
+[[package]]
+name = "serai-genesis-liquidity-primitives"
+version = "0.1.0"
+dependencies = [
+ "borsh",
+ "parity-scale-codec",
+ "scale-info",
+ "serai-primitives",
+ "serai-validator-sets-primitives",
+ "serde",
+ "sp-std",
+ "zeroize",
+]
+
[[package]]
name = "serai-in-instructions-pallet"
version = "0.1.0"
@@ -8137,6 +8171,8 @@ dependencies = [
"scale-info",
"serai-coins-pallet",
"serai-dex-pallet",
+ "serai-genesis-liquidity-pallet",
+ "serai-genesis-liquidity-primitives",
"serai-in-instructions-primitives",
"serai-primitives",
"serai-validator-sets-pallet",
@@ -8406,6 +8442,7 @@ dependencies = [
"serai-abi",
"serai-coins-pallet",
"serai-dex-pallet",
+ "serai-genesis-liquidity-pallet",
"serai-in-instructions-pallet",
"serai-primitives",
"serai-signals-pallet",
diff --git a/deny.toml b/deny.toml
index 3359de0f4..960250516 100644
--- a/deny.toml
+++ b/deny.toml
@@ -53,6 +53,8 @@ exceptions = [
{ allow = ["AGPL-3.0"], name = "serai-coins-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-dex-pallet" },
+ { allow = ["AGPL-3.0"], name = "serai-genesis-liquidity-pallet" },
+
{ allow = ["AGPL-3.0"], name = "serai-in-instructions-pallet" },
{ allow = ["AGPL-3.0"], name = "serai-validator-sets-pallet" },
diff --git a/substrate/abi/Cargo.toml b/substrate/abi/Cargo.toml
index 547761d88..c2947aaab 100644
--- a/substrate/abi/Cargo.toml
+++ b/substrate/abi/Cargo.toml
@@ -33,6 +33,7 @@ frame-support = { git = "https://github.com/serai-dex/substrate", default-featur
serai-primitives = { path = "../primitives", version = "0.1", default-features = false }
serai-coins-primitives = { path = "../coins/primitives", version = "0.1", default-features = false }
serai-validator-sets-primitives = { path = "../validator-sets/primitives", version = "0.1", default-features = false }
+serai-genesis-liquidity-primitives = { path = "../genesis-liquidity/primitives", version = "0.1", default-features = false }
serai-in-instructions-primitives = { path = "../in-instructions/primitives", version = "0.1", default-features = false }
serai-signals-primitives = { path = "../signals/primitives", version = "0.1", default-features = false }
@@ -55,6 +56,7 @@ std = [
"serai-primitives/std",
"serai-coins-primitives/std",
"serai-validator-sets-primitives/std",
+ "serai-genesis-liquidity-primitives/std",
"serai-in-instructions-primitives/std",
"serai-signals-primitives/std",
]
@@ -63,6 +65,7 @@ borsh = [
"serai-primitives/borsh",
"serai-coins-primitives/borsh",
"serai-validator-sets-primitives/borsh",
+ "serai-genesis-liquidity-primitives/borsh",
"serai-in-instructions-primitives/borsh",
"serai-signals-primitives/borsh",
]
@@ -71,6 +74,7 @@ serde = [
"serai-primitives/serde",
"serai-coins-primitives/serde",
"serai-validator-sets-primitives/serde",
+ "serai-genesis-liquidity-primitives/serde",
"serai-in-instructions-primitives/serde",
"serai-signals-primitives/serde",
]
diff --git a/substrate/abi/src/coins.rs b/substrate/abi/src/coins.rs
index 56255b0a8..9466db0f9 100644
--- a/substrate/abi/src/coins.rs
+++ b/substrate/abi/src/coins.rs
@@ -13,15 +13,6 @@ pub enum Call {
burn_with_instruction { instruction: OutInstructionWithBalance },
}
-#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
-#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
-#[cfg_attr(feature = "serde", derive(serde::Serialize))]
-#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
-pub enum LiquidityTokensCall {
- transfer { to: SeraiAddress, balance: Balance },
- burn { balance: Balance },
-}
-
#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
diff --git a/substrate/abi/src/genesis_liquidity.rs b/substrate/abi/src/genesis_liquidity.rs
new file mode 100644
index 000000000..461284141
--- /dev/null
+++ b/substrate/abi/src/genesis_liquidity.rs
@@ -0,0 +1,21 @@
+pub use serai_genesis_liquidity_primitives as primitives;
+
+use serai_primitives::*;
+use primitives::*;
+
+#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub enum Call {
+ remove_coin_liquidity { balance: Balance },
+ oraclize_values { values: Values, signature: Signature },
+}
+
+#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
+#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub enum Event {
+ GenesisLiquidityAdded { by: SeraiAddress, balance: Balance },
+ GenesisLiquidityRemoved { by: SeraiAddress, balance: Balance },
+ GenesisLiquidityAddedToPool { coin1: Balance, coin2: Balance },
+ EconomicSecurityReached { network: NetworkId },
+}
diff --git a/substrate/abi/src/lib.rs b/substrate/abi/src/lib.rs
index 2670bef78..ac8b8824c 100644
--- a/substrate/abi/src/lib.rs
+++ b/substrate/abi/src/lib.rs
@@ -12,12 +12,15 @@ pub mod system;
pub mod timestamp;
pub mod coins;
+pub mod liquidity_tokens;
pub mod dex;
pub mod validator_sets;
pub mod in_instructions;
pub mod signals;
+pub mod genesis_liquidity;
+
pub mod babe;
pub mod grandpa;
@@ -27,8 +30,9 @@ pub mod tx;
pub enum Call {
Timestamp(timestamp::Call),
Coins(coins::Call),
- LiquidityTokens(coins::LiquidityTokensCall),
+ LiquidityTokens(liquidity_tokens::Call),
Dex(dex::Call),
+ GenesisLiquidity(genesis_liquidity::Call),
ValidatorSets(validator_sets::Call),
InInstructions(in_instructions::Call),
Signals(signals::Call),
@@ -48,8 +52,9 @@ pub enum Event {
Timestamp,
TransactionPayment(TransactionPaymentEvent),
Coins(coins::Event),
- LiquidityTokens(coins::Event),
+ LiquidityTokens(liquidity_tokens::Event),
Dex(dex::Event),
+ GenesisLiquidity(genesis_liquidity::Event),
ValidatorSets(validator_sets::Event),
InInstructions(in_instructions::Event),
Signals(signals::Event),
diff --git a/substrate/abi/src/liquidity_tokens.rs b/substrate/abi/src/liquidity_tokens.rs
new file mode 100644
index 000000000..6bdc651b6
--- /dev/null
+++ b/substrate/abi/src/liquidity_tokens.rs
@@ -0,0 +1,18 @@
+use serai_primitives::{Balance, SeraiAddress};
+
+#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
+#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub enum Call {
+ burn { balance: Balance },
+ transfer { to: SeraiAddress, balance: Balance },
+}
+
+#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
+#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
+pub enum Event {
+ Mint { to: SeraiAddress, balance: Balance },
+ Burn { from: SeraiAddress, balance: Balance },
+ Transfer { from: SeraiAddress, to: SeraiAddress, balance: Balance },
+}
diff --git a/substrate/client/src/serai/dex.rs b/substrate/client/src/serai/dex.rs
index 00108dfef..d9edc56b6 100644
--- a/substrate/client/src/serai/dex.rs
+++ b/substrate/client/src/serai/dex.rs
@@ -1,7 +1,9 @@
use sp_core::bounded_vec::BoundedVec;
use serai_abi::primitives::{SeraiAddress, Amount, Coin};
-use crate::{SeraiError, TemporalSerai};
+use scale::{decode_from_bytes, Encode};
+
+use crate::{Serai, SeraiError, TemporalSerai};
pub type DexEvent = serai_abi::dex::Event;
@@ -57,4 +59,20 @@ impl<'a> SeraiDex<'a> {
send_to: address,
})
}
+
+ /// Returns the reserves of `coin:SRI` pool.
+ pub async fn get_reserves(&self, coin: Coin) -> Result