Skip to content

Commit d0a30ea

Browse files
authored
feat: minimum fee list (#570)
* add minimum fee config and validation * fix integration * bump version * change config * add metrics * fix labels * fix label 2
1 parent b6df18b commit d0a30ea

File tree

8 files changed

+276
-45
lines changed

8 files changed

+276
-45
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auction-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "auction-server"
3-
version = "0.32.2"
3+
version = "0.33.0"
44
edition = "2021"
55
license-file = "license.txt"
66

auction-server/config.sample.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ chains:
2929
- Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
3030
- So11111111111111111111111111111111111111112
3131
- EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
32+
allow_permissionless_quote_requests: true
33+
minimum_fee_list:
34+
profiles:
35+
- profile_id: 0b059fa2-189f-4498-a646-e7ee1ed79c3c
36+
minimum_fees:
37+
- mint: Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
38+
fee_ppm: 100
39+
- mint: So11111111111111111111111111111111111111112
40+
fee_ppm: 200
3241

3342
lazer:
3443
price_feeds:

auction-server/src/config.rs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use {
1919
fs,
2020
time::Duration,
2121
},
22+
uuid::Uuid,
2223
};
2324

2425
pub mod server;
@@ -150,33 +151,39 @@ pub enum Config {
150151
pub struct ConfigSvm {
151152
/// Id of the express relay program.
152153
#[serde_as(as = "DisplayFromStr")]
153-
pub express_relay_program_id: Pubkey,
154+
pub express_relay_program_id: Pubkey,
154155
/// RPC endpoint to use for reading from the blockchain.
155-
pub rpc_read_url: String,
156+
pub rpc_read_url: String,
156157
/// RPC endpoint to use for broadcasting transactions
157-
pub rpc_tx_submission_urls: Vec<String>,
158+
pub rpc_tx_submission_urls: Vec<String>,
158159
/// WS endpoint to use for interacting with the blockchain.
159-
pub ws_addr: String,
160+
pub ws_addr: String,
160161
/// Timeout for RPC requests in seconds.
161162
#[serde(default = "ConfigSvm::default_rpc_timeout_svm")]
162-
pub rpc_timeout: u64,
163+
pub rpc_timeout: u64,
163164
#[serde(default)]
164165
/// Percentile of prioritization fees to query from the `rpc_read_url`.
165166
/// This should be None unless the RPC `getRecentPrioritizationFees`'s supports the percentile parameter, for example Triton RPC.
166167
/// It is an integer between 0 and 10000 with 10000 representing 100%.
167-
pub prioritization_fee_percentile: Option<u64>,
168+
pub prioritization_fee_percentile: Option<u64>,
168169
/// List of accepted token programs for the swap instruction.
169170
#[serde_as(as = "Vec<DisplayFromStr>")]
170-
pub accepted_token_programs: Vec<Pubkey>,
171+
pub accepted_token_programs: Vec<Pubkey>,
171172
/// Ordered list of fee tokens, with first being the most preferred.
172173
#[serde_as(as = "Vec<DisplayFromStr>")]
173-
pub ordered_fee_tokens: Vec<Pubkey>,
174+
pub ordered_fee_tokens: Vec<Pubkey>,
174175
/// Whitelisted token mints
175176
#[serde(default)]
176-
pub token_whitelist: TokenWhitelistConfig,
177+
pub token_whitelist: TokenWhitelistConfig,
178+
/// Minimum fee list
179+
#[serde(default)]
180+
pub minimum_fee_list: MinimumFeeListConfig,
181+
/// Whether to allow permissionless quote requests.
182+
#[serde(default)]
183+
pub allow_permissionless_quote_requests: bool,
177184
/// Auction time for the chain (how long to wait before choosing winning bids)
178185
#[serde(default = "ConfigSvm::default_auction_time", with = "humantime_serde")]
179-
pub auction_time: Duration,
186+
pub auction_time: Duration,
180187
}
181188

182189
impl ConfigSvm {
@@ -199,3 +206,25 @@ pub struct TokenWhitelistConfig {
199206
#[serde_as(as = "Vec<DisplayFromStr>")]
200207
pub whitelist_mints: Vec<Pubkey>,
201208
}
209+
210+
/// Optional minimum fee list to determine validity of quote request
211+
#[serde_as]
212+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
213+
pub struct MinimumFeeListConfig {
214+
#[serde(default)]
215+
pub profiles: Vec<MinimumFeeProfile>,
216+
}
217+
218+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
219+
pub struct MinimumFeeProfile {
220+
pub profile_id: Option<Uuid>,
221+
pub minimum_fees: Vec<MinimumFee>,
222+
}
223+
224+
#[serde_as]
225+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
226+
pub struct MinimumFee {
227+
#[serde_as(as = "DisplayFromStr")]
228+
pub mint: Pubkey,
229+
pub fee_ppm: u64,
230+
}

auction-server/src/opportunity/service/get_quote.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,17 @@ impl Service {
195195
};
196196
let config = self.get_config(&quote_create.chain_id)?;
197197

198-
// validate token mints being whitelisted at the earliest point to fail fast
199-
if !config.token_whitelist.is_token_mint_allowed(&mint_user) {
200-
return Err(RestError::TokenMintNotAllowed(
201-
"Input".to_string(),
202-
mint_user.to_string(),
203-
));
204-
}
205-
if !config.token_whitelist.is_token_mint_allowed(&mint_searcher) {
206-
return Err(RestError::TokenMintNotAllowed(
207-
"Output".to_string(),
208-
mint_searcher.to_string(),
209-
));
210-
}
211-
212198
let referral_fee_info =
213199
self.unwrap_referral_fee_info(quote_create.referral_fee_info, &quote_create.chain_id)?;
214200

201+
config.validate_quote(
202+
quote_create.chain_id.clone(),
203+
mint_user,
204+
mint_searcher,
205+
quote_create.profile_id,
206+
referral_fee_info.referral_fee_ppm,
207+
)?;
208+
215209
// TODO*: we should fix the Opportunity struct (or create a new format) to more clearly distinguish Swap opps from traditional opps
216210
// currently, we are using the same struct and just setting the unspecified token amount to 0
217211
let metadata = self

0 commit comments

Comments
 (0)