Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions harnesses/bridge-monitor/cmd/monitor/squid_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,24 @@ func (s *SquidBridge) TestRoute(route TestRoute, amount, amountUsd float64, rawU
gasUsd += v
}

costUsd := inUsd - outUsd + gasUsd
// Prefer fromAmountUSD - toAmountUSD as the all-in cost (captures spread + fees + gas
// as netted by the router). Fall back to explicit fee+gas sum when the USD amounts
// are identical (e.g. stable→stable where spot prices cancel out).
diffUsd := inUsd - outUsd
var costUsd float64
if diffUsd > 0.001 {
costUsd = diffUsd
} else {
costUsd = bridgeFeeUsd + gasUsd
}
if costUsd < 0 {
costUsd = 0
}
costPct := 0.0
if amountUsd > 0 {
costPct = (costUsd / amountUsd) * 100
}
slippage := costUsd - bridgeFeeUsd - gasUsd
slippage := diffUsd - bridgeFeeUsd - gasUsd
if slippage < 0 {
slippage = 0
}
Expand Down
Loading