diff --git a/core/bin/zksync_api/src/fee_ticker/ticker_info.rs b/core/bin/zksync_api/src/fee_ticker/ticker_info.rs index f87d96631..7db09e71d 100644 --- a/core/bin/zksync_api/src/fee_ticker/ticker_info.rs +++ b/core/bin/zksync_api/src/fee_ticker/ticker_info.rs @@ -20,6 +20,8 @@ use zksync_types::{Address, Token, TokenId, TokenLike, TokenPrice}; // Local deps use crate::fee_ticker::PriceError; +const TICKET_INFO_GET_LAST_TOKEN_PRICE: &str = "ticker_info.get_last_token_price"; + pub trait FeeTickerClone { fn clone_box(&self) -> Box; } @@ -194,7 +196,16 @@ impl FeeTickerInfo for TickerInfo { // TODO: remove hardcode for RDOC token if token.symbol == "RDOC" { - metrics::histogram!("ticker_info.get_last_token_price", start.elapsed(), "type" => "RDOC"); + metrics::histogram!(TICKET_INFO_GET_LAST_TOKEN_PRICE, start.elapsed(), "type" => "RDOC"); + return Ok(TokenPrice { + usd_price: Ratio::from_integer(1u32.into()), + last_updated: Utc::now(), + }); + } + + // TODO: remove hardcode for USDRIF token + if token.symbol == "USDRIF" { + metrics::histogram!(TICKET_INFO_GET_LAST_TOKEN_PRICE, start.elapsed(), "type" => "USDRIF"); return Ok(TokenPrice { usd_price: Ratio::from_integer(1u32.into()), last_updated: Utc::now(), @@ -210,7 +221,7 @@ impl FeeTickerInfo for TickerInfo { return Ok(historical_price); } - metrics::histogram!("ticker_info.get_last_token_price", start.elapsed(), "type" => "error"); + metrics::histogram!(TICKET_INFO_GET_LAST_TOKEN_PRICE, start.elapsed(), "type" => "error"); Err(PriceError::db_error("No price stored in database")) } @@ -310,6 +321,23 @@ mod tests { assert_eq!(actual_quote.usd_price.to_u32().unwrap(), RDOC_VALUE); } + #[tokio::test] + async fn should_return_one_for_usdrif() { + const USDRIF_SYMBOL: &str = "USDRIF"; + const USDRIF_VALUE: u32 = 1; + + let usdrif_token_like = TokenLike::Symbol(String::from(USDRIF_SYMBOL)); + + let connection_pool = ConnectionPool::new(Some(1)); + let ticker_api = TickerInfo::new(connection_pool); + + let actual_quote = FeeTickerInfo::get_last_token_price(&ticker_api, usdrif_token_like) + .await + .unwrap(); + + assert_eq!(actual_quote.usd_price.to_u32().unwrap(), USDRIF_VALUE); + } + #[tokio::test] async fn should_return_value_from_cache() { const TEST_TOKEN_SYMBOL: &str = "TEST"; diff --git a/infrastructure/zk/src/run/run.ts b/infrastructure/zk/src/run/run.ts index 6a1f080b0..8e690c0d4 100644 --- a/infrastructure/zk/src/run/run.ts +++ b/infrastructure/zk/src/run/run.ts @@ -29,7 +29,8 @@ export async function deployERC20(command: 'dev' | 'new', name?: string, symbol? if (command == 'dev') { await utils.spawn(`yarn --silent --cwd contracts deploy-erc20 add-multi '[ { "name": "wBTC", "symbol": "wBTC", "decimals": 8, "implementation": "RevertTransferERC20" }, - { "name": "RDOC", "symbol": "RDOC", "decimals": 18 }, + { "name": "RDOCs", "symbol": "RDOC", "decimals": 18 }, + { "name": "USDRIF", "symbol": "USDRIF", "decimals": 18 }, { "name": "RSK Infrastructure Framework", "symbol": "RIF", "decimals": 18 } ]' > ./etc/tokens/localhost.json`); @@ -38,7 +39,9 @@ export async function deployERC20(command: 'dev' | 'new', name?: string, symbol? const tokens: Token[] = localhostTokensFile && JSON.parse(localhostTokensFile); const deployedUnconditionallyValidAddresses = (tokens && - tokens.filter((token) => ['RDOC', 'RIF'].includes(token.symbol)).map(({ address }) => address)) || + tokens + .filter((token) => ['USDRIF', 'RDOC', 'RIF'].includes(token.symbol)) + .map(({ address }) => address)) || []; const feeTickerConfigFile = fs.readFileSync('./etc/env/dev/fee_ticker.toml', 'utf-8');