Skip to content

Commit

Permalink
remove some unused code investment-related (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm authored Jul 9, 2024
1 parent e784233 commit 2710a5f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 111 deletions.
20 changes: 0 additions & 20 deletions libs/mocks/src/investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ pub mod pallet {
) {
register_call!(move |(a, b)| f(a, b));
}

pub fn mock_investment_requires_collect(
f: impl Fn(&T::AccountId, T::InvestmentId) -> bool + 'static,
) {
register_call!(move |(a, b)| f(a, b));
}

pub fn mock_redemption_requires_collect(
f: impl Fn(&T::AccountId, T::InvestmentId) -> bool + 'static,
) {
register_call!(move |(a, b)| f(a, b));
}
}

impl<T: Config> Investment<T::AccountId> for Pallet<T> {
Expand Down Expand Up @@ -105,14 +93,6 @@ pub mod pallet {
) -> Result<Self::TrancheAmount, Self::Error> {
execute_call!((a, b))
}

fn investment_requires_collect(a: &T::AccountId, b: T::InvestmentId) -> bool {
execute_call!((a, b))
}

fn redemption_requires_collect(a: &T::AccountId, b: T::InvestmentId) -> bool {
execute_call!((a, b))
}
}

impl<T: Config> InvestmentCollector<T::AccountId> for Pallet<T> {
Expand Down
14 changes: 0 additions & 14 deletions libs/traits/src/investments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ pub trait Investment<AccountId> {
who: &AccountId,
investment_id: Self::InvestmentId,
) -> Result<Self::TrancheAmount, Self::Error>;

/// Checks whether an investment requires to be collected before it can be
/// updated.
///
/// NOTE: Defaults to false if the investment does not exist.
fn investment_requires_collect(investor: &AccountId, investment_id: Self::InvestmentId)
-> bool;

/// Checks whether a redemption requires to be collected before it can be
/// further updated.
///
/// NOTE: Defaults to false if the redemption does not exist.
fn redemption_requires_collect(investor: &AccountId, investment_id: Self::InvestmentId)
-> bool;
}

/// A trait which allows to collect existing investments and redemptions.
Expand Down
24 changes: 0 additions & 24 deletions pallets/investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,30 +1123,6 @@ impl<T: Config> Investment<T::AccountId> for Pallet<T> {
Ok(RedeemOrders::<T>::get(who, investment_id)
.map_or_else(Zero::zero, |order| order.amount()))
}

fn investment_requires_collect(
investor: &T::AccountId,
investment_id: Self::InvestmentId,
) -> bool {
InvestOrders::<T>::get(investor, investment_id)
.map(|order| {
let cur_order_id = InvestOrderId::<T>::get(investment_id);
order.submitted_at() != cur_order_id
})
.unwrap_or(false)
}

fn redemption_requires_collect(
investor: &T::AccountId,
investment_id: Self::InvestmentId,
) -> bool {
RedeemOrders::<T>::get(investor, investment_id)
.map(|order| {
let cur_order_id = RedeemOrderId::<T>::get(investment_id);
order.submitted_at() != cur_order_id
})
.unwrap_or(false)
}
}

impl<T: Config> OrderManager for Pallet<T> {
Expand Down
53 changes: 0 additions & 53 deletions runtime/integration-tests/src/cases/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1906,13 +1906,6 @@ mod foreign_investments {
enable_liquidity_pool_transferability::<T>(currency_id);
let investment_currency_id: CurrencyId = default_investment_id::<T>().into();

assert!(
!pallet_investments::Pallet::<T>::investment_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Process 50% of investment at 25% rate, i.e. 1 pool currency = 4 tranche
// tokens
assert_ok!(pallet_investments::Pallet::<T>::process_invest_orders(
Expand All @@ -1926,27 +1919,13 @@ mod foreign_investments {
}
));

// Pre collect assertions
assert!(
pallet_investments::Pallet::<T>::investment_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Collecting through Investments should denote amounts and transition
// state
assert_ok!(pallet_investments::Pallet::<T>::collect_investments_for(
RawOrigin::Signed(Keyring::Alice.into()).into(),
investor.clone(),
default_investment_id::<T>()
));
assert!(
!pallet_investments::Pallet::<T>::investment_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Tranche Tokens should still be transferred to collected to
// domain locator account already
Expand Down Expand Up @@ -2026,12 +2005,6 @@ mod foreign_investments {
investor.clone(),
default_investment_id::<T>()
));
assert!(
!pallet_investments::Pallet::<T>::investment_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Tranche Tokens should be transferred to collected to
// domain locator account already
Expand Down Expand Up @@ -2565,12 +2538,6 @@ mod foreign_investments {
&pool_account,
redeem_amount
));
assert!(
!pallet_investments::Pallet::<T>::redemption_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Process 50% of redemption at 25% rate, i.e. 1 pool currency = 4 tranche
// tokens
Expand All @@ -2585,14 +2552,6 @@ mod foreign_investments {
}
));

// Pre collect assertions
assert!(
pallet_investments::Pallet::<T>::redemption_requires_collect(
&investor,
default_investment_id::<T>()
)
);

// Collecting through investments should denote amounts and transition
// state
assert_ok!(pallet_investments::Pallet::<T>::collect_redemptions_for(
Expand Down Expand Up @@ -2634,12 +2593,6 @@ mod foreign_investments {
}
.into()
}));
assert!(
!pallet_investments::Pallet::<T>::redemption_requires_collect(
&investor,
default_investment_id::<T>()
)
);
// Since foreign currency is pool currency, the swap is immediately fulfilled
// and ExecutedCollectRedeem dispatched
assert!(frame_system::Pallet::<T>::events().iter().any(|e| e.event
Expand Down Expand Up @@ -2676,12 +2629,6 @@ mod foreign_investments {
investor.clone(),
default_investment_id::<T>()
));
assert!(
!pallet_investments::Pallet::<T>::redemption_requires_collect(
&investor,
default_investment_id::<T>()
)
);
assert!(!frame_system::Pallet::<T>::events().iter().any(|e| {
e.event
== pallet_investments::Event::<T>::RedeemCollectedForNonClearedOrderId {
Expand Down

0 comments on commit 2710a5f

Please sign in to comment.