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

Method simulate

crates/shared/src/order_creation_simulation.rs:80–103  ·  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
91 // simulation. To avoid unnecessary overhead in the happy path
92 // we assume orders are well behaved and do a regular simulation
93 // by default. Except when it's an EIP 1271 order in which case
94 // we always have to run the more complex code to figure out how
95 // much gas the signature check needs.
96 if !matches!(order.signature, Signature::Eip1271(_)) && inputs.simulate().await.is_ok() {
97 return Ok(SimulationSuccess {
98 eip1271_signature_verification_gas: 0,
99 });
100 }
101
102 analyze_simulation(order, inputs).await
103 }
104}
105
106impl OrderCreationSimulator {

Callers 1

simulate_with_timeoutMethod · 0.45

Calls 2

analyze_simulationFunction · 0.85
prepare_simulationMethod · 0.80

Tested by

no test coverage detected