Skip to content

Commit

Permalink
chore: removed cf_pool_simulate_swap_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Janislav authored and dandanlen committed Dec 17, 2024
1 parent e149a50 commit e1d7fa5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
35 changes: 11 additions & 24 deletions state-chain/custom-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use sc_rpc_spec_v2::chain_head::{
api::ChainHeadApiServer, ChainHead, ChainHeadConfig, FollowEvent,
};
use serde::{Deserialize, Serialize};
use sp_api::{ApiError, ApiExt, CallApiAt};
use sp_api::{ApiError, CallApiAt};
use sp_core::U256;
use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT, UniqueSaturatedInto},
Expand All @@ -67,7 +67,7 @@ use state_chain_runtime::{
SimulatedSwapInformation, TransactionScreeningEvents, ValidatorInfo, VaultSwapDetails,
},
safe_mode::RuntimeSafeMode,
Block, Hash, NetworkFee, SolanaInstance,
Hash, NetworkFee, SolanaInstance,
};
use std::{
collections::{BTreeMap, HashMap},
Expand Down Expand Up @@ -1514,33 +1514,20 @@ where
.collect()
});
self.with_runtime_api(at, |api, hash| {
if api.api_version::<dyn CustomRuntimeApi<Block>>(hash).unwrap().unwrap() < 2 {
let old_result = api.cf_pool_simulate_swap_before_version_2(
Ok::<_, CfApiError>(
api.cf_pool_simulate_swap(
hash,
from_asset,
to_asset,
amount,
broker_commission,
dca_parameters,
additional_orders,
)?;
Ok(old_result.map(|old_version| {
into_rpc_swap_output(old_version.into(), from_asset, to_asset)
})?)
} else {
Ok::<_, CfApiError>(
api.cf_pool_simulate_swap(
hash,
from_asset,
to_asset,
amount,
broker_commission,
dca_parameters,
additional_orders,
)?
.map(|simulated_swap_info_v2| {
into_rpc_swap_output(simulated_swap_info_v2, from_asset, to_asset)
})?,
)
}
)?
.map(|simulated_swap_info_v2| {
into_rpc_swap_output(simulated_swap_info_v2, from_asset, to_asset)
})?,
)
})
}

Expand Down
7 changes: 0 additions & 7 deletions state-chain/runtime/src/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,6 @@ decl_runtime_apis!(
base_asset: Asset,
quote_asset: Asset,
) -> Result<PoolPriceV2, DispatchErrorWithMessage>;
#[changed_in(2)]
fn cf_pool_simulate_swap(
from: Asset,
to: Asset,
amount: AssetAmount,
additional_limit_orders: Option<Vec<SimulateSwapAdditionalOrder>>,
) -> Result<SimulatedSwapInformation!["1.0.0"], DispatchErrorWithMessage>;
fn cf_pool_simulate_swap(
from: Asset,
to: Asset,
Expand Down

0 comments on commit e1d7fa5

Please sign in to comment.