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

Function executed_amount

crates/simulator/src/encoding.rs:541–570  ·  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

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

Callers 1

Calls 6

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

Tested by

no test coverage detected