Skip to content

Commit f2af11d

Browse files
DanijelCBSCvijanCBSwer1stZlayaMordavovac12
authoredJan 24, 2025··
Feature/apollo update collateral factor (#1302)
* feat: setting up collateral factor and implementing it in borrow and add_collateral extrinsic * Presto: publish Crop Receipt (#1294) Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * Presto: fix strings (#1296) Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * cover with wip new fee events (#1297) * Presto: fix USA name (#1298) Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * Prepare release 4.5.2 (#1299) Co-authored-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * Presto: benchmarks (#1300) * benchmarks Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * weights Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> --------- Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * fix: adjusting the default value for the collateral factor * Presto: minor fix flag Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * Change fee to small fee for vesting (#1304) * change fee to small fee for vesting * Random xor-fee remint (#1305) * Random xor-fee remint * Add benchmark * Fix clippy * Fix review issues * Prepare release 4.5.3 (#1306) * Prepare release 4.5.3 * Update Cargo.lock * Benchmark results of benchmarking-4.5.3 from master (#1308) * Fix benchmarking * benchmarking results Signed-off-by: sorabot <bot@soramitsu.co.jp> * Fix benchmarks * Fix xor-fee and demeter benchmarks * Fix remint without wip * benchmarking results Signed-off-by: sorabot <bot@soramitsu.co.jp> --------- Signed-off-by: sorabot <bot@soramitsu.co.jp> Co-authored-by: Vladimir Stepanenko <vovac12@gmail.com> * 1171 xorless fee part 2 (#1290) * add check for depth * change assets in migration * compute fee for order book and vested transfer * update Carrgo.lock * add set referrer --------- Co-authored-by: Vladimir Stepanenko <vovac12@gmail.com> * aggregating total collateral amount in separate storage for easier tracking * migrations for the new approach with total collateral amount * test coverage of new features * updating typos in the lib of apollo pallet * migration update * Test coverage for updated migration * minor update to migrations tests in apollo platform * Moving runtime upgrade to empty struct (MigrateToV1) with OnRuntimeUpgrade implementation * Presto KYC (#1309) Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> * fix: typo * fix: changing migration checks for pre and post upgrade * Update const STORAGE_VERSION from 0 to 1 Co-authored-by: Vladimir Stepanenko <vovac12@gmail.com> * Update multiplier for reading the old and new storage Co-authored-by: Vladimir Stepanenko <vovac12@gmail.com> * Fix TBC reserves distribution (#1311) * Fix TBC reserves distribution * Update pallets/multicollateral-bonding-curve-pool/src/mock.rs Co-authored-by: Taras Rusakovich <56021558+ZlayaMorda@users.noreply.github.com> --------- Co-authored-by: Taras Rusakovich <56021558+ZlayaMorda@users.noreply.github.com> * Prepare release 4.5.4 (#1312) * feat: added apollo-platform migrations to the runtime migrations --------- Signed-off-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> Signed-off-by: sorabot <bot@soramitsu.co.jp> Co-authored-by: CvijanCBS <cvijan@ceresblockchain.solutions> Co-authored-by: Mikhail Tagirov <dev.mikhail.tagirov@outlook.com> Co-authored-by: Taras Rusakovich <56021558+ZlayaMorda@users.noreply.github.com> Co-authored-by: Vladimir Stepanenko <vovac12@gmail.com> Co-authored-by: sorabot <32125183+sorabot@users.noreply.github.com> Co-authored-by: Cvijan Djukanovic <159775818+CvijanCBS@users.noreply.github.com>
1 parent 37be80a commit f2af11d

File tree

7 files changed

+1303
-7
lines changed

7 files changed

+1303
-7
lines changed
 

‎pallets/apollo-platform/src/benchmarking.rs

+11
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,17 @@ benchmarks! {
576576
assert_last_event::<T>(Event::ChangedRewardsAmount(caller, true, balance!(1)).into());
577577
}
578578

579+
change_collateral_factor {
580+
let caller = pallet::AuthorityAccount::<T>::get();
581+
}: {
582+
ApolloPlatform::<T>::change_collateral_factor(
583+
RawOrigin::Signed(caller.clone()).into(),
584+
balance!(1)
585+
).unwrap()
586+
} verify {
587+
assert_last_event::<T>(Event::ChangedCollateralFactorAmount(caller,balance!(1)).into());
588+
}
589+
579590
change_rewards_per_block {
580591
let caller = pallet::AuthorityAccount::<T>::get();
581592
let asset_id_xor = XOR;

‎pallets/apollo-platform/src/lib.rs

+170-5
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ pub struct PoolInfo {
5454
}
5555

5656
pub use pallet::*;
57+
pub mod migrations;
5758

5859
#[frame_support::pallet]
5960
pub mod pallet {
6061
use crate::{BorrowingPosition, LendingPosition, PoolInfo, WeightInfo};
6162
use common::prelude::{Balance, FixedWrapper, SwapAmount};
6263
use common::{
6364
balance, AssetIdOf, AssetManager, DEXId, LiquiditySourceFilter, PriceVariant,
64-
CERES_ASSET_ID, DAI,
65+
CERES_ASSET_ID, DAI, KUSD,
6566
};
6667
use common::{LiquidityProxyTrait, PriceToolsProvider, APOLLO_ASSET_ID};
6768
use frame_support::log::{debug, warn};
6869
use frame_support::pallet_prelude::{ValueQuery, *};
6970
use frame_support::sp_runtime::traits::AccountIdConversion;
71+
use frame_support::traits::StorageVersion;
7072
use frame_support::PalletId;
7173
use frame_system::offchain::{SendTransactionTypes, SubmitTransaction};
7274
use frame_system::pallet_prelude::*;
@@ -108,8 +110,12 @@ pub mod pallet {
108110

109111
pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
110112

113+
/// The current storage version.
114+
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
115+
111116
#[pallet::pallet]
112117
#[pallet::generate_store(pub (super) trait Store)]
118+
#[pallet::storage_version(STORAGE_VERSION)]
113119
#[pallet::without_storage_info]
114120
pub struct Pallet<T>(PhantomData<T>);
115121

@@ -139,6 +145,12 @@ pub mod pallet {
139145
OptionQuery,
140146
>;
141147

148+
/// User AccountId -> Collateral Asset -> Total Collateral Amount
149+
#[pallet::storage]
150+
#[pallet::getter(fn user_total_collateral)]
151+
pub type UserTotalCollateral<T: Config> =
152+
StorageDoubleMap<_, Identity, AccountIdOf<T>, Identity, AssetIdOf<T>, Balance, OptionQuery>;
153+
142154
#[pallet::storage]
143155
#[pallet::getter(fn pool_info)]
144156
pub type PoolData<T: Config> = StorageMap<_, Identity, AssetIdOf<T>, PoolInfo, OptionQuery>;
@@ -193,6 +205,17 @@ pub mod pallet {
193205
pub type BorrowingRewards<T: Config> =
194206
StorageValue<_, Balance, ValueQuery, FixedBorrowingRewards<T>>;
195207

208+
/// Default collateral factor
209+
#[pallet::type_value]
210+
pub fn DefaultCollateralFactor<T: Config>() -> Balance {
211+
balance!(0.001)
212+
}
213+
214+
#[pallet::storage]
215+
#[pallet::getter(fn collateral_factor)]
216+
pub type CollateralFactor<T: Config> =
217+
StorageValue<_, Balance, ValueQuery, DefaultCollateralFactor<T>>;
218+
196219
#[pallet::type_value]
197220
pub fn FixedLendingRewardsPerBlock<T: Config>() -> Balance {
198221
balance!(0.03805175)
@@ -236,6 +259,8 @@ pub mod pallet {
236259
ChangedRewardsAmount(AccountIdOf<T>, bool, Balance),
237260
//// ChangedRewardsAmountPerBlock [who, is_lending, amount]
238261
ChangedRewardsAmountPerBlock(AccountIdOf<T>, bool, Balance),
262+
/// Changed Borrowing factor [who, amount]
263+
ChangedCollateralFactorAmount(AccountIdOf<T>, Balance),
239264
/// Liquidated [who, asset_id]
240265
Liquidated(AccountIdOf<T>, AssetIdOf<T>),
241266
/// Pool removed [who, asset_id]
@@ -542,14 +567,39 @@ pub mod pallet {
542567
.try_into_balance()
543568
.unwrap_or(0);
544569

570+
let mut borrow_info =
571+
<UserBorrowingInfo<T>>::get(borrowing_asset, user.clone()).unwrap_or_default();
572+
573+
if collateral_asset == KUSD.into() {
574+
let factor = <CollateralFactor<T>>::get();
575+
576+
// To get total collateral for a user
577+
let total_existing_collateral =
578+
<UserTotalCollateral<T>>::get(user.clone(), collateral_asset)
579+
.unwrap_or(Zero::zero());
580+
581+
// Calculate the maximum allowed collateral for KUSD
582+
let max_allowed_collateral = Self::calculate_max_allowed_collateral(
583+
user_lending_info
584+
.lending_amount
585+
.saturating_add(total_existing_collateral),
586+
factor,
587+
)?;
588+
589+
let new_total_collateral =
590+
total_existing_collateral.saturating_add(collateral_amount);
591+
592+
ensure!(
593+
new_total_collateral <= max_allowed_collateral,
594+
Error::<T>::InvalidCollateralAmount
595+
);
596+
}
597+
545598
ensure!(
546599
collateral_amount <= user_lending_info.lending_amount,
547600
Error::<T>::InvalidCollateralAmount
548601
);
549602

550-
let mut borrow_info =
551-
<UserBorrowingInfo<T>>::get(borrowing_asset, user.clone()).unwrap_or_default();
552-
553603
// Add borrowing amount, collateral amount and interest to user if exists, otherwise create new user
554604
if let Some(mut user_info) = borrow_info.get_mut(&collateral_asset) {
555605
let block_number = <frame_system::Pallet<T>>::block_number();
@@ -602,6 +652,9 @@ pub mod pallet {
602652
<PoolData<T>>::insert(collateral_asset, collateral_pool_info);
603653
<PoolData<T>>::insert(borrowing_asset, borrow_pool_info);
604654

655+
// Update the total collateral
656+
Self::update_total_collateral(&user, &collateral_asset, collateral_amount)?;
657+
605658
// Transfer borrowing amount to user
606659
T::AssetManager::transfer_from(
607660
&borrowing_asset,
@@ -873,6 +926,13 @@ pub mod pallet {
873926
<PoolData<T>>::insert(collateral_asset, collateral_pool_info);
874927
<PoolData<T>>::insert(borrowing_asset, borrow_pool_info);
875928

929+
// Update the total collateral
930+
Self::decrease_total_collateral(
931+
&user,
932+
&collateral_asset,
933+
user_info.collateral_amount,
934+
)?;
935+
876936
// Transfer borrowing amount and borrowing interest to pallet
877937
T::AssetManager::transfer_from(
878938
&borrowing_asset,
@@ -1011,7 +1071,7 @@ pub mod pallet {
10111071
// Calculate total borrow and total collateral in dollars
10121072
let mut total_borrowed: Balance = 0;
10131073

1014-
// Distributing and calculating total borrwed
1074+
// Distributing and calculating total borrowed
10151075
for (collateral_asset, user_info) in user_infos.iter() {
10161076
// Calculate collateral in dollars
10171077
let collateral_asset_price = Self::get_price(*collateral_asset);
@@ -1067,6 +1127,13 @@ pub mod pallet {
10671127
.total_collateral
10681128
.saturating_sub(user_info.collateral_amount);
10691129

1130+
// Update the total collateral
1131+
Self::decrease_total_collateral(
1132+
&user,
1133+
collateral_asset,
1134+
user_info.collateral_amount,
1135+
)?;
1136+
10701137
<PoolData<T>>::insert(*collateral_asset, collateral_pool_info);
10711138
// Add user's borrowed amount tied with this asset to total_borrowed in given asset
10721139
total_borrowed += user_info.borrowing_amount;
@@ -1225,6 +1292,30 @@ pub mod pallet {
12251292
let mut borrow_info =
12261293
<UserBorrowingInfo<T>>::get(borrowing_asset, user.clone()).unwrap_or_default();
12271294

1295+
if collateral_asset == KUSD.into() {
1296+
let factor = <CollateralFactor<T>>::get();
1297+
// To get total collateral for a user
1298+
let total_existing_collateral =
1299+
<UserTotalCollateral<T>>::get(user.clone(), collateral_asset)
1300+
.unwrap_or(Zero::zero());
1301+
1302+
// Calculate the maximum allowed collateral for KUSD
1303+
let max_allowed_collateral = Self::calculate_max_allowed_collateral(
1304+
user_lending_info
1305+
.lending_amount
1306+
.saturating_add(total_existing_collateral),
1307+
factor,
1308+
)?;
1309+
1310+
let new_total_collateral =
1311+
total_existing_collateral.saturating_add(collateral_amount);
1312+
1313+
ensure!(
1314+
new_total_collateral <= max_allowed_collateral,
1315+
Error::<T>::InvalidCollateralAmount
1316+
);
1317+
}
1318+
12281319
// Add borrowing amount, collateral amount and interest to user if exists, otherwise return error
12291320
if let Some(mut user_info) = borrow_info.get_mut(&collateral_asset) {
12301321
let block_number = <frame_system::Pallet<T>>::block_number();
@@ -1262,6 +1353,9 @@ pub mod pallet {
12621353
.saturating_sub(collateral_amount);
12631354
collateral_pool_info.total_collateral += collateral_amount;
12641355

1356+
// Update the total collateral
1357+
Self::update_total_collateral(&user, &collateral_asset, collateral_amount)?;
1358+
12651359
<PoolData<T>>::insert(collateral_asset, collateral_pool_info);
12661360

12671361
Self::deposit_event(Event::CollateralAdded(
@@ -1273,6 +1367,25 @@ pub mod pallet {
12731367

12741368
Ok(().into())
12751369
}
1370+
1371+
/// Change rewards amount
1372+
#[pallet::call_index(12)]
1373+
#[pallet::weight(<T as Config>::WeightInfo::change_collateral_factor())]
1374+
pub fn change_collateral_factor(
1375+
origin: OriginFor<T>,
1376+
amount: Balance,
1377+
) -> DispatchResultWithPostInfo {
1378+
let user = ensure_signed(origin)?;
1379+
1380+
if user != AuthorityAccount::<T>::get() {
1381+
return Err(Error::<T>::Unauthorized.into());
1382+
}
1383+
1384+
<CollateralFactor<T>>::put(amount);
1385+
1386+
Self::deposit_event(Event::ChangedCollateralFactorAmount(user, amount));
1387+
Ok(().into())
1388+
}
12761389
}
12771390

12781391
/// Validate unsigned call to this pallet.
@@ -1475,6 +1588,47 @@ pub mod pallet {
14751588
)
14761589
}
14771590

1591+
/// Increase total collateral amount for a user and asset
1592+
fn update_total_collateral(
1593+
user: &AccountIdOf<T>,
1594+
collateral_asset: &AssetIdOf<T>,
1595+
amount_to_add: Balance,
1596+
) -> DispatchResult {
1597+
<UserTotalCollateral<T>>::mutate(user, collateral_asset, |current_collateral| {
1598+
// If no existing collateral, start with the new amount
1599+
// Otherwise, add the new amount
1600+
*current_collateral = Some(
1601+
current_collateral
1602+
.unwrap_or(Zero::zero())
1603+
.saturating_add(amount_to_add),
1604+
)
1605+
});
1606+
1607+
Ok(())
1608+
}
1609+
1610+
/// Decrease total collateral amount for a user and asset
1611+
fn decrease_total_collateral(
1612+
user: &AccountIdOf<T>,
1613+
collateral_asset: &AssetIdOf<T>,
1614+
amount_to_remove: Balance,
1615+
) -> DispatchResult {
1616+
<UserTotalCollateral<T>>::mutate(user, collateral_asset, |current_collateral| {
1617+
if let Some(current) = *current_collateral {
1618+
let new_amount = current.saturating_sub(amount_to_remove);
1619+
1620+
// Remove the entry if it reaches zero, otherwise update
1621+
if new_amount == Zero::zero() {
1622+
*current_collateral = None;
1623+
} else {
1624+
*current_collateral = Some(new_amount);
1625+
}
1626+
}
1627+
});
1628+
1629+
Ok(())
1630+
}
1631+
14781632
pub fn distribute_protocol_interest(
14791633
asset_id: AssetIdOf<T>,
14801634
amount: Balance,
@@ -1565,6 +1719,17 @@ pub mod pallet {
15651719
Ok(().into())
15661720
}
15671721

1722+
fn calculate_max_allowed_collateral(
1723+
lending_amount: Balance,
1724+
factor: Balance,
1725+
) -> Result<Balance, DispatchError> {
1726+
Ok(
1727+
(FixedWrapper::from(lending_amount) * FixedWrapper::from(factor))
1728+
.try_into_balance()
1729+
.unwrap_or(0),
1730+
)
1731+
}
1732+
15681733
fn update_interests(block_number: BlockNumberFor<T>) -> Weight {
15691734
let mut counter: u64 = 0;
15701735
let pool_index = block_number % T::BLOCKS_PER_FIFTEEN_MINUTES;
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
use crate::{Config, Pallet, UserBorrowingInfo, UserTotalCollateral};
2+
use common::prelude::Balance;
3+
use frame_support::log::{error, info};
4+
use frame_support::pallet_prelude::*;
5+
use frame_support::traits::OnRuntimeUpgrade;
6+
use frame_support::traits::StorageVersion;
7+
use sp_runtime::traits::Zero;
8+
9+
pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
10+
11+
impl<T> OnRuntimeUpgrade for MigrateToV1<T>
12+
where
13+
T: Config,
14+
{
15+
fn on_runtime_upgrade() -> frame_support::weights::Weight {
16+
if Pallet::<T>::on_chain_storage_version() != StorageVersion::new(0) {
17+
error!(
18+
"Runtime upgrade executed with wrong storage version, expected 0, got {:?}",
19+
Pallet::<T>::on_chain_storage_version()
20+
);
21+
return <T as frame_system::Config>::DbWeight::get().reads(1);
22+
}
23+
24+
info!("Applying migration to version 2: Convert borrowing info to total collateral");
25+
26+
// Perform migration
27+
<UserBorrowingInfo<T>>::iter().for_each(|(_, user, old_borrowing_map)| {
28+
old_borrowing_map
29+
.iter()
30+
.for_each(|(collateral_asset, borrow_info)| {
31+
let additional_collateral = borrow_info.collateral_amount;
32+
33+
if additional_collateral > Balance::zero() {
34+
let current_total_collateral =
35+
<UserTotalCollateral<T>>::get(&user, collateral_asset)
36+
.unwrap_or_else(Zero::zero);
37+
38+
let updated_total_collateral =
39+
current_total_collateral.saturating_add(additional_collateral);
40+
41+
<UserTotalCollateral<T>>::insert(
42+
user.clone(),
43+
collateral_asset,
44+
updated_total_collateral,
45+
);
46+
}
47+
});
48+
});
49+
50+
let total_migrated_entries = <UserTotalCollateral<T>>::iter().count();
51+
info!(
52+
"Migrated {} user total collateral entries",
53+
total_migrated_entries
54+
);
55+
56+
// Update storage version
57+
StorageVersion::new(1).put::<Pallet<T>>();
58+
59+
// Calculate and return weight
60+
<T as frame_system::Config>::DbWeight::get().reads_writes(
61+
total_migrated_entries as u64 * 3, // read old and new storage
62+
total_migrated_entries as u64, // write new storage
63+
)
64+
}
65+
66+
#[cfg(feature = "try-runtime")]
67+
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
68+
ensure!(
69+
Pallet::<T>::on_chain_storage_version() == StorageVersion::new(0),
70+
"must upgrade linearly"
71+
);
72+
Ok(Vec::new()) // No state needed for pre-upgrade check
73+
}
74+
75+
#[cfg(feature = "try-runtime")]
76+
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
77+
let total_migrated_entries = <UserTotalCollateral<T>>::iter().count();
78+
ensure!(
79+
total_migrated_entries > 0,
80+
"No entries migrated during upgrade"
81+
);
82+
83+
ensure!(
84+
Pallet::<T>::on_chain_storage_version() == StorageVersion::new(1),
85+
"should be upgraded to version 1"
86+
);
87+
Ok(())
88+
}
89+
}

‎pallets/apollo-platform/src/mock.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use {
1515
AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource,
1616
DEXId::Polkaswap,
1717
DEXInfo, Description, FromGenericPair, LiquidityProxyTrait, PriceToolsProvider,
18-
PriceVariant, APOLLO_ASSET_ID, CERES_ASSET_ID, DAI, DOT, KSM, VXOR, XOR, XST,
18+
PriceVariant, APOLLO_ASSET_ID, CERES_ASSET_ID, DAI, DOT, KSM, KUSD, VXOR, XOR, XST,
1919
},
2020
currencies::BasicCurrencyAdapter,
2121
frame_support::{
@@ -167,6 +167,12 @@ impl PriceToolsProvider<AssetId> for MockPriceTools {
167167
(&KSM, &DAI) => Ok(balance!(1)),
168168
(&DOT, &KSM) => Ok(balance!(1)),
169169
(&KSM, &DOT) => Ok(balance!(1)),
170+
(&KUSD, &DOT) => Ok(balance!(1)),
171+
(&DOT, &KUSD) => Ok(balance!(1)),
172+
(&XOR, &KUSD) => Ok(balance!(1)),
173+
(&KUSD, &XOR) => Ok(balance!(1)),
174+
(&DAI, &KUSD) => Ok(balance!(1)),
175+
(&KUSD, &DAI) => Ok(balance!(1)),
170176
_ => Ok(balance!(0)),
171177
},
172178
PriceVariant::Sell => match (input_asset_id, output_asset_id) {
@@ -183,6 +189,12 @@ impl PriceToolsProvider<AssetId> for MockPriceTools {
183189
(&KSM, &DAI) => Ok(balance!(1)),
184190
(&DOT, &KSM) => Ok(balance!(1)),
185191
(&KSM, &DOT) => Ok(balance!(1)),
192+
(&KUSD, &DOT) => Ok(balance!(1)),
193+
(&DOT, &KUSD) => Ok(balance!(1)),
194+
(&XOR, &KUSD) => Ok(balance!(1)),
195+
(&KUSD, &XOR) => Ok(balance!(1)),
196+
(&DAI, &KUSD) => Ok(balance!(1)),
197+
(&KUSD, &DAI) => Ok(balance!(1)),
186198
_ => Ok(balance!(0)),
187199
},
188200
}
@@ -351,6 +363,17 @@ impl Default for ExtBuilder {
351363
None,
352364
None,
353365
),
366+
(
367+
KUSD,
368+
alice(),
369+
AssetSymbol(b"KUSD".to_vec()),
370+
AssetName(b"Kensetsu Stable Dollar".to_vec()),
371+
18,
372+
Balance::from(0u32),
373+
true,
374+
None,
375+
None,
376+
),
354377
],
355378
endowed_accounts: vec![
356379
(alice(), APOLLO_ASSET_ID, balance!(300000)),

‎pallets/apollo-platform/src/tests.rs

+978
Large diffs are not rendered by default.

‎pallets/apollo-platform/src/weights.rs

+27
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub trait WeightInfo {
6767
fn withdraw() -> Weight;
6868
fn repay() -> Weight;
6969
fn change_rewards_amount() -> Weight;
70+
fn change_collateral_factor() -> Weight;
7071
fn change_rewards_per_block() -> Weight;
7172
fn liquidate() -> Weight;
7273
fn remove_pool() -> Weight;
@@ -250,6 +251,19 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
250251
}
251252
/// Storage: ApolloPlatform AuthorityAccount (r:1 w:0)
252253
/// Proof Skipped: ApolloPlatform AuthorityAccount (max_values: Some(1), max_size: None, mode: Measured)
254+
/// Storage: ApolloPlatform CollateralFactor (r:0 w:1)
255+
/// Proof Skipped: ApolloPlatform CollateralFactor (max_values: Some(1), max_size: None, mode: Measured)
256+
fn change_collateral_factor() -> Weight {
257+
// Proof Size summary in bytes:
258+
// Measured: `114`
259+
// Estimated: `723`
260+
// Minimum execution time: 21_704_000 picoseconds.
261+
Weight::from_parts(22_211_000, 723)
262+
.saturating_add(T::DbWeight::get().reads(1_u64))
263+
.saturating_add(T::DbWeight::get().writes(1_u64))
264+
}
265+
/// Storage: ApolloPlatform AuthorityAccount (r:1 w:0)
266+
/// Proof Skipped: ApolloPlatform AuthorityAccount (max_values: Some(1), max_size: None, mode: Measured)
253267
/// Storage: ApolloPlatform PoolData (r:2 w:1)
254268
/// Proof Skipped: ApolloPlatform PoolData (max_values: None, max_size: None, mode: Measured)
255269
/// Storage: ApolloPlatform LendingRewardsPerBlock (r:0 w:1)
@@ -532,6 +546,19 @@ impl WeightInfo for () {
532546
}
533547
/// Storage: ApolloPlatform AuthorityAccount (r:1 w:0)
534548
/// Proof Skipped: ApolloPlatform AuthorityAccount (max_values: Some(1), max_size: None, mode: Measured)
549+
/// Storage: ApolloPlatform CollateralFactor (r:0 w:1)
550+
/// Proof Skipped: ApolloPlatform CollateralFactor (max_values: Some(1), max_size: None, mode: Measured)
551+
fn change_collateral_factor() -> Weight {
552+
// Proof Size summary in bytes:
553+
// Measured: `114`
554+
// Estimated: `723`
555+
// Minimum execution time: 21_704_000 picoseconds.
556+
Weight::from_parts(22_211_000, 723)
557+
.saturating_add(RocksDbWeight::get().reads(1_u64))
558+
.saturating_add(RocksDbWeight::get().writes(1_u64))
559+
}
560+
/// Storage: ApolloPlatform AuthorityAccount (r:1 w:0)
561+
/// Proof Skipped: ApolloPlatform AuthorityAccount (max_values: Some(1), max_size: None, mode: Measured)
535562
/// Storage: ApolloPlatform PoolData (r:2 w:1)
536563
/// Proof Skipped: ApolloPlatform PoolData (max_values: None, max_size: None, mode: Measured)
537564
/// Storage: ApolloPlatform LendingRewardsPerBlock (r:0 w:1)

‎runtime/src/migrations.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2929
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31-
pub type Migrations = (WipMigrations,);
31+
pub type Migrations = (
32+
WipMigrations,
33+
apollo_platform::migrations::MigrateToV1<crate::Runtime>,
34+
);
3235

3336
#[cfg(feature = "wip")]
3437
pub type WipMigrations =

0 commit comments

Comments
 (0)
Please sign in to comment.