ETH Price: $1,891.10 (+1.66%)

Transaction Decoder

Block:
21971727 at Mar-04-2025 06:26:47 AM +UTC
Transaction Fee:
0.002683099767467868 ETH $5.07
Gas Used:
3,296,588 Gas / 0.813902061 Gwei

Emitted Events:

1534 0x5e80caf3d631ada4f71b915717766257fc8c684a.0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0( 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x000000000000000000000000a7c4c2e81092c0601b5170cc8b0491ddd1f5fb02 )
1535 EndpointV2.DelegateSet( sender=0x5e80caf3d631ada4f71b915717766257fc8c684a, delegate=[Sender] 0xa7c4c2e81092c0601b5170cc8b0491ddd1f5fb02 )

Account State Difference:

  Address   Before After State Difference Code
0x1a440760...c50fE728c
(LayerZero: EndpointV2)
(Titan Builder)
15.211670936471562556 Eth15.212234056175601744 Eth0.000563119704039188
0x5E80CAf3...7fC8c684a
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 3399361855361989922553607983271317404157016506231812456987554191094256348355516890622684558655711660153275956258701716083636805682463481860259550845468387350569414748338769783977018094368829236890998818127048170593051953308434585780566275434633919164999987256079056000186452398491958913105835166720894383702170615347204228359308798659654376957362297330379316085033129018116134431529229290944911587585928367771076773757580322737654003972008627039379662955258004917765156242959390528236227424377081776581418729088204291187040589460519635385361453279955624059561956762896959465756490810322088918395897036304418022587185136072079936217436585057427579903721244192240434032965268544075724046061139659767819857315715098048442288319114459952067273169237236217665485697088388414635145458300401973681113935061519769949742702305883831638705814822569054060909627882639971243933630960729410877078126580431182990351209092020071384992976656472572672500932241087590846924995693201999635762601603876405627499853967045155129192750409375168495451952956567221401269719168102027010725746666841181208099972211559806211757670056705032199487620288041256602419200902097474565845008239268655800829772596568767227161432036437681656904070134822135910553665426137736614064570029027071929676662140336967283178340617128167064445491852342988980996864748240855518972811135537738826444088973755524785061204525751552587665790741843879419150165172046363057723810293132136552909228404870173298833229987201759904797176493675276391286183621811730179541206787519700009551228606232993562315310621467943767133877626435207870142859540291190509271861408151257880094448279288912638160078548096583576357816452105166048496948861459841088678988082379780732731117852540831804916261135591649780545287869110398217443914704473416657263340389964350421361357146063544048378406593384222089609770708519416846844606721640702513592454765778595889626660724536899062178242385231416413010432871518944128986721028890189537013818863214567157269636618325618663732391222727284371478733151471276843733560721083513440810997022645022908202671112737398228430045579006617710366989306740391159329065341519583930506027160293960902991948475658878353676070824485776150335058569198678892670285472618662694349652455974416144555177612990740092970457082299664165321395327496111501837942996178621126575802510482327838013403040649273744296472971835901734034899367788543310735439106457138640429073913664573328935119708863363490155134049790189671147336017701503312438072602768953915462631240088360642229048710780417560522768179537264925151350723021383036239333356945793990782084819335893568113701192244099749340477105531130900369965533693864653111246313192098776330862814294134378839309733557166617110397096880343690242429479724117776062372918775571736443061652385780565745428314038699987566825631452891630497933357663249002654206573966407379960144674889928372320519693445660581755664972799322674508434178735598406332695089385329115647626131220061551379935962508750908522569751468928896015165744944294896164284841025762228294968175574853348075630420083957210613876936057620818414206066911186272690416328811134055103081802036334321251510431415770066767176159686334369066205865832332604039640629591260089747960415727753666416907287282934781760953132263384394157319083922843709504166909227542836037858474935315763716729929343344114459104988225350215307474117480166035324128353186886495559502580383704975991849508784388999058284870446608698929176818016523209178295182542398837671051864704421431978230557484503005129943048111376483104689422691375221789735829841009965448163264432837516707957722684754217257168278346589925959772826216006072159440488124395299256442953178217798384008280177173132055735570206205418481222420514282133719594324677029155790711883098121360662910554942039465126427262060775176949822770283105143170926693538466437664483900691073004973973465612135863528419452403344529359130081070567481631569909402298667815441520955269119634457098778377914323164321479612234982049046808494609072147085718381364118300230244136815902163412122129181745943226557852671913994800554840790062074184855786333244293781288326816493392105574964226716575660442422071774868491018005238607944801064327730604517719069724468805239447874216272221753148775259882560183462759194414177603509449456836143977728105961134405888604867898565824720081461321018910889133875724800527960482177570767016870420147337401619135738459223622842218660109970418289083997609183906232900995351252002609853892931081128753119514577517821824708189590744578336226593313533461305733060402608421763984290764879707045524756927634921836341779326486442335530386636014288821964293341035373910899611457798956590189336192572171451143193268516705302505842698815279362744584700140024208065534886227272092438377646225793546094297956461393362665957511496320011194441156913536753703825874330829932380694672119063768806412194120089394225850389574180988377475040314820163929075251187017752353612916580490201353964572712790935089584439193782451144526540588663025550911182605015324177155231478568782208456407928025444828221379484102556222854506127769883985699668285035581254516397572145409120234267948614114146009017354490385657202859060231693724831715400302500604915255657674381235200953866010224172652321972505447614545491192303937222126449815733426082631952370300355063349388228260601770167320809088488721620132495631193738389846727875362862777766959655090382742182651141983494777075454992587149210860420600981346378456550499528105726412641651525258475053320401758454777495160888366824253724483074557024729834129710349428637884837983085187373154154643253053396463647190042853329609010706584674011755138587263027341177098990830308249876936912920854634540964843050680653149428890936783627569275550463941713880838976808882435605739404781651436911225981830171104370512246155049916280754544434614929359973812729376715935462564379362785178271399889954724800099293433956626200990761286941871253701462343453237258300092775328904435705679771359639079146738746870342168342405255923169594632518846004033221977843504384145592625418109983105541148997384237747903946650455420847262115313950235901521373097795770931268181636744185220518877295689965370463975724022133237378929380069857695765561982821781254946441376004967279078787367494851596738977659741007599750527577415933636041248356932342960089114719553606048259270501193301642927731045785994262033656765942808750204713244847624753647968292673135913293299756618310038401024866833037518314813007812621366236728215486052151065428908885559146693721313179388396167852556369580982460467347150566756989245270466939339919969255441567673051192189001204302839475591060352152996126148332560649201522627817152094979571894797806000692774414425942627449925188551214084393685938042441618452361522578815015927520299132302719683354632876799784570014313342545776921393982125557499662639896826446348732604122763131309197388102477883328620868530236968905944386624696548079871300390209621510450478339557364118047237472832256722119062425270556684584365795634084164962160932711532460633523440440999252065118732619734491096962965532966656086299876674335557438592857635830430858404844823113626109357806288779458876380535382513429603628886276326442170480822811902370160200917351941884503711499623733194690656941838193975686316236223625993945718452008894209509078562125008866071699153940005123949015158701712401045208184713337278356476270669435003287502117102178720931733682706582315871860340016055861502266515204331547985332672541109340844530650115993232964656474305588740389861970428814771417599348078778209874003360031561990445104870992051150557990580401478441301808007730818235978433673803294488358687365012720625639805906226552396212741076767422915671964092841636141167503648122585097667663576059927086649835592010750514280381067071341452350164576169180905376640958427622944335107602898923285273325444024738097842642156803703191083369260842952711306551671293799922504947566802482031952630224772955964193572684635612552575167665636536800316564676450459356847652451755898895184159599032483289389330222028518256747049767650438919731313497961381457344657281051684808617813184222723836432435017117068872076385452778928181325009846654705356882620718143398741767639084584616204199795955679246929161384632773328200081729380273730638847277805211844118394867958317805477287350449983062664421035031155112139703070973813986523692880706082304167540143616404028954135201731109333072334701875274683752526236487648003320289552195078568010527404497899319323299848844393580376309735777799573806802197844778044136026319298982325716783667956950381607028641901157673521415049974966045017323002496292259448854900991900903341603913445173156223951854751488296815949901234956650594355815306841605223959340134962052763409411160919188739735085705482883089406045441986635027051083536915013750755778957537034570503745100033437936770892168419495532537409477419839498698205861845371167039520623779490990341501265870646558745735292833702101158776622473492699687351314125425018636797878661801612075008530703097191631793737366877823207879050685008564526200527223257699262822389942749169072692693717607050392487116951212061450847040898524098648116209926446200932582841337422111030468448179566142595514085204647533663389575971125584034774561194521799346275279429285382309786499563924005753132500400929542745736896641302546304847990227895871589205496974184389404622136346608360312669764254253239131793939549186685811449304083227974884854104611353661649432505015634917377196539101678424992478893094329054743110173352223308584229338273144529069968524599070565699124142876419112210904010159382388072656090589176704823298454513210528957405129978184379219639061601606931113016184463332061747579273177373506321660584860589216884400147398528024381598791590546111775439080738494014779561117914139604292423200607980737455610415741052879830955561466213218108655583602776331757391432543918965998100891114245170780187491028144929752034253893489742231140148453877471976658613076419407109781977923819048352512280207681262195630661630817541655626120953659558693728863202988417992581266444109689868913231934163815945271936251675620426899542536654291682396160598565486516146371798787685415217760929551894890468714383548586237035217898838640404163438450383681654942836974724395393912531935628314422972290816041254617519467846041456884410466717588943657505030368208682038284837445905649840395886405923328334692181202715155803811671569977660368471899684527239006790618268960996025187837086422439250335776163791284613408536552647584824368584586344692038050947751680747673483163254993555159797751972408326761814218200042833496620964104240066683549845007639093815987303740879567957479283812321888790649409547261599241338520314973327207818713616680424346496515486015415145942344441587422128868285288262383841505245306720667896792700513782477934445729588140133795395932570610957285729045235121211812354805611664954622511976661160220594265494441320497979553870151831362365587436112779313226408266107465266405766947834796110095185027386574928763806730626370007097785740287906219062899248080597961256228847287147978034625825240230743772655790547218063027569132843758060807937584540536403232275556696692176322372504361651470537921987322371362898464491700364842489559509104086404542704695509737367839895352407924608575763425271306410434327939766827001030316565417705459769970609480405808244251620191775751302592762516473826400349594883138839965734258977673317176583883739258795159935668864337520221971855031021889162491559549247657919005755331911328401628504479998863208203419018612910500398391373087574467800099433446597153709853324172874783860926207867020737326780026061625997145113551706442982300673530950042634503165660463761490013353401191305273537976613158089058682145840049817789728014683122278704942878502651161576813226697168056084597803838677921910244054037743353888931343429393083389483141972146717234814020908655769422130826694639168516776062543169654932311212482360567965560004933000323682477329184728462166751165678686295366844157088682370503039412935776822490038006034662304867847719145688016585105556413931130757795140269519803120815074583978538216453988659805815853794902425413411567680654700095527700299786645206626453712567403495206299820124626637122123490061066672239532176634168646168651024975236174084553519666929171321046210523834641289615756644640569232480094859637319282607161607447640291190199993362717443959829919813462828605052309592231985112827615093821349835871804467407379614197520229361294534433176860567540146125646981970303311526531750010240733265513045323489822544961314087422737854434916972793093835630101374633968010956170233629095473878549090947973552706254457544264442892049829699735294328881186257147350556153084408810968442639824480519682784484053757711878653397880710831445354211874563169321111751822931069756046376345741651499695602806229314469163907831858777951263813457753963978757651467192476796883133138306416867878543744637996008114523212955691885334076827454429689985737306112936168571538416782836531027625099058689786319082234527925459739005805953025427218279432545681583493738986217005771911269292369749791957450937395193714491609120050286998954436733894822293172617628756573981490983891470090854406346800515808381691981329656003655039699197760986708679055462762996863622357768550576443343328986765835389938930064154184189918129917047346903085269654419252715571440348498188696513286538493162380895552425595608012122018779648376263340890260818850708082431478451675287638184744465550206476683581301742272366430236496478669133708491526987126150869441656034440596223729664443209227402310252855945418544198007068304316377794866540556649499115729722771720839784252728225055194014443893671871078081050335972383828840168419903219627865239080076165711703155335462153264739938229231008479171863026903580880919192447780670614157115530890081383602164779332296202975188340337486714134640981612307107058996782772359996793120576203716490585737610281418618433905133198345221382713712364009616447562484363787756894363396139052466649376432602094169411234832202095029107354622488507221554083479191154412377352056049242222671277041273701563304663402960344100812065621321373101772084574928215652812505826800251426417348421739285250844515591657637085737429910096779382229211647212990273849230911463400385349447415773775764329345391424002597404309040689216887380113561246064847035541042089437414192583551877537391258775498575159113434483216898978920296637726973151967329366205395324606440510273553818948238526211378818566611497162848004487325144302671611195977895032028384126021233057948478524980976089423729155999028033785049629504424394917165044895339185840216980115402400975932553959468232613374517684156992546661413436528483535837861685749903536620754913500013027979202107301300383404640969409627976296353534854070201569358702538223513708637542862972099842163407394760548556011223207093328884546107882606986241110048906690791495404902421417393837872418737336982848463970906858781531542982641748160429719575979045586894418177668173450839941375776156845435693827500513920322637715218461738447152363003082156486806183575894268322486539665231714534126520807015232216998781777056604718921072419480962631556513848826445433131009031052129526019309766461015260688371114298553294637312889569205809558376110705515870092888649194202858049347226987721916982422254224224074505317447728328151369872023715638502577334802468776602198050780857269252522919190816337795100804411224063022078431605543997269582163031005343964844285779102104458047568036068860062723737263556643584932834903218329960485410485532955914426275630999820724417325475501962888563767503522014350076570563512310563727061254482304181008535673990549937879518139790029507350221032462587970647807991305558358512517546857120599086693344603593036440209522505959449765709327886950850079283621063576934901212148716077372849013082839459469735944844500399650809219321907365981417018188668380413566560212411492547713398667353952828737144326163797143504988546561645108711258550799630880854979651712468422259327789988245734917819807350647870900702023957349005356015799959900966636997325274802786348099195623303494894695239586594242720306378231275415174625918824512556943365840026467125052917419299998961095903980298317595335337811358038419148524124663582924983050569091376576291448119725940520934147226716371471444418455259730507649742442270691319782317955235368146725937611355882020061538690801357441328298199833453200041268726910719784124533038380437395810331308740864215101915787822282611387836705559675880409826741485292232238175714741706568669973290135851449870048399067538335213137539185706230862589095169551902145230616370391780912779100428998314160949982503138768358316003283251420900562696905953570269732700313778371757953775182809328221631541991510867315737746688432022045717395027949598288735968291460269109981953133407262019084009328448067821531389106951981293038425937890341934511097850103456273845232220225068336944719315491964398358151266761379572828399465564335391129104213017951941397910238441079875971518141265383377344941222087916932734943913802421380453792529305238772107121180431303064899475682799970717033167496514886863792072546542675568261199024689942153817283512907402103914934897193744153564978001792862854153215582108607302210478240277400319167181516079162375384889500465093492911655337941542336481083004889075873435115225945739356072682200651924407795468458652828598119138908144527902210247846507745032813286949148823682957870869730437524242874088322258258381927939081025296873903132571930576242296341115841908124283418052161929794113488147970137164033412043118502704787361335572888650431506575011255671833882263710627115762985482512598583571927481046420702340715995554443476741885800274018079538273990351897168827475869747159229496527809709005654642839290945488806594171536109187789282262989705813443842487087915035922516040058595061176475505432827686740670428676452169813613872900401893737340401802313530616525916911339628396514450120886806706293700918031201244399651036902509979190265943609831997752201876354173140067585859710782186138684533435400224695977275951827801996690851792464403382085869899352623696567252208480792299741760673631350966012347911126226167168286016224058454661191285496895826242134388195101844506933034778187735116583981846329046239640492484903108461005736038640320657683136625769411794514065406135769201440923145918677443218510250176057245635288609702845168179006993417172314532118309129892294993519220270306832445498577505892878430759808779726226862334388617120851413417910028851305073112058359452275904222632902227902406745940113310174470338782000284969590675476619772320276785943153231771973523941514469064687863171747878085889347099005978875697138440990793627664048567090498287617372977374808155311878202481809713883409091836080975775505467717329718018381942919342186612364382799977927940351407784863330931952547755127072183527632357000692116204518000438353842697473727684536867037813698526560252394273680868759817447939639873886686108901993401366266545383749252536017707808980929415246282914928682757074864103953710261142884290277376750275656940953158590251988313417338411627564289075128719816928977215383752881910347664702150966535791878338474594541019766812577461102620068578485912864285130264881173550351620319222625707680505143728251928414245389779375380036768920912804356399328376998874847007586746419488507844644114127383225878080214117953388651313672066799672287343089656249750101011639082176456064531095644521150695240649523060621340775681544637295386091623128928901531237855210714277575245088995654270371297764146881362985360617565551213423490839567604725832349503281693105510578965922485506687385212143432409057288722114591256700233104183248724148159075607345889903117843527175281121965353412554960321937321260845373888662843706652157195533587719600551135446096225431186164802220104832416885620791315137185125010702570850109810434388723795779208459456929288966239453410267069277491994008447461812063552740300500271545742543490137731761551059184050383494411359189791737734960040966680261521306958458881391423339358674794052138719468797219583102540104295594933397516398005637716518134637841850550904805995532528499316290311317554782590827779919777355172479871149096464767649602786346928722959713601189025776193570058394666461181227293518499577141487187465719794891634830551904893700562372307512378555575480310812934914054422094600728315526442936050925582335078804187608468606940708059618934667076455332629093347242831857684368793268127533740206789457313116838048004165750245660734076547407055792509573313432397032231548183788356854273324822435597028817003696584101855773129935018113491302329822934151057040132646609520797933644137707258498118880680872633213005954251736133956924232464253974186097243115525335159295968928181342107099652917571211037347273688178583422730900663183906031187681880376259430071607536943722705347669289272328314263924068219349024506757857779173476496969177821769754347404837610763765782645491087144373954572067612575838063020769718436605753937196868338376013606071253843743487064903214907893008132820585139803726255616936641261614973016509719816706638430138318339787613214486694030223351197028436674416273971812940407243027130212574949938405492833590664301545827947090947356819874431764078295371407590619673927809639397498707912593947400827213964721419323004140715105428004226762919364712104614156784914627555880097474594661617365791286742267912327467370028589108169472983356249060725364366895957973101261093334701877225267547737962731735018645771686249822071655502567799812448766790321025465917473304359347377172486701204772216244265012518848068790715705334650046546701564565029917850328046441483178410834318308264448553353067585308999641070305197576004593650060436109182673415005390093891401796976325551274452886983101658364506592325229769169653715583723748507114385952996748160831984097676386965513050407773225582565543296480250986652509653620495196141766561614509361857561253577101315055321563826019775934554752993416260485679328245329945012245678737435769817027370575716959308949820801739175334277127525851196180921844494603159841698528905887275191300241836276287418297313237303608983740865151909140313196431338989696157131041061006304374317555964723387571177889083491188664912716610456793855800197764980581960740500298805247330174658356726821801247435073305021786418765460335567911852958619056032272470574207121423071993927375919361720087919556735155533429749708475497854551806419231188858861794625201569725517968206400633611325845751720480017425079750413468327158021976834063712618314209690632256109048582571450967640580865562928787684309750369392295554201752966563416706780681314715736095271142913069682324805581717778600587610174156419196616791200931367828454511109610648899725170294197374251919044159292588867769737510660877486297772378932384842127435061148253746428649381534070291859728380244690131303649495886423447001683176713353997424433600465073236275667631375726104780557750526840121320136379081615446845674283164062168467034603636785888994677317384585795746022661039669549547550260779872023894305676550489492809289651439909733484110787241117487996739193936942807189516368969785667959621991721338497925971662886835873855901766760990131928323526915701989927364462694194872530636827563194716062191615086699512964465524191694676401697071673302818067602855634278060970578003106503621629472863578743262052604869717458452607451882710127693530870851464121495820210135229947501761955948316755523466831930545083027212793626910148135909341208181996577380762792720280150607669867740181155101340034401787781806473599452275425121133485882757516387731009307325699953011734794397524567552712167887757469013940670569506075792608195914301703107844085258283284417884799528441816466308088699337337471348546306579162888874923317258863480853326469805851437208537588022452755361490692890380292727971629121340682157821032566634593551127531337413742652168047147100629635057542132504798681518261142847883517805165435519314612988731888479471603844875126703702428292890782011037264284540264452209847108086288164427049478636755528661653696856086921257538575305322406143527162046717864018897360511524252553310555550163544631606349333142627793349535327240936387354093461330533050269809417646954737323621231219521008170038283548987965007591399506668370925830460286794165927635501608011937507844389426156503925804104070455840809330718463042459676927258129328130025937376728627713222358101831894010737604945075950347923611347482695846709438021221675609042256521851767130900883480950698615218487595193873429741316972335500036835065364874793157065428797828061184282130035240831221600960169103704001213125263911694306708850938724554766587402270138589648227535098918348586704696384035300942025216251165215959348877299629142092440458754948429464169103821167001567907663962703383057579329387255146763308713343935424837812778624679225523254689435810218907731780305625826810399129262285235611325402039645305737793778836859651550595986474262774056361932621480304927256473182210478974778193472366527385427218598118126807624726449459165669878081845431761374584430804265282613912608486793367944972348259295463953475817661527214924424116516696290796774823364496818242965875064295257513796157968532501967985434391580343441023841171296190828232401887696382199819675676858607291641094631729785105233143328460922183080223169917248254083242933488413132819404204856738002030895273784529228965462909408785408534157597283839058519705363740022658501443419039354452822242661898784796053888267996687200928584461012053764813675502611523859012601043487362647084137829180165969488499907011362444459443519697214611467973078569587115011425866375651702065285226609470111964805841965956539910908306084511384163850278282670036896137409091780481350943079399855279014426600704184320720665812507496629667600039755078361514116174200009965109982838531206591752674880366084939375251856592456685458099875515676349581041916592835677466595775500047839291388887942139636946131763903473288725886888242644893223771909874539622746102265082523547945753178819055315224726434349402463148244506526697584713658213141702015075020205647779467546532869807291948557008098355184839678503026672508061768659336485127480207517655716831045261291026641001763315410473681442861312760227535305074313800104079456670313509567833450494120252085412906668728180687356834932487118855514476842436069021548627340594200365079795951866295039788399141417708900288664215678683253531514610080002318535838306861005463901429002814430276431316389027491431373458075322161511552390662386881185573972692607098694351862277979895096697858546314112403547974356630830175620697387571164370798555974151904257923314743137266780717060300371755267879875951617155471758471863950720518003002620127952892749287737005471506522422505559631852829686811002043978094335701202361013737599641960817050185830672257982777855636892605115456045315112510708884076151812035764301790209179004416728534212178493635662247733572514442797507742101060749223010892152285769632222952508000632409599064893061978170954461841613292887560852332482532145124273033311538211426765410362593955484665922647111142654979834793840713277742470006790055060604464004218046707663180466206004619108072726691356670524968998036588408472691660861535512768469865829541532672591685959689995722243147260911422870320599467209794223310626560173260692370389826493521211326711600902720046943554132405724817320578336375060289566176215654740199884833080686324226808167686842831355589825004615298614226052570409468760226004628358647440338764775066473441592875730098426010186057659323179672862977774443286956636761736869427857672722921179434699910960457530835572113372033717316202354176270196333044303066789368291691657307701761724139264585481414884477896194532951915535194091477841020857392993739344434209021552612136787182187645947052120654381336619336860220203169163716426708642206567730139822806951289391065701968947540813313100538240178641144543625400661329823797750374865679107503656780398046015383231667472133441488916754030277703755225395110161216616223953063407280002087071496007244049445342299645368535237573626269952500315110671606167546563831250179536432346105356203458185587044229645900407364030075122134318921009953950778711475324366492219020692837180447840467250388895939281924940247767417348025717374908814838871027417376222813940976448819794859331484744849993125601734612123025813192281092095978394515911969547872242887021247018111255023878590473766663407413607659218223826191209899782864383314978119169768599418054570528335064238524911020857720202777762628666922015953022900823922636680885610222766847383332691125542577559632904552092433439126033142346541373227881152378147493946373065869886945443926744540981104038140381401690943113201701818514047858553273102685217530905131885494572798721261437190990146396779509504617062917187285163089836056673803707669997911863994421804680137619259569108144799527896142097362141317718424002049562991098585686238684325002320407375028913210187557694603096523361646460543529665693912566210691574091057124907489835910625658354585623072651558850500229502636615393038403033718839548886787996566294608098425086478188862619247890980549590941531461850753125457686006931775700984759616084211204938575180461569670903623043251003590486475856492602701089846286555782364898450765870774103858858364693145234087422550836982264119079499381034441225193481882502846490803425060311144247092436879315052994238331969488873343242168983347517498482429788151842416038844896137651606372174966084196763287043125402853401818299723232770050196339196951572106862216341009545155338875767261563417781487341225765649746025966451652056393591096439643707448165688995887917441504650197487021610979043004259633457531004503115989511473683467165027169376094063393739165517198229394683044418349400764080934080249720597772751021638819766565512391384157457594357745058109433946603746048329391651056778858740975329897922830032355469881667292925189378378386903842896687052097829234270170633938347122123526707948499074221521093314077245071064518007319227857775294736512366588970187198850987046383794030354001645344483246586575978936938559638629714397224332317645091384441890556828870459611290109161562188219298367125457245017357784780802618380175323033686445721472874978902787108574443711437234748424513426041697128472987369515541386842975425165174846955531776060672340142522650607330747696936086599506617723390994190267504277853683766656500418754693748655504602180326432441949230862013439138733488566760602558229691792138657453694155753074013854215284880628472004452262164675818699742754724607803846019805654984564643520785288784628599012500132867359475327469210377053496978825767158158335160039900048080259731082394605616613685465911688114125575815756400873260299294604679089949533337454605403032557809664013428353229038277502922612633947061471901461917022113289481245125860423389950754933420608839071212980813829125584890347964405682154677010688084922711829363602362743677181921756926706446222142209508569450421752912302363407307473169797845586470852880359318962365812801632169620500020226919646164306887473511656483759649539872252783823921775121228090654980698662780319464501844577915536287850736049006883356321288924166584405347702654395450535292444214793334231728834002276395478359034380671101009607728975523472612624062350903404926947993780993775509026216463749495696731954042019310352080224835079591369128520304616213886427664542037794808865310065413750975804221464014891040212517511010035557269026871695421421282685236333584012580500107024941335175491595670727742776734133161148365995109922339396822267500936949518529992222165537891172144900111556317737727093901639883032327728169660923442155462898526016431766494927414639901411008913588934115441917410679084301205092091117506448668357828274687615292714538644701040871079264753054820962693935480759334339283993510750851011547798252869133023061635107299450032350674824588407119556098533572092205867013454778183550819474743855678456380763129792601709321418724789102948948729471168686333282103613666125809683449590364520086683815054582582869896569701547258190661726737828002519710152916780229434040974009456195838308871165038017590174407350199891888256957120305962937602503886104518732822558209023699121062325022587619829908289253968464576678178346245287376112050073361785955561166419005416758341270285175262298518516699717950687645919642313603218848903053078789362962457607270552042245333805330187147758132222712237960801202094955880145234634855343619791230090949439998258802359251697780572264210005572926390085557617134786074335451041090948412212353467028517624092656173035350302198321434724187062951240451200545610227081154929578806672402083486836128922953998883757834033933804946627288619943708892463613392664983700097978782798047050224571900572501808733275305822745636440607772606083101804567923855069355144440041111734353807545897056559125561414818074502056979823239371484126325403381543595654466898558354122049135919561072120803775659912113306095551042670113908852916054829533242456231337128771470581902436831833857612365551157321350730595278001493404969024552573099388586580329414022998151782759492174638782282295477540786793287906184162035480716389753161555313569884304245644539397977165693054592345925993016880241244911839367218771576663210833724582009735478638303300891959020681848809223479959027599734783769399442578067097262451493643493696009755357288781906483905801522059846337651922741156913229588199373132434876040562716451005601606100437863235637934629712673296445324464934181873458553871381295242112621442675817134004585792440441827760397642664919132693347113005484290642147516548689237513705418829515116756881988585005374561460216593906182638975463223312213081823940487695558333702421010586196945849934777313626270395859012208149905314226348076640445529249125430171945120139831228567129244789107868592613193133931042040501309446001564548990354042121502212550896257097631053800454950907192042290355483277389164051300065935998543615771505940698759451751709785058743925221938788428003646555521073452837672044371004457941667639940068172829794167221085009707421196170224621703973712923997859856359632562638467370796546789433260907414977653311912017910271523235528470308072134791013377981468100368058956833487469732248226240345015365879217747884286040358880175999741686831251507
0xa7C4C2e8...DD1f5Fb02
0.023166128600755052 Eth
Nonce: 5
0.020483028833287184 Eth
Nonce: 6
0.002683099767467868

