@@ -27,7 +27,7 @@ use frame_support::{
2727 transactional,
2828} ;
2929
30- use zenlink_protocol:: { AssetBalance , AssetId , ExportZenlink } ;
30+ use zenlink_protocol:: { AssetBalance , ExportZenlink } ;
3131use zenlink_stable_amm:: traits:: StableAmmApi ;
3232
3333#[ derive( Encode , Decode , Clone , PartialEq , Eq , Debug , TypeInfo ) ]
@@ -47,9 +47,9 @@ pub enum StableSwapMode {
4747}
4848
4949#[ derive( Encode , Decode , Clone , PartialEq , Eq , Debug , TypeInfo ) ]
50- pub enum Route < PoolId , CurrencyId > {
51- Stable ( StablePath < PoolId , CurrencyId > ) ,
52- Normal ( Vec < AssetId > ) ,
50+ pub enum Route < PoolId , StableCurrencyId , NormalCurrencyId > {
51+ Stable ( StablePath < PoolId , StableCurrencyId > ) ,
52+ Normal ( Vec < NormalCurrencyId > ) ,
5353}
5454
5555pub use pallet:: * ;
@@ -88,19 +88,29 @@ pub mod pallet {
8888 + Into < AssetBalance >
8989 + TypeInfo ;
9090
91- type CurrencyId : Parameter
91+ // The currency id use in stable amm
92+ type StableCurrencyId : Parameter
9293 + Member
9394 + Copy
9495 + MaybeSerializeDeserialize
9596 + Ord
9697 + TypeInfo
9798 + MaxEncodedLen ;
9899
99- type NormalAmm : ExportZenlink < AccountIdOf < Self > , AssetId > ;
100+ // The currency id use in standard amm
101+ type NormalCurrencyId : Parameter
102+ + Member
103+ + Copy
104+ + MaybeSerializeDeserialize
105+ + Ord
106+ + TypeInfo
107+ + MaxEncodedLen ;
108+
109+ type NormalAmm : ExportZenlink < AccountIdOf < Self > , Self :: NormalCurrencyId > ;
100110
101111 type StableAMM : StableAmmApi <
102112 Self :: StablePoolId ,
103- Self :: CurrencyId ,
113+ Self :: StableCurrencyId ,
104114 AccountIdOf < Self > ,
105115 Self :: Balance ,
106116 > ;
@@ -135,7 +145,7 @@ pub mod pallet {
135145 origin : OriginFor < T > ,
136146 amount_in : T :: Balance ,
137147 amount_out_min : T :: Balance ,
138- routes : Vec < Route < T :: StablePoolId , T :: CurrencyId > > ,
148+ routes : Vec < Route < T :: StablePoolId , T :: StableCurrencyId , T :: NormalCurrencyId > > ,
139149 to : T :: AccountId ,
140150 deadline : T :: BlockNumber ,
141151 ) -> DispatchResult {
@@ -175,7 +185,7 @@ pub mod pallet {
175185impl < T : Config > Pallet < T > {
176186 fn stable_swap (
177187 who : & T :: AccountId ,
178- path : & StablePath < T :: StablePoolId , T :: CurrencyId > ,
188+ path : & StablePath < T :: StablePoolId , T :: StableCurrencyId > ,
179189 amount_in : T :: Balance ,
180190 to : & T :: AccountId ,
181191 ) -> Result < T :: Balance , DispatchError > {
@@ -235,7 +245,7 @@ impl<T: Config> Pallet<T> {
235245 fn swap (
236246 who : & T :: AccountId ,
237247 amount_in : T :: Balance ,
238- path : & [ AssetId ] ,
248+ path : & [ T :: NormalCurrencyId ] ,
239249 to : & T :: AccountId ,
240250 ) -> DispatchResult {
241251 T :: NormalAmm :: inner_swap_exact_assets_for_assets (
@@ -249,7 +259,7 @@ impl<T: Config> Pallet<T> {
249259
250260 fn currency_index_from_stable_pool (
251261 pool_id : T :: StablePoolId ,
252- currency_id : T :: CurrencyId ,
262+ currency_id : T :: StableCurrencyId ,
253263 ) -> Result < u32 , DispatchError > {
254264 T :: StableAMM :: currency_index ( pool_id, currency_id)
255265 . ok_or_else ( || Error :: < T > :: MismatchPoolAndCurrencyId . into ( ) )
0 commit comments