Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ozankaymak committed Sep 9, 2024
1 parent 9ae025f commit fdda0de
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,13 @@ where
Ok(())
}

async fn is_profitable(&self, withdrawal_amount: u64) -> Result<bool, BridgeError> {
async fn is_profitable(
&self,
input_amount: u64,
withdrawal_amount: u64,
) -> Result<bool, BridgeError> {
// Check if the withdrawal amount is within the acceptable range
if withdrawal_amount > self.config.bridge_amount_sats {
if (withdrawal_amount - input_amount) > self.config.bridge_amount_sats {
Ok(false)
} else {
// Calculate net profit after the withdrawal
Expand All @@ -333,7 +337,10 @@ where
) -> Result<Option<Txid>, BridgeError> {
// TODO: check that withdrawal_idx has the input_utxo.outpoint

if !self.is_profitable(output_txout.value.to_sat()).await? {
if !self
.is_profitable(input_utxo.txout.value.to_sat(), output_txout.value.to_sat())
.await?
{
return Ok(None);
}
let tx_ins = TransactionBuilder::create_tx_ins(vec![input_utxo.outpoint]);
Expand Down

0 comments on commit fdda0de

Please sign in to comment.