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

Function executed_amount

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

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