Skip to content

Commit

Permalink
simplify amm support dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Nov 11, 2024
1 parent 9e33836 commit 8dc92ed
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 32 deletions.
3 changes: 1 addition & 2 deletions pallets/dca/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ impl pallet_route_executor::Config for Test {
type EdToRefundCalculator = MockedEdCalculator;
type OraclePriceProvider = PriceProviderMock;
type OraclePeriod = RouteValidationOraclePeriod;
type BatchIdProvider = AmmSupport;
type OperationIdProvider = AmmSupport;
type AmmUnifiedEventSupport = AmmSupport;
type WeightInfo = ();
}

Expand Down
11 changes: 0 additions & 11 deletions pallets/omnipool/proptest-regressions/tests/invariants.txt

This file was deleted.

3 changes: 1 addition & 2 deletions pallets/otc-settlements/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ impl pallet_route_executor::Config for Test {
type OraclePeriod = RouteValidationOraclePeriod;
type DefaultRoutePoolType = DefaultRoutePoolType;
type TechnicalOrigin = EnsureRoot<Self::AccountId>;
type BatchIdProvider = AmmSupport;
type OperationIdProvider = AmmSupport;
type AmmUnifiedEventSupport = AmmSupport;
type WeightInfo = ();
}

Expand Down
19 changes: 8 additions & 11 deletions pallets/route-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,8 @@ pub mod pallet {
/// Origin able to set route without validation
type TechnicalOrigin: EnsureOrigin<Self::RuntimeOrigin>;

/// Event id provider for unified events
type BatchIdProvider: IncrementalIdProvider<IncrementalId>;

/// Operation id provider for unified events
type OperationIdProvider: ExecutionTypeStack<IncrementalIdType>;
/// AMM Unified event support
type AmmUnifiedEventSupport: IncrementalIdProvider<IncrementalId> + ExecutionTypeStack<IncrementalIdType>;

/// Weight information for the extrinsics.
type WeightInfo: AmmTradeWeights<Trade<Self::AssetId>>;
Expand Down Expand Up @@ -266,8 +263,8 @@ pub mod pallet {

let route_length = route.len();

let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?;
T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?;
let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?;
T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?;

for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() {
Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade);
Expand Down Expand Up @@ -311,7 +308,7 @@ pub mod pallet {
event_id: next_event_id,
});

let _ = T::OperationIdProvider::pop()?;
let _ = T::AmmUnifiedEventSupport::pop()?;

Ok(())
}
Expand Down Expand Up @@ -504,8 +501,8 @@ impl<T: Config> Pallet<T> {

let route_length = route.len();

let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?;
T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?;
let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?;
T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?;

for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() {
Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade);
Expand Down Expand Up @@ -550,7 +547,7 @@ impl<T: Config> Pallet<T> {
event_id: next_event_id,
});

let _ = T::OperationIdProvider::pop()?;
let _ = T::AmmUnifiedEventSupport::pop()?;

Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions pallets/route-executor/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ impl Config for Test {
type OraclePeriod = RouteValidationOraclePeriod;
type DefaultRoutePoolType = DefaultRoutePoolType;
type TechnicalOrigin = EnsureRoot<Self::AccountId>;
type BatchIdProvider = AmmSupport;
type OperationIdProvider = AmmSupport;
type AmmUnifiedEventSupport = AmmSupport;
type WeightInfo = ();
}

Expand Down
3 changes: 1 addition & 2 deletions runtime/adapters/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,8 @@ impl pallet_route_executor::Config for Test {
type DefaultRoutePoolType = DefaultRoutePoolType;
type TechnicalOrigin = EnsureRoot<Self::AccountId>;
type OraclePeriod = RouteValidationOraclePeriod;
type BatchIdProvider = AmmSupport;
type AmmUnifiedEventSupport = AmmSupport;
type WeightInfo = ();
type OperationIdProvider = AmmSupport;
}

pub struct MockedEdCalculator;
Expand Down
3 changes: 1 addition & 2 deletions runtime/hydradx/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,8 @@ impl pallet_route_executor::Config for Runtime {
type TechnicalOrigin = SuperMajorityTechCommittee;
type EdToRefundCalculator = RefundAndLockedEdCalculator;
type OraclePriceProvider = hydradx_adapters::OraclePriceProvider<AssetId, EmaOracle, LRNA>;
type BatchIdProvider = AmmSupport;
type OraclePeriod = RouteValidationOraclePeriod;
type OperationIdProvider = AmmSupport;
type AmmUnifiedEventSupport = AmmSupport;
}

parameter_types! {
Expand Down

0 comments on commit 8dc92ed

Please sign in to comment.