Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/bin/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ async fn process_jup_swap<T: Signers>(
ui_amount: Option<f64>,
slippage_bps: u64,
lot_selection_method: LotSelectionMethod,
lot_numbers: Option<HashSet<usize>>,
signers: T,
existing_signature: Option<Signature>,
if_from_balance_exceeds: Option<u64>,
Expand Down Expand Up @@ -1051,6 +1052,7 @@ async fn process_jup_swap<T: Signers>(
to_token,
to_token_price,
lot_selection_method,
lot_numbers,
)?;
} else {
let amount = match ui_amount {
Expand Down Expand Up @@ -1228,6 +1230,7 @@ async fn process_jup_swap<T: Signers>(
to_token,
to_token_price,
lot_selection_method,
lot_numbers,
)?;

if !send_transaction_until_expired(rpc_clients, &transaction, last_valid_block_height)
Expand Down Expand Up @@ -5287,6 +5290,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
price exceeds this percentage"),
)
.arg(lot_selection_arg())
.arg(lot_numbers_arg())
.arg(
Arg::with_name("transaction")
.long("transaction")
Expand Down Expand Up @@ -6471,6 +6475,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let address = address.expect("address");
let lot_selection_method =
value_t_or_exit!(arg_matches, "lot_selection", LotSelectionMethod);
let lot_numbers = lot_numbers_of(arg_matches, "lot_numbers");
let signature = value_t!(arg_matches, "transaction", Signature).ok();
let if_from_balance_exceeds = value_t!(arg_matches, "if_from_balance_exceeds", f64)
.ok()
Expand All @@ -6488,6 +6493,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
ui_amount,
slippage_bps,
lot_selection_method,
lot_numbers,
vec![signer],
signature,
if_from_balance_exceeds,
Expand Down
7 changes: 6 additions & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub struct PendingSwap {
pub to_token_price: Decimal,

pub lot_selection_method: LotSelectionMethod,
pub lot_numbers: Option<HashSet<usize>>,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -909,6 +910,7 @@ impl Db {
to_token: MaybeToken,
to_token_price: Decimal,
lot_selection_method: LotSelectionMethod,
lot_numbers: Option<HashSet<usize>>,
) -> DbResult<()> {
let _ = self
.get_account(address, from_token)
Expand All @@ -923,6 +925,7 @@ impl Db {
to_token,
to_token_price,
lot_selection_method,
lot_numbers,
});
self.save()
}
Expand All @@ -940,6 +943,7 @@ impl Db {
to_token,
to_token_price,
lot_selection_method,
lot_numbers,
..
} = self
.data
Expand All @@ -962,7 +966,8 @@ impl Db {

self.auto_save(false)?;
if let Some((when, from_amount, to_amount)) = success {
let lots = from_account.extract_lots(self, from_amount, lot_selection_method, None)?;
let lots =
from_account.extract_lots(self, from_amount, lot_selection_method, lot_numbers)?;

let to_amount_over_from_amount = to_amount as f64 / from_amount as f64;
for lot in lots {
Expand Down
1 change: 1 addition & 0 deletions src/vendor/kamino/fraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl TryFrom<U256> for U128 {
}
}

#[allow(dead_code)]
pub struct FractionDisplay<'a>(&'a Fraction);

impl Display for FractionDisplay<'_> {
Expand Down
Loading