2025-12-02 16:24:17 -05:00
|
|
|
#![doc = include_str!("../README.md")]
|
|
|
|
|
#![deny(missing_docs)]
|
|
|
|
|
#![cfg_attr(not(any(feature = "std", test)), no_std)]
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
extern crate alloc;
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
#[expect(clippy::cast_possible_truncation)]
|
|
|
|
|
#[frame_support::pallet]
|
|
|
|
|
mod pallet {
|
|
|
|
|
use frame_system::pallet_prelude::*;
|
|
|
|
|
use frame_support::pallet_prelude::*;
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
use serai_abi::{
|
|
|
|
|
primitives::{prelude::*, crypto::Signature, genesis_liquidity::GenesisValues},
|
|
|
|
|
genesis_liquidity::Event,
|
|
|
|
|
};
|
2024-09-01 01:55:42 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
use serai_core_pallet::Pallet as Core;
|
|
|
|
|
type Coins<T> = serai_coins_pallet::Pallet<T, serai_coins_pallet::CoinsInstance>;
|
|
|
|
|
type LiquidityTokens<T> =
|
|
|
|
|
serai_coins_pallet::Pallet<T, serai_coins_pallet::LiquidityTokensInstance>;
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
use super::*;
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// The configuration of this pallet.
|
2024-07-19 02:30:19 +03:00
|
|
|
#[pallet::config]
|
|
|
|
|
pub trait Config:
|
|
|
|
|
frame_system::Config
|
2025-12-02 16:24:17 -05:00
|
|
|
+ serai_core_pallet::Config
|
|
|
|
|
+ serai_coins_pallet::Config<serai_coins_pallet::CoinsInstance>
|
|
|
|
|
+ serai_coins_pallet::Config<serai_coins_pallet::LiquidityTokensInstance>
|
|
|
|
|
+ serai_dex_pallet::Config
|
2024-07-19 02:30:19 +03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// An error incurred.
|
2024-07-19 02:30:19 +03:00
|
|
|
#[pallet::error]
|
2025-12-02 16:24:17 -05:00
|
|
|
pub enum Error<T> {}
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// The Pallet struct.
|
2024-07-19 02:30:19 +03:00
|
|
|
#[pallet::pallet]
|
2025-12-02 16:24:17 -05:00
|
|
|
pub struct Pallet<T>(_);
|
2024-07-19 02:30:19 +03:00
|
|
|
|
|
|
|
|
impl<T: Config> Pallet<T> {
|
2025-12-02 16:24:17 -05:00
|
|
|
fn emit_event(event: Event) {
|
|
|
|
|
Core::<T>::emit_event(event)
|
2024-07-19 02:30:19 +03:00
|
|
|
}
|
2025-12-02 16:24:17 -05:00
|
|
|
}
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// The minimum amount of liquidity allowed to be initially added.
|
|
|
|
|
///
|
|
|
|
|
/// This should be sufficiently low it isn't inaccessible, yet sufficiently high that future
|
|
|
|
|
/// additions can be reasonably grained when their share of the new supply is calculated.
|
|
|
|
|
///
|
|
|
|
|
/// This constant is duplicated with `serai-dex-pallet` intentionally as while they have the same
|
|
|
|
|
/// value, they are distinct constants and don't require being equivalent.
|
|
|
|
|
const MINIMUM_LIQUIDITY: u64 = 1 << 16;
|
2024-07-19 02:30:19 +03:00
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
impl<T: Config> Pallet<T> {
|
|
|
|
|
/// Add liquidity on behalf of the specified address.
|
|
|
|
|
pub fn add_liquidity(to: SeraiAddress, balance: ExternalBalance) -> Result<(), Error<T>> {
|
|
|
|
|
todo!("TODO")
|
2024-07-19 02:30:19 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[pallet::call]
|
|
|
|
|
impl<T: Config> Pallet<T> {
|
2025-12-02 16:24:17 -05:00
|
|
|
/// Oraclize the values of the coins available on genesis, relative to BTC.
|
|
|
|
|
///
|
|
|
|
|
/// This will trigger the addition of the liquidity into the pools and their initialization.
|
2024-07-19 02:30:19 +03:00
|
|
|
#[pallet::call_index(0)]
|
2025-12-02 16:24:17 -05:00
|
|
|
#[pallet::weight((0, DispatchClass::Normal))] // TODO
|
|
|
|
|
pub fn oraclize_values(
|
|
|
|
|
origin: OriginFor<T>,
|
|
|
|
|
values: GenesisValues,
|
|
|
|
|
signature: Signature,
|
|
|
|
|
) -> DispatchResult {
|
|
|
|
|
todo!("TODO")
|
2024-07-19 02:30:19 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// Transfer genesis liquidity.
|
2024-07-19 02:30:19 +03:00
|
|
|
#[pallet::call_index(1)]
|
2025-12-02 16:24:17 -05:00
|
|
|
#[pallet::weight((0, DispatchClass::Normal))] // TODO
|
|
|
|
|
pub fn transfer_genesis_liquidity(
|
2024-07-19 02:30:19 +03:00
|
|
|
origin: OriginFor<T>,
|
2025-12-02 16:24:17 -05:00
|
|
|
to: SeraiAddress,
|
|
|
|
|
genesis_liquidity: ExternalBalance,
|
2024-07-19 02:30:19 +03:00
|
|
|
) -> DispatchResult {
|
2025-12-02 16:24:17 -05:00
|
|
|
todo!("TODO")
|
2024-07-19 02:30:19 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 16:24:17 -05:00
|
|
|
/// Remove genesis liquidity.
|
|
|
|
|
#[pallet::call_index(2)]
|
|
|
|
|
#[pallet::weight((0, DispatchClass::Normal))] // TODO
|
|
|
|
|
pub fn remove_genesis_liquidity(
|
|
|
|
|
origin: OriginFor<T>,
|
|
|
|
|
genesis_liquidity: ExternalBalance,
|
|
|
|
|
) -> DispatchResult {
|
|
|
|
|
todo!("TODO")
|
2024-07-19 02:30:19 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub use pallet::*;
|