Skip to content

Commit

Permalink
Merge #1955
Browse files Browse the repository at this point in the history
1955: Fix eth enabled for fees r=Deniallugo a=perekopskiy



Co-authored-by: perekopskiy <[email protected]>
  • Loading branch information
bors-matterlabs-dev[bot] and perekopskiy authored Oct 12, 2021
2 parents d541409 + 3a8efcb commit 096b702
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 5 additions & 4 deletions core/bin/zksync_api/src/api_server/rest/v02/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,15 @@ mod tests {
token_id: TokenId,
config: &ZkSyncConfig,
) -> anyhow::Result<bool> {
let market_volume = TokenDBCache::get_token_market_volume(storage, token_id).await?;
let min_market_volume = Ratio::from(
BigUint::from_f64(config.ticker.liquidity_volume)
.expect("TickerConfig::liquidity_volume must be positive"),
);
Ok(market_volume
.map(|volume| volume.market_volume.ge(&min_market_volume))
.unwrap_or(false))
let filtered = storage
.tokens_schema()
.filter_tokens_by_market_volume(vec![token_id], &min_market_volume)
.await?;
Ok(!filtered.is_empty())
}

#[actix_rt::test]
Expand Down
11 changes: 8 additions & 3 deletions core/lib/storage/src/tokens/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,21 @@ impl<'a, 'c> TokensSchema<'a, 'c> {
.fetch_all(self.0.conn())
.await?;

let result = Ok(tokens
let mut result: HashSet<_> = tokens
.into_iter()
.map(|t| TokenId(t.token_id as u32))
.collect());
.collect();

// ETH always has enough market volume
if tokens_to_check.contains(&0) && !result.contains(&TokenId(0)) {
result.insert(TokenId(0));
}

metrics::histogram!(
"sql.token.load_token_ids_that_enabled_for_fees",
start.elapsed()
);
result
Ok(result)
}

/// Get the number of ERC20 tokens from Database
Expand Down

0 comments on commit 096b702

Please sign in to comment.