Execution Trace

0x5e80caf3d631ada4f71b915717766257fc8c684a.61010060( )
  • EndpointV2.setDelegate( _delegate=0xa7C4C2e81092c0601B5170cc8b0491DDD1f5Fb02 )
  • FiatTokenProxy.STATICCALL( )
    • FiatTokenV2_2.DELEGATECALL( )
      File 1 of 3: EndpointV2
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
      pragma solidity ^0.8.0;
      import "../utils/Context.sol";
      /**
       * @dev Contract module which provides a basic access control mechanism, where
       * there is an account (an owner) that can be granted exclusive access to
       * specific functions.
       *
       * By default, the owner account will be the one that deploys the contract. This
       * can later be changed with {transferOwnership}.
       *
       * This module is used through inheritance. It will make available the modifier
       * `onlyOwner`, which can be applied to your functions to restrict their use to
       * the owner.
       */
      abstract contract Ownable is Context {
          address private _owner;
          event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
          /**
           * @dev Initializes the contract setting the deployer as the initial owner.
           */
          constructor() {
              _transferOwnership(_msgSender());
          }
          /**
           * @dev Throws if called by any account other than the owner.
           */
          modifier onlyOwner() {
              _checkOwner();
              _;
          }
          /**
           * @dev Returns the address of the current owner.
           */
          function owner() public view virtual returns (address) {
              return _owner;
          }
          /**
           * @dev Throws if the sender is not the owner.
           */
          function _checkOwner() internal view virtual {
              require(owner() == _msgSender(), "Ownable: caller is not the owner");
          }
          /**
           * @dev Leaves the contract without owner. It will not be possible to call
           * `onlyOwner` functions. Can only be called by the current owner.
           *
           * NOTE: Renouncing ownership will leave the contract without an owner,
           * thereby disabling any functionality that is only available to the owner.
           */
          function renounceOwnership() public virtual onlyOwner {
              _transferOwnership(address(0));
          }
          /**
           * @dev Transfers ownership of the contract to a new account (`newOwner`).
           * Can only be called by the current owner.
           */
          function transferOwnership(address newOwner) public virtual onlyOwner {
              require(newOwner != address(0), "Ownable: new owner is the zero address");
              _transferOwnership(newOwner);
          }
          /**
           * @dev Transfers ownership of the contract to a new account (`newOwner`).
           * Internal function without access restriction.
           */
          function _transferOwnership(address newOwner) internal virtual {
              address oldOwner = _owner;
              _owner = newOwner;
              emit OwnershipTransferred(oldOwner, newOwner);
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Interface of the ERC20 standard as defined in the EIP.
       */
      interface IERC20 {
          /**
           * @dev Emitted when `value` tokens are moved from one account (`from`) to
           * another (`to`).
           *
           * Note that `value` may be zero.
           */
          event Transfer(address indexed from, address indexed to, uint256 value);
          /**
           * @dev Emitted when the allowance of a `spender` for an `owner` is set by
           * a call to {approve}. `value` is the new allowance.
           */
          event Approval(address indexed owner, address indexed spender, uint256 value);
          /**
           * @dev Returns the amount of tokens in existence.
           */
          function totalSupply() external view returns (uint256);
          /**
           * @dev Returns the amount of tokens owned by `account`.
           */
          function balanceOf(address account) external view returns (uint256);
          /**
           * @dev Moves `amount` tokens from the caller's account to `to`.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transfer(address to, uint256 amount) external returns (bool);
          /**
           * @dev Returns the remaining number of tokens that `spender` will be
           * allowed to spend on behalf of `owner` through {transferFrom}. This is
           * zero by default.
           *
           * This value changes when {approve} or {transferFrom} are called.
           */
          function allowance(address owner, address spender) external view returns (uint256);
          /**
           * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * IMPORTANT: Beware that changing an allowance with this method brings the risk
           * that someone may use both the old and the new allowance by unfortunate
           * transaction ordering. One possible solution to mitigate this race
           * condition is to first reduce the spender's allowance to 0 and set the
           * desired value afterwards:
           * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
           *
           * Emits an {Approval} event.
           */
          function approve(address spender, uint256 amount) external returns (bool);
          /**
           * @dev Moves `amount` tokens from `from` to `to` using the
           * allowance mechanism. `amount` is then deducted from the caller's
           * allowance.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transferFrom(address from, address to, uint256 amount) external returns (bool);
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
       * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
       *
       * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
       * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
       * need to send a transaction, and thus is not required to hold Ether at all.
       *
       * ==== Security Considerations
       *
       * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
       * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
       * considered as an intention to spend the allowance in any specific way. The second is that because permits have
       * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
       * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
       * generally recommended is:
       *
       * ```solidity
       * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
       *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
       *     doThing(..., value);
       * }
       *
       * function doThing(..., uint256 value) public {
       *     token.safeTransferFrom(msg.sender, address(this), value);
       *     ...
       * }
       * ```
       *
       * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
       * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
       * {SafeERC20-safeTransferFrom}).
       *
       * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
       * contracts should have entry points that don't rely on permit.
       */
      interface IERC20Permit {
          /**
           * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
           * given ``owner``'s signed approval.
           *
           * IMPORTANT: The same issues {IERC20-approve} has related to transaction
           * ordering also apply here.
           *
           * Emits an {Approval} event.
           *
           * Requirements:
           *
           * - `spender` cannot be the zero address.
           * - `deadline` must be a timestamp in the future.
           * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
           * over the EIP712-formatted function arguments.
           * - the signature must use ``owner``'s current nonce (see {nonces}).
           *
           * For more information on the signature format, see the
           * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
           * section].
           *
           * CAUTION: See Security Considerations above.
           */
          function permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) external;
          /**
           * @dev Returns the current nonce for `owner`. This value must be
           * included whenever a signature is generated for {permit}.
           *
           * Every successful call to {permit} increases ``owner``'s nonce by one. This
           * prevents a signature from being used multiple times.
           */
          function nonces(address owner) external view returns (uint256);
          /**
           * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
           */
          // solhint-disable-next-line func-name-mixedcase
          function DOMAIN_SEPARATOR() external view returns (bytes32);
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
      pragma solidity ^0.8.0;
      import "../IERC20.sol";
      import "../extensions/IERC20Permit.sol";
      import "../../../utils/Address.sol";
      /**
       * @title SafeERC20
       * @dev Wrappers around ERC20 operations that throw on failure (when the token
       * contract returns false). Tokens that return no value (and instead revert or
       * throw on failure) are also supported, non-reverting calls are assumed to be
       * successful.
       * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
       * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
       */
      library SafeERC20 {
          using Address for address;
          /**
           * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
           * non-reverting calls are assumed to be successful.
           */
          function safeTransfer(IERC20 token, address to, uint256 value) internal {
              _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
          }
          /**
           * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
           * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
           */
          function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
              _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
          }
          /**
           * @dev Deprecated. This function has issues similar to the ones found in
           * {IERC20-approve}, and its usage is discouraged.
           *
           * Whenever possible, use {safeIncreaseAllowance} and
           * {safeDecreaseAllowance} instead.
           */
          function safeApprove(IERC20 token, address spender, uint256 value) internal {
              // safeApprove should only be called when setting an initial allowance,
              // or when resetting it to zero. To increase and decrease it, use
              // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
              require(
                  (value == 0) || (token.allowance(address(this), spender) == 0),
                  "SafeERC20: approve from non-zero to non-zero allowance"
              );
              _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
          }
          /**
           * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
           * non-reverting calls are assumed to be successful.
           */
          function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
              uint256 oldAllowance = token.allowance(address(this), spender);
              _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
          }
          /**
           * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
           * non-reverting calls are assumed to be successful.
           */
          function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
              unchecked {
                  uint256 oldAllowance = token.allowance(address(this), spender);
                  require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                  _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
              }
          }
          /**
           * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
           * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
           * to be set to zero before setting it to a non-zero value, such as USDT.
           */
          function forceApprove(IERC20 token, address spender, uint256 value) internal {
              bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
              if (!_callOptionalReturnBool(token, approvalCall)) {
                  _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
                  _callOptionalReturn(token, approvalCall);
              }
          }
          /**
           * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
           * Revert on invalid signature.
           */
          function safePermit(
              IERC20Permit token,
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal {
              uint256 nonceBefore = token.nonces(owner);
              token.permit(owner, spender, value, deadline, v, r, s);
              uint256 nonceAfter = token.nonces(owner);
              require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
          }
          /**
           * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
           * on the return value: the return value is optional (but if data is returned, it must not be false).
           * @param token The token targeted by the call.
           * @param data The call data (encoded using abi.encode or one of its variants).
           */
          function _callOptionalReturn(IERC20 token, bytes memory data) private {
              // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
              // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
              // the target address contains contract code and also asserts for success in the low-level call.
              bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
              require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
          }
          /**
           * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
           * on the return value: the return value is optional (but if data is returned, it must not be false).
           * @param token The token targeted by the call.
           * @param data The call data (encoded using abi.encode or one of its variants).
           *
           * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
           */
          function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
              // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
              // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
              // and not revert is the subcall reverts.
              (bool success, bytes memory returndata) = address(token).call(data);
              return
                  success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
      pragma solidity ^0.8.1;
      /**
       * @dev Collection of functions related to the address type
       */
      library Address {
          /**
           * @dev Returns true if `account` is a contract.
           *
           * [IMPORTANT]
           * ====
           * It is unsafe to assume that an address for which this function returns
           * false is an externally-owned account (EOA) and not a contract.
           *
           * Among others, `isContract` will return false for the following
           * types of addresses:
           *
           *  - an externally-owned account
           *  - a contract in construction
           *  - an address where a contract will be created
           *  - an address where a contract lived, but was destroyed
           *
           * Furthermore, `isContract` will also return true if the target contract within
           * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
           * which only has an effect at the end of a transaction.
           * ====
           *
           * [IMPORTANT]
           * ====
           * You shouldn't rely on `isContract` to protect against flash loan attacks!
           *
           * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
           * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
           * constructor.
           * ====
           */
          function isContract(address account) internal view returns (bool) {
              // This method relies on extcodesize/address.code.length, which returns 0
              // for contracts in construction, since the code is only stored at the end
              // of the constructor execution.
              return account.code.length > 0;
          }
          /**
           * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
           * `recipient`, forwarding all available gas and reverting on errors.
           *
           * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
           * of certain opcodes, possibly making contracts go over the 2300 gas limit
           * imposed by `transfer`, making them unable to receive funds via
           * `transfer`. {sendValue} removes this limitation.
           *
           * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
           *
           * IMPORTANT: because control is transferred to `recipient`, care must be
           * taken to not create reentrancy vulnerabilities. Consider using
           * {ReentrancyGuard} or the
           * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
           */
          function sendValue(address payable recipient, uint256 amount) internal {
              require(address(this).balance >= amount, "Address: insufficient balance");
              (bool success, ) = recipient.call{value: amount}("");
              require(success, "Address: unable to send value, recipient may have reverted");
          }
          /**
           * @dev Performs a Solidity function call using a low level `call`. A
           * plain `call` is an unsafe replacement for a function call: use this
           * function instead.
           *
           * If `target` reverts with a revert reason, it is bubbled up by this
           * function (like regular Solidity function calls).
           *
           * Returns the raw returned data. To convert to the expected return value,
           * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
           *
           * Requirements:
           *
           * - `target` must be a contract.
           * - calling `target` with `data` must not revert.
           *
           * _Available since v3.1._
           */
          function functionCall(address target, bytes memory data) internal returns (bytes memory) {
              return functionCallWithValue(target, data, 0, "Address: low-level call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
           * `errorMessage` as a fallback revert reason when `target` reverts.
           *
           * _Available since v3.1._
           */
          function functionCall(
              address target,
              bytes memory data,
              string memory errorMessage
          ) internal returns (bytes memory) {
              return functionCallWithValue(target, data, 0, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but also transferring `value` wei to `target`.
           *
           * Requirements:
           *
           * - the calling contract must have an ETH balance of at least `value`.
           * - the called Solidity function must be `payable`.
           *
           * _Available since v3.1._
           */
          function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
              return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
          }
          /**
           * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
           * with `errorMessage` as a fallback revert reason when `target` reverts.
           *
           * _Available since v3.1._
           */
          function functionCallWithValue(
              address target,
              bytes memory data,
              uint256 value,
              string memory errorMessage
          ) internal returns (bytes memory) {
              require(address(this).balance >= value, "Address: insufficient balance for call");
              (bool success, bytes memory returndata) = target.call{value: value}(data);
              return verifyCallResultFromTarget(target, success, returndata, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but performing a static call.
           *
           * _Available since v3.3._
           */
          function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
              return functionStaticCall(target, data, "Address: low-level static call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
           * but performing a static call.
           *
           * _Available since v3.3._
           */
          function functionStaticCall(
              address target,
              bytes memory data,
              string memory errorMessage
          ) internal view returns (bytes memory) {
              (bool success, bytes memory returndata) = target.staticcall(data);
              return verifyCallResultFromTarget(target, success, returndata, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but performing a delegate call.
           *
           * _Available since v3.4._
           */
          function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
              return functionDelegateCall(target, data, "Address: low-level delegate call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
           * but performing a delegate call.
           *
           * _Available since v3.4._
           */
          function functionDelegateCall(
              address target,
              bytes memory data,
              string memory errorMessage
          ) internal returns (bytes memory) {
              (bool success, bytes memory returndata) = target.delegatecall(data);
              return verifyCallResultFromTarget(target, success, returndata, errorMessage);
          }
          /**
           * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
           * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
           *
           * _Available since v4.8._
           */
          function verifyCallResultFromTarget(
              address target,
              bool success,
              bytes memory returndata,
              string memory errorMessage
          ) internal view returns (bytes memory) {
              if (success) {
                  if (returndata.length == 0) {
                      // only check isContract if the call was successful and the return data is empty
                      // otherwise we already know that it was a contract
                      require(isContract(target), "Address: call to non-contract");
                  }
                  return returndata;
              } else {
                  _revert(returndata, errorMessage);
              }
          }
          /**
           * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
           * revert reason or using the provided one.
           *
           * _Available since v4.3._
           */
          function verifyCallResult(
              bool success,
              bytes memory returndata,
              string memory errorMessage
          ) internal pure returns (bytes memory) {
              if (success) {
                  return returndata;
              } else {
                  _revert(returndata, errorMessage);
              }
          }
          function _revert(bytes memory returndata, string memory errorMessage) private pure {
              // Look for revert reason and bubble it up if present
              if (returndata.length > 0) {
                  // The easiest way to bubble the revert reason is using memory via assembly
                  /// @solidity memory-safe-assembly
                  assembly {
                      let returndata_size := mload(returndata)
                      revert(add(32, returndata), returndata_size)
                  }
              } else {
                  revert(errorMessage);
              }
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Provides information about the current execution context, including the
       * sender of the transaction and its data. While these are generally available
       * via msg.sender and msg.data, they should not be accessed in such a direct
       * manner, since when dealing with meta-transactions the account sending and
       * paying for execution may not be the actual sender (as far as an application
       * is concerned).
       *
       * This contract is only required for intermediate, library-like contracts.
       */
      abstract contract Context {
          function _msgSender() internal view virtual returns (address) {
              return msg.sender;
          }
          function _msgData() internal view virtual returns (bytes calldata) {
              return msg.data;
          }
          function _contextSuffixLength() internal view virtual returns (uint256) {
              return 0;
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
      pragma solidity ^0.8.0;
      import "./IERC165.sol";
      /**
       * @dev Implementation of the {IERC165} interface.
       *
       * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
       * for the additional interface id that will be supported. For example:
       *
       * ```solidity
       * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
       *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
       * }
       * ```
       *
       * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
       */
      abstract contract ERC165 is IERC165 {
          /**
           * @dev See {IERC165-supportsInterface}.
           */
          function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
              return interfaceId == type(IERC165).interfaceId;
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Interface of the ERC165 standard, as defined in the
       * https://eips.ethereum.org/EIPS/eip-165[EIP].
       *
       * Implementers can declare support of contract interfaces, which can then be
       * queried by others ({ERC165Checker}).
       *
       * For an implementation, see {ERC165}.
       */
      interface IERC165 {
          /**
           * @dev Returns true if this contract implements the interface defined by
           * `interfaceId`. See the corresponding
           * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
           * to learn more about how these ids are created.
           *
           * This function call must use less than 30 000 gas.
           */
          function supportsInterface(bytes4 interfaceId) external view returns (bool);
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
      import { MessagingFee, MessagingParams, MessagingReceipt, Origin, ILayerZeroEndpointV2 } from "./interfaces/ILayerZeroEndpointV2.sol";
      import { ISendLib, Packet } from "./interfaces/ISendLib.sol";
      import { ILayerZeroReceiver } from "./interfaces/ILayerZeroReceiver.sol";
      import { Errors } from "./libs/Errors.sol";
      import { GUID } from "./libs/GUID.sol";
      import { Transfer } from "./libs/Transfer.sol";
      import { MessagingChannel } from "./MessagingChannel.sol";
      import { MessagingComposer } from "./MessagingComposer.sol";
      import { MessageLibManager } from "./MessageLibManager.sol";
      import { MessagingContext } from "./MessagingContext.sol";
      // LayerZero EndpointV2 is fully backward compatible with LayerZero Endpoint(V1), but it also supports additional
      // features that Endpoint(V1) does not support now and may not in the future. We have also changed some terminology
      // to clarify pre-existing language that might have been confusing.
      //
      // The following is a list of terminology changes:
      //     -chainId -> eid
      //          - Rationale: chainId was a term we initially used to describe an endpoint on a specific chain. Since
      //          LayerZero supports non-EVMs we could not map the classic EVM chainIds to the LayerZero chainIds, making it
      //          confusing for developers. With the addition of EndpointV2 and its backward compatible nature, we would have
      //          two chainIds per chain that has Endpoint(V1), further confusing developers. We have decided to change the
      //          name to Endpoint Id, or eid, for simplicity and clarity.
      //     -adapterParams -> options
      //     -userApplication -> oapp. Omnichain Application
      //     -srcAddress -> sender
      //     -dstAddress -> receiver
      //          - Rationale: The sender/receiver on EVM is the address. However, on non-EVM chains, the sender/receiver could
      //          represented as a public key, or some other identifier. The term sender/receiver is more generic
      //     -payload -> message.
      //          - Rationale: The term payload is used in the context of a packet, which is a combination of the message and GUID
      contract EndpointV2 is ILayerZeroEndpointV2, MessagingChannel, MessageLibManager, MessagingComposer, MessagingContext {
          address public lzToken;
          mapping(address oapp => address delegate) public delegates;
          /// @param _eid the unique Endpoint Id for this deploy that all other Endpoints can use to send to it
          constructor(uint32 _eid, address _owner) MessagingChannel(_eid) {
              _transferOwnership(_owner);
          }
          /// @dev MESSAGING STEP 0
          /// @notice This view function gives the application built on top of LayerZero the ability to requests a quote
          /// with the same parameters as they would to send their message. Since the quotes are given on chain there is a
          /// race condition in which the prices could change between the time the user gets their quote and the time they
          /// submit their message. If the price moves up and the user doesn't send enough funds the transaction will revert,
          /// if the price goes down the _refundAddress provided by the app will be refunded the difference.
          /// @param _params the messaging parameters
          /// @param _sender the sender of the message
          function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory) {
              // lzToken must be set to support payInLzToken
              if (_params.payInLzToken && lzToken == address(0x0)) revert Errors.LZ_LzTokenUnavailable();
              // get the correct outbound nonce
              uint64 nonce = outboundNonce[_sender][_params.dstEid][_params.receiver] + 1;
              // construct the packet with a GUID
              Packet memory packet = Packet({
                  nonce: nonce,
                  srcEid: eid,
                  sender: _sender,
                  dstEid: _params.dstEid,
                  receiver: _params.receiver,
                  guid: GUID.generate(nonce, eid, _sender, _params.dstEid, _params.receiver),
                  message: _params.message
              });
              // get the send library by sender and dst eid
              // use _ to avoid variable shadowing
              address _sendLibrary = getSendLibrary(_sender, _params.dstEid);
              return ISendLib(_sendLibrary).quote(packet, _params.options, _params.payInLzToken);
          }
          /// @dev MESSAGING STEP 1 - OApp need to transfer the fees to the endpoint before sending the message
          /// @param _params the messaging parameters
          /// @param _refundAddress the address to refund both the native and lzToken
          function send(
              MessagingParams calldata _params,
              address _refundAddress
          ) external payable sendContext(_params.dstEid, msg.sender) returns (MessagingReceipt memory) {
              if (_params.payInLzToken && lzToken == address(0x0)) revert Errors.LZ_LzTokenUnavailable();
              // send message
              (MessagingReceipt memory receipt, address _sendLibrary) = _send(msg.sender, _params);
              // OApp can simulate with 0 native value it will fail with error including the required fee, which can be provided in the actual call
              // this trick can be used to avoid the need to write the quote() function
              // however, without the quote view function it will be hard to compose an oapp on chain
              uint256 suppliedNative = _suppliedNative();
              uint256 suppliedLzToken = _suppliedLzToken(_params.payInLzToken);
              _assertMessagingFee(receipt.fee, suppliedNative, suppliedLzToken);
              // handle lz token fees
              _payToken(lzToken, receipt.fee.lzTokenFee, suppliedLzToken, _sendLibrary, _refundAddress);
              // handle native fees
              _payNative(receipt.fee.nativeFee, suppliedNative, _sendLibrary, _refundAddress);
              return receipt;
          }
          /// @dev internal function for sending the messages used by all external send methods
          /// @param _sender the address of the application sending the message to the destination chain
          /// @param _params the messaging parameters
          function _send(
              address _sender,
              MessagingParams calldata _params
          ) internal returns (MessagingReceipt memory, address) {
              // get the correct outbound nonce
              uint64 latestNonce = _outbound(_sender, _params.dstEid, _params.receiver);
              // construct the packet with a GUID
              Packet memory packet = Packet({
                  nonce: latestNonce,
                  srcEid: eid,
                  sender: _sender,
                  dstEid: _params.dstEid,
                  receiver: _params.receiver,
                  guid: GUID.generate(latestNonce, eid, _sender, _params.dstEid, _params.receiver),
                  message: _params.message
              });
              // get the send library by sender and dst eid
              address _sendLibrary = getSendLibrary(_sender, _params.dstEid);
              // messageLib always returns encodedPacket with guid
              (MessagingFee memory fee, bytes memory encodedPacket) = ISendLib(_sendLibrary).send(
                  packet,
                  _params.options,
                  _params.payInLzToken
              );
              // Emit packet information for DVNs, Executors, and any other offchain infrastructure to only listen
              // for this one event to perform their actions.
              emit PacketSent(encodedPacket, _params.options, _sendLibrary);
              return (MessagingReceipt(packet.guid, latestNonce, fee), _sendLibrary);
          }
          /// @dev MESSAGING STEP 2 - on the destination chain
          /// @dev configured receive library verifies a message
          /// @param _origin a struct holding the srcEid, nonce, and sender of the message
          /// @param _receiver the receiver of the message
          /// @param _payloadHash the payload hash of the message
          function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external {
              if (!isValidReceiveLibrary(_receiver, _origin.srcEid, msg.sender)) revert Errors.LZ_InvalidReceiveLibrary();
              uint64 lazyNonce = lazyInboundNonce[_receiver][_origin.srcEid][_origin.sender];
              if (!_initializable(_origin, _receiver, lazyNonce)) revert Errors.LZ_PathNotInitializable();
              if (!_verifiable(_origin, _receiver, lazyNonce)) revert Errors.LZ_PathNotVerifiable();
              // insert the message into the message channel
              _inbound(_receiver, _origin.srcEid, _origin.sender, _origin.nonce, _payloadHash);
              emit PacketVerified(_origin, _receiver, _payloadHash);
          }
          /// @dev MESSAGING STEP 3 - the last step
          /// @dev execute a verified message to the designated receiver
          /// @dev the execution provides the execution context (caller, extraData) to the receiver. the receiver can optionally assert the caller and validate the untrusted extraData
          /// @dev cant reentrant because the payload is cleared before execution
          /// @param _origin the origin of the message
          /// @param _receiver the receiver of the message
          /// @param _guid the guid of the message
          /// @param _message the message
          /// @param _extraData the extra data provided by the executor. this data is untrusted and should be validated.
          function lzReceive(
              Origin calldata _origin,
              address _receiver,
              bytes32 _guid,
              bytes calldata _message,
              bytes calldata _extraData
          ) external payable {
              // clear the payload first to prevent reentrancy, and then execute the message
              _clearPayload(_receiver, _origin.srcEid, _origin.sender, _origin.nonce, abi.encodePacked(_guid, _message));
              ILayerZeroReceiver(_receiver).lzReceive{ value: msg.value }(_origin, _guid, _message, msg.sender, _extraData);
              emit PacketDelivered(_origin, _receiver);
          }
          /// @param _origin the origin of the message
          /// @param _receiver the receiver of the message
          /// @param _guid the guid of the message
          /// @param _message the message
          /// @param _extraData the extra data provided by the executor.
          /// @param _reason the reason for failure
          function lzReceiveAlert(
              Origin calldata _origin,
              address _receiver,
              bytes32 _guid,
              uint256 _gas,
              uint256 _value,
              bytes calldata _message,
              bytes calldata _extraData,
              bytes calldata _reason
          ) external {
              emit LzReceiveAlert(_receiver, msg.sender, _origin, _guid, _gas, _value, _message, _extraData, _reason);
          }
          /// @dev Oapp uses this interface to clear a message.
          /// @dev this is a PULL mode versus the PUSH mode of lzReceive
          /// @dev the cleared message can be ignored by the app (effectively burnt)
          /// @dev authenticated by oapp
          /// @param _origin the origin of the message
          /// @param _guid the guid of the message
          /// @param _message the message
          function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external {
              _assertAuthorized(_oapp);
              bytes memory payload = abi.encodePacked(_guid, _message);
              _clearPayload(_oapp, _origin.srcEid, _origin.sender, _origin.nonce, payload);
              emit PacketDelivered(_origin, _oapp);
          }
          /// @dev allows reconfiguration to recover from wrong configurations
          /// @dev users should never approve the EndpointV2 contract to spend their non-layerzero tokens
          /// @dev override this function if the endpoint is charging ERC20 tokens as native
          /// @dev only owner
          /// @param _lzToken the new layer zero token address
          function setLzToken(address _lzToken) public virtual onlyOwner {
              lzToken = _lzToken;
              emit LzTokenSet(_lzToken);
          }
          /// @dev recover the token sent to this contract by mistake
          /// @dev only owner
          /// @param _token the token to recover. if 0x0 then it is native token
          /// @param _to the address to send the token to
          /// @param _amount the amount to send
          function recoverToken(address _token, address _to, uint256 _amount) external onlyOwner {
              Transfer.nativeOrToken(_token, _to, _amount);
          }
          /// @dev handling token payments on endpoint. the sender must approve the endpoint to spend the token
          /// @dev internal function
          /// @param _token the token to pay
          /// @param _required the amount required
          /// @param _supplied the amount supplied
          /// @param _receiver the receiver of the token
          function _payToken(
              address _token,
              uint256 _required,
              uint256 _supplied,
              address _receiver,
              address _refundAddress
          ) internal {
              if (_required > 0) {
                  Transfer.token(_token, _receiver, _required);
              }
              if (_required < _supplied) {
                  unchecked {
                      // refund the excess
                      Transfer.token(_token, _refundAddress, _supplied - _required);
                  }
              }
          }
          /// @dev handling native token payments on endpoint
          /// @dev override this if the endpoint is charging ERC20 tokens as native
          /// @dev internal function
          /// @param _required the amount required
          /// @param _supplied the amount supplied
          /// @param _receiver the receiver of the native token
          /// @param _refundAddress the address to refund the excess to
          function _payNative(
              uint256 _required,
              uint256 _supplied,
              address _receiver,
              address _refundAddress
          ) internal virtual {
              if (_required > 0) {
                  Transfer.native(_receiver, _required);
              }
              if (_required < _supplied) {
                  unchecked {
                      // refund the excess
                      Transfer.native(_refundAddress, _supplied - _required);
                  }
              }
          }
          /// @dev get the balance of the lzToken as the supplied lzToken fee if payInLzToken is true
          function _suppliedLzToken(bool _payInLzToken) internal view returns (uint256 supplied) {
              if (_payInLzToken) {
                  supplied = IERC20(lzToken).balanceOf(address(this));
                  // if payInLzToken is true, the supplied fee must be greater than 0 to prevent a race condition
                  // in which an oapp sending a message with lz token and the lz token is set to a new token between the tx
                  // being sent and the tx being mined. if the required lz token fee is 0 and the old lz token would be
                  // locked in the contract instead of being refunded
                  if (supplied == 0) revert Errors.LZ_ZeroLzTokenFee();
              }
          }
          /// @dev override this if the endpoint is charging ERC20 tokens as native
          function _suppliedNative() internal view virtual returns (uint256) {
              return msg.value;
          }
          /// @dev Assert the required fees and the supplied fees are enough
          function _assertMessagingFee(
              MessagingFee memory _required,
              uint256 _suppliedNativeFee,
              uint256 _suppliedLzTokenFee
          ) internal pure {
              if (_required.nativeFee > _suppliedNativeFee || _required.lzTokenFee > _suppliedLzTokenFee) {
                  revert Errors.LZ_InsufficientFee(
                      _required.nativeFee,
                      _suppliedNativeFee,
                      _required.lzTokenFee,
                      _suppliedLzTokenFee
                  );
              }
          }
          /// @dev override this if the endpoint is charging ERC20 tokens as native
          /// @return 0x0 if using native. otherwise the address of the native ERC20 token
          function nativeToken() external view virtual returns (address) {
              return address(0x0);
          }
          /// @notice delegate is authorized by the oapp to configure anything in layerzero
          function setDelegate(address _delegate) external {
              delegates[msg.sender] = _delegate;
              emit DelegateSet(msg.sender, _delegate);
          }
          // ========================= Internal =========================
          function _initializable(
              Origin calldata _origin,
              address _receiver,
              uint64 _lazyInboundNonce
          ) internal view returns (bool) {
              return
                  _lazyInboundNonce > 0 || // allowInitializePath already checked
                  ILayerZeroReceiver(_receiver).allowInitializePath(_origin);
          }
          /// @dev bytes(0) payloadHash can never be submitted
          function _verifiable(
              Origin calldata _origin,
              address _receiver,
              uint64 _lazyInboundNonce
          ) internal view returns (bool) {
              return
                  _origin.nonce > _lazyInboundNonce || // either initializing an empty slot or reverifying
                  inboundPayloadHash[_receiver][_origin.srcEid][_origin.sender][_origin.nonce] != EMPTY_PAYLOAD_HASH; // only allow reverifying if it hasn't been executed
          }
          /// @dev assert the caller to either be the oapp or the delegate
          function _assertAuthorized(address _oapp) internal view override(MessagingChannel, MessageLibManager) {
              if (msg.sender != _oapp && msg.sender != delegates[_oapp]) revert Errors.LZ_Unauthorized();
          }
          // ========================= VIEW FUNCTIONS FOR OFFCHAIN ONLY =========================
          // Not involved in any state transition function.
          // ====================================================================================
          function initializable(Origin calldata _origin, address _receiver) external view returns (bool) {
              return _initializable(_origin, _receiver, lazyInboundNonce[_receiver][_origin.srcEid][_origin.sender]);
          }
          function verifiable(Origin calldata _origin, address _receiver) external view returns (bool) {
              return _verifiable(_origin, _receiver, lazyInboundNonce[_receiver][_origin.srcEid][_origin.sender]);
          }
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
      import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
      import { IMessageLib, MessageLibType } from "./interfaces/IMessageLib.sol";
      import { IMessageLibManager, SetConfigParam } from "./interfaces/IMessageLibManager.sol";
      import { Errors } from "./libs/Errors.sol";
      import { BlockedMessageLib } from "./messagelib/BlockedMessageLib.sol";
      abstract contract MessageLibManager is Ownable, IMessageLibManager {
          address private constant DEFAULT_LIB = address(0);
          // the library that reverts both on send and quote
          // must be configured on construction and be immutable
          address public immutable blockedLibrary;
          // only registered libraries all valid libraries
          // the blockedLibrary will be registered on construction
          address[] internal registeredLibraries;
          mapping(address lib => bool) public isRegisteredLibrary;
          // both sendLibrary and receiveLibrary config can be lazily resolved
          mapping(address sender => mapping(uint32 dstEid => address lib)) internal sendLibrary;
          mapping(address receiver => mapping(uint32 srcEid => address lib)) internal receiveLibrary;
          mapping(address receiver => mapping(uint32 srcEid => Timeout)) public receiveLibraryTimeout;
          mapping(uint32 dstEid => address lib) public defaultSendLibrary;
          mapping(uint32 srcEid => address lib) public defaultReceiveLibrary;
          mapping(uint32 srcEid => Timeout) public defaultReceiveLibraryTimeout;
          constructor() {
              blockedLibrary = address(new BlockedMessageLib());
              registerLibrary(blockedLibrary);
          }
          modifier onlyRegistered(address _lib) {
              if (!isRegisteredLibrary[_lib]) revert Errors.LZ_OnlyRegisteredLib();
              _;
          }
          modifier isSendLib(address _lib) {
              if (_lib != DEFAULT_LIB) {
                  if (IMessageLib(_lib).messageLibType() == MessageLibType.Receive) revert Errors.LZ_OnlySendLib();
              }
              _;
          }
          modifier isReceiveLib(address _lib) {
              if (_lib != DEFAULT_LIB) {
                  if (IMessageLib(_lib).messageLibType() == MessageLibType.Send) revert Errors.LZ_OnlyReceiveLib();
              }
              _;
          }
          modifier onlyRegisteredOrDefault(address _lib) {
              if (!isRegisteredLibrary[_lib] && _lib != DEFAULT_LIB) revert Errors.LZ_OnlyRegisteredOrDefaultLib();
              _;
          }
          /// @dev check if the library supported the eid.
          modifier onlySupportedEid(address _lib, uint32 _eid) {
              /// @dev doesnt need to check for default lib, because when they are initially added they get passed through this modifier
              if (_lib != DEFAULT_LIB) {
                  if (!IMessageLib(_lib).isSupportedEid(_eid)) revert Errors.LZ_UnsupportedEid();
              }
              _;
          }
          function getRegisteredLibraries() external view returns (address[] memory) {
              return registeredLibraries;
          }
          /// @notice The Send Library is the Oapp specified library that will be used to send the message to the destination
          /// endpoint. If the Oapp does not specify a Send Library, the default Send Library will be used.
          /// @dev If the Oapp does not have a selected Send Library, this function will resolve to the default library
          /// configured by LayerZero
          /// @return lib address of the Send Library
          /// @param _sender The address of the Oapp that is sending the message
          /// @param _dstEid The destination endpoint id
          function getSendLibrary(address _sender, uint32 _dstEid) public view returns (address lib) {
              lib = sendLibrary[_sender][_dstEid];
              if (lib == DEFAULT_LIB) {
                  lib = defaultSendLibrary[_dstEid];
                  if (lib == address(0x0)) revert Errors.LZ_DefaultSendLibUnavailable();
              }
          }
          function isDefaultSendLibrary(address _sender, uint32 _dstEid) public view returns (bool) {
              return sendLibrary[_sender][_dstEid] == DEFAULT_LIB;
          }
          /// @dev the receiveLibrary can be lazily resolved that if not set it will point to the default configured by LayerZero
          function getReceiveLibrary(address _receiver, uint32 _srcEid) public view returns (address lib, bool isDefault) {
              lib = receiveLibrary[_receiver][_srcEid];
              if (lib == DEFAULT_LIB) {
                  lib = defaultReceiveLibrary[_srcEid];
                  if (lib == address(0x0)) revert Errors.LZ_DefaultReceiveLibUnavailable();
                  isDefault = true;
              }
          }
          /// @dev called when the endpoint checks if the msgLib attempting to verify the msg is the configured msgLib of the Oapp
          /// @dev this check provides the ability for Oapp to lock in a trusted msgLib
          /// @dev it will fist check if the msgLib is the currently configured one. then check if the msgLib is the one in grace period of msgLib versioning upgrade
          function isValidReceiveLibrary(
              address _receiver,
              uint32 _srcEid,
              address _actualReceiveLib
          ) public view returns (bool) {
              // early return true if the _actualReceiveLib is the currently configured one
              (address expectedReceiveLib, bool isDefault) = getReceiveLibrary(_receiver, _srcEid);
              if (_actualReceiveLib == expectedReceiveLib) {
                  return true;
              }
              // check the timeout condition otherwise
              // if the Oapp is using defaultReceiveLibrary, use the default Timeout config
              // otherwise, use the Timeout configured by the Oapp
              Timeout memory timeout = isDefault
                  ? defaultReceiveLibraryTimeout[_srcEid]
                  : receiveLibraryTimeout[_receiver][_srcEid];
              // requires the _actualReceiveLib to be the same as the one in grace period and the grace period has not expired
              // block.number is uint256 so timeout.expiry must > 0, which implies a non-ZERO value
              if (timeout.lib == _actualReceiveLib && timeout.expiry > block.number) {
                  // timeout lib set and has not expired
                  return true;
              }
              // returns false by default
              return false;
          }
          //------- Owner interfaces
          /// @dev all libraries have to implement the erc165 interface to prevent wrong configurations
          /// @dev only owner
          function registerLibrary(address _lib) public onlyOwner {
              // must have the right interface
              if (!IERC165(_lib).supportsInterface(type(IMessageLib).interfaceId)) revert Errors.LZ_UnsupportedInterface();
              // must have not been registered
              if (isRegisteredLibrary[_lib]) revert Errors.LZ_AlreadyRegistered();
              // insert into both the map and the list
              isRegisteredLibrary[_lib] = true;
              registeredLibraries.push(_lib);
              emit LibraryRegistered(_lib);
          }
          /// @dev owner setting the defaultSendLibrary
          /// @dev can set to the blockedLibrary, which is a registered library
          /// @dev the msgLib must enable the support before they can be registered to the endpoint as the default
          /// @dev only owner
          function setDefaultSendLibrary(
              uint32 _eid,
              address _newLib
          ) external onlyOwner onlyRegistered(_newLib) isSendLib(_newLib) onlySupportedEid(_newLib, _eid) {
              // must provide a different value
              if (defaultSendLibrary[_eid] == _newLib) revert Errors.LZ_SameValue();
              defaultSendLibrary[_eid] = _newLib;
              emit DefaultSendLibrarySet(_eid, _newLib);
          }
          /// @dev owner setting the defaultSendLibrary
          /// @dev must be a registered library (including blockLibrary) with the eid support enabled
          /// @dev in version migration, it can add a grace period to the old library. if the grace period is 0, it will delete the timeout configuration.
          /// @dev only owner
          function setDefaultReceiveLibrary(
              uint32 _eid,
              address _newLib,
              uint256 _gracePeriod
          ) external onlyOwner onlyRegistered(_newLib) isReceiveLib(_newLib) onlySupportedEid(_newLib, _eid) {
              address oldLib = defaultReceiveLibrary[_eid];
              // must provide a different value
              if (oldLib == _newLib) revert Errors.LZ_SameValue();
              defaultReceiveLibrary[_eid] = _newLib;
              emit DefaultReceiveLibrarySet(_eid, _newLib);
              if (_gracePeriod > 0) {
                  // override the current default timeout to the [old_lib + new expiry]
                  Timeout storage timeout = defaultReceiveLibraryTimeout[_eid];
                  timeout.lib = oldLib;
                  timeout.expiry = block.number + _gracePeriod;
                  emit DefaultReceiveLibraryTimeoutSet(_eid, oldLib, timeout.expiry);
              } else {
                  // otherwise, remove the old configuration.
                  delete defaultReceiveLibraryTimeout[_eid];
                  emit DefaultReceiveLibraryTimeoutSet(_eid, oldLib, 0);
              }
          }
          /// @dev owner setting the defaultSendLibrary
          /// @dev must be a registered library (including blockLibrary) with the eid support enabled
          /// @dev can used to (1) extend the current configuration (2) force remove the current configuration (3) change to a new configuration
          /// @param _expiry the block number when lib expires
          function setDefaultReceiveLibraryTimeout(
              uint32 _eid,
              address _lib,
              uint256 _expiry
          ) external onlyRegistered(_lib) isReceiveLib(_lib) onlySupportedEid(_lib, _eid) onlyOwner {
              if (_expiry == 0) {
                  // force remove the current configuration
                  delete defaultReceiveLibraryTimeout[_eid];
              } else {
                  // override it with new configuration
                  if (_expiry <= block.number) revert Errors.LZ_InvalidExpiry();
                  Timeout storage timeout = defaultReceiveLibraryTimeout[_eid];
                  timeout.lib = _lib;
                  timeout.expiry = _expiry;
              }
              emit DefaultReceiveLibraryTimeoutSet(_eid, _lib, _expiry);
          }
          /// @dev returns true only if both the default send/receive libraries are set
          function isSupportedEid(uint32 _eid) external view returns (bool) {
              return defaultSendLibrary[_eid] != address(0) && defaultReceiveLibrary[_eid] != address(0);
          }
          //------- OApp interfaces
          /// @dev Oapp setting the sendLibrary
          /// @dev must be a registered library (including blockLibrary) with the eid support enabled
          /// @dev authenticated by the Oapp
          function setSendLibrary(
              address _oapp,
              uint32 _eid,
              address _newLib
          ) external onlyRegisteredOrDefault(_newLib) isSendLib(_newLib) onlySupportedEid(_newLib, _eid) {
              _assertAuthorized(_oapp);
              // must provide a different value
              if (sendLibrary[_oapp][_eid] == _newLib) revert Errors.LZ_SameValue();
              sendLibrary[_oapp][_eid] = _newLib;
              emit SendLibrarySet(_oapp, _eid, _newLib);
          }
          /// @dev Oapp setting the receiveLibrary
          /// @dev must be a registered library (including blockLibrary) with the eid support enabled
          /// @dev in version migration, it can add a grace period to the old library. if the grace period is 0, it will delete the timeout configuration.
          /// @dev authenticated by the Oapp
          /// @param _gracePeriod the number of blocks from now until oldLib expires
          function setReceiveLibrary(
              address _oapp,
              uint32 _eid,
              address _newLib,
              uint256 _gracePeriod
          ) external onlyRegisteredOrDefault(_newLib) isReceiveLib(_newLib) onlySupportedEid(_newLib, _eid) {
              _assertAuthorized(_oapp);
              address oldLib = receiveLibrary[_oapp][_eid];
              // must provide new values
              if (oldLib == _newLib) revert Errors.LZ_SameValue();
              receiveLibrary[_oapp][_eid] = _newLib;
              emit ReceiveLibrarySet(_oapp, _eid, _newLib);
              if (_gracePeriod > 0) {
                  // to simplify the logic, we only allow to set timeout if neither the new lib nor old lib is DEFAULT_LIB, which would should read the default timeout configurations
                  // (1) if the Oapp wants to fall back to the DEFAULT, then set the newLib to DEFAULT with grace period == 0
                  // (2) if the Oapp wants to change to a non DEFAULT from DEFAULT, then set the newLib to 'non-default' with _gracePeriod == 0, then use setReceiveLibraryTimeout() interface
                  if (oldLib == DEFAULT_LIB || _newLib == DEFAULT_LIB) revert Errors.LZ_OnlyNonDefaultLib();
                  // write to storage
                  Timeout memory timeout = Timeout({ lib: oldLib, expiry: block.number + _gracePeriod });
                  receiveLibraryTimeout[_oapp][_eid] = timeout;
                  emit ReceiveLibraryTimeoutSet(_oapp, _eid, oldLib, timeout.expiry);
              } else {
                  delete receiveLibraryTimeout[_oapp][_eid];
                  emit ReceiveLibraryTimeoutSet(_oapp, _eid, oldLib, 0);
              }
          }
          /// @dev Oapp setting the defaultSendLibrary
          /// @dev must be a registered library (including blockLibrary) with the eid support enabled
          /// @dev can used to (1) extend the current configuration (2)  force remove the current configuration (3) change to a new configuration
          /// @param _expiry the block number when lib expires
          function setReceiveLibraryTimeout(
              address _oapp,
              uint32 _eid,
              address _lib,
              uint256 _expiry
          ) external onlyRegistered(_lib) isReceiveLib(_lib) onlySupportedEid(_lib, _eid) {
              _assertAuthorized(_oapp);
              (, bool isDefault) = getReceiveLibrary(_oapp, _eid);
              // if current library is DEFAULT, Oapp cant set the timeout
              if (isDefault) revert Errors.LZ_OnlyNonDefaultLib();
              if (_expiry == 0) {
                  // force remove the current configuration
                  delete receiveLibraryTimeout[_oapp][_eid];
              } else {
                  // override it with new configuration
                  if (_expiry <= block.number) revert Errors.LZ_InvalidExpiry();
                  Timeout storage timeout = receiveLibraryTimeout[_oapp][_eid];
                  timeout.lib = _lib;
                  timeout.expiry = _expiry;
              }
              emit ReceiveLibraryTimeoutSet(_oapp, _eid, _lib, _expiry);
          }
          //------- library config setter/getter. all pass-through functions to the msgLib
          /// @dev authenticated by the _oapp
          function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external onlyRegistered(_lib) {
              _assertAuthorized(_oapp);
              IMessageLib(_lib).setConfig(_oapp, _params);
          }
          /// @dev a view function to query the current configuration of the OApp
          function getConfig(
              address _oapp,
              address _lib,
              uint32 _eid,
              uint32 _configType
          ) external view onlyRegistered(_lib) returns (bytes memory config) {
              return IMessageLib(_lib).getConfig(_eid, _oapp, _configType);
          }
          function _assertAuthorized(address _oapp) internal virtual;
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { IMessagingChannel } from "./interfaces/IMessagingChannel.sol";
      import { Errors } from "./libs/Errors.sol";
      import { GUID } from "./libs/GUID.sol";
      abstract contract MessagingChannel is IMessagingChannel {
          bytes32 public constant EMPTY_PAYLOAD_HASH = bytes32(0);
          bytes32 public constant NIL_PAYLOAD_HASH = bytes32(type(uint256).max);
          // The universally unique id (UUID) of this deployed Endpoint
          uint32 public immutable eid;
          mapping(address receiver => mapping(uint32 srcEid => mapping(bytes32 sender => uint64 nonce)))
              public lazyInboundNonce;
          mapping(address receiver => mapping(uint32 srcEid => mapping(bytes32 sender => mapping(uint64 inboundNonce => bytes32 payloadHash))))
              public inboundPayloadHash;
          mapping(address sender => mapping(uint32 dstEid => mapping(bytes32 receiver => uint64 nonce))) public outboundNonce;
          /// @param _eid is the universally unique id (UUID) of this deployed Endpoint
          constructor(uint32 _eid) {
              eid = _eid;
          }
          /// @dev increase and return the next outbound nonce
          function _outbound(address _sender, uint32 _dstEid, bytes32 _receiver) internal returns (uint64 nonce) {
              unchecked {
                  nonce = ++outboundNonce[_sender][_dstEid][_receiver];
              }
          }
          /// @dev inbound won't update the nonce eagerly to allow unordered verification
          /// @dev instead, it will update the nonce lazily when the message is received
          /// @dev messages can only be cleared in order to preserve censorship-resistance
          function _inbound(
              address _receiver,
              uint32 _srcEid,
              bytes32 _sender,
              uint64 _nonce,
              bytes32 _payloadHash
          ) internal {
              if (_payloadHash == EMPTY_PAYLOAD_HASH) revert Errors.LZ_InvalidPayloadHash();
              inboundPayloadHash[_receiver][_srcEid][_sender][_nonce] = _payloadHash;
          }
          /// @dev returns the max index of the longest gapless sequence of verified msg nonces.
          /// @dev the uninitialized value is 0. the first nonce is always 1
          /// @dev it starts from the lazyInboundNonce (last checkpoint) and iteratively check if the next nonce has been verified
          /// @dev this function can OOG if too many backlogs, but it can be trivially fixed by just clearing some prior messages
          /// @dev NOTE: Oapp explicitly skipped nonces count as "verified" for these purposes
          /// @dev eg. [1,2,3,4,6,7] => 4, [1,2,6,8,10] => 2, [1,3,4,5,6] => 1
          function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) public view returns (uint64) {
              uint64 nonceCursor = lazyInboundNonce[_receiver][_srcEid][_sender];
              // find the effective inbound currentNonce
              unchecked {
                  while (_hasPayloadHash(_receiver, _srcEid, _sender, nonceCursor + 1)) {
                      ++nonceCursor;
                  }
              }
              return nonceCursor;
          }
          /// @dev checks if the storage slot is not initialized. Assumes computationally infeasible that payload can hash to 0
          function _hasPayloadHash(
              address _receiver,
              uint32 _srcEid,
              bytes32 _sender,
              uint64 _nonce
          ) internal view returns (bool) {
              return inboundPayloadHash[_receiver][_srcEid][_sender][_nonce] != EMPTY_PAYLOAD_HASH;
          }
          /// @dev the caller must provide _nonce to prevent skipping the unintended nonce
          /// @dev it could happen in some race conditions, e.g. to skip nonce 3, but nonce 3 was consumed first
          /// @dev usage: skipping the next nonce to prevent message verification, e.g. skip a message when Precrime throws alerts
          /// @dev if the Oapp wants to skip a verified message, it should call the clear() function instead
          /// @dev after skipping, the lazyInboundNonce is set to the provided nonce, which makes the inboundNonce also the provided nonce
          /// @dev ie. allows the Oapp to increment the lazyInboundNonce without having had that corresponding msg be verified
          function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external {
              _assertAuthorized(_oapp);
              if (_nonce != inboundNonce(_oapp, _srcEid, _sender) + 1) revert Errors.LZ_InvalidNonce(_nonce);
              lazyInboundNonce[_oapp][_srcEid][_sender] = _nonce;
              emit InboundNonceSkipped(_srcEid, _sender, _oapp, _nonce);
          }
          /// @dev Marks a packet as verified, but disallows execution until it is re-verified.
          /// @dev Reverts if the provided _payloadHash does not match the currently verified payload hash.
          /// @dev A non-verified nonce can be nilified by passing EMPTY_PAYLOAD_HASH for _payloadHash.
          /// @dev Assumes the computational intractability of finding a payload that hashes to bytes32.max.
          /// @dev Authenticated by the caller
          function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external {
              _assertAuthorized(_oapp);
              bytes32 curPayloadHash = inboundPayloadHash[_oapp][_srcEid][_sender][_nonce];
              if (curPayloadHash != _payloadHash) revert Errors.LZ_PayloadHashNotFound(curPayloadHash, _payloadHash);
              if (_nonce <= lazyInboundNonce[_oapp][_srcEid][_sender] && curPayloadHash == EMPTY_PAYLOAD_HASH)
                  revert Errors.LZ_InvalidNonce(_nonce);
              // set it to nil
              inboundPayloadHash[_oapp][_srcEid][_sender][_nonce] = NIL_PAYLOAD_HASH;
              emit PacketNilified(_srcEid, _sender, _oapp, _nonce, _payloadHash);
          }
          /// @dev Marks a nonce as unexecutable and un-verifiable. The nonce can never be re-verified or executed.
          /// @dev Reverts if the provided _payloadHash does not match the currently verified payload hash.
          /// @dev Only packets with nonces less than or equal to the lazy inbound nonce can be burned.
          /// @dev Reverts if the nonce has already been executed.
          /// @dev Authenticated by the caller
          function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external {
              _assertAuthorized(_oapp);
              bytes32 curPayloadHash = inboundPayloadHash[_oapp][_srcEid][_sender][_nonce];
              if (curPayloadHash != _payloadHash) revert Errors.LZ_PayloadHashNotFound(curPayloadHash, _payloadHash);
              if (curPayloadHash == EMPTY_PAYLOAD_HASH || _nonce > lazyInboundNonce[_oapp][_srcEid][_sender])
                  revert Errors.LZ_InvalidNonce(_nonce);
              delete inboundPayloadHash[_oapp][_srcEid][_sender][_nonce];
              emit PacketBurnt(_srcEid, _sender, _oapp, _nonce, _payloadHash);
          }
          /// @dev calling this function will clear the stored message and increment the lazyInboundNonce to the provided nonce
          /// @dev if a lot of messages are queued, the messages can be cleared with a smaller step size to prevent OOG
          /// @dev NOTE: this function does not change inboundNonce, it only changes the lazyInboundNonce up to the provided nonce
          function _clearPayload(
              address _receiver,
              uint32 _srcEid,
              bytes32 _sender,
              uint64 _nonce,
              bytes memory _payload
          ) internal returns (bytes32 actualHash) {
              uint64 currentNonce = lazyInboundNonce[_receiver][_srcEid][_sender];
              if (_nonce > currentNonce) {
                  unchecked {
                      // try to lazily update the inboundNonce till the _nonce
                      for (uint64 i = currentNonce + 1; i <= _nonce; ++i) {
                          if (!_hasPayloadHash(_receiver, _srcEid, _sender, i)) revert Errors.LZ_InvalidNonce(i);
                      }
                      lazyInboundNonce[_receiver][_srcEid][_sender] = _nonce;
                  }
              }
              // check the hash of the payload to verify the executor has given the proper payload that has been verified
              actualHash = keccak256(_payload);
              bytes32 expectedHash = inboundPayloadHash[_receiver][_srcEid][_sender][_nonce];
              if (expectedHash != actualHash) revert Errors.LZ_PayloadHashNotFound(expectedHash, actualHash);
              // remove it from the storage
              delete inboundPayloadHash[_receiver][_srcEid][_sender][_nonce];
          }
          /// @dev returns the GUID for the next message given the path
          /// @dev the Oapp might want to include the GUID into the message in some cases
          function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32) {
              uint64 nextNonce = outboundNonce[_sender][_dstEid][_receiver] + 1;
              return GUID.generate(nextNonce, eid, _sender, _dstEid, _receiver);
          }
          function _assertAuthorized(address _oapp) internal virtual;
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { IMessagingComposer } from "./interfaces/IMessagingComposer.sol";
      import { ILayerZeroComposer } from "./interfaces/ILayerZeroComposer.sol";
      import { Errors } from "./libs/Errors.sol";
      abstract contract MessagingComposer is IMessagingComposer {
          bytes32 private constant NO_MESSAGE_HASH = bytes32(0);
          bytes32 private constant RECEIVED_MESSAGE_HASH = bytes32(uint256(1));
          mapping(address from => mapping(address to => mapping(bytes32 guid => mapping(uint16 index => bytes32 messageHash))))
              public composeQueue;
          /// @dev the Oapp sends the lzCompose message to the endpoint
          /// @dev the composer MUST assert the sender because anyone can send compose msg with this function
          /// @dev with the same GUID, the Oapp can send compose to multiple _composer at the same time
          /// @dev authenticated by the msg.sender
          /// @param _to the address which will receive the composed message
          /// @param _guid the message guid
          /// @param _message the message
          function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external {
              // must have not been sent before
              if (composeQueue[msg.sender][_to][_guid][_index] != NO_MESSAGE_HASH) revert Errors.LZ_ComposeExists();
              composeQueue[msg.sender][_to][_guid][_index] = keccak256(_message);
              emit ComposeSent(msg.sender, _to, _guid, _index, _message);
          }
          /// @dev execute a composed messages from the sender to the composer (receiver)
          /// @dev the execution provides the execution context (caller, extraData) to the receiver.
          ///      the receiver can optionally assert the caller and validate the untrusted extraData
          /// @dev can not re-entrant
          /// @param _from the address which sends the composed message. in most cases, it is the Oapp's address.
          /// @param _to the address which receives the composed message
          /// @param _guid the message guid
          /// @param _message the message
          /// @param _extraData the extra data provided by the executor. this data is untrusted and should be validated.
          function lzCompose(
              address _from,
              address _to,
              bytes32 _guid,
              uint16 _index,
              bytes calldata _message,
              bytes calldata _extraData
          ) external payable {
              // assert the validity
              bytes32 expectedHash = composeQueue[_from][_to][_guid][_index];
              bytes32 actualHash = keccak256(_message);
              if (expectedHash != actualHash) revert Errors.LZ_ComposeNotFound(expectedHash, actualHash);
              // marks the message as received to prevent reentrancy
              // cannot just delete the value, otherwise the message can be sent again and could result in some undefined behaviour
              // even though the sender(composing Oapp) is implicitly fully trusted by the composer.
              // eg. sender may not even realize it has such a bug
              composeQueue[_from][_to][_guid][_index] = RECEIVED_MESSAGE_HASH;
              ILayerZeroComposer(_to).lzCompose{ value: msg.value }(_from, _guid, _message, msg.sender, _extraData);
              emit ComposeDelivered(_from, _to, _guid, _index);
          }
          /// @param _from the address which sends the composed message
          /// @param _to the address which receives the composed message
          /// @param _guid the message guid
          /// @param _message the message
          /// @param _extraData the extra data provided by the executor
          /// @param _reason the reason why the message is not received
          function lzComposeAlert(
              address _from,
              address _to,
              bytes32 _guid,
              uint16 _index,
              uint256 _gas,
              uint256 _value,
              bytes calldata _message,
              bytes calldata _extraData,
              bytes calldata _reason
          ) external {
              emit LzComposeAlert(_from, _to, msg.sender, _guid, _index, _gas, _value, _message, _extraData, _reason);
          }
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { IMessagingContext } from "./interfaces/IMessagingContext.sol";
      import { Errors } from "./libs/Errors.sol";
      /// this contract acts as a non-reentrancy guard and a source of messaging context
      /// the context includes the remote eid and the sender address
      /// it separates the send and receive context to allow messaging receipts (send back on receive())
      abstract contract MessagingContext is IMessagingContext {
          uint256 private constant NOT_ENTERED = 1;
          uint256 private _sendContext = NOT_ENTERED;
          /// @dev the sendContext is set to 8 bytes 0s + 4 bytes eid + 20 bytes sender
          modifier sendContext(uint32 _dstEid, address _sender) {
              if (_sendContext != NOT_ENTERED) revert Errors.LZ_SendReentrancy();
              _sendContext = (uint256(_dstEid) << 160) | uint160(_sender);
              _;
              _sendContext = NOT_ENTERED;
          }
          /// @dev returns true if sending message
          function isSendingMessage() public view returns (bool) {
              return _sendContext != NOT_ENTERED;
          }
          /// @dev returns (eid, sender) if sending message, (0, 0) otherwise
          function getSendContext() external view returns (uint32, address) {
              return isSendingMessage() ? _getSendContext(_sendContext) : (0, address(0));
          }
          function _getSendContext(uint256 _context) internal pure returns (uint32, address) {
              return (uint32(_context >> 160), address(uint160(_context)));
          }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      /**
       * @title ILayerZeroComposer
       */
      interface ILayerZeroComposer {
          /**
           * @notice Composes a LayerZero message from an OApp.
           * @param _from The address initiating the composition, typically the OApp where the lzReceive was called.
           * @param _guid The unique identifier for the corresponding LayerZero src/dst tx.
           * @param _message The composed message payload in bytes. NOT necessarily the same payload passed via lzReceive.
           * @param _executor The address of the executor for the composed message.
           * @param _extraData Additional arbitrary data in bytes passed by the entity who executes the lzCompose.
           */
          function lzCompose(
              address _from,
              bytes32 _guid,
              bytes calldata _message,
              address _executor,
              bytes calldata _extraData
          ) external payable;
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      import { IMessageLibManager } from "./IMessageLibManager.sol";
      import { IMessagingComposer } from "./IMessagingComposer.sol";
      import { IMessagingChannel } from "./IMessagingChannel.sol";
      import { IMessagingContext } from "./IMessagingContext.sol";
      struct MessagingParams {
          uint32 dstEid;
          bytes32 receiver;
          bytes message;
          bytes options;
          bool payInLzToken;
      }
      struct MessagingReceipt {
          bytes32 guid;
          uint64 nonce;
          MessagingFee fee;
      }
      struct MessagingFee {
          uint256 nativeFee;
          uint256 lzTokenFee;
      }
      struct Origin {
          uint32 srcEid;
          bytes32 sender;
          uint64 nonce;
      }
      interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
          event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);
          event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);
          event PacketDelivered(Origin origin, address receiver);
          event LzReceiveAlert(
              address indexed receiver,
              address indexed executor,
              Origin origin,
              bytes32 guid,
              uint256 gas,
              uint256 value,
              bytes message,
              bytes extraData,
              bytes reason
          );
          event LzTokenSet(address token);
          event DelegateSet(address sender, address delegate);
          function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);
          function send(
              MessagingParams calldata _params,
              address _refundAddress
          ) external payable returns (MessagingReceipt memory);
          function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;
          function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);
          function initializable(Origin calldata _origin, address _receiver) external view returns (bool);
          function lzReceive(
              Origin calldata _origin,
              address _receiver,
              bytes32 _guid,
              bytes calldata _message,
              bytes calldata _extraData
          ) external payable;
          // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
          function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;
          function setLzToken(address _lzToken) external;
          function lzToken() external view returns (address);
          function nativeToken() external view returns (address);
          function setDelegate(address _delegate) external;
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      import { Origin } from "./ILayerZeroEndpointV2.sol";
      interface ILayerZeroReceiver {
          function allowInitializePath(Origin calldata _origin) external view returns (bool);
          function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64);
          function lzReceive(
              Origin calldata _origin,
              bytes32 _guid,
              bytes calldata _message,
              address _executor,
              bytes calldata _extraData
          ) external payable;
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
      import { SetConfigParam } from "./IMessageLibManager.sol";
      enum MessageLibType {
          Send,
          Receive,
          SendAndReceive
      }
      interface IMessageLib is IERC165 {
          function setConfig(address _oapp, SetConfigParam[] calldata _config) external;
          function getConfig(uint32 _eid, address _oapp, uint32 _configType) external view returns (bytes memory config);
          function isSupportedEid(uint32 _eid) external view returns (bool);
          // message libs of same major version are compatible
          function version() external view returns (uint64 major, uint8 minor, uint8 endpointVersion);
          function messageLibType() external view returns (MessageLibType);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      struct SetConfigParam {
          uint32 eid;
          uint32 configType;
          bytes config;
      }
      interface IMessageLibManager {
          struct Timeout {
              address lib;
              uint256 expiry;
          }
          event LibraryRegistered(address newLib);
          event DefaultSendLibrarySet(uint32 eid, address newLib);
          event DefaultReceiveLibrarySet(uint32 eid, address newLib);
          event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
          event SendLibrarySet(address sender, uint32 eid, address newLib);
          event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
          event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);
          function registerLibrary(address _lib) external;
          function isRegisteredLibrary(address _lib) external view returns (bool);
          function getRegisteredLibraries() external view returns (address[] memory);
          function setDefaultSendLibrary(uint32 _eid, address _newLib) external;
          function defaultSendLibrary(uint32 _eid) external view returns (address);
          function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _timeout) external;
          function defaultReceiveLibrary(uint32 _eid) external view returns (address);
          function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
          function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
          function isSupportedEid(uint32 _eid) external view returns (bool);
          function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);
          /// ------------------- OApp interfaces -------------------
          function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;
          function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);
          function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);
          function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;
          function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);
          function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external;
          function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
          function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
          function getConfig(
              address _oapp,
              address _lib,
              uint32 _eid,
              uint32 _configType
          ) external view returns (bytes memory config);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      interface IMessagingChannel {
          event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
          event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
          event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
          function eid() external view returns (uint32);
          // this is an emergency function if a message cannot be verified for some reasons
          // required to provide _nextNonce to avoid race condition
          function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;
          function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
          function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
          function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);
          function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
          function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);
          function inboundPayloadHash(
              address _receiver,
              uint32 _srcEid,
              bytes32 _sender,
              uint64 _nonce
          ) external view returns (bytes32);
          function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      interface IMessagingComposer {
          event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);
          event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);
          event LzComposeAlert(
              address indexed from,
              address indexed to,
              address indexed executor,
              bytes32 guid,
              uint16 index,
              uint256 gas,
              uint256 value,
              bytes message,
              bytes extraData,
              bytes reason
          );
          function composeQueue(
              address _from,
              address _to,
              bytes32 _guid,
              uint16 _index
          ) external view returns (bytes32 messageHash);
          function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;
          function lzCompose(
              address _from,
              address _to,
              bytes32 _guid,
              uint16 _index,
              bytes calldata _message,
              bytes calldata _extraData
          ) external payable;
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      interface IMessagingContext {
          function isSendingMessage() external view returns (bool);
          function getSendContext() external view returns (uint32 dstEid, address sender);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.8.0;
      import { MessagingFee } from "./ILayerZeroEndpointV2.sol";
      import { IMessageLib } from "./IMessageLib.sol";
      struct Packet {
          uint64 nonce;
          uint32 srcEid;
          address sender;
          uint32 dstEid;
          bytes32 receiver;
          bytes32 guid;
          bytes message;
      }
      interface ISendLib is IMessageLib {
          function send(
              Packet calldata _packet,
              bytes calldata _options,
              bool _payInLzToken
          ) external returns (MessagingFee memory, bytes memory encodedPacket);
          function quote(
              Packet calldata _packet,
              bytes calldata _options,
              bool _payInLzToken
          ) external view returns (MessagingFee memory);
          function setTreasury(address _treasury) external;
          function withdrawFee(address _to, uint256 _amount) external;
          function withdrawLzTokenFee(address _lzToken, address _to, uint256 _amount) external;
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      library AddressCast {
          error AddressCast_InvalidSizeForAddress();
          error AddressCast_InvalidAddress();
          function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) {
              if (_addressBytes.length > 32) revert AddressCast_InvalidAddress();
              result = bytes32(_addressBytes);
              unchecked {
                  uint256 offset = 32 - _addressBytes.length;
                  result = result >> (offset * 8);
              }
          }
          function toBytes32(address _address) internal pure returns (bytes32 result) {
              result = bytes32(uint256(uint160(_address)));
          }
          function toBytes(bytes32 _addressBytes32, uint256 _size) internal pure returns (bytes memory result) {
              if (_size == 0 || _size > 32) revert AddressCast_InvalidSizeForAddress();
              result = new bytes(_size);
              unchecked {
                  uint256 offset = 256 - _size * 8;
                  assembly {
                      mstore(add(result, 32), shl(offset, _addressBytes32))
                  }
              }
          }
          function toAddress(bytes32 _addressBytes32) internal pure returns (address result) {
              result = address(uint160(uint256(_addressBytes32)));
          }
          function toAddress(bytes calldata _addressBytes) internal pure returns (address result) {
              if (_addressBytes.length != 20) revert AddressCast_InvalidAddress();
              result = address(bytes20(_addressBytes));
          }
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      library Errors {
          error LZ_LzTokenUnavailable();
          error LZ_InvalidReceiveLibrary();
          error LZ_InvalidNonce(uint64 nonce);
          error LZ_InvalidArgument();
          error LZ_InvalidExpiry();
          error LZ_InvalidAmount(uint256 required, uint256 supplied);
          error LZ_OnlyRegisteredOrDefaultLib();
          error LZ_OnlyRegisteredLib();
          error LZ_OnlyNonDefaultLib();
          error LZ_Unauthorized();
          error LZ_DefaultSendLibUnavailable();
          error LZ_DefaultReceiveLibUnavailable();
          error LZ_PathNotInitializable();
          error LZ_PathNotVerifiable();
          error LZ_OnlySendLib();
          error LZ_OnlyReceiveLib();
          error LZ_UnsupportedEid();
          error LZ_UnsupportedInterface();
          error LZ_AlreadyRegistered();
          error LZ_SameValue();
          error LZ_InvalidPayloadHash();
          error LZ_PayloadHashNotFound(bytes32 expected, bytes32 actual);
          error LZ_ComposeNotFound(bytes32 expected, bytes32 actual);
          error LZ_ComposeExists();
          error LZ_SendReentrancy();
          error LZ_NotImplemented();
          error LZ_InsufficientFee(
              uint256 requiredNative,
              uint256 suppliedNative,
              uint256 requiredLzToken,
              uint256 suppliedLzToken
          );
          error LZ_ZeroLzTokenFee();
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { AddressCast } from "./AddressCast.sol";
      library GUID {
          using AddressCast for address;
          function generate(
              uint64 _nonce,
              uint32 _srcEid,
              address _sender,
              uint32 _dstEid,
              bytes32 _receiver
          ) internal pure returns (bytes32) {
              return keccak256(abi.encodePacked(_nonce, _srcEid, _sender.toBytes32(), _dstEid, _receiver));
          }
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
      import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
      library Transfer {
          using SafeERC20 for IERC20;
          address internal constant ADDRESS_ZERO = address(0);
          error Transfer_NativeFailed(address _to, uint256 _value);
          error Transfer_ToAddressIsZero();
          function native(address _to, uint256 _value) internal {
              if (_to == ADDRESS_ZERO) revert Transfer_ToAddressIsZero();
              (bool success, ) = _to.call{ value: _value }("");
              if (!success) revert Transfer_NativeFailed(_to, _value);
          }
          function token(address _token, address _to, uint256 _value) internal {
              if (_to == ADDRESS_ZERO) revert Transfer_ToAddressIsZero();
              IERC20(_token).safeTransfer(_to, _value);
          }
          function nativeOrToken(address _token, address _to, uint256 _value) internal {
              if (_token == ADDRESS_ZERO) {
                  native(_to, _value);
              } else {
                  token(_token, _to, _value);
              }
          }
      }
      // SPDX-License-Identifier: LZBL-1.2
      pragma solidity ^0.8.20;
      import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
      import { IMessageLib, MessageLibType } from "../interfaces/IMessageLib.sol";
      import { Errors } from "../libs/Errors.sol";
      contract BlockedMessageLib is ERC165 {
          function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
              return interfaceId == type(IMessageLib).interfaceId || super.supportsInterface(interfaceId);
          }
          function version() external pure returns (uint64 major, uint8 minor, uint8 endpointVersion) {
              return (type(uint64).max, type(uint8).max, 2);
          }
          function messageLibType() external pure returns (MessageLibType) {
              return MessageLibType.SendAndReceive;
          }
          function isSupportedEid(uint32) external pure returns (bool) {
              return true;
          }
          fallback() external {
              revert Errors.LZ_NotImplemented();
          }
      }
      

      File 2 of 3: FiatTokenProxy
      pragma solidity ^0.4.24;
      
      // File: zos-lib/contracts/upgradeability/Proxy.sol
      
      /**
       * @title Proxy
       * @dev Implements delegation of calls to other contracts, with proper
       * forwarding of return values and bubbling of failures.
       * It defines a fallback function that delegates all calls to the address
       * returned by the abstract _implementation() internal function.
       */
      contract Proxy {
        /**
         * @dev Fallback function.
         * Implemented entirely in `_fallback`.
         */
        function () payable external {
          _fallback();
        }
      
        /**
         * @return The Address of the implementation.
         */
        function _implementation() internal view returns (address);
      
        /**
         * @dev Delegates execution to an implementation contract.
         * This is a low level function that doesn't return to its internal call site.
         * It will return to the external caller whatever the implementation returns.
         * @param implementation Address to delegate.
         */
        function _delegate(address implementation) internal {
          assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize)
      
            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
      
            // Copy the returned data.
            returndatacopy(0, 0, returndatasize)
      
            switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize) }
            default { return(0, returndatasize) }
          }
        }
      
        /**
         * @dev Function that is run as the first thing in the fallback function.
         * Can be redefined in derived contracts to add functionality.
         * Redefinitions must call super._willFallback().
         */
        function _willFallback() internal {
        }
      
        /**
         * @dev fallback implementation.
         * Extracted to enable manual triggering.
         */
        function _fallback() internal {
          _willFallback();
          _delegate(_implementation());
        }
      }
      
      // File: openzeppelin-solidity/contracts/AddressUtils.sol
      
      /**
       * Utility library of inline functions on addresses
       */
      library AddressUtils {
      
        /**
         * Returns whether the target address is a contract
         * @dev This function will return false if invoked during the constructor of a contract,
         * as the code is not actually created until after the constructor finishes.
         * @param addr address to check
         * @return whether the target address is a contract
         */
        function isContract(address addr) internal view returns (bool) {
          uint256 size;
          // XXX Currently there is no better way to check if there is a contract in an address
          // than to check the size of the code at that address.
          // See https://ethereum.stackexchange.com/a/14016/36603
          // for more details about how this works.
          // TODO Check this again before the Serenity release, because all addresses will be
          // contracts then.
          // solium-disable-next-line security/no-inline-assembly
          assembly { size := extcodesize(addr) }
          return size > 0;
        }
      
      }
      
      // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol
      
      /**
       * @title UpgradeabilityProxy
       * @dev This contract implements a proxy that allows to change the
       * implementation address to which it will delegate.
       * Such a change is called an implementation upgrade.
       */
      contract UpgradeabilityProxy is Proxy {
        /**
         * @dev Emitted when the implementation is upgraded.
         * @param implementation Address of the new implementation.
         */
        event Upgraded(address implementation);
      
        /**
         * @dev Storage slot with the address of the current implementation.
         * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
         * validated in the constructor.
         */
        bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
      
        /**
         * @dev Contract constructor.
         * @param _implementation Address of the initial implementation.
         */
        constructor(address _implementation) public {
          assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
      
          _setImplementation(_implementation);
        }
      
        /**
         * @dev Returns the current implementation.
         * @return Address of the current implementation
         */
        function _implementation() internal view returns (address impl) {
          bytes32 slot = IMPLEMENTATION_SLOT;
          assembly {
            impl := sload(slot)
          }
        }
      
        /**
         * @dev Upgrades the proxy to a new implementation.
         * @param newImplementation Address of the new implementation.
         */
        function _upgradeTo(address newImplementation) internal {
          _setImplementation(newImplementation);
          emit Upgraded(newImplementation);
        }
      
        /**
         * @dev Sets the implementation address of the proxy.
         * @param newImplementation Address of the new implementation.
         */
        function _setImplementation(address newImplementation) private {
          require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
      
          bytes32 slot = IMPLEMENTATION_SLOT;
      
          assembly {
            sstore(slot, newImplementation)
          }
        }
      }
      
      // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol
      
      /**
       * @title AdminUpgradeabilityProxy
       * @dev This contract combines an upgradeability proxy with an authorization
       * mechanism for administrative tasks.
       * All external functions in this contract must be guarded by the
       * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
       * feature proposal that would enable this to be done automatically.
       */
      contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
        /**
         * @dev Emitted when the administration has been transferred.
         * @param previousAdmin Address of the previous admin.
         * @param newAdmin Address of the new admin.
         */
        event AdminChanged(address previousAdmin, address newAdmin);
      
        /**
         * @dev Storage slot with the admin of the contract.
         * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
         * validated in the constructor.
         */
        bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
      
        /**
         * @dev Modifier to check whether the `msg.sender` is the admin.
         * If it is, it will run the function. Otherwise, it will delegate the call
         * to the implementation.
         */
        modifier ifAdmin() {
          if (msg.sender == _admin()) {
            _;
          } else {
            _fallback();
          }
        }
      
        /**
         * Contract constructor.
         * It sets the `msg.sender` as the proxy administrator.
         * @param _implementation address of the initial implementation.
         */
        constructor(address _implementation) UpgradeabilityProxy(_implementation) public {
          assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
      
          _setAdmin(msg.sender);
        }
      
        /**
         * @return The address of the proxy admin.
         */
        function admin() external view ifAdmin returns (address) {
          return _admin();
        }
      
        /**
         * @return The address of the implementation.
         */
        function implementation() external view ifAdmin returns (address) {
          return _implementation();
        }
      
        /**
         * @dev Changes the admin of the proxy.
         * Only the current admin can call this function.
         * @param newAdmin Address to transfer proxy administration to.
         */
        function changeAdmin(address newAdmin) external ifAdmin {
          require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
          emit AdminChanged(_admin(), newAdmin);
          _setAdmin(newAdmin);
        }
      
        /**
         * @dev Upgrade the backing implementation of the proxy.
         * Only the admin can call this function.
         * @param newImplementation Address of the new implementation.
         */
        function upgradeTo(address newImplementation) external ifAdmin {
          _upgradeTo(newImplementation);
        }
      
        /**
         * @dev Upgrade the backing implementation of the proxy and call a function
         * on the new implementation.
         * This is useful to initialize the proxied contract.
         * @param newImplementation Address of the new implementation.
         * @param data Data to send as msg.data in the low level call.
         * It should include the signature and the parameters of the function to be
         * called, as described in
         * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
         */
        function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin {
          _upgradeTo(newImplementation);
          require(address(this).call.value(msg.value)(data));
        }
      
        /**
         * @return The admin slot.
         */
        function _admin() internal view returns (address adm) {
          bytes32 slot = ADMIN_SLOT;
          assembly {
            adm := sload(slot)
          }
        }
      
        /**
         * @dev Sets the address of the proxy admin.
         * @param newAdmin Address of the new proxy admin.
         */
        function _setAdmin(address newAdmin) internal {
          bytes32 slot = ADMIN_SLOT;
      
          assembly {
            sstore(slot, newAdmin)
          }
        }
      
        /**
         * @dev Only fall back when the sender is not the admin.
         */
        function _willFallback() internal {
          require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
          super._willFallback();
        }
      }
      
      // File: contracts/FiatTokenProxy.sol
      
      /**
      * Copyright CENTRE SECZ 2018
      *
      * Permission is hereby granted, free of charge, to any person obtaining a copy 
      * of this software and associated documentation files (the "Software"), to deal 
      * in the Software without restriction, including without limitation the rights 
      * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
      * copies of the Software, and to permit persons to whom the Software is furnished to 
      * do so, subject to the following conditions:
      *
      * The above copyright notice and this permission notice shall be included in all 
      * copies or substantial portions of the Software.
      *
      * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
      * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
      * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
      * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
      * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      */
      
      pragma solidity ^0.4.24;
      
      
      /**
       * @title FiatTokenProxy
       * @dev This contract proxies FiatToken calls and enables FiatToken upgrades
      */ 
      contract FiatTokenProxy is AdminUpgradeabilityProxy {
          constructor(address _implementation) public AdminUpgradeabilityProxy(_implementation) {
          }
      }

      File 3 of 3: FiatTokenV2_2
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { EIP712Domain } from "./EIP712Domain.sol"; // solhint-disable-line no-unused-import
      import { Blacklistable } from "../v1/Blacklistable.sol"; // solhint-disable-line no-unused-import
      import { FiatTokenV1 } from "../v1/FiatTokenV1.sol"; // solhint-disable-line no-unused-import
      import { FiatTokenV2 } from "./FiatTokenV2.sol"; // solhint-disable-line no-unused-import
      import { FiatTokenV2_1 } from "./FiatTokenV2_1.sol";
      import { EIP712 } from "../util/EIP712.sol";
      // solhint-disable func-name-mixedcase
      /**
       * @title FiatToken V2.2
       * @notice ERC20 Token backed by fiat reserves, version 2.2
       */
      contract FiatTokenV2_2 is FiatTokenV2_1 {
          /**
           * @notice Initialize v2.2
           * @param accountsToBlacklist   A list of accounts to migrate from the old blacklist
           * @param newSymbol             New token symbol
           * data structure to the new blacklist data structure.
           */
          function initializeV2_2(
              address[] calldata accountsToBlacklist,
              string calldata newSymbol
          ) external {
              // solhint-disable-next-line reason-string
              require(_initializedVersion == 2);
              // Update fiat token symbol
              symbol = newSymbol;
              // Add previously blacklisted accounts to the new blacklist data structure
              // and remove them from the old blacklist data structure.
              for (uint256 i = 0; i < accountsToBlacklist.length; i++) {
                  require(
                      _deprecatedBlacklisted[accountsToBlacklist[i]],
                      "FiatTokenV2_2: Blacklisting previously unblacklisted account!"
                  );
                  _blacklist(accountsToBlacklist[i]);
                  delete _deprecatedBlacklisted[accountsToBlacklist[i]];
              }
              _blacklist(address(this));
              delete _deprecatedBlacklisted[address(this)];
              _initializedVersion = 3;
          }
          /**
           * @dev Internal function to get the current chain id.
           * @return The current chain id.
           */
          function _chainId() internal virtual view returns (uint256) {
              uint256 chainId;
              assembly {
                  chainId := chainid()
              }
              return chainId;
          }
          /**
           * @inheritdoc EIP712Domain
           */
          function _domainSeparator() internal override view returns (bytes32) {
              return EIP712.makeDomainSeparator(name, "2", _chainId());
          }
          /**
           * @notice Update allowance with a signed permit
           * @dev EOA wallet signatures should be packed in the order of r, s, v.
           * @param owner       Token owner's address (Authorizer)
           * @param spender     Spender's address
           * @param value       Amount of allowance
           * @param deadline    The time at which the signature expires (unix time), or max uint256 value to signal no expiration
           * @param signature   Signature bytes signed by an EOA wallet or a contract wallet
           */
          function permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              bytes memory signature
          ) external whenNotPaused {
              _permit(owner, spender, value, deadline, signature);
          }
          /**
           * @notice Execute a transfer with a signed authorization
           * @dev EOA wallet signatures should be packed in the order of r, s, v.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
           */
          function transferWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              bytes memory signature
          ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
              _transferWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  signature
              );
          }
          /**
           * @notice Receive a transfer with a signed authorization from the payer
           * @dev This has an additional check to ensure that the payee's address
           * matches the caller of this function to prevent front-running attacks.
           * EOA wallet signatures should be packed in the order of r, s, v.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
           */
          function receiveWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              bytes memory signature
          ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
              _receiveWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  signature
              );
          }
          /**
           * @notice Attempt to cancel an authorization
           * @dev Works only if the authorization is not yet used.
           * EOA wallet signatures should be packed in the order of r, s, v.
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
           */
          function cancelAuthorization(
              address authorizer,
              bytes32 nonce,
              bytes memory signature
          ) external whenNotPaused {
              _cancelAuthorization(authorizer, nonce, signature);
          }
          /**
           * @dev Helper method that sets the blacklist state of an account on balanceAndBlacklistStates.
           * If _shouldBlacklist is true, we apply a (1 << 255) bitmask with an OR operation on the
           * account's balanceAndBlacklistState. This flips the high bit for the account to 1,
           * indicating that the account is blacklisted.
           *
           * If _shouldBlacklist if false, we reset the account's balanceAndBlacklistStates to their
           * balances. This clears the high bit for the account, indicating that the account is unblacklisted.
           * @param _account         The address of the account.
           * @param _shouldBlacklist True if the account should be blacklisted, false if the account should be unblacklisted.
           */
          function _setBlacklistState(address _account, bool _shouldBlacklist)
              internal
              override
          {
              balanceAndBlacklistStates[_account] = _shouldBlacklist
                  ? balanceAndBlacklistStates[_account] | (1 << 255)
                  : _balanceOf(_account);
          }
          /**
           * @dev Helper method that sets the balance of an account on balanceAndBlacklistStates.
           * Since balances are stored in the last 255 bits of the balanceAndBlacklistStates value,
           * we need to ensure that the updated balance does not exceed (2^255 - 1).
           * Since blacklisted accounts' balances cannot be updated, the method will also
           * revert if the account is blacklisted
           * @param _account The address of the account.
           * @param _balance The new fiat token balance of the account (max: (2^255 - 1)).
           */
          function _setBalance(address _account, uint256 _balance) internal override {
              require(
                  _balance <= ((1 << 255) - 1),
                  "FiatTokenV2_2: Balance exceeds (2^255 - 1)"
              );
              require(
                  !_isBlacklisted(_account),
                  "FiatTokenV2_2: Account is blacklisted"
              );
              balanceAndBlacklistStates[_account] = _balance;
          }
          /**
           * @inheritdoc Blacklistable
           */
          function _isBlacklisted(address _account)
              internal
              override
              view
              returns (bool)
          {
              return balanceAndBlacklistStates[_account] >> 255 == 1;
          }
          /**
           * @dev Helper method to obtain the balance of an account. Since balances
           * are stored in the last 255 bits of the balanceAndBlacklistStates value,
           * we apply a ((1 << 255) - 1) bit bitmask with an AND operation on the
           * balanceAndBlacklistState to obtain the balance.
           * @param _account  The address of the account.
           * @return          The fiat token balance of the account.
           */
          function _balanceOf(address _account)
              internal
              override
              view
              returns (uint256)
          {
              return balanceAndBlacklistStates[_account] & ((1 << 255) - 1);
          }
          /**
           * @inheritdoc FiatTokenV1
           */
          function approve(address spender, uint256 value)
              external
              override
              whenNotPaused
              returns (bool)
          {
              _approve(msg.sender, spender, value);
              return true;
          }
          /**
           * @inheritdoc FiatTokenV2
           */
          function permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) external override whenNotPaused {
              _permit(owner, spender, value, deadline, v, r, s);
          }
          /**
           * @inheritdoc FiatTokenV2
           */
          function increaseAllowance(address spender, uint256 increment)
              external
              override
              whenNotPaused
              returns (bool)
          {
              _increaseAllowance(msg.sender, spender, increment);
              return true;
          }
          /**
           * @inheritdoc FiatTokenV2
           */
          function decreaseAllowance(address spender, uint256 decrement)
              external
              override
              whenNotPaused
              returns (bool)
          {
              _decreaseAllowance(msg.sender, spender, decrement);
              return true;
          }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.2 <0.8.0;
      /**
       * @dev Collection of functions related to the address type
       */
      library Address {
          /**
           * @dev Returns true if `account` is a contract.
           *
           * [IMPORTANT]
           * ====
           * It is unsafe to assume that an address for which this function returns
           * false is an externally-owned account (EOA) and not a contract.
           *
           * Among others, `isContract` will return false for the following
           * types of addresses:
           *
           *  - an externally-owned account
           *  - a contract in construction
           *  - an address where a contract will be created
           *  - an address where a contract lived, but was destroyed
           * ====
           */
          function isContract(address account) internal view returns (bool) {
              // This method relies on extcodesize, which returns 0 for contracts in
              // construction, since the code is only stored at the end of the
              // constructor execution.
              uint256 size;
              // solhint-disable-next-line no-inline-assembly
              assembly { size := extcodesize(account) }
              return size > 0;
          }
          /**
           * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
           * `recipient`, forwarding all available gas and reverting on errors.
           *
           * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
           * of certain opcodes, possibly making contracts go over the 2300 gas limit
           * imposed by `transfer`, making them unable to receive funds via
           * `transfer`. {sendValue} removes this limitation.
           *
           * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
           *
           * IMPORTANT: because control is transferred to `recipient`, care must be
           * taken to not create reentrancy vulnerabilities. Consider using
           * {ReentrancyGuard} or the
           * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
           */
          function sendValue(address payable recipient, uint256 amount) internal {
              require(address(this).balance >= amount, "Address: insufficient balance");
              // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
              (bool success, ) = recipient.call{ value: amount }("");
              require(success, "Address: unable to send value, recipient may have reverted");
          }
          /**
           * @dev Performs a Solidity function call using a low level `call`. A
           * plain`call` is an unsafe replacement for a function call: use this
           * function instead.
           *
           * If `target` reverts with a revert reason, it is bubbled up by this
           * function (like regular Solidity function calls).
           *
           * Returns the raw returned data. To convert to the expected return value,
           * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
           *
           * Requirements:
           *
           * - `target` must be a contract.
           * - calling `target` with `data` must not revert.
           *
           * _Available since v3.1._
           */
          function functionCall(address target, bytes memory data) internal returns (bytes memory) {
            return functionCall(target, data, "Address: low-level call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
           * `errorMessage` as a fallback revert reason when `target` reverts.
           *
           * _Available since v3.1._
           */
          function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
              return functionCallWithValue(target, data, 0, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but also transferring `value` wei to `target`.
           *
           * Requirements:
           *
           * - the calling contract must have an ETH balance of at least `value`.
           * - the called Solidity function must be `payable`.
           *
           * _Available since v3.1._
           */
          function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
              return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
          }
          /**
           * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
           * with `errorMessage` as a fallback revert reason when `target` reverts.
           *
           * _Available since v3.1._
           */
          function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
              require(address(this).balance >= value, "Address: insufficient balance for call");
              require(isContract(target), "Address: call to non-contract");
              // solhint-disable-next-line avoid-low-level-calls
              (bool success, bytes memory returndata) = target.call{ value: value }(data);
              return _verifyCallResult(success, returndata, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but performing a static call.
           *
           * _Available since v3.3._
           */
          function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
              return functionStaticCall(target, data, "Address: low-level static call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
           * but performing a static call.
           *
           * _Available since v3.3._
           */
          function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
              require(isContract(target), "Address: static call to non-contract");
              // solhint-disable-next-line avoid-low-level-calls
              (bool success, bytes memory returndata) = target.staticcall(data);
              return _verifyCallResult(success, returndata, errorMessage);
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
           * but performing a delegate call.
           *
           * _Available since v3.4._
           */
          function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
              return functionDelegateCall(target, data, "Address: low-level delegate call failed");
          }
          /**
           * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
           * but performing a delegate call.
           *
           * _Available since v3.4._
           */
          function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
              require(isContract(target), "Address: delegate call to non-contract");
              // solhint-disable-next-line avoid-low-level-calls
              (bool success, bytes memory returndata) = target.delegatecall(data);
              return _verifyCallResult(success, returndata, errorMessage);
          }
          function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
              if (success) {
                  return returndata;
              } else {
                  // Look for revert reason and bubble it up if present
                  if (returndata.length > 0) {
                      // The easiest way to bubble the revert reason is using memory via assembly
                      // solhint-disable-next-line no-inline-assembly
                      assembly {
                          let returndata_size := mload(returndata)
                          revert(add(32, returndata), returndata_size)
                      }
                  } else {
                      revert(errorMessage);
                  }
              }
          }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.0 <0.8.0;
      import "./IERC20.sol";
      import "../../math/SafeMath.sol";
      import "../../utils/Address.sol";
      /**
       * @title SafeERC20
       * @dev Wrappers around ERC20 operations that throw on failure (when the token
       * contract returns false). Tokens that return no value (and instead revert or
       * throw on failure) are also supported, non-reverting calls are assumed to be
       * successful.
       * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
       * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
       */
      library SafeERC20 {
          using SafeMath for uint256;
          using Address for address;
          function safeTransfer(IERC20 token, address to, uint256 value) internal {
              _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
          }
          function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
              _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
          }
          /**
           * @dev Deprecated. This function has issues similar to the ones found in
           * {IERC20-approve}, and its usage is discouraged.
           *
           * Whenever possible, use {safeIncreaseAllowance} and
           * {safeDecreaseAllowance} instead.
           */
          function safeApprove(IERC20 token, address spender, uint256 value) internal {
              // safeApprove should only be called when setting an initial allowance,
              // or when resetting it to zero. To increase and decrease it, use
              // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
              // solhint-disable-next-line max-line-length
              require((value == 0) || (token.allowance(address(this), spender) == 0),
                  "SafeERC20: approve from non-zero to non-zero allowance"
              );
              _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
          }
          function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
              uint256 newAllowance = token.allowance(address(this), spender).add(value);
              _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
          }
          function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
              uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
              _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
          }
          /**
           * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
           * on the return value: the return value is optional (but if data is returned, it must not be false).
           * @param token The token targeted by the call.
           * @param data The call data (encoded using abi.encode or one of its variants).
           */
          function _callOptionalReturn(IERC20 token, bytes memory data) private {
              // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
              // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
              // the target address contains contract code and also asserts for success in the low-level call.
              bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
              if (returndata.length > 0) { // Return data is optional
                  // solhint-disable-next-line max-line-length
                  require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
              }
          }
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.0 <0.8.0;
      /**
       * @dev Interface of the ERC20 standard as defined in the EIP.
       */
      interface IERC20 {
          /**
           * @dev Returns the amount of tokens in existence.
           */
          function totalSupply() external view returns (uint256);
          /**
           * @dev Returns the amount of tokens owned by `account`.
           */
          function balanceOf(address account) external view returns (uint256);
          /**
           * @dev Moves `amount` tokens from the caller's account to `recipient`.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transfer(address recipient, uint256 amount) external returns (bool);
          /**
           * @dev Returns the remaining number of tokens that `spender` will be
           * allowed to spend on behalf of `owner` through {transferFrom}. This is
           * zero by default.
           *
           * This value changes when {approve} or {transferFrom} are called.
           */
          function allowance(address owner, address spender) external view returns (uint256);
          /**
           * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * IMPORTANT: Beware that changing an allowance with this method brings the risk
           * that someone may use both the old and the new allowance by unfortunate
           * transaction ordering. One possible solution to mitigate this race
           * condition is to first reduce the spender's allowance to 0 and set the
           * desired value afterwards:
           * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
           *
           * Emits an {Approval} event.
           */
          function approve(address spender, uint256 amount) external returns (bool);
          /**
           * @dev Moves `amount` tokens from `sender` to `recipient` using the
           * allowance mechanism. `amount` is then deducted from the caller's
           * allowance.
           *
           * Returns a boolean value indicating whether the operation succeeded.
           *
           * Emits a {Transfer} event.
           */
          function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
          /**
           * @dev Emitted when `value` tokens are moved from one account (`from`) to
           * another (`to`).
           *
           * Note that `value` may be zero.
           */
          event Transfer(address indexed from, address indexed to, uint256 value);
          /**
           * @dev Emitted when the allowance of a `spender` for an `owner` is set by
           * a call to {approve}. `value` is the new allowance.
           */
          event Approval(address indexed owner, address indexed spender, uint256 value);
      }
      // SPDX-License-Identifier: MIT
      pragma solidity >=0.6.0 <0.8.0;
      /**
       * @dev Wrappers over Solidity's arithmetic operations with added overflow
       * checks.
       *
       * Arithmetic operations in Solidity wrap on overflow. This can easily result
       * in bugs, because programmers usually assume that an overflow raises an
       * error, which is the standard behavior in high level programming languages.
       * `SafeMath` restores this intuition by reverting the transaction when an
       * operation overflows.
       *
       * Using this library instead of the unchecked operations eliminates an entire
       * class of bugs, so it's recommended to use it always.
       */
      library SafeMath {
          /**
           * @dev Returns the addition of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              uint256 c = a + b;
              if (c < a) return (false, 0);
              return (true, c);
          }
          /**
           * @dev Returns the substraction of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b > a) return (false, 0);
              return (true, a - b);
          }
          /**
           * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
           *
           * _Available since v3.4._
           */
          function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
              // benefit is lost if 'b' is also tested.
              // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
              if (a == 0) return (true, 0);
              uint256 c = a * b;
              if (c / a != b) return (false, 0);
              return (true, c);
          }
          /**
           * @dev Returns the division of two unsigned integers, with a division by zero flag.
           *
           * _Available since v3.4._
           */
          function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b == 0) return (false, 0);
              return (true, a / b);
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
           *
           * _Available since v3.4._
           */
          function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
              if (b == 0) return (false, 0);
              return (true, a % b);
          }
          /**
           * @dev Returns the addition of two unsigned integers, reverting on
           * overflow.
           *
           * Counterpart to Solidity's `+` operator.
           *
           * Requirements:
           *
           * - Addition cannot overflow.
           */
          function add(uint256 a, uint256 b) internal pure returns (uint256) {
              uint256 c = a + b;
              require(c >= a, "SafeMath: addition overflow");
              return c;
          }
          /**
           * @dev Returns the subtraction of two unsigned integers, reverting on
           * overflow (when the result is negative).
           *
           * Counterpart to Solidity's `-` operator.
           *
           * Requirements:
           *
           * - Subtraction cannot overflow.
           */
          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b <= a, "SafeMath: subtraction overflow");
              return a - b;
          }
          /**
           * @dev Returns the multiplication of two unsigned integers, reverting on
           * overflow.
           *
           * Counterpart to Solidity's `*` operator.
           *
           * Requirements:
           *
           * - Multiplication cannot overflow.
           */
          function mul(uint256 a, uint256 b) internal pure returns (uint256) {
              if (a == 0) return 0;
              uint256 c = a * b;
              require(c / a == b, "SafeMath: multiplication overflow");
              return c;
          }
          /**
           * @dev Returns the integer division of two unsigned integers, reverting on
           * division by zero. The result is rounded towards zero.
           *
           * Counterpart to Solidity's `/` operator. Note: this function uses a
           * `revert` opcode (which leaves remaining gas untouched) while Solidity
           * uses an invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function div(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b > 0, "SafeMath: division by zero");
              return a / b;
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
           * reverting when dividing by zero.
           *
           * Counterpart to Solidity's `%` operator. This function uses a `revert`
           * opcode (which leaves remaining gas untouched) while Solidity uses an
           * invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function mod(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b > 0, "SafeMath: modulo by zero");
              return a % b;
          }
          /**
           * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
           * overflow (when the result is negative).
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {trySub}.
           *
           * Counterpart to Solidity's `-` operator.
           *
           * Requirements:
           *
           * - Subtraction cannot overflow.
           */
          function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b <= a, errorMessage);
              return a - b;
          }
          /**
           * @dev Returns the integer division of two unsigned integers, reverting with custom message on
           * division by zero. The result is rounded towards zero.
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {tryDiv}.
           *
           * Counterpart to Solidity's `/` operator. Note: this function uses a
           * `revert` opcode (which leaves remaining gas untouched) while Solidity
           * uses an invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b > 0, errorMessage);
              return a / b;
          }
          /**
           * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
           * reverting with custom message when dividing by zero.
           *
           * CAUTION: This function is deprecated because it requires allocating memory for the error
           * message unnecessarily. For custom revert reasons use {tryMod}.
           *
           * Counterpart to Solidity's `%` operator. This function uses a `revert`
           * opcode (which leaves remaining gas untouched) while Solidity uses an
           * invalid opcode to revert (consuming all remaining gas).
           *
           * Requirements:
           *
           * - The divisor cannot be zero.
           */
          function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
              require(b > 0, errorMessage);
              return a % b;
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { FiatTokenV2 } from "./FiatTokenV2.sol";
      // solhint-disable func-name-mixedcase
      /**
       * @title FiatToken V2.1
       * @notice ERC20 Token backed by fiat reserves, version 2.1
       */
      contract FiatTokenV2_1 is FiatTokenV2 {
          /**
           * @notice Initialize v2.1
           * @param lostAndFound  The address to which the locked funds are sent
           */
          function initializeV2_1(address lostAndFound) external {
              // solhint-disable-next-line reason-string
              require(_initializedVersion == 1);
              uint256 lockedAmount = _balanceOf(address(this));
              if (lockedAmount > 0) {
                  _transfer(address(this), lostAndFound, lockedAmount);
              }
              _blacklist(address(this));
              _initializedVersion = 2;
          }
          /**
           * @notice Version string for the EIP712 domain separator
           * @return Version string
           */
          function version() external pure returns (string memory) {
              return "2";
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { FiatTokenV1_1 } from "../v1.1/FiatTokenV1_1.sol";
      import { EIP712 } from "../util/EIP712.sol";
      import { EIP3009 } from "./EIP3009.sol";
      import { EIP2612 } from "./EIP2612.sol";
      /**
       * @title FiatToken V2
       * @notice ERC20 Token backed by fiat reserves, version 2
       */
      contract FiatTokenV2 is FiatTokenV1_1, EIP3009, EIP2612 {
          uint8 internal _initializedVersion;
          /**
           * @notice Initialize v2
           * @param newName   New token name
           */
          function initializeV2(string calldata newName) external {
              // solhint-disable-next-line reason-string
              require(initialized && _initializedVersion == 0);
              name = newName;
              _DEPRECATED_CACHED_DOMAIN_SEPARATOR = EIP712.makeDomainSeparator(
                  newName,
                  "2"
              );
              _initializedVersion = 1;
          }
          /**
           * @notice Increase the allowance by a given increment
           * @param spender   Spender's address
           * @param increment Amount of increase in allowance
           * @return True if successful
           */
          function increaseAllowance(address spender, uint256 increment)
              external
              virtual
              whenNotPaused
              notBlacklisted(msg.sender)
              notBlacklisted(spender)
              returns (bool)
          {
              _increaseAllowance(msg.sender, spender, increment);
              return true;
          }
          /**
           * @notice Decrease the allowance by a given decrement
           * @param spender   Spender's address
           * @param decrement Amount of decrease in allowance
           * @return True if successful
           */
          function decreaseAllowance(address spender, uint256 decrement)
              external
              virtual
              whenNotPaused
              notBlacklisted(msg.sender)
              notBlacklisted(spender)
              returns (bool)
          {
              _decreaseAllowance(msg.sender, spender, decrement);
              return true;
          }
          /**
           * @notice Execute a transfer with a signed authorization
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function transferWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
              _transferWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  v,
                  r,
                  s
              );
          }
          /**
           * @notice Receive a transfer with a signed authorization from the payer
           * @dev This has an additional check to ensure that the payee's address
           * matches the caller of this function to prevent front-running attacks.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function receiveWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
              _receiveWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  v,
                  r,
                  s
              );
          }
          /**
           * @notice Attempt to cancel an authorization
           * @dev Works only if the authorization is not yet used.
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function cancelAuthorization(
              address authorizer,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) external whenNotPaused {
              _cancelAuthorization(authorizer, nonce, v, r, s);
          }
          /**
           * @notice Update allowance with a signed permit
           * @param owner       Token owner's address (Authorizer)
           * @param spender     Spender's address
           * @param value       Amount of allowance
           * @param deadline    The time at which the signature expires (unix time), or max uint256 value to signal no expiration
           * @param v           v of the signature
           * @param r           r of the signature
           * @param s           s of the signature
           */
          function permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              uint8 v,
              bytes32 r,
              bytes32 s
          )
              external
              virtual
              whenNotPaused
              notBlacklisted(owner)
              notBlacklisted(spender)
          {
              _permit(owner, spender, value, deadline, v, r, s);
          }
          /**
           * @dev Internal function to increase the allowance by a given increment
           * @param owner     Token owner's address
           * @param spender   Spender's address
           * @param increment Amount of increase
           */
          function _increaseAllowance(
              address owner,
              address spender,
              uint256 increment
          ) internal override {
              _approve(owner, spender, allowed[owner][spender].add(increment));
          }
          /**
           * @dev Internal function to decrease the allowance by a given decrement
           * @param owner     Token owner's address
           * @param spender   Spender's address
           * @param decrement Amount of decrease
           */
          function _decreaseAllowance(
              address owner,
              address spender,
              uint256 decrement
          ) internal override {
              _approve(
                  owner,
                  spender,
                  allowed[owner][spender].sub(
                      decrement,
                      "ERC20: decreased allowance below zero"
                  )
              );
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      // solhint-disable func-name-mixedcase
      /**
       * @title EIP712 Domain
       */
      contract EIP712Domain {
          // was originally DOMAIN_SEPARATOR
          // but that has been moved to a method so we can override it in V2_2+
          bytes32 internal _DEPRECATED_CACHED_DOMAIN_SEPARATOR;
          /**
           * @notice Get the EIP712 Domain Separator.
           * @return The bytes32 EIP712 domain separator.
           */
          function DOMAIN_SEPARATOR() external view returns (bytes32) {
              return _domainSeparator();
          }
          /**
           * @dev Internal method to get the EIP712 Domain Separator.
           * @return The bytes32 EIP712 domain separator.
           */
          function _domainSeparator() internal virtual view returns (bytes32) {
              return _DEPRECATED_CACHED_DOMAIN_SEPARATOR;
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { AbstractFiatTokenV2 } from "./AbstractFiatTokenV2.sol";
      import { EIP712Domain } from "./EIP712Domain.sol";
      import { SignatureChecker } from "../util/SignatureChecker.sol";
      import { MessageHashUtils } from "../util/MessageHashUtils.sol";
      /**
       * @title EIP-3009
       * @notice Provide internal implementation for gas-abstracted transfers
       * @dev Contracts that inherit from this must wrap these with publicly
       * accessible functions, optionally adding modifiers where necessary
       */
      abstract contract EIP3009 is AbstractFiatTokenV2, EIP712Domain {
          // keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
          bytes32
              public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH = 0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267;
          // keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
          bytes32
              public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
          // keccak256("CancelAuthorization(address authorizer,bytes32 nonce)")
          bytes32
              public constant CANCEL_AUTHORIZATION_TYPEHASH = 0x158b0a9edf7a828aad02f63cd515c68ef2f50ba807396f6d12842833a1597429;
          /**
           * @dev authorizer address => nonce => bool (true if nonce is used)
           */
          mapping(address => mapping(bytes32 => bool)) private _authorizationStates;
          event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
          event AuthorizationCanceled(
              address indexed authorizer,
              bytes32 indexed nonce
          );
          /**
           * @notice Returns the state of an authorization
           * @dev Nonces are randomly generated 32-byte data unique to the
           * authorizer's address
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @return True if the nonce is used
           */
          function authorizationState(address authorizer, bytes32 nonce)
              external
              view
              returns (bool)
          {
              return _authorizationStates[authorizer][nonce];
          }
          /**
           * @notice Execute a transfer with a signed authorization
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function _transferWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal {
              _transferWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  abi.encodePacked(r, s, v)
              );
          }
          /**
           * @notice Execute a transfer with a signed authorization
           * @dev EOA wallet signatures should be packed in the order of r, s, v.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
           */
          function _transferWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              bytes memory signature
          ) internal {
              _requireValidAuthorization(from, nonce, validAfter, validBefore);
              _requireValidSignature(
                  from,
                  keccak256(
                      abi.encode(
                          TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce
                      )
                  ),
                  signature
              );
              _markAuthorizationAsUsed(from, nonce);
              _transfer(from, to, value);
          }
          /**
           * @notice Receive a transfer with a signed authorization from the payer
           * @dev This has an additional check to ensure that the payee's address
           * matches the caller of this function to prevent front-running attacks.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function _receiveWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal {
              _receiveWithAuthorization(
                  from,
                  to,
                  value,
                  validAfter,
                  validBefore,
                  nonce,
                  abi.encodePacked(r, s, v)
              );
          }
          /**
           * @notice Receive a transfer with a signed authorization from the payer
           * @dev This has an additional check to ensure that the payee's address
           * matches the caller of this function to prevent front-running attacks.
           * EOA wallet signatures should be packed in the order of r, s, v.
           * @param from          Payer's address (Authorizer)
           * @param to            Payee's address
           * @param value         Amount to be transferred
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           * @param nonce         Unique nonce
           * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
           */
          function _receiveWithAuthorization(
              address from,
              address to,
              uint256 value,
              uint256 validAfter,
              uint256 validBefore,
              bytes32 nonce,
              bytes memory signature
          ) internal {
              require(to == msg.sender, "FiatTokenV2: caller must be the payee");
              _requireValidAuthorization(from, nonce, validAfter, validBefore);
              _requireValidSignature(
                  from,
                  keccak256(
                      abi.encode(
                          RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
                          from,
                          to,
                          value,
                          validAfter,
                          validBefore,
                          nonce
                      )
                  ),
                  signature
              );
              _markAuthorizationAsUsed(from, nonce);
              _transfer(from, to, value);
          }
          /**
           * @notice Attempt to cancel an authorization
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @param v             v of the signature
           * @param r             r of the signature
           * @param s             s of the signature
           */
          function _cancelAuthorization(
              address authorizer,
              bytes32 nonce,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal {
              _cancelAuthorization(authorizer, nonce, abi.encodePacked(r, s, v));
          }
          /**
           * @notice Attempt to cancel an authorization
           * @dev EOA wallet signatures should be packed in the order of r, s, v.
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
           */
          function _cancelAuthorization(
              address authorizer,
              bytes32 nonce,
              bytes memory signature
          ) internal {
              _requireUnusedAuthorization(authorizer, nonce);
              _requireValidSignature(
                  authorizer,
                  keccak256(
                      abi.encode(CANCEL_AUTHORIZATION_TYPEHASH, authorizer, nonce)
                  ),
                  signature
              );
              _authorizationStates[authorizer][nonce] = true;
              emit AuthorizationCanceled(authorizer, nonce);
          }
          /**
           * @notice Validates that signature against input data struct
           * @param signer        Signer's address
           * @param dataHash      Hash of encoded data struct
           * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
           */
          function _requireValidSignature(
              address signer,
              bytes32 dataHash,
              bytes memory signature
          ) private view {
              require(
                  SignatureChecker.isValidSignatureNow(
                      signer,
                      MessageHashUtils.toTypedDataHash(_domainSeparator(), dataHash),
                      signature
                  ),
                  "FiatTokenV2: invalid signature"
              );
          }
          /**
           * @notice Check that an authorization is unused
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           */
          function _requireUnusedAuthorization(address authorizer, bytes32 nonce)
              private
              view
          {
              require(
                  !_authorizationStates[authorizer][nonce],
                  "FiatTokenV2: authorization is used or canceled"
              );
          }
          /**
           * @notice Check that authorization is valid
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           * @param validAfter    The time after which this is valid (unix time)
           * @param validBefore   The time before which this is valid (unix time)
           */
          function _requireValidAuthorization(
              address authorizer,
              bytes32 nonce,
              uint256 validAfter,
              uint256 validBefore
          ) private view {
              require(
                  now > validAfter,
                  "FiatTokenV2: authorization is not yet valid"
              );
              require(now < validBefore, "FiatTokenV2: authorization is expired");
              _requireUnusedAuthorization(authorizer, nonce);
          }
          /**
           * @notice Mark an authorization as used
           * @param authorizer    Authorizer's address
           * @param nonce         Nonce of the authorization
           */
          function _markAuthorizationAsUsed(address authorizer, bytes32 nonce)
              private
          {
              _authorizationStates[authorizer][nonce] = true;
              emit AuthorizationUsed(authorizer, nonce);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { AbstractFiatTokenV2 } from "./AbstractFiatTokenV2.sol";
      import { EIP712Domain } from "./EIP712Domain.sol";
      import { MessageHashUtils } from "../util/MessageHashUtils.sol";
      import { SignatureChecker } from "../util/SignatureChecker.sol";
      /**
       * @title EIP-2612
       * @notice Provide internal implementation for gas-abstracted approvals
       */
      abstract contract EIP2612 is AbstractFiatTokenV2, EIP712Domain {
          // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
          bytes32
              public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
          mapping(address => uint256) private _permitNonces;
          /**
           * @notice Nonces for permit
           * @param owner Token owner's address (Authorizer)
           * @return Next nonce
           */
          function nonces(address owner) external view returns (uint256) {
              return _permitNonces[owner];
          }
          /**
           * @notice Verify a signed approval permit and execute if valid
           * @param owner     Token owner's address (Authorizer)
           * @param spender   Spender's address
           * @param value     Amount of allowance
           * @param deadline  The time at which the signature expires (unix time), or max uint256 value to signal no expiration
           * @param v         v of the signature
           * @param r         r of the signature
           * @param s         s of the signature
           */
          function _permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal {
              _permit(owner, spender, value, deadline, abi.encodePacked(r, s, v));
          }
          /**
           * @notice Verify a signed approval permit and execute if valid
           * @dev EOA wallet signatures should be packed in the order of r, s, v.
           * @param owner      Token owner's address (Authorizer)
           * @param spender    Spender's address
           * @param value      Amount of allowance
           * @param deadline   The time at which the signature expires (unix time), or max uint256 value to signal no expiration
           * @param signature  Signature byte array signed by an EOA wallet or a contract wallet
           */
          function _permit(
              address owner,
              address spender,
              uint256 value,
              uint256 deadline,
              bytes memory signature
          ) internal {
              require(
                  deadline == type(uint256).max || deadline >= now,
                  "FiatTokenV2: permit is expired"
              );
              bytes32 typedDataHash = MessageHashUtils.toTypedDataHash(
                  _domainSeparator(),
                  keccak256(
                      abi.encode(
                          PERMIT_TYPEHASH,
                          owner,
                          spender,
                          value,
                          _permitNonces[owner]++,
                          deadline
                      )
                  )
              );
              require(
                  SignatureChecker.isValidSignatureNow(
                      owner,
                      typedDataHash,
                      signature
                  ),
                  "EIP2612: invalid signature"
              );
              _approve(owner, spender, value);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { AbstractFiatTokenV1 } from "../v1/AbstractFiatTokenV1.sol";
      abstract contract AbstractFiatTokenV2 is AbstractFiatTokenV1 {
          function _increaseAllowance(
              address owner,
              address spender,
              uint256 increment
          ) internal virtual;
          function _decreaseAllowance(
              address owner,
              address spender,
              uint256 decrement
          ) internal virtual;
      }
      /**
       * SPDX-License-Identifier: MIT
       *
       * Copyright (c) 2016 Smart Contract Solutions, Inc.
       * Copyright (c) 2018-2020 CENTRE SECZ
       *
       * Permission is hereby granted, free of charge, to any person obtaining a copy
       * of this software and associated documentation files (the "Software"), to deal
       * in the Software without restriction, including without limitation the rights
       * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       * copies of the Software, and to permit persons to whom the Software is
       * furnished to do so, subject to the following conditions:
       *
       * The above copyright notice and this permission notice shall be included in
       * copies or substantial portions of the Software.
       *
       * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
       * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
       * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
       * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
       * SOFTWARE.
       */
      pragma solidity 0.6.12;
      import { Ownable } from "./Ownable.sol";
      /**
       * @notice Base contract which allows children to implement an emergency stop
       * mechanism
       * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/feb665136c0dae9912e08397c1a21c4af3651ef3/contracts/lifecycle/Pausable.sol
       * Modifications:
       * 1. Added pauser role, switched pause/unpause to be onlyPauser (6/14/2018)
       * 2. Removed whenNotPause/whenPaused from pause/unpause (6/14/2018)
       * 3. Removed whenPaused (6/14/2018)
       * 4. Switches ownable library to use ZeppelinOS (7/12/18)
       * 5. Remove constructor (7/13/18)
       * 6. Reformat, conform to Solidity 0.6 syntax and add error messages (5/13/20)
       * 7. Make public functions external (5/27/20)
       */
      contract Pausable is Ownable {
          event Pause();
          event Unpause();
          event PauserChanged(address indexed newAddress);
          address public pauser;
          bool public paused = false;
          /**
           * @dev Modifier to make a function callable only when the contract is not paused.
           */
          modifier whenNotPaused() {
              require(!paused, "Pausable: paused");
              _;
          }
          /**
           * @dev throws if called by any account other than the pauser
           */
          modifier onlyPauser() {
              require(msg.sender == pauser, "Pausable: caller is not the pauser");
              _;
          }
          /**
           * @dev called by the owner to pause, triggers stopped state
           */
          function pause() external onlyPauser {
              paused = true;
              emit Pause();
          }
          /**
           * @dev called by the owner to unpause, returns to normal state
           */
          function unpause() external onlyPauser {
              paused = false;
              emit Unpause();
          }
          /**
           * @notice Updates the pauser address.
           * @param _newPauser The address of the new pauser.
           */
          function updatePauser(address _newPauser) external onlyOwner {
              require(
                  _newPauser != address(0),
                  "Pausable: new pauser is the zero address"
              );
              pauser = _newPauser;
              emit PauserChanged(pauser);
          }
      }
      /**
       * SPDX-License-Identifier: MIT
       *
       * Copyright (c) 2018 zOS Global Limited.
       * Copyright (c) 2018-2020 CENTRE SECZ
       *
       * Permission is hereby granted, free of charge, to any person obtaining a copy
       * of this software and associated documentation files (the "Software"), to deal
       * in the Software without restriction, including without limitation the rights
       * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       * copies of the Software, and to permit persons to whom the Software is
       * furnished to do so, subject to the following conditions:
       *
       * The above copyright notice and this permission notice shall be included in
       * copies or substantial portions of the Software.
       *
       * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
       * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
       * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
       * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
       * SOFTWARE.
       */
      pragma solidity 0.6.12;
      /**
       * @notice The Ownable contract has an owner address, and provides basic
       * authorization control functions
       * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-labs/blob/3887ab77b8adafba4a26ace002f3a684c1a3388b/upgradeability_ownership/contracts/ownership/Ownable.sol
       * Modifications:
       * 1. Consolidate OwnableStorage into this contract (7/13/18)
       * 2. Reformat, conform to Solidity 0.6 syntax, and add error messages (5/13/20)
       * 3. Make public functions external (5/27/20)
       */
      contract Ownable {
          // Owner of the contract
          address private _owner;
          /**
           * @dev Event to show ownership has been transferred
           * @param previousOwner representing the address of the previous owner
           * @param newOwner representing the address of the new owner
           */
          event OwnershipTransferred(address previousOwner, address newOwner);
          /**
           * @dev The constructor sets the original owner of the contract to the sender account.
           */
          constructor() public {
              setOwner(msg.sender);
          }
          /**
           * @dev Tells the address of the owner
           * @return the address of the owner
           */
          function owner() external view returns (address) {
              return _owner;
          }
          /**
           * @dev Sets a new owner address
           */
          function setOwner(address newOwner) internal {
              _owner = newOwner;
          }
          /**
           * @dev Throws if called by any account other than the owner.
           */
          modifier onlyOwner() {
              require(msg.sender == _owner, "Ownable: caller is not the owner");
              _;
          }
          /**
           * @dev Allows the current owner to transfer control of the contract to a newOwner.
           * @param newOwner The address to transfer ownership to.
           */
          function transferOwnership(address newOwner) external onlyOwner {
              require(
                  newOwner != address(0),
                  "Ownable: new owner is the zero address"
              );
              emit OwnershipTransferred(_owner, newOwner);
              setOwner(newOwner);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
      import { AbstractFiatTokenV1 } from "./AbstractFiatTokenV1.sol";
      import { Ownable } from "./Ownable.sol";
      import { Pausable } from "./Pausable.sol";
      import { Blacklistable } from "./Blacklistable.sol";
      /**
       * @title FiatToken
       * @dev ERC20 Token backed by fiat reserves
       */
      contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable {
          using SafeMath for uint256;
          string public name;
          string public symbol;
          uint8 public decimals;
          string public currency;
          address public masterMinter;
          bool internal initialized;
          /// @dev A mapping that stores the balance and blacklist states for a given address.
          /// The first bit defines whether the address is blacklisted (1 if blacklisted, 0 otherwise).
          /// The last 255 bits define the balance for the address.
          mapping(address => uint256) internal balanceAndBlacklistStates;
          mapping(address => mapping(address => uint256)) internal allowed;
          uint256 internal totalSupply_ = 0;
          mapping(address => bool) internal minters;
          mapping(address => uint256) internal minterAllowed;
          event Mint(address indexed minter, address indexed to, uint256 amount);
          event Burn(address indexed burner, uint256 amount);
          event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
          event MinterRemoved(address indexed oldMinter);
          event MasterMinterChanged(address indexed newMasterMinter);
          /**
           * @notice Initializes the fiat token contract.
           * @param tokenName       The name of the fiat token.
           * @param tokenSymbol     The symbol of the fiat token.
           * @param tokenCurrency   The fiat currency that the token represents.
           * @param tokenDecimals   The number of decimals that the token uses.
           * @param newMasterMinter The masterMinter address for the fiat token.
           * @param newPauser       The pauser address for the fiat token.
           * @param newBlacklister  The blacklister address for the fiat token.
           * @param newOwner        The owner of the fiat token.
           */
          function initialize(
              string memory tokenName,
              string memory tokenSymbol,
              string memory tokenCurrency,
              uint8 tokenDecimals,
              address newMasterMinter,
              address newPauser,
              address newBlacklister,
              address newOwner
          ) public {
              require(!initialized, "FiatToken: contract is already initialized");
              require(
                  newMasterMinter != address(0),
                  "FiatToken: new masterMinter is the zero address"
              );
              require(
                  newPauser != address(0),
                  "FiatToken: new pauser is the zero address"
              );
              require(
                  newBlacklister != address(0),
                  "FiatToken: new blacklister is the zero address"
              );
              require(
                  newOwner != address(0),
                  "FiatToken: new owner is the zero address"
              );
              name = tokenName;
              symbol = tokenSymbol;
              currency = tokenCurrency;
              decimals = tokenDecimals;
              masterMinter = newMasterMinter;
              pauser = newPauser;
              blacklister = newBlacklister;
              setOwner(newOwner);
              initialized = true;
          }
          /**
           * @dev Throws if called by any account other than a minter.
           */
          modifier onlyMinters() {
              require(minters[msg.sender], "FiatToken: caller is not a minter");
              _;
          }
          /**
           * @notice Mints fiat tokens to an address.
           * @param _to The address that will receive the minted tokens.
           * @param _amount The amount of tokens to mint. Must be less than or equal
           * to the minterAllowance of the caller.
           * @return True if the operation was successful.
           */
          function mint(address _to, uint256 _amount)
              external
              whenNotPaused
              onlyMinters
              notBlacklisted(msg.sender)
              notBlacklisted(_to)
              returns (bool)
          {
              require(_to != address(0), "FiatToken: mint to the zero address");
              require(_amount > 0, "FiatToken: mint amount not greater than 0");
              uint256 mintingAllowedAmount = minterAllowed[msg.sender];
              require(
                  _amount <= mintingAllowedAmount,
                  "FiatToken: mint amount exceeds minterAllowance"
              );
              totalSupply_ = totalSupply_.add(_amount);
              _setBalance(_to, _balanceOf(_to).add(_amount));
              minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
              emit Mint(msg.sender, _to, _amount);
              emit Transfer(address(0), _to, _amount);
              return true;
          }
          /**
           * @dev Throws if called by any account other than the masterMinter
           */
          modifier onlyMasterMinter() {
              require(
                  msg.sender == masterMinter,
                  "FiatToken: caller is not the masterMinter"
              );
              _;
          }
          /**
           * @notice Gets the minter allowance for an account.
           * @param minter The address to check.
           * @return The remaining minter allowance for the account.
           */
          function minterAllowance(address minter) external view returns (uint256) {
              return minterAllowed[minter];
          }
          /**
           * @notice Checks if an account is a minter.
           * @param account The address to check.
           * @return True if the account is a minter, false if the account is not a minter.
           */
          function isMinter(address account) external view returns (bool) {
              return minters[account];
          }
          /**
           * @notice Gets the remaining amount of fiat tokens a spender is allowed to transfer on
           * behalf of the token owner.
           * @param owner   The token owner's address.
           * @param spender The spender's address.
           * @return The remaining allowance.
           */
          function allowance(address owner, address spender)
              external
              override
              view
              returns (uint256)
          {
              return allowed[owner][spender];
          }
          /**
           * @notice Gets the totalSupply of the fiat token.
           * @return The totalSupply of the fiat token.
           */
          function totalSupply() external override view returns (uint256) {
              return totalSupply_;
          }
          /**
           * @notice Gets the fiat token balance of an account.
           * @param account  The address to check.
           * @return balance The fiat token balance of the account.
           */
          function balanceOf(address account)
              external
              override
              view
              returns (uint256)
          {
              return _balanceOf(account);
          }
          /**
           * @notice Sets a fiat token allowance for a spender to spend on behalf of the caller.
           * @param spender The spender's address.
           * @param value   The allowance amount.
           * @return True if the operation was successful.
           */
          function approve(address spender, uint256 value)
              external
              virtual
              override
              whenNotPaused
              notBlacklisted(msg.sender)
              notBlacklisted(spender)
              returns (bool)
          {
              _approve(msg.sender, spender, value);
              return true;
          }
          /**
           * @dev Internal function to set allowance.
           * @param owner     Token owner's address.
           * @param spender   Spender's address.
           * @param value     Allowance amount.
           */
          function _approve(
              address owner,
              address spender,
              uint256 value
          ) internal override {
              require(owner != address(0), "ERC20: approve from the zero address");
              require(spender != address(0), "ERC20: approve to the zero address");
              allowed[owner][spender] = value;
              emit Approval(owner, spender, value);
          }
          /**
           * @notice Transfers tokens from an address to another by spending the caller's allowance.
           * @dev The caller must have some fiat token allowance on the payer's tokens.
           * @param from  Payer's address.
           * @param to    Payee's address.
           * @param value Transfer amount.
           * @return True if the operation was successful.
           */
          function transferFrom(
              address from,
              address to,
              uint256 value
          )
              external
              override
              whenNotPaused
              notBlacklisted(msg.sender)
              notBlacklisted(from)
              notBlacklisted(to)
              returns (bool)
          {
              require(
                  value <= allowed[from][msg.sender],
                  "ERC20: transfer amount exceeds allowance"
              );
              _transfer(from, to, value);
              allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
              return true;
          }
          /**
           * @notice Transfers tokens from the caller.
           * @param to    Payee's address.
           * @param value Transfer amount.
           * @return True if the operation was successful.
           */
          function transfer(address to, uint256 value)
              external
              override
              whenNotPaused
              notBlacklisted(msg.sender)
              notBlacklisted(to)
              returns (bool)
          {
              _transfer(msg.sender, to, value);
              return true;
          }
          /**
           * @dev Internal function to process transfers.
           * @param from  Payer's address.
           * @param to    Payee's address.
           * @param value Transfer amount.
           */
          function _transfer(
              address from,
              address to,
              uint256 value
          ) internal override {
              require(from != address(0), "ERC20: transfer from the zero address");
              require(to != address(0), "ERC20: transfer to the zero address");
              require(
                  value <= _balanceOf(from),
                  "ERC20: transfer amount exceeds balance"
              );
              _setBalance(from, _balanceOf(from).sub(value));
              _setBalance(to, _balanceOf(to).add(value));
              emit Transfer(from, to, value);
          }
          /**
           * @notice Adds or updates a new minter with a mint allowance.
           * @param minter The address of the minter.
           * @param minterAllowedAmount The minting amount allowed for the minter.
           * @return True if the operation was successful.
           */
          function configureMinter(address minter, uint256 minterAllowedAmount)
              external
              whenNotPaused
              onlyMasterMinter
              returns (bool)
          {
              minters[minter] = true;
              minterAllowed[minter] = minterAllowedAmount;
              emit MinterConfigured(minter, minterAllowedAmount);
              return true;
          }
          /**
           * @notice Removes a minter.
           * @param minter The address of the minter to remove.
           * @return True if the operation was successful.
           */
          function removeMinter(address minter)
              external
              onlyMasterMinter
              returns (bool)
          {
              minters[minter] = false;
              minterAllowed[minter] = 0;
              emit MinterRemoved(minter);
              return true;
          }
          /**
           * @notice Allows a minter to burn some of its own tokens.
           * @dev The caller must be a minter, must not be blacklisted, and the amount to burn
           * should be less than or equal to the account's balance.
           * @param _amount the amount of tokens to be burned.
           */
          function burn(uint256 _amount)
              external
              whenNotPaused
              onlyMinters
              notBlacklisted(msg.sender)
          {
              uint256 balance = _balanceOf(msg.sender);
              require(_amount > 0, "FiatToken: burn amount not greater than 0");
              require(balance >= _amount, "FiatToken: burn amount exceeds balance");
              totalSupply_ = totalSupply_.sub(_amount);
              _setBalance(msg.sender, balance.sub(_amount));
              emit Burn(msg.sender, _amount);
              emit Transfer(msg.sender, address(0), _amount);
          }
          /**
           * @notice Updates the master minter address.
           * @param _newMasterMinter The address of the new master minter.
           */
          function updateMasterMinter(address _newMasterMinter) external onlyOwner {
              require(
                  _newMasterMinter != address(0),
                  "FiatToken: new masterMinter is the zero address"
              );
              masterMinter = _newMasterMinter;
              emit MasterMinterChanged(masterMinter);
          }
          /**
           * @inheritdoc Blacklistable
           */
          function _blacklist(address _account) internal override {
              _setBlacklistState(_account, true);
          }
          /**
           * @inheritdoc Blacklistable
           */
          function _unBlacklist(address _account) internal override {
              _setBlacklistState(_account, false);
          }
          /**
           * @dev Helper method that sets the blacklist state of an account.
           * @param _account         The address of the account.
           * @param _shouldBlacklist True if the account should be blacklisted, false if the account should be unblacklisted.
           */
          function _setBlacklistState(address _account, bool _shouldBlacklist)
              internal
              virtual
          {
              _deprecatedBlacklisted[_account] = _shouldBlacklist;
          }
          /**
           * @dev Helper method that sets the balance of an account.
           * @param _account The address of the account.
           * @param _balance The new fiat token balance of the account.
           */
          function _setBalance(address _account, uint256 _balance) internal virtual {
              balanceAndBlacklistStates[_account] = _balance;
          }
          /**
           * @inheritdoc Blacklistable
           */
          function _isBlacklisted(address _account)
              internal
              virtual
              override
              view
              returns (bool)
          {
              return _deprecatedBlacklisted[_account];
          }
          /**
           * @dev Helper method to obtain the balance of an account.
           * @param _account  The address of the account.
           * @return          The fiat token balance of the account.
           */
          function _balanceOf(address _account)
              internal
              virtual
              view
              returns (uint256)
          {
              return balanceAndBlacklistStates[_account];
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { Ownable } from "./Ownable.sol";
      /**
       * @title Blacklistable Token
       * @dev Allows accounts to be blacklisted by a "blacklister" role
       */
      abstract contract Blacklistable is Ownable {
          address public blacklister;
          mapping(address => bool) internal _deprecatedBlacklisted;
          event Blacklisted(address indexed _account);
          event UnBlacklisted(address indexed _account);
          event BlacklisterChanged(address indexed newBlacklister);
          /**
           * @dev Throws if called by any account other than the blacklister.
           */
          modifier onlyBlacklister() {
              require(
                  msg.sender == blacklister,
                  "Blacklistable: caller is not the blacklister"
              );
              _;
          }
          /**
           * @dev Throws if argument account is blacklisted.
           * @param _account The address to check.
           */
          modifier notBlacklisted(address _account) {
              require(
                  !_isBlacklisted(_account),
                  "Blacklistable: account is blacklisted"
              );
              _;
          }
          /**
           * @notice Checks if account is blacklisted.
           * @param _account The address to check.
           * @return True if the account is blacklisted, false if the account is not blacklisted.
           */
          function isBlacklisted(address _account) external view returns (bool) {
              return _isBlacklisted(_account);
          }
          /**
           * @notice Adds account to blacklist.
           * @param _account The address to blacklist.
           */
          function blacklist(address _account) external onlyBlacklister {
              _blacklist(_account);
              emit Blacklisted(_account);
          }
          /**
           * @notice Removes account from blacklist.
           * @param _account The address to remove from the blacklist.
           */
          function unBlacklist(address _account) external onlyBlacklister {
              _unBlacklist(_account);
              emit UnBlacklisted(_account);
          }
          /**
           * @notice Updates the blacklister address.
           * @param _newBlacklister The address of the new blacklister.
           */
          function updateBlacklister(address _newBlacklister) external onlyOwner {
              require(
                  _newBlacklister != address(0),
                  "Blacklistable: new blacklister is the zero address"
              );
              blacklister = _newBlacklister;
              emit BlacklisterChanged(blacklister);
          }
          /**
           * @dev Checks if account is blacklisted.
           * @param _account The address to check.
           * @return true if the account is blacklisted, false otherwise.
           */
          function _isBlacklisted(address _account)
              internal
              virtual
              view
              returns (bool);
          /**
           * @dev Helper method that blacklists an account.
           * @param _account The address to blacklist.
           */
          function _blacklist(address _account) internal virtual;
          /**
           * @dev Helper method that unblacklists an account.
           * @param _account The address to unblacklist.
           */
          function _unBlacklist(address _account) internal virtual;
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
      abstract contract AbstractFiatTokenV1 is IERC20 {
          function _approve(
              address owner,
              address spender,
              uint256 value
          ) internal virtual;
          function _transfer(
              address from,
              address to,
              uint256 value
          ) internal virtual;
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { Ownable } from "../v1/Ownable.sol";
      import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
      import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
      contract Rescuable is Ownable {
          using SafeERC20 for IERC20;
          address private _rescuer;
          event RescuerChanged(address indexed newRescuer);
          /**
           * @notice Returns current rescuer
           * @return Rescuer's address
           */
          function rescuer() external view returns (address) {
              return _rescuer;
          }
          /**
           * @notice Revert if called by any account other than the rescuer.
           */
          modifier onlyRescuer() {
              require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
              _;
          }
          /**
           * @notice Rescue ERC20 tokens locked up in this contract.
           * @param tokenContract ERC20 token contract address
           * @param to        Recipient address
           * @param amount    Amount to withdraw
           */
          function rescueERC20(
              IERC20 tokenContract,
              address to,
              uint256 amount
          ) external onlyRescuer {
              tokenContract.safeTransfer(to, amount);
          }
          /**
           * @notice Updates the rescuer address.
           * @param newRescuer The address of the new rescuer.
           */
          function updateRescuer(address newRescuer) external onlyOwner {
              require(
                  newRescuer != address(0),
                  "Rescuable: new rescuer is the zero address"
              );
              _rescuer = newRescuer;
              emit RescuerChanged(newRescuer);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { FiatTokenV1 } from "../v1/FiatTokenV1.sol";
      import { Rescuable } from "./Rescuable.sol";
      /**
       * @title FiatTokenV1_1
       * @dev ERC20 Token backed by fiat reserves
       */
      contract FiatTokenV1_1 is FiatTokenV1, Rescuable {
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      import { ECRecover } from "./ECRecover.sol";
      import { IERC1271 } from "../interface/IERC1271.sol";
      /**
       * @dev Signature verification helper that can be used instead of `ECRecover.recover` to seamlessly support both ECDSA
       * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets.
       *
       * Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/21bb89ef5bfc789b9333eb05e3ba2b7b284ac77c/contracts/utils/cryptography/SignatureChecker.sol
       */
      library SignatureChecker {
          /**
           * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
           * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECRecover.recover`.
           * @param signer        Address of the claimed signer
           * @param digest        Keccak-256 hash digest of the signed message
           * @param signature     Signature byte array associated with hash
           */
          function isValidSignatureNow(
              address signer,
              bytes32 digest,
              bytes memory signature
          ) external view returns (bool) {
              if (!isContract(signer)) {
                  return ECRecover.recover(digest, signature) == signer;
              }
              return isValidERC1271SignatureNow(signer, digest, signature);
          }
          /**
           * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
           * against the signer smart contract using ERC1271.
           * @param signer        Address of the claimed signer
           * @param digest        Keccak-256 hash digest of the signed message
           * @param signature     Signature byte array associated with hash
           *
           * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
           * change through time. It could return true at block N and false at block N+1 (or the opposite).
           */
          function isValidERC1271SignatureNow(
              address signer,
              bytes32 digest,
              bytes memory signature
          ) internal view returns (bool) {
              (bool success, bytes memory result) = signer.staticcall(
                  abi.encodeWithSelector(
                      IERC1271.isValidSignature.selector,
                      digest,
                      signature
                  )
              );
              return (success &&
                  result.length >= 32 &&
                  abi.decode(result, (bytes32)) ==
                  bytes32(IERC1271.isValidSignature.selector));
          }
          /**
           * @dev Checks if the input address is a smart contract.
           */
          function isContract(address addr) internal view returns (bool) {
              uint256 size;
              assembly {
                  size := extcodesize(addr)
              }
              return size > 0;
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      /**
       * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
       *
       * The library provides methods for generating a hash of a message that conforms to the
       * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
       * specifications.
       */
      library MessageHashUtils {
          /**
           * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
           * Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/21bb89ef5bfc789b9333eb05e3ba2b7b284ac77c/contracts/utils/cryptography/MessageHashUtils.sol
           *
           * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
           * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the
           * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
           *
           * @param domainSeparator    Domain separator
           * @param structHash         Hashed EIP-712 data struct
           * @return digest            The keccak256 digest of an EIP-712 typed data
           */
          function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash)
              internal
              pure
              returns (bytes32 digest)
          {
              assembly {
                  let ptr := mload(0x40)
                  mstore(ptr, "\\x19\\x01")
                  mstore(add(ptr, 0x02), domainSeparator)
                  mstore(add(ptr, 0x22), structHash)
                  digest := keccak256(ptr, 0x42)
              }
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      /**
       * @title EIP712
       * @notice A library that provides EIP712 helper functions
       */
      library EIP712 {
          /**
           * @notice Make EIP712 domain separator
           * @param name      Contract name
           * @param version   Contract version
           * @param chainId   Blockchain ID
           * @return Domain separator
           */
          function makeDomainSeparator(
              string memory name,
              string memory version,
              uint256 chainId
          ) internal view returns (bytes32) {
              return
                  keccak256(
                      abi.encode(
                          // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                          0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                          keccak256(bytes(name)),
                          keccak256(bytes(version)),
                          chainId,
                          address(this)
                      )
                  );
          }
          /**
           * @notice Make EIP712 domain separator
           * @param name      Contract name
           * @param version   Contract version
           * @return Domain separator
           */
          function makeDomainSeparator(string memory name, string memory version)
              internal
              view
              returns (bytes32)
          {
              uint256 chainId;
              assembly {
                  chainId := chainid()
              }
              return makeDomainSeparator(name, version, chainId);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      /**
       * @title ECRecover
       * @notice A library that provides a safe ECDSA recovery function
       */
      library ECRecover {
          /**
           * @notice Recover signer's address from a signed message
           * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/65e4ffde586ec89af3b7e9140bdc9235d1254853/contracts/cryptography/ECDSA.sol
           * Modifications: Accept v, r, and s as separate arguments
           * @param digest    Keccak-256 hash digest of the signed message
           * @param v         v of the signature
           * @param r         r of the signature
           * @param s         s of the signature
           * @return Signer address
           */
          function recover(
              bytes32 digest,
              uint8 v,
              bytes32 r,
              bytes32 s
          ) internal pure returns (address) {
              // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
              // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
              // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
              // signatures from current libraries generate a unique signature with an s-value in the lower half order.
              //
              // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
              // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
              // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
              // these malleable signatures as well.
              if (
                  uint256(s) >
                  0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
              ) {
                  revert("ECRecover: invalid signature 's' value");
              }
              if (v != 27 && v != 28) {
                  revert("ECRecover: invalid signature 'v' value");
              }
              // If the signature is valid (and not malleable), return the signer address
              address signer = ecrecover(digest, v, r, s);
              require(signer != address(0), "ECRecover: invalid signature");
              return signer;
          }
          /**
           * @notice Recover signer's address from a signed message
           * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0053ee040a7ff1dbc39691c9e67a69f564930a88/contracts/utils/cryptography/ECDSA.sol
           * @param digest    Keccak-256 hash digest of the signed message
           * @param signature Signature byte array associated with hash
           * @return Signer address
           */
          function recover(bytes32 digest, bytes memory signature)
              internal
              pure
              returns (address)
          {
              require(signature.length == 65, "ECRecover: invalid signature length");
              bytes32 r;
              bytes32 s;
              uint8 v;
              // ecrecover takes the signature parameters, and the only way to get them
              // currently is to use assembly.
              /// @solidity memory-safe-assembly
              assembly {
                  r := mload(add(signature, 0x20))
                  s := mload(add(signature, 0x40))
                  v := byte(0, mload(add(signature, 0x60)))
              }
              return recover(digest, v, r, s);
          }
      }
      /**
       * SPDX-License-Identifier: Apache-2.0
       *
       * Copyright (c) 2023, Circle Internet Financial, LLC.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      pragma solidity 0.6.12;
      /**
       * @dev Interface of the ERC1271 standard signature validation method for
       * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
       */
      interface IERC1271 {
          /**
           * @dev Should return whether the signature provided is valid for the provided data
           * @param hash          Hash of the data to be signed
           * @param signature     Signature byte array associated with the provided data hash
           * @return magicValue   bytes4 magic value 0x1626ba7e when function passes
           */
          function isValidSignature(bytes32 hash, bytes memory signature)
              external
              view
              returns (bytes4 magicValue);
      }