-
Notifications
You must be signed in to change notification settings - Fork 569
/
Copy pathlib.rs
2471 lines (2215 loc) · 85.3 KB
/
lib.rs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file is part of Acala.
// Copyright (C) 2020-2023 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! The Dev runtime. This can be compiled with `#[no_std]`, ready for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit.
#![recursion_limit = "512"]
#![allow(clippy::unnecessary_mut_passed)]
#![allow(clippy::or_fun_call)]
#![allow(clippy::from_over_into)]
#![allow(clippy::upper_case_acronyms)]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use codec::{Decode, DecodeLimit, Encode};
use runtime_common::precompile::AcalaPrecompiles;
use scale_info::TypeInfo;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, BadOrigin, BlakeTwo256, Block as BlockT, Bounded, Convert,
SaturatedConversion, StaticLookup,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, ArithmeticError, DispatchResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill,
RuntimeDebug,
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use frame_system::{EnsureRoot, EnsureSigned, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping};
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
use module_relaychain::RelayChainCallBuilder;
use module_support::{AssetIdMapping, DispatchableTask, PoolId};
use module_transaction_payment::TargetedFeeAdjustment;
use cumulus_pallet_parachain_system::RelaychainDataProvider;
use orml_traits::{
create_median_value_data_provider, define_aggregrated_parameters, parameter_type_with_key,
parameters::ParameterStoreAdapter, DataFeeder, DataProviderExtended,
};
use orml_utilities::simulate_execution;
use pallet_transaction_payment::RuntimeDispatchInfo;
pub use frame_support::{
construct_runtime,
pallet_prelude::InvalidTransaction,
parameter_types,
traits::{
ConstBool, ConstU128, ConstU16, ConstU32, Contains, ContainsLengthBound, Currency as PalletCurrency, Currency,
EnsureOrigin, EqualPrivilegeOnly, Everything, Get, Imbalance, InstanceFilter, IsSubType, IsType,
KeyOwnerProofSystem, LockIdentifier, Nothing, OnRuntimeUpgrade, OnUnbalanced, Randomness, SortedMembers,
},
weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight},
PalletId, StorageValue,
};
pub use pallet_collective::MemberCount;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use authority::AuthorityConfigImpl;
pub use constants::{fee::*, time::*};
use module_support::{ExchangeRateProvider, FractionalRate};
use primitives::currency::AssetIds;
pub use primitives::{
define_combined_task,
evm::{
decode_gas_limit, decode_gas_price, AccessListItem, BlockLimits, EstimateResourcesRequest,
EthereumTransactionMessage,
},
task::TaskResult,
unchecked_extrinsic::AcalaUncheckedExtrinsic,
AccountId, AccountIndex, Address, Amount, AuctionId, AuthoritysOriginId, Balance, BlockNumber, CurrencyId,
DataProviderId, DexShare, EraIndex, Hash, Lease, Moment, Multiplier, Nonce, ReserveIdentifier, Share, Signature,
TokenSymbol, TradingPair,
};
pub use runtime_common::{
cent, dollar, microcent, millicent, AcalaDropAssets, AllPrecompiles, CheckRelayNumber, CurrencyHooks,
EnsureRootOrAllGeneralCouncil, EnsureRootOrAllTechnicalCommittee, EnsureRootOrHalfFinancialCouncil,
EnsureRootOrHalfGeneralCouncil, EnsureRootOrHalfHomaCouncil, EnsureRootOrOneGeneralCouncil,
EnsureRootOrOneThirdsTechnicalCommittee, EnsureRootOrThreeFourthsGeneralCouncil,
EnsureRootOrTwoThirdsGeneralCouncil, EnsureRootOrTwoThirdsTechnicalCommittee, ExchangeRate,
ExistentialDepositsTimesOneHundred, FinancialCouncilInstance, FinancialCouncilMembershipInstance, GasToWeight,
GeneralCouncilInstance, GeneralCouncilMembershipInstance, HomaCouncilInstance, HomaCouncilMembershipInstance,
MaxTipsOfPriority, OffchainSolutionWeightLimit, OperationalFeeMultiplier, OperatorMembershipInstanceAcala, Price,
ProxyType, Rate, Ratio, RuntimeBlockLength, RuntimeBlockWeights, SystemContractsFilter, TechnicalCommitteeInstance,
TechnicalCommitteeMembershipInstance, TimeStampedPrice, TipPerWeightStep, ACA, AUSD, DOT, LCDOT, LDOT, TAP,
};
pub use xcm::v3::prelude::*;
mod authority;
mod benchmarking;
pub mod constants;
/// Weights for pallets used in the runtime.
mod weights;
pub mod xcm_config;
/// This runtime version.
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("acala"),
impl_name: create_runtime_str!("acala"),
authoring_version: 1,
spec_version: 2220,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 3,
state_version: 0,
};
/// The version infromation used to identify this runtime when compiled
/// natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
}
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
// Pallet accounts of runtime
parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"aca/trsy");
pub const LoansPalletId: PalletId = PalletId(*b"aca/loan");
pub const DEXPalletId: PalletId = PalletId(*b"aca/dexm");
pub const CDPTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt");
pub const CDPEnginePalletId: PalletId = PalletId(*b"aca/cdpe");
pub const HomaPalletId: PalletId = PalletId(*b"aca/homa");
pub const HonzonTreasuryPalletId: PalletId = PalletId(*b"aca/hztr");
pub const HomaTreasuryPalletId: PalletId = PalletId(*b"aca/hmtr");
pub const IncentivesPalletId: PalletId = PalletId(*b"aca/inct");
pub const CollatorPotId: PalletId = PalletId(*b"aca/cpot");
// Treasury reserve
pub const TreasuryReservePalletId: PalletId = PalletId(*b"aca/reve");
pub const NftPalletId: PalletId = PalletId(*b"aca/aNFT");
// Vault all unrleased native token.
pub UnreleasedNativeVaultAccountId: AccountId = PalletId(*b"aca/urls").into_account_truncating();
// This Pallet is only used to payment fee pool, it's not added to whitelist by design.
// because transaction payment pallet will ensure the accounts always have enough ED.
pub const TransactionPaymentPalletId: PalletId = PalletId(*b"aca/fees");
pub const LiquidCrowdloanPalletId: PalletId = PalletId(*b"aca/lqcl");
pub const StableAssetPalletId: PalletId = PalletId(*b"nuts/sta");
}
pub fn get_all_module_accounts() -> Vec<AccountId> {
vec![
LoansPalletId::get().into_account_truncating(),
CDPEnginePalletId::get().into_account_truncating(),
CDPTreasuryPalletId::get().into_account_truncating(),
CollatorPotId::get().into_account_truncating(),
DEXPalletId::get().into_account_truncating(),
HomaPalletId::get().into_account_truncating(),
HomaTreasuryPalletId::get().into_account_truncating(),
HonzonTreasuryPalletId::get().into_account_truncating(),
IncentivesPalletId::get().into_account_truncating(),
TreasuryPalletId::get().into_account_truncating(),
TreasuryReservePalletId::get().into_account_truncating(),
UnreleasedNativeVaultAccountId::get(),
StableAssetPalletId::get().into_account_truncating(),
]
}
parameter_types! {
pub const BlockHashCount: BlockNumber = 1200; // mortal tx can be valid up to 4 hour after signing
pub const Version: RuntimeVersion = VERSION;
pub const SS58Prefix: u8 = 10; // Ss58AddressFormat::AcalaAccount
}
pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool {
let is_core_call = matches!(
call,
RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_)
);
if is_core_call {
// always allow core call
return true;
}
let is_paused = module_transaction_pause::PausedTransactionFilter::<Runtime>::contains(call);
if is_paused {
// no paused call
return false;
}
if let RuntimeCall::PolkadotXcm(xcm_method) = call {
match xcm_method {
pallet_xcm::Call::send { .. }
| pallet_xcm::Call::execute { .. }
| pallet_xcm::Call::teleport_assets { .. }
| pallet_xcm::Call::reserve_transfer_assets { .. }
| pallet_xcm::Call::limited_reserve_transfer_assets { .. }
| pallet_xcm::Call::limited_teleport_assets { .. } => {
return false;
}
pallet_xcm::Call::force_xcm_version { .. }
| pallet_xcm::Call::force_default_xcm_version { .. }
| pallet_xcm::Call::force_subscribe_version_notify { .. }
| pallet_xcm::Call::force_unsubscribe_version_notify { .. }
| pallet_xcm::Call::force_suspension { .. } => {
return true;
}
pallet_xcm::Call::__Ignore { .. } => {
unimplemented!()
}
}
}
true
}
}
impl frame_system::Config for Runtime {
type AccountId = AccountId;
type RuntimeCall = RuntimeCall;
type Lookup = (AccountIdLookup<AccountId, AccountIndex>, EvmAccounts);
type Nonce = Nonce;
type Hash = Hash;
type Hashing = BlakeTwo256;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type BlockHashCount = BlockHashCount;
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type Version = Version;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = (
module_evm::CallKillAccount<Runtime>,
module_evm_accounts::CallKillAccount<Runtime>,
);
type DbWeight = RocksDbWeight;
type BaseCallFilter = BaseCallFilter;
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = ConstU32<32>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
}
impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type EventHandler = CollatorSelection;
}
parameter_types! {
pub const SessionDuration: BlockNumber = 2 * HOURS; // used in SessionManagerConfig of genesis
}
impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ValidatorId = <Self as frame_system::Config>::AccountId;
// we don't have stash and controller, thus we don't need the convert as well.
type ValidatorIdOf = module_collator_selection::IdentityCollator;
type ShouldEndSession = SessionManager;
type NextSessionRotation = SessionManager;
type SessionManager = CollatorSelection;
// Essentially just Aura, but lets be pedantic.
type SessionHandler = <SessionKeys as sp_runtime::traits::OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type WeightInfo = ();
}
parameter_types! {
pub const CollatorKickThreshold: Permill = Permill::from_percent(60);
}
impl module_collator_selection::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ValidatorSet = Session;
type UpdateOrigin = EnsureRootOrHalfGeneralCouncil;
type PotId = CollatorPotId;
type MinCandidates = ConstU32<1>;
type MaxCandidates = ConstU32<50>;
type MaxInvulnerables = ConstU32<10>;
type KickPenaltySessionLength = ConstU32<8>;
type CollatorKickThreshold = CollatorKickThreshold;
type MinRewardDistributeAmount = ConstU128<0>;
type WeightInfo = weights::module_collator_selection::WeightInfo<Runtime>;
}
parameter_types! {
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = Moment;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}
// pallet-treasury did not impl OnUnbalanced<Credit>, need an adapter to handle dust.
type CreditOf = frame_support::traits::fungible::Credit<<Runtime as frame_system::Config>::AccountId, Balances>;
pub struct DustRemovalAdapter;
impl OnUnbalanced<CreditOf> for DustRemovalAdapter {
fn on_nonzero_unbalanced(amount: CreditOf) {
let new_amount = NegativeImbalance::new(amount.peek());
Treasury::on_nonzero_unbalanced(new_amount);
}
}
parameter_types! {
pub NativeTokenExistentialDeposit: Balance = 10 * cent(ACA); // 0.1 ACA
pub const MaxReserves: u32 = ReserveIdentifier::Count as u32;
// For weight estimation, we assume that the most locks on an individual account will be 50.
// This number may need to be adjusted in the future if this assumption no longer holds true.
pub const MaxLocks: u32 = 50;
}
impl pallet_balances::Config for Runtime {
type Balance = Balance;
type DustRemoval = DustRemovalAdapter;
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = NativeTokenExistentialDeposit;
type AccountStore = module_support::SystemAccountStore<Runtime>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = ReserveIdentifier;
type WeightInfo = ();
type RuntimeHoldReason = ReserveIdentifier;
type FreezeIdentifier = ();
type MaxHolds = MaxReserves;
type MaxFreezes = ();
}
parameter_types! {
pub TransactionByteFee: Balance = millicent(ACA);
/// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less
/// than this will decrease the weight and more will increase.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
/// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to
/// change the fees more rapidly.
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000);
/// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure
/// that combined with `AdjustmentVariable`, we can recover from the minimum.
/// See `multiplier_can_grow_from_zero`.
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128);
pub MaximumMultiplier: Multiplier = Bounded::max_value();
}
pub type SlowAdjustingFeeUpdate<R> =
TargetedFeeAdjustment<R, TargetBlockFullness, AdjustmentVariable, MinimumMultiplier, MaximumMultiplier>;
impl pallet_sudo::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WeightInfo = ();
}
parameter_types! {
pub const GeneralCouncilMotionDuration: BlockNumber = 3 * DAYS;
pub const CouncilDefaultMaxProposals: u32 = 20;
pub const CouncilDefaultMaxMembers: u32 = 30;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}
impl pallet_collective::Config<GeneralCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = GeneralCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}
impl pallet_membership::Config<GeneralCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type RemoveOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type SwapOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type ResetOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type PrimeOrigin = EnsureRootOrThreeFourthsGeneralCouncil;
type MembershipInitialized = GeneralCouncil;
type MembershipChanged = GeneralCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}
parameter_types! {
pub const FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
}
impl pallet_collective::Config<FinancialCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = FinancialCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}
impl pallet_membership::Config<FinancialCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = FinancialCouncil;
type MembershipChanged = FinancialCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}
parameter_types! {
pub const HomaCouncilMotionDuration: BlockNumber = 3 * DAYS;
}
impl pallet_collective::Config<HomaCouncilInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = HomaCouncilMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}
impl pallet_membership::Config<HomaCouncilMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = HomaCouncil;
type MembershipChanged = HomaCouncil;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}
parameter_types! {
pub const TechnicalCommitteeMotionDuration: BlockNumber = 3 * DAYS;
}
impl pallet_collective::Config<TechnicalCommitteeInstance> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalCommitteeMotionDuration;
type MaxProposals = CouncilDefaultMaxProposals;
type MaxMembers = CouncilDefaultMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxProposalWeight = MaxProposalWeight;
}
impl pallet_membership::Config<TechnicalCommitteeMembershipInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = CouncilDefaultMaxMembers;
type WeightInfo = ();
}
impl pallet_membership::Config<OperatorMembershipInstanceAcala> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type PrimeOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type MembershipInitialized = ();
type MembershipChanged = AcalaOracle;
type MaxMembers = ConstU32<50>;
type WeightInfo = ();
}
impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
}
parameter_types! {
pub MultisigDepositBase: Balance = deposit(1, 88);
pub MultisigDepositFactor: Balance = deposit(0, 32);
}
impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = MultisigDepositBase;
type DepositFactor = MultisigDepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = ();
}
pub struct GeneralCouncilProvider;
impl SortedMembers<AccountId> for GeneralCouncilProvider {
fn contains(who: &AccountId) -> bool {
GeneralCouncil::is_member(who)
}
fn sorted_members() -> Vec<AccountId> {
GeneralCouncil::members()
}
#[cfg(feature = "runtime-benchmarks")]
fn add(_: &AccountId) {
unimplemented!()
}
}
impl ContainsLengthBound for GeneralCouncilProvider {
fn max_len() -> usize {
CouncilDefaultMaxMembers::get() as usize
}
fn min_len() -> usize {
0
}
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub ProposalBondMinimum: Balance = 10 * dollar(ACA);
pub ProposalBondMaximum: Balance = 50 * dollar(ACA);
pub const SpendPeriod: BlockNumber = 30 * DAYS;
pub const Burn: Permill = Permill::from_percent(1);
pub const TipCountdown: BlockNumber = 2 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(5);
pub TipReportDepositBase: Balance = deposit(1, 0);
pub BountyDepositBase: Balance = deposit(1, 0);
pub const BountyDepositPayoutDelay: BlockNumber = 6 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 35 * DAYS;
pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50);
pub CuratorDepositMin: Balance = dollar(ACA);
pub CuratorDepositMax: Balance = 100 * dollar(ACA);
pub BountyValueMinimum: Balance = 5 * dollar(ACA);
pub DataDepositPerByte: Balance = deposit(0, 1);
pub const MaximumReasonLength: u32 = 8192;
pub const SevenDays: BlockNumber = 7 * DAYS;
pub const OneDay: BlockNumber = DAYS;
}
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = EnsureRootOrHalfGeneralCouncil;
type RejectOrigin = EnsureRootOrHalfGeneralCouncil;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
type SpendFunds = Bounties;
type WeightInfo = ();
type MaxApprovals = ConstU32<30>;
}
impl pallet_bounties::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyValueMinimum = BountyValueMinimum;
type CuratorDepositMultiplier = CuratorDepositMultiplier;
type CuratorDepositMin = CuratorDepositMin;
type CuratorDepositMax = CuratorDepositMax;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = ();
type ChildBountyManager = ();
}
impl pallet_tips::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = GeneralCouncilProvider;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = ();
}
parameter_types! {
pub const LaunchPeriod: BlockNumber = 5 * DAYS;
pub const VotingPeriod: BlockNumber = 5 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
pub MinimumDeposit: Balance = 1000 * dollar(ACA);
pub const EnactmentPeriod: BlockNumber = 2 * DAYS;
pub const VoteLockingPeriod: BlockNumber = 14 * DAYS;
pub const CooloffPeriod: BlockNumber = 7 * DAYS;
}
impl pallet_democracy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type MinimumDeposit = MinimumDeposit;
/// A straight majority of the council can decide what their next motion is.
type ExternalOrigin = EnsureRootOrHalfGeneralCouncil;
/// A majority can have the next scheduled referendum be a straight majority-carries vote.
type ExternalMajorityOrigin = EnsureRootOrHalfGeneralCouncil;
/// A unanimous council can have the next scheduled referendum be a straight default-carries
/// (NTB) vote.
type ExternalDefaultOrigin = EnsureRootOrAllGeneralCouncil;
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
type InstantOrigin = EnsureRootOrAllTechnicalCommittee;
type InstantAllowed = ConstBool<true>;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type BlacklistOrigin = EnsureRoot<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EnsureRootOrAllTechnicalCommittee;
// Any single technical committee member may veto a coming council proposal, however they can
// only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCommitteeInstance>;
type CooloffPeriod = CooloffPeriod;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = ConstU32<100>;
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = ConstU32<100>;
type Preimages = Preimage;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
type SubmitOrigin = EnsureSigned<AccountId>;
}
impl orml_auction::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AuctionId = AuctionId;
type Handler = AuctionManager;
type WeightInfo = weights::orml_auction::WeightInfo<Runtime>;
}
impl orml_authority::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type Scheduler = Scheduler;
type AsOriginId = AuthoritysOriginId;
type AuthorityConfig = AuthorityConfigImpl;
type WeightInfo = weights::orml_authority::WeightInfo<Runtime>;
}
parameter_types! {
pub const MinimumCount: u32 = 5;
pub const ExpiresIn: Moment = 1000 * 60 * 60; // 1 hours
pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]);
pub const MaxFeedValues: u32 = 10; // max 10 values allowd to feed in one call.
}
type AcalaDataProvider = orml_oracle::Instance1;
impl orml_oracle::Config<AcalaDataProvider> for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnNewData = ();
type CombineData = orml_oracle::DefaultCombineData<Runtime, MinimumCount, ExpiresIn, AcalaDataProvider>;
type Time = Timestamp;
type OracleKey = CurrencyId;
type OracleValue = Price;
type RootOperatorAccountId = RootOperatorAccountId;
type Members = OperatorMembershipAcala;
type MaxHasDispatchedSize = ConstU32<20>;
type WeightInfo = ();
type MaxFeedValues = MaxFeedValues;
}
create_median_value_data_provider!(
AggregatedDataProvider,
CurrencyId,
Price,
TimeStampedPrice,
[AcalaOracle]
);
// Aggregated data provider cannot feed.
impl DataFeeder<CurrencyId, Price, AccountId> for AggregatedDataProvider {
fn feed_value(_: Option<AccountId>, _: CurrencyId, _: Price) -> DispatchResult {
Err("Not supported".into())
}
}
parameter_type_with_key! {
pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance {
match currency_id {
CurrencyId::Token(symbol) => match symbol {
TokenSymbol::AUSD => 10 * cent(*currency_id),
TokenSymbol::DOT => cent(*currency_id),
TokenSymbol::LDOT => 5 * cent(*currency_id),
TokenSymbol::TAP => dollar(*currency_id),
TokenSymbol::KAR |
TokenSymbol::KUSD |
TokenSymbol::KSM |
TokenSymbol::LKSM |
TokenSymbol::BNC |
TokenSymbol::PHA |
TokenSymbol::VSKSM |
TokenSymbol::ACA |
TokenSymbol::KBTC |
TokenSymbol::KINT |
TokenSymbol::TAI => Balance::max_value() // unsupported
},
CurrencyId::DexShare(dex_share_0, _) => {
let currency_id_0: CurrencyId = (*dex_share_0).into();
// initial dex share amount is calculated based on currency_id_0,
// use the ED of currency_id_0 as the ED of lp token.
if currency_id_0 == GetNativeCurrencyId::get() {
NativeTokenExistentialDeposit::get()
} else if let CurrencyId::Erc20(address) = currency_id_0 {
// LP token with erc20
AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(address)).
map_or(Balance::max_value(), |metatata| metatata.minimal_balance)
} else {
Self::get(¤cy_id_0)
}
},
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance),
CurrencyId::StableAssetPoolToken(stable_asset_id) => {
AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)).
map_or(Balance::max_value(), |metatata| metatata.minimal_balance)
},
CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::DOT)), // the same as DOT
CurrencyId::ForeignAsset(foreign_asset_id) => {
AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)).
map_or(Balance::max_value(), |metatata| metatata.minimal_balance)
},
}
};
}
pub struct DustRemovalWhitelist;
impl Contains<AccountId> for DustRemovalWhitelist {
fn contains(a: &AccountId) -> bool {
get_all_module_accounts().contains(a)
}
}
parameter_types! {
pub AcalaTreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating();
}
impl orml_tokens::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = Amount;
type CurrencyId = CurrencyId;
type WeightInfo = weights::orml_tokens::WeightInfo<Runtime>;
type ExistentialDeposits = ExistentialDeposits;
type CurrencyHooks = CurrencyHooks<Runtime, AcalaTreasuryAccount>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = ReserveIdentifier;
type DustRemovalWhitelist = DustRemovalWhitelist;
}
parameter_type_with_key! {
pub LiquidCrowdloanLeaseBlockNumber: |lease: Lease| -> Option<BlockNumber> {
match lease {
13 => Some(17_856_000),
_ => None
}
};
}
parameter_type_with_key! {
pub PricingPegged: |currency_id: CurrencyId| -> Option<CurrencyId> {
match currency_id {
// taiKSM
CurrencyId::StableAssetPoolToken(0) => Some(DOT),
_ => None,
}
};
}
parameter_types! {
pub StableCurrencyFixedPrice: Price = Price::saturating_from_rational(1, 1);
pub RewardRatePerRelaychainBlock: Rate = Rate::saturating_from_rational(2_492, 100_000_000_000u128); // 14% annual staking reward rate of Polkadot
}
impl module_prices::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Source = AggregatedDataProvider;
type GetStableCurrencyId = GetStableCurrencyId;
type StableCurrencyFixedPrice = StableCurrencyFixedPrice;
type GetStakingCurrencyId = GetStakingCurrencyId;
type GetLiquidCurrencyId = GetLiquidCurrencyId;
type LockOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type LiquidStakingExchangeRateProvider = Homa;
type DEX = Dex;
type Currency = Currencies;
type Erc20InfoMapping = EvmErc20InfoMapping<Runtime>;
type LiquidCrowdloanLeaseBlockNumber = LiquidCrowdloanLeaseBlockNumber;
type RelayChainBlockNumber = RelaychainDataProvider<Runtime>;
type RewardRatePerRelaychainBlock = RewardRatePerRelaychainBlock;
type PricingPegged = PricingPegged;
type WeightInfo = weights::module_prices::WeightInfo<Runtime>;
}
parameter_types! {
pub const GetNativeCurrencyId: CurrencyId = ACA;
pub const GetStableCurrencyId: CurrencyId = AUSD;
pub const GetLiquidCurrencyId: CurrencyId = LDOT;
pub const GetStakingCurrencyId: CurrencyId = DOT;
pub Erc20HoldingAccount: H160 = primitives::evm::ERC20_HOLDING_ACCOUNT;
}
impl module_currencies::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MultiCurrency = Tokens;
type NativeCurrency = BasicCurrencyAdapter<Runtime, Balances, Amount, BlockNumber>;
type GetNativeCurrencyId = GetNativeCurrencyId;
type Erc20HoldingAccount = Erc20HoldingAccount;
type WeightInfo = weights::module_currencies::WeightInfo<Runtime>;
type AddressMapping = EvmAddressMapping<Runtime>;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type GasToWeight = GasToWeight;
type SweepOrigin = EnsureRootOrOneGeneralCouncil;
type OnDust = module_currencies::TransferDust<Runtime, AcalaTreasuryAccount>;
}
parameter_types! {
pub AcalaFoundationAccounts: Vec<AccountId> = vec![
hex_literal::hex!["5336f96b54fa1832d517549bbffdfba2cae8983b8dcf65caff82d616014f5951"].into(), // 22khtd8Zu9CpCY7DR4EPmmX66Aqsc91ShRAhehSWKGL7XDpL
hex_literal::hex!["26adf1c3a5b73f8640404d59ccb81de3ede79965b140addc7d8c0ff8736b5c53"].into(), // 21kK5T9tvL8nVdAAWizjtBgRbGcAs466iU6ZxeNWb7mFgg5i
hex_literal::hex!["7e32626ae20238b3f2c63299bdc1eb4729c7aadc995ce2abaa4e42130209f5d5"].into(), // 23j4ay2zBSgaSs18xstipmHBNi39W2Su9n8G89kWrz8eCe8F
TreasuryPalletId::get().into_account_truncating(),
TreasuryReservePalletId::get().into_account_truncating(),
];
}
pub struct EnsureAcalaFoundation;
impl EnsureOrigin<RuntimeOrigin> for EnsureAcalaFoundation {
type Success = AccountId;
fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
Into::<Result<RawOrigin<AccountId>, RuntimeOrigin>>::into(o).and_then(|o| match o {
RawOrigin::Signed(caller) => {
if AcalaFoundationAccounts::get().contains(&caller) {
Ok(caller)
} else {
Err(RuntimeOrigin::from(Some(caller)))
}
}
r => Err(RuntimeOrigin::from(r)),
})
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed");
Ok(RuntimeOrigin::from(RawOrigin::Signed(zero_account_id)))
}
}
impl orml_vesting::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = pallet_balances::Pallet<Runtime>;
type MinVestedTransfer = ConstU128<0>;
type VestedTransferOrigin = EnsureAcalaFoundation;
type WeightInfo = weights::orml_vesting::WeightInfo<Runtime>;
type MaxVestingSchedules = ConstU32<100>;
type BlockNumberProvider = RelaychainDataProvider<Runtime>;
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
}
impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = ConstU32<10>;
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = Preimage;
}
parameter_types! {
pub PreimageBaseDeposit: Balance = deposit(2, 64);
pub PreimageByteDeposit: Balance = deposit(0, 1);
}
impl pallet_preimage::Config for Runtime {
type WeightInfo = ();
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
}
parameter_types! {
pub MinimumIncrementSize: Rate = Rate::saturating_from_rational(2, 100);
pub const AuctionTimeToClose: BlockNumber = 15 * MINUTES;
pub const AuctionDurationSoftCap: BlockNumber = 24 * HOURS;
}
impl module_auction_manager::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Currencies;
type Auction = Auction;
type MinimumIncrementSize = MinimumIncrementSize;
type AuctionTimeToClose = AuctionTimeToClose;
type AuctionDurationSoftCap = AuctionDurationSoftCap;
type GetStableCurrencyId = GetStableCurrencyId;
type CDPTreasury = CdpTreasury;
type PriceSource = module_prices::PriorityLockedPriceProvider<Runtime>;
type UnsignedPriority = runtime_common::AuctionManagerUnsignedPriority;
type EmergencyShutdown = EmergencyShutdown;
type WeightInfo = weights::module_auction_manager::WeightInfo<Runtime>;
}
impl module_loans::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Currencies;
type RiskManager = CdpEngine;
type CDPTreasury = CdpTreasury;
type PalletId = LoansPalletId;