MCPcopy Create free account
hub / github.com/cowprotocol/services / simulate

Method simulate

crates/shared/src/order_creation_simulation.rs:80–102  ·  view source on GitHub ↗
(
        &self,
        order: &Order,
        full_app_data: &str,
        full_balance_check: bool,
    )

Source from the content-addressed store, hash-verified

78impl OrderSimulating for OrderCreationSimulator {
79 #[tracing::instrument(skip_all, fields(order_uid = %order.metadata.uid))]
80 async fn simulate(
81 &self,
82 order: &Order,
83 full_app_data: &str,
84 full_balance_check: bool,
85 ) -> Result<SimulationSuccess, OrderSimulationError> {
86 let inputs = self
87 .prepare_simulation(order, full_app_data, full_balance_check)
88 .await?;
89
90 // Generating a failure report is more costly than a standard simulation.
91 // To avoid unnecessary overhead in the happy path we assume orders are
92 // well behaved and do a regular simulation by default. Except when it's
93 // an EIP 1271 order in which case we always have to run the more complex
94 // code to figure out how much gas the signature check needs.
95 if !matches!(order.signature, Signature::Eip1271(_)) && inputs.simulate().await.is_ok() {
96 return Ok(SimulationSuccess {
97 eip1271_signature_verification_gas: 0,
98 });
99 }
100
101 analyze_simulation(order, inputs).await
102 }
103}
104
105impl OrderCreationSimulator {

Callers 1

simulate_with_timeoutMethod · 0.45

Calls 2

analyze_simulationFunction · 0.85
prepare_simulationMethod · 0.80

Tested by

no test coverage detected