mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Fix bug in the scanner regarding forwarded output amounts
We'd report the amount originally received, minus 2x the cost to aggregate, regardless the amount successfully forwarded. We should've reduced to the amount successfully forwarded, if it was smaller, in case the cost to forward exceeded the aggregation cost.
This commit is contained in:
parent
f11a6b4ff1
commit
3c787e005f
1 changed files with 9 additions and 1 deletions
|
@ -361,7 +361,7 @@ impl<D: Db, S: ScannerFeed, Sch: Scheduler<S>> ContinuallyRan for EventualityTas
|
|||
continue;
|
||||
};
|
||||
|
||||
let Some((return_address, in_instruction)) =
|
||||
let Some((return_address, mut in_instruction)) =
|
||||
ScannerGlobalDb::<S>::return_address_and_in_instruction_for_forwarded_output(
|
||||
&txn, &forwarded,
|
||||
)
|
||||
|
@ -370,6 +370,14 @@ impl<D: Db, S: ScannerFeed, Sch: Scheduler<S>> ContinuallyRan for EventualityTas
|
|||
// forwarding an output
|
||||
continue;
|
||||
};
|
||||
|
||||
// We use the original amount, minus twice the cost to aggregate
|
||||
// If the fees we paid to forward this now (less than the cost to aggregate now, yet not
|
||||
// necessarily the cost to aggregate historically) caused this amount to be less, reduce
|
||||
// it accordingly
|
||||
in_instruction.balance.amount.0 =
|
||||
in_instruction.balance.amount.0.min(output.balance().amount.0);
|
||||
|
||||
queue_output_until_block::<S>(
|
||||
&mut txn,
|
||||
b + S::WINDOW_LENGTH,
|
||||
|
|
Loading…
Reference in a new issue