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

Function cancel_order

crates/database/src/orders.rs:465–485  ·  view source on GitHub ↗
(
    ex: &mut PgConnection,
    order_uid: &OrderUid,
    timestamp: DateTime<Utc>,
)

Source from the content-addressed store, hash-verified

463
464#[instrument(skip_all)]
465pub async fn cancel_order(
466 ex: &mut PgConnection,
467 order_uid: &OrderUid,
468 timestamp: DateTime<Utc>,
469) -> Result<(), sqlx::Error> {
470 // We do not overwrite previously cancelled orders,
471 // but this query does allow the user to soft cancel
472 // an order that has already been invalidated on-chain.
473 const QUERY: &str = r#"
474UPDATE orders
475SET cancellation_timestamp = $1
476WHERE uid = $2
477AND cancellation_timestamp IS NULL
478 "#;
479 sqlx::query(QUERY)
480 .bind(timestamp)
481 .bind(order_uid.0.as_ref())
482 .execute(ex)
483 .await
484 .map(|_| ())
485}
486
487/// Interactions are read as arrays of their fields: target, value, data.
488/// This is done as sqlx does not support reading arrays of more complicated

Callers 2

postgres_cancel_orderFunction · 0.70
order_cancellationFunction · 0.50

Calls 2

queryFunction · 0.85
executeMethod · 0.45

Tested by 1

order_cancellationFunction · 0.40