-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathasset_conversion.rs
More file actions
94 lines (92 loc) · 3.83 KB
/
Copy pathasset_conversion.rs
File metadata and controls
94 lines (92 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! # FintradeX Asset Conversion Configuration
//!
//! This module configures the asset conversion functionality for the FintradeX parachain,
//! enabling seamless conversion between different assets and currencies.
//!
//! ## Features
//!
//! - **Multi-Asset Support**: Conversion between various asset types
//! - **Liquidity Pools**: Automated market making for conversions
//! - **Cross-Chain Assets**: Support for assets from different chains
//! - **Trading Integration**: Seamless integration with trading operations
//!
//! ## Configuration
//!
//! - Asset conversion pallet configuration
//! - Liquidity pool management
//! - Fee structure for conversions
//! - Cross-chain asset support
//!
//! For more information, visit [https://fintradex.io/](https://fintradex.io/)
//use crate::configs::assets::AssetConversionOrigin;
use crate::{
constants::currency::*, AccountId, Assets, Balance, Balances,Treasury, PoolAssets, Runtime, RuntimeEvent,
};
use frame_support::{
instances::Instance2,
parameter_types,
traits::{
fungible::{NativeFromLeft, NativeOrWithId, UnionOf},
tokens::imbalance::ResolveAssetTo,
ConstU32,
},
PalletId
};
use pallet_asset_conversion::{AccountIdConverter, Ascending, Chain, WithFirstAsset};
use sp_runtime::Permill;
// Near your other imports / types:
parameter_types! {
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub const PoolSetupFee: Balance = 10*FINTS; // should be more or equal to the existential deposit
pub const MintMinLiquidity: Balance = 10_000_000_000_000_000; // 10k units with 12 decimals; .
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
pub const Native: NativeOrWithId<u32> = NativeOrWithId::Native;
pub TreasuryAccount: AccountId = Treasury::account_id();
}
impl pallet_asset_conversion::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = u128;
type HigherPrecisionBalance = primitive_types::U256;
type AssetKind = NativeOrWithId<u32>;
type Assets = UnionOf<Balances, Assets, NativeFromLeft, NativeOrWithId<u32>, AccountId>;
type PoolId = (Self::AssetKind, Self::AssetKind);
type PoolLocator = Chain<
WithFirstAsset<
Native,
AccountId,
NativeOrWithId<u32>,
AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
>,
Ascending<
AccountId,
NativeOrWithId<u32>,
AccountIdConverter<AssetConversionPalletId, Self::PoolId>,
>,
>;
type PoolAssetId = <Self as pallet_assets::Config<Instance2>>::AssetId;
type PoolAssets = PoolAssets;
type PoolSetupFee = PoolSetupFee;
type PoolSetupFeeAsset = Native;
//type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
type PoolSetupFeeTarget = ResolveAssetTo<TreasuryAccount,Self::Assets>;
type PalletId = AssetConversionPalletId;
type LPFee = ConstU32<3>; // means 0.3%
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
type WeightInfo = pallet_asset_conversion::weights::SubstrateWeight<Runtime>;
type MaxSwapPathLength = ConstU32<4>;
type MintMinLiquidity = MintMinLiquidity;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<(
NativeOrWithId<u32>,
NativeOrWithId<u32>,
)>;
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type DepositAsset = Balances;
type WeightInfo = pallet_asset_conversion_ops::weights::SubstrateWeight<Runtime>;
}