Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support zero fee limit orders #16

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::{bail, Context, Result};
use ethers::prelude::*;
use hex::ToHex;
use std::{collections::HashMap, time::Duration};
use tokio::time::sleep;
Expand Down Expand Up @@ -173,7 +174,7 @@ async fn handle_swap(
}
};

let sell_amount_after_fees = requested_swap.amount_in - quote.fee_amount;
let sell_amount_after_fees = requested_swap.amount_in;
let buy_amount_after_fees_and_slippage =
quote.buy_amount_after_fee * (10000 - config.slippage_tolerance_bps) / 10000;

Expand All @@ -184,7 +185,7 @@ async fn handle_swap(
sell_amount_after_fees,
buy_amount_after_fees_and_slippage,
valid_to: quote.valid_to,
fee_amount: quote.fee_amount,
fee_amount: U256::zero(),
order_creator: requested_swap.order_creator,
price_checker: requested_swap.price_checker,
price_checker_data: &requested_swap.price_checker_data,
Expand All @@ -199,7 +200,7 @@ async fn handle_swap(
sell_amount: sell_amount_after_fees,
buy_amount: buy_amount_after_fees_and_slippage,
valid_to: quote.valid_to,
fee_amount: quote.fee_amount,
fee_amount: U256::zero(),
receiver: requested_swap.receiver,
eip_1271_signature: &eip_1271_signature,
quote_id: quote.id,
Expand Down