mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 05:59:23 +00:00
5% buffer for swap mints; 20% restrction on out of pool value
This commit is contained in:
@@ -33,6 +33,7 @@ pallet-transaction-payment = { git = "https://github.com/serai-dex/substrate", d
|
||||
|
||||
serai-primitives = { path = "../../primitives", default-features = false, features = ["serde"] }
|
||||
coins-primitives = { package = "serai-coins-primitives", path = "../primitives", default-features = false }
|
||||
in-ins-primitives = { package = "serai-in-instructions-primitives", path = "../../in-instructions/primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
std = [
|
||||
@@ -47,6 +48,7 @@ std = [
|
||||
|
||||
"serai-primitives/std",
|
||||
"coins-primitives/std",
|
||||
"in-ins-primitives/std",
|
||||
]
|
||||
|
||||
runtime-benchmarks = [
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
use serai_primitives::{Coin, SubstrateAmount, Balance};
|
||||
|
||||
pub trait AllowMint {
|
||||
fn is_allowed(balance: &Balance) -> bool;
|
||||
fn is_allowed(balance: &Balance, for_swap: bool) -> bool;
|
||||
}
|
||||
|
||||
impl AllowMint for () {
|
||||
fn is_allowed(_: &Balance) -> bool {
|
||||
fn is_allowed(_: &Balance, _: bool) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ pub mod pallet {
|
||||
pub use coins_primitives as primitives;
|
||||
use primitives::*;
|
||||
|
||||
use in_ins_primitives::SWAP_ACCOUNT;
|
||||
|
||||
type LiquidityTokensInstance = crate::Instance1;
|
||||
|
||||
#[pallet::config]
|
||||
@@ -159,7 +161,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Errors if any amount overflows.
|
||||
pub fn mint(to: Public, balance: Balance) -> Result<(), Error<T, I>> {
|
||||
if !T::AllowMint::is_allowed(&balance) {
|
||||
if !T::AllowMint::is_allowed(&balance, to == SWAP_ACCOUNT.into()) {
|
||||
Err(Error::<T, I>::MintNotAllowed)?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user