Skip to content

Commit

Permalink
add deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Jan 8, 2025
1 parent 5b18982 commit 1ce1cf3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions contracts/svm/programs/express_relay/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod clock;
pub mod error;
pub mod sdk;
pub mod state;
Expand All @@ -7,6 +8,7 @@ pub mod utils;

use {
crate::{
clock::check_deadline,
error::ErrorCode,
state::*,
swap::PostFeeSwapArgs,
Expand Down Expand Up @@ -92,9 +94,7 @@ pub mod express_relay {

/// Submits a bid for a particular (permission, router) pair and distributes bids according to splits.
pub fn submit_bid(ctx: Context<SubmitBid>, data: SubmitBidArgs) -> Result<()> {
if data.deadline < Clock::get()?.unix_timestamp {
return err!(ErrorCode::DeadlinePassed);
}
check_deadline(data.deadline)?;

// check that not cpi.
if get_stack_height() > TRANSACTION_LEVEL_STACK_HEIGHT {
Expand Down Expand Up @@ -158,6 +158,8 @@ pub mod express_relay {
}

pub fn swap(ctx: Context<Swap>, data: SwapArgs) -> Result<()> {
check_deadline(data.deadline)?;

let PostFeeSwapArgs {
input_after_fees,
output_after_fees,
Expand Down Expand Up @@ -360,6 +362,7 @@ pub enum FeeToken {
/// This choice is made to minimize confusion for the searchers, who are more likely to parse the program
#[derive(AnchorSerialize, AnchorDeserialize, Eq, PartialEq, Clone, Copy, Debug)]
pub struct SwapArgs {
pub deadline: i64,
pub amount_input: u64,
pub amount_output: u64,
// The referral fee is specified in basis points
Expand Down

0 comments on commit 1ce1cf3

Please sign in to comment.