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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auction-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auction-server"
version = "0.32.2"
version = "0.33.0"
edition = "2021"
license-file = "license.txt"

Expand Down
9 changes: 9 additions & 0 deletions auction-server/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ chains:
- Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
- So11111111111111111111111111111111111111112
- EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
allow_permissionless_quote_requests: true
minimum_fee_list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this schema has some ambiguities:

  • Having an enabled flag seems unusual. We can just comment the whole section to disable it. By default, when I look at some config file and see a section exists, I assume that it's configured properly and I don't look for a enable/disable flag.
  • This config allows multiple profiles without profile_id which is not well-defined, maybe we can have a default_profile next to profiles section and enforce profile_id in the profiles section.
  • If the name field is only for readability reasons, we can use comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the enabled flag is just out of consistency with the way we have set up token whitelist. but agreed, we don't need this.

agreed with removing the name field from the config.

for the default profile, we could do that, but i have a preference for keeping the config less verbose. also, this is only relevant if allow_permissionless_quote_requests is set to true

profiles:
- profile_id: 0b059fa2-189f-4498-a646-e7ee1ed79c3c
minimum_fees:
- mint: Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
fee_ppm: 100
- mint: So11111111111111111111111111111111111111112
fee_ppm: 200

lazer:
price_feeds:
Expand Down
49 changes: 39 additions & 10 deletions auction-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use {
fs,
time::Duration,
},
uuid::Uuid,
};

pub mod server;
Expand Down Expand Up @@ -150,33 +151,39 @@ pub enum Config {
pub struct ConfigSvm {
/// Id of the express relay program.
#[serde_as(as = "DisplayFromStr")]
pub express_relay_program_id: Pubkey,
pub express_relay_program_id: Pubkey,
/// RPC endpoint to use for reading from the blockchain.
pub rpc_read_url: String,
pub rpc_read_url: String,
/// RPC endpoint to use for broadcasting transactions
pub rpc_tx_submission_urls: Vec<String>,
pub rpc_tx_submission_urls: Vec<String>,
/// WS endpoint to use for interacting with the blockchain.
pub ws_addr: String,
pub ws_addr: String,
/// Timeout for RPC requests in seconds.
#[serde(default = "ConfigSvm::default_rpc_timeout_svm")]
pub rpc_timeout: u64,
pub rpc_timeout: u64,
#[serde(default)]
/// Percentile of prioritization fees to query from the `rpc_read_url`.
/// This should be None unless the RPC `getRecentPrioritizationFees`'s supports the percentile parameter, for example Triton RPC.
/// It is an integer between 0 and 10000 with 10000 representing 100%.
pub prioritization_fee_percentile: Option<u64>,
pub prioritization_fee_percentile: Option<u64>,
/// List of accepted token programs for the swap instruction.
#[serde_as(as = "Vec<DisplayFromStr>")]
pub accepted_token_programs: Vec<Pubkey>,
pub accepted_token_programs: Vec<Pubkey>,
/// Ordered list of fee tokens, with first being the most preferred.
#[serde_as(as = "Vec<DisplayFromStr>")]
pub ordered_fee_tokens: Vec<Pubkey>,
pub ordered_fee_tokens: Vec<Pubkey>,
/// Whitelisted token mints
#[serde(default)]
pub token_whitelist: TokenWhitelistConfig,
pub token_whitelist: TokenWhitelistConfig,
/// Minimum fee list
#[serde(default)]
pub minimum_fee_list: MinimumFeeListConfig,
/// Whether to allow permissionless quote requests.
#[serde(default)]
pub allow_permissionless_quote_requests: bool,
/// Auction time for the chain (how long to wait before choosing winning bids)
#[serde(default = "ConfigSvm::default_auction_time", with = "humantime_serde")]
pub auction_time: Duration,
pub auction_time: Duration,
}

impl ConfigSvm {
Expand All @@ -199,3 +206,25 @@ pub struct TokenWhitelistConfig {
#[serde_as(as = "Vec<DisplayFromStr>")]
pub whitelist_mints: Vec<Pubkey>,
}

/// Optional minimum fee list to determine validity of quote request
#[serde_as]
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct MinimumFeeListConfig {
#[serde(default)]
pub profiles: Vec<MinimumFeeProfile>,
}

#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct MinimumFeeProfile {
pub profile_id: Option<Uuid>,
pub minimum_fees: Vec<MinimumFee>,
}

#[serde_as]
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct MinimumFee {
#[serde_as(as = "DisplayFromStr")]
pub mint: Pubkey,
pub fee_ppm: u64,
}
22 changes: 8 additions & 14 deletions auction-server/src/opportunity/service/get_quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,17 @@ impl Service {
};
let config = self.get_config(&quote_create.chain_id)?;

// validate token mints being whitelisted at the earliest point to fail fast
if !config.token_whitelist.is_token_mint_allowed(&mint_user) {
return Err(RestError::TokenMintNotAllowed(
"Input".to_string(),
mint_user.to_string(),
));
}
if !config.token_whitelist.is_token_mint_allowed(&mint_searcher) {
return Err(RestError::TokenMintNotAllowed(
"Output".to_string(),
mint_searcher.to_string(),
));
}

let referral_fee_info =
self.unwrap_referral_fee_info(quote_create.referral_fee_info, &quote_create.chain_id)?;

config.validate_quote(
quote_create.chain_id.clone(),
mint_user,
mint_searcher,
quote_create.profile_id,
referral_fee_info.referral_fee_ppm,
)?;

// TODO*: we should fix the Opportunity struct (or create a new format) to more clearly distinguish Swap opps from traditional opps
// currently, we are using the same struct and just setting the unspecified token amount to 0
let metadata = self
Expand Down
Loading
Loading