Skip to content

Commit

Permalink
feat: optimal swap calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ts0yu authored Aug 21, 2024
1 parent 5f30573 commit 297a17a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/engine/arbitrageur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ impl Arbitrageur for DefaultArbitrageur {
end.to_i32_saturating().unwrap(),
)
.await;

let k = a.clone() * b.clone();

// closed form optimal swap solution, ref: https://arxiv.org/pdf/1911.03380
let optimal_swap =
Float::with_val(53, 0).max(&(a.clone() - (k / (signal.pool.fee * (a / b)))));
}
}

Expand Down

0 comments on commit 297a17a

Please sign in to comment.