package Ġcom . sw iss chain . matching . engine . services . validators . input . impl Ċ Ċ import Ġcom . sw iss chain . matching . engine . da os . context . Cash InOut Context Ċ import Ġcom . sw iss chain . matching . engine . da os . fee . v 2 . New Fee Instruction Ċ import Ġcom . sw iss chain . matching . engine . fee . check Fee Ċ import Ġcom . sw iss chain . matching . engine . holders . Application Settings Holder Ċ import Ġcom . sw iss chain . matching . engine . incoming . parsers . data . Cash InOut Parsed Data Ċ import Ġcom . sw iss chain . matching . engine . services . validators . impl . ValidationException Ċ import Ġcom . sw iss chain . matching . engine . services . validators . input . Cash InOut Operation Input Validator Ċ import Ġcom . sw iss chain . matching . engine . utils . Number Utils Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġjava . math . BigDecimal Ċ Ċ @ Component Ċ class ĠCash InOut Operation Input Validator Impl Ġconstructor ( private Ġval Ġapplication Settings Holder : ĠApplication Settings Holder ) Ġ: ĠCash InOut Operation Input Validator Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠLOGGER Ġ= ĠLoggerFactory . getLogger ( Cash InOut Operation Input Validator Impl :: class . java . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġperform Validation ( cash InOut Parsed Data : ĠCash InOut Parsed Data ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcash InOut Context Ġ= Ġcash InOut Parsed Data . message Wrapper . context Ġas ĠCash InOut Context ĊĠĠĠĠĠĠĠ Ġis Asset Exist ( cash InOut Context , Ġcash InOut Parsed Data . asset Id ) ĊĠĠĠĠĠĠĠ Ġis Fee Valid ( cash InOut Context . cash InOut Operation . fee Instructions ) ĊĠĠĠĠĠĠĠ Ġis Asset Enabled ( cash InOut Context ) ĊĠĠĠĠĠĠĠ Ġis Volume Accuracy Valid ( cash InOut Context ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Asset Exist ( cash InOut Context : ĠCash InOut Context , Ġinput Asset Id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( cash InOut Context . cash InOut Operation . asset Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLOGGER . info (" Asset Ġwith Ġid : Ġ$ input Asset Id Ġdoes Ġnot Ġexist , Ġcash Ġin / out Ġoperation ; Ġ${ cash InOut Context . cash InOut Operation . external Id }), Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" for Ġclient Ġ${ cash InOut Context . cash InOut Operation . wallet Id }") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠValidation Exception ( ValidationException . Validation . UNKNOWN _ AS SET ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Volume Accuracy Valid ( cash InOut Context : ĠCash InOut Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġamount Ġ= Ġcash InOut Context . cash InOut Operation . amount ĊĠĠĠĠĠĠĠ Ġval Ġasset Ġ= Ġcash InOut Context . cash InOut Operation . asset ĊĠĠĠĠĠĠĠ Ġval Ġvolume Valid Ġ= ĠNumber Utils . is Scale Small er OrEqual ( amount , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġasset !!. accuracy ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ(! volume Valid ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLOGGER . info (" Volume Ġaccuracy Ġis Ġinvalid Ġclient : Ġ${ cash InOut Context . cash InOut Operation . wallet Id }, Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" asset : Ġ${ asset . symbol }, Ġvolume : Ġ$ amount ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠValidation Exception ( ValidationException . Validation . INVALID _ VOLUME _ AC CUR ACY ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Asset Enabled ( cash InOut Context : ĠCash InOut Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġamount Ġ= Ġcash InOut Context . cash InOut Operation . amount ĊĠĠĠĠĠĠĠ Ġval Ġasset Ġ= Ġcash InOut Context . cash InOut Operation . asset ĊĠĠĠĠĠĠĠ Ġif Ġ( amount Ġ< ĠBigDecimal . ZERO Ġ&& Ġapplication Settings Holder . is Asset Disabled ( asset !!. symbol )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLOGGER . info (" Cash Ġout Ġoperation Ġ(${ cash InOut Context . cash InOut Operation . external Id }) Ġfor Ġclient Ġ${ cash InOut Context . cash InOut Operation . wallet Id } Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" asset Ġ${ asset . symbol }, Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" volume : Ġ${ Number Utils . round For Print ( amount )} : Ġdisabled Ġasset ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠValidation Exception ( ValidationException . Validation . DISABLED _ AS SET ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Fee Valid ( fee Instructions : ĠList < New Fee Instruction > ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! check Fee ( fee Instructions )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠValidation Exception ( ValidationException . Validation . INVALID _ F EE , Ġ" invalid Ġfee Ġfor Ġclient ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }