Skip to content

Commit 9f3f13a

Browse files
feat: allow partiall auction filling (#113)
1 parent acfb723 commit 9f3f13a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

programs/folio/src/instructions/auction/bid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub fn handler(
234234

235235
let folio_bump: u8;
236236

237-
let (raw_sell_amount, raw_bought_amount, _price, scaled_folio_token_total_supply) = {
237+
let (_, raw_bought_amount, _price, scaled_folio_token_total_supply) = {
238238
let folio = &mut ctx.accounts.folio.load_mut()?;
239239
// checks auction is ongoing
240240
ctx.accounts

programs/folio/src/utils/accounts/auction.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl Auction {
345345
}
346346
}
347347

348-
/// return (sell_amount, bid_amount, price D18{buyTok/sellTok}, scaled_folio_token_total_supply)
348+
/// return (max_sell_amount, bid_amount, price D18{buyTok/sellTok}, scaled_folio_token_total_supply)
349349
pub fn get_bid(
350350
&self,
351351
folio: &Folio,
@@ -389,18 +389,18 @@ impl Auction {
389389
.to_token_amount(Rounding::Floor)?
390390
.0;
391391
let sell_amount_available = sell_amount_available_from_buy.min(raw_sell_available);
392+
check_condition!(
393+
sell_amount_available >= raw_sell_amount,
394+
InsufficientBalance
395+
);
392396

393397
// bidAmount
394-
let bid_amount = Decimal::from_token_amount(sell_amount_available)?
398+
let bid_amount = Decimal::from_token_amount(raw_sell_amount)?
395399
.mul(&scaled_price)?
396400
.div(&Decimal::ONE_E18)?
397401
.to_token_amount(Rounding::Floor)?
398402
.0;
399403

400-
check_condition!(
401-
sell_amount_available >= raw_sell_amount,
402-
InsufficientBalance
403-
);
404404
check_condition!(
405405
bid_amount != 0 && bid_amount <= raw_max_buy_amount,
406406
SlippageExceeded

0 commit comments

Comments
 (0)