Skip to content
Merged
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
11 changes: 3 additions & 8 deletions mm2src/mm2_main/src/lp_swap/max_maker_vol_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ pub enum MaxMakerVolRpcError {
},
#[display(fmt = "No such coin {}", coin)]
NoSuchCoin { coin: String },
#[display(fmt = "Coin {} is wallet only", coin)]
CoinIsWalletOnly { coin: String },
#[display(fmt = "Transport error: {}", _0)]
Transport(String),
#[display(fmt = "Internal error: {}", _0)]
Expand Down Expand Up @@ -111,11 +109,10 @@ impl From<CheckBalanceError> for MaxMakerVolRpcError {
impl HttpStatusCode for MaxMakerVolRpcError {
fn status_code(&self) -> StatusCode {
match self {
MaxMakerVolRpcError::NoSuchCoin { .. } => StatusCode::NOT_FOUND,
MaxMakerVolRpcError::NotSufficientBalance { .. }
| MaxMakerVolRpcError::NotSufficientBaseCoinBalance { .. }
| MaxMakerVolRpcError::VolumeTooLow { .. }
| MaxMakerVolRpcError::NoSuchCoin { .. }
| MaxMakerVolRpcError::CoinIsWalletOnly { .. } => StatusCode::BAD_REQUEST,
| MaxMakerVolRpcError::VolumeTooLow { .. } => StatusCode::BAD_REQUEST,
MaxMakerVolRpcError::Transport(_) | MaxMakerVolRpcError::InternalError(_) => {
StatusCode::INTERNAL_SERVER_ERROR
},
Expand All @@ -138,14 +135,12 @@ pub struct MaxMakerVolResponse {

pub async fn max_maker_vol(ctx: MmArc, req: MaxMakerVolRequest) -> MmResult<MaxMakerVolResponse, MaxMakerVolRpcError> {
let coin = lp_coinfind_or_err(&ctx, &req.coin).await?;
if coin.wallet_only(&ctx) {
return MmError::err(MaxMakerVolRpcError::CoinIsWalletOnly { coin: req.coin });
}
let CoinVolumeInfo {
volume,
balance,
locked_by_swaps,
} = get_max_maker_vol(&ctx, &coin).await?;

Ok(MaxMakerVolResponse {
coin: req.coin,
volume: MmNumberMultiRepr::from(volume),
Expand Down