Skip to content

Commit e1dc1b0

Browse files
committed
program: builder codes dont throw tx on missing acc
1 parent 61f8f4f commit e1dc1b0

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

programs/drift/src/controller/orders.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,9 +2329,13 @@ pub fn fulfill_perp_order_with_amm(
23292329

23302330
let builder_fee = builder_fee_option.unwrap_or(0);
23312331

2332-
if let (Some(idx), Some(escrow)) = (builder_order_idx, rev_share_escrow.as_mut()) {
2333-
let mut order = escrow.get_order_mut(idx)?;
2334-
order.fees_accrued = order.fees_accrued.safe_add(builder_fee)?;
2332+
if builder_fee != 0 {
2333+
if let (Some(idx), Some(escrow)) = (builder_order_idx, rev_share_escrow.as_mut()) {
2334+
let mut order = escrow.get_order_mut(idx)?;
2335+
order.fees_accrued = order.fees_accrued.safe_add(builder_fee)?;
2336+
} else {
2337+
msg!("Order has builder fee but no escrow account found, in the future this tx will fail.");
2338+
}
23352339
}
23362340

23372341
// Increment the protocol's total fee variables
@@ -2834,9 +2838,13 @@ pub fn fulfill_perp_order_with_match(
28342838
)?;
28352839
let builder_fee = builder_fee_option.unwrap_or(0);
28362840

2837-
if let (Some(idx), Some(escrow)) = (builder_order_idx, rev_share_escrow.as_deref_mut()) {
2838-
let mut order = escrow.get_order_mut(idx)?;
2839-
order.fees_accrued = order.fees_accrued.safe_add(builder_fee)?;
2841+
if builder_fee != 0 {
2842+
if let (Some(idx), Some(escrow)) = (builder_order_idx, rev_share_escrow.as_deref_mut()) {
2843+
let mut order = escrow.get_order_mut(idx)?;
2844+
order.fees_accrued = order.fees_accrued.safe_add(builder_fee)?;
2845+
} else {
2846+
msg!("Order has builder fee but no escrow account found, in the future this tx will fail.");
2847+
}
28402848
}
28412849

28422850
// Increment the markets house's total fee variables

programs/drift/src/instructions/keeper.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,7 @@ pub fn place_signed_msg_taker_order<'c: 'info, 'info>(
745745
builder_fee_bps = Some(builder_fee);
746746
escrow_zc = Some(escrow);
747747
} else {
748-
msg!("RevenueEscrow account must be provided if builder fields are present in OrderParams");
749-
return Err(ErrorCode::InvalidSignedMsgOrderParam.into());
748+
msg!("Order has builder fee but no escrow account found, in the future this tx will fail.");
750749
}
751750
}
752751

0 commit comments

Comments
 (0)