Skip to content

Commit

Permalink
wip: sanity checks fn
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Sep 22, 2023
1 parent 39b4041 commit 766bef3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libs/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ where
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct TrancheCurrency {
pub(crate) pool_id: PoolId,
pub(crate) tranche_id: TrancheId,
pub pool_id: PoolId,
pub tranche_id: TrancheId,
}

impl From<TrancheCurrency> for CurrencyId {
Expand Down
18 changes: 15 additions & 3 deletions runtime/centrifuge/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
// GNU General Public License for more details.
use codec::{Decode, Encode};

Check warning on line 12 in runtime/centrifuge/src/migrations.rs

View workflow job for this annotation

GitHub Actions / docs

unused imports: `Decode`, `Encode`

use crate::{PoolSystem, Runtime, Weight};
use crate::{Investments, PoolSystem, Runtime, Weight};

Check warning on line 14 in runtime/centrifuge/src/migrations.rs

View workflow job for this annotation

GitHub Actions / docs

unused import: `PoolSystem`

pub type UpgradeCentrifuge1021 = anemoy_pool::Migration;

/// Migrate the Anemoy Pool's currency from LpEthUSC to Circle's USDC,
/// native on Polkadot's AssetHub.
mod anemoy_pool {

use cfg_primitives::PoolId;
use cfg_types::tokens::CurrencyId;
use cfg_primitives::{PoolId, TrancheId};
use cfg_types::tokens::{CurrencyId, TrancheCurrency};
use frame_support::traits::OnRuntimeUpgrade;
use pallet_pool_system::PoolDetailsOf;

Check warning on line 25 in runtime/centrifuge/src/migrations.rs

View workflow job for this annotation

GitHub Actions / docs

unused import: `pallet_pool_system::PoolDetailsOf`
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;
#[cfg(feature = "try-runtime")]
use frame_support::ensure;
use cfg_types::orders::TotalOrder;

use super::*;

Expand Down Expand Up @@ -85,4 +86,15 @@ mod anemoy_pool {
Ok(())
}
}

// todo(nuno): also check that pool value is 0 and check also that Investments::InvestOrders and
// Investments::RedeemOrder have no entries from Anemoy; the latter ones seem tricky at first
// sight since they are double maps first keyed by an AccountId, meaning we need to transverse
// that first which is more costly.
fn sanity_checks(tranche_id: TrancheId) -> bool {

Check warning on line 94 in runtime/centrifuge/src/migrations.rs

View workflow job for this annotation

GitHub Actions / docs

function `sanity_checks` is never used
let tc = TrancheCurrency { pool_id: ANEMOY_POOL_ID, tranche_id};

Investments::acc_active_invest_order(tc) == TotalOrder::default()
&& Investments::acc_active_redeem_order(tc) == TotalOrder::default()
}
}

0 comments on commit 766bef3

Please sign in to comment.