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

Function executed_amount

crates/simulator/src/encoding.rs:544–573  ·  view source on GitHub ↗

Computes the exact amount the order should be filled with based on the configured [`ExecutionAmount`]. If `Remaining` is configured we look up how much the order was already filled in the settlement contract and deduct that from the full amount.

(
    builder: &SimulationBuilder,
    order: &Order,
    block: u64,
)

Source from the content-addressed store, hash-verified

542/// was already filled in the settlement contract and deduct
543/// that from the full amount.
544async fn executed_amount(
545 builder: &SimulationBuilder,
546 order: &Order,
547 block: u64,
548) -> Result<U256, BuildError> {
549 let full = match order.data.kind {
550 OrderKind::Sell => order.data.sell_amount,
551 OrderKind::Buy => order.data.buy_amount,
552 };
553
554 Ok(match order.executed_amount {
555 ExecutionAmount::Full => full,
556 ExecutionAmount::Explicit(amount) => amount,
557 ExecutionAmount::Remaining => {
558 let uid = order
559 .data
560 .uid(&builder.simulator.0.domain_separator, order.owner);
561 let filled_amount = builder
562 .simulator
563 .0
564 .settlement
565 .filledAmount(Bytes::from(uid.0))
566 .block(block.into())
567 .call()
568 .await
569 .map_err(|err| BuildError::FilledAmountQuery(err.into()))?;
570 full.saturating_sub(filled_amount)
571 }
572 })
573}
574
575/// Resolves all [`AccountOverrideRequest`]s concurrently on a best-effort
576/// basis. Returns the fully resolved state overrides and

Callers 1

Calls 6

filledAmountMethod · 0.80
uidMethod · 0.45
callMethod · 0.45
blockMethod · 0.45
intoMethod · 0.45
saturating_subMethod · 0.45

Tested by

no test coverage detected