ETH Price: $2,992.72 (+7.66%)

Transaction Decoder

Block:
13148013 at Sep-02-2021 06:58:39 PM +UTC
Transaction Fee:
0.40111926306943799 ETH $1,200.44
Gas Used:
2,429,623 Gas / 165.09526913 Gwei

Emitted Events:

65 WETH9.Transfer( src=BatchAuction, dst=[Receiver] Proxy, wad=11942316243591909019948 )
66 BatchAuction.AuctionFinalized( )
67 WETH9.Approval( src=[Receiver] Proxy, guy=UniswapV2Router02, wad=2985000000000000000000 )
68 InitializedProxy.0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925( 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925, 0x000000000000000000000000f5c27c6fe782cbb5c85989ea3e75754748153459, 0x000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f, 000000000000000000000000000000000000000002bdd9a7c6b09058b1c00000 )
69 UniswapV2Factory.PairCreated( token0=InitializedProxy, token1=WETH9, pair=UniswapV2Pair, 1878 )
70 WETH9.Transfer( src=[Receiver] Proxy, dst=UniswapV2Pair, wad=2985000000000000000000 )
71 InitializedProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000f5c27c6fe782cbb5c85989ea3e75754748153459, 0x000000000000000000000000c96f20099d96b37d7ede66ff9e4de59b9b1065b1, 000000000000000000000000000000000000000002bdd9a7c6b09058b1c00000 )
72 InitializedProxy.0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925( 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925, 0x000000000000000000000000f5c27c6fe782cbb5c85989ea3e75754748153459, 0x000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f, 0000000000000000000000000000000000000000000000000000000000000000 )
73 UniswapV2Pair.Transfer( from=0x0000000000000000000000000000000000000000, to=0x0000000000000000000000000000000000000000, value=1000 )
74 UniswapV2Pair.Transfer( from=0x0000000000000000000000000000000000000000, to=[Receiver] Proxy, value=1591454451525396312055925 )
75 UniswapV2Pair.Sync( reserve0=848484848000000000000000000, reserve1=2985000000000000000000 )
76 UniswapV2Pair.Mint( sender=UniswapV2Router02, amount0=848484848000000000000000000, amount1=2985000000000000000000 )
77 Proxy.0x442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e( 0x442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e, 250a007f59d32137c2b54d1607d30b1f8232753d7c1ed477b9838c58e4b1d683, 0000000000000000000000000000000000000000000000000000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
0x5e29C9Bf...9726745f3
0x9E64B47b...16C0c4110
357.542401445517022724 Eth
Nonce: 1532
357.141282182447584734 Eth
Nonce: 1533
0.40111926306943799
0xBAac2B44...9f2Fe8899
0xC02aaA39...83C756Cc2
0xC0AEe478...cE9e4f2Ac
(SushiSwap: SushiV2Factory)
0xc96F2009...b9B1065b1
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 970373714831926824185720946407840263919885073365469911651691774426946431665543512266471865775868962627047669120248256871330625770147892446909619397165810409821289694709588701323306867677257649208384978349326387418445535411191118173905878669248600552166591791127934899764776865837522151370137666890102937838273775714968403856071175813256007843767997955403679486028211556891105243817726967350283407681114102132506579105125304277564748167815342846397024705072290664688887558303342418259078870337858807302319256353732814537234856888289613708027399674335981848864884958452594500448750123709185757271799691704594825598460045237586046981286669973607497255811248054916336618770260591883114344560407110384952401173472315603951832690057890728508533745208338355059829327548814715428518717514222047513979665697375218597595236539309508342917627352671706653209120529696995353248818356303163358689521388719239190242456394183021189172097977158907875657912486338605550512879487546676611633302271475230667775383719586180157187006417919294738744302779946465631339458792305308388695808298977436244150528688722984158355049284028840226995683127551502032244556088325501540382610106837793499207544745847718703884658674971349811778799823186899170503086682057503015478989252616739182840170696904121594239897477811643131587177762472373252413961045631116709127211075498543319742453850377373997193487204507937988130627395736990058948639391539526660279803561610920474370751025762940139057313015758758177084944501064026665275431427980754256105434841498616423371358100769582975367394534305839627596757926422255187488652424989920991106699704285218110087276668191579082991838055940384641216906778353396018761511726797808610883741967942439137978054277212926284323547744109748783704275823053134686965394765704525445335194995340096279909491669098968935048953229629943910852066846595255766003226661174563949284052662117683721297660878592752685812469412066226405256310300438123619122828358311956300515948584897168820181311307515960755566624820143581320130400436732430638757868105953235466201800551590642755199648768273840591217733703620122243046325177668875516589566186636552174328659351513829282183884728262737218293545660596090969194471746871639948423418133586283866848948755311858692792320015436705816826440167723594281725277786605652770607698595900860223296437361927414376806437454204221244562486431899121071258780478379713316090152930112403133360327562653887016859083131040153889215211323340813891512208835582785595562532764709571103779102385994607473767759168295977624053955553512127361136426538721787686273453511216321239183520203588811113863626898343603784694118873851299330941956336018763877641535415884115710877740619706271918898464309749601333378501029178035189073363581003538216114898931114069302906737007051217887941611058391704483961983559785678569226084393692748550358504162988262743787900735768854607548925214343876751173683240824537308869801034098086776090912184840943364789608450108459058933828983365323127039638227524786338618000741006805641404819667044578037513628325173792992961824268689937669803599385494531623006692678868266120342454231855367906672560857809652908409078712367240635083658783854998584107465781037693112513504825080582332559347701051998974052053888576433850257906421102691284722864269704993003259908294704731616967666654167264848619972686653049260286109671848420793729709370897804926875423209863906428649310141041420009308127692597213921785490932788250583591674330356319897647747966146273898207930464771640539235830297333795401391504913652002320834613139741729368076652639464809773036076522969727659814124493464736987149809623832179451960770442040089734066312381297621879209022972801995571207352139151813089383646316351003310088139583590200672467808917264244386886686780453034140252637399180853260893922871128134433658609402748592130103963716546418725297520172944253857179183372468597190740759330590535670086374039630566975022955063170235065419296211949925273534052166004931987053298744637680011520831696542439607935300090502442438628514704477777102077986400176928856421605465129904174375972069211884462686883127713983467366860696368293716646956430672441424157258002385728282981306401694519326352934263298910982764980359652051223655655973714964833272423536068705931065645195932747891957766635776607472853023498124125964636568569512510264833392965747882773042738073847722385153647116948377688001424405819072114441606023784819011307292593178371303550296069228919741033823614181671434165165421383404767918836111241485989602761334449249466478212271691824027973863031222508351251598385598912343174008560798462069422639468405381063772605084007897065125907501478031106752086726688148537339128408569442511472471975545649657946884040962639071287276756275296263185109094564560920665709490772570679214129986144483752172595065335376963118597353944360246948948707586104853443176504880336918799957791065013022708627522814449711198702971114199024767133622346271292454993091805558177225768153096898303215097794211384523665473480643159410975016566620094591227052545319983765731532882350692747959420304224788485546890539259456085729469644680536986534637473170030708752822844772728987369817960256444094330702380885247926779415102435230803511443387105218505773040253262681523812180336520174794063087828241652218468762070586639746038321444642339626887634561153005479829608775330513173749405949716488789916381320425408414358752168817056559748812376244000590762854954314312663591755959405349006342640619098860796240062136157017719308399118564718743424013383953737720966358025713878278595430321887831137936259968296108592516513885707646624386380588008284583091803577117355591715374847170183589884461644255753143821210520303003100589083442202872479208287982760509683028047435613917926769745754618786845568335164562199183803448267307125507647424953068096864047151973851978073177428952839368627496204245025512138852305067922475400744111741971427173134495092218577816898603979675657754170230151168303366348265812641753106106772591540444252313523596780852703861172946736140246608460295875532543210426388979849381559833437039563435941549222227434569151633120212031453018819385630747722690813161762643419447206720512857089685827237039229397153740701597393287473724788562809034793328475823300677471937317677691837237894690439996426670181098526505342455729605979013749562452983747978768114552446856852023712514155703336513599427920772230682119186309321861914970213987289588275852035719372336659513573113656877618591862649326611914128580797181101364248322503230781633164186818231899634001311333258722839527336120702530738349212452416436300664085922190387117741793094198905592333357837426362099693208264568304704344967573770233806317187230870419409670937264725195884319274347207104410975884158365820401269043531976282629352504595598126046414093102768964092394311909425922966147107009361287347299428758092883122692136112630686169998346027329153711259532475731043582179362533519845870327551250060165488318315803827996089999110430800065530467920180163722884927674657200276626081910461803269368952628730875439204264162932081120527913006557957744514889818853925809011263078396276018428867706926005115509213333228605275574890553026955179599871709202395034822652888141269309109734322733264506756420204739831230530880327169751198067980692564160862893983370283465694590183203769738224718314349984179540394198676053375664759977675702219997771811838247986690461023015927827429492578944271012650006574408024585377051203614603729660654456777990209191502022990197729818969864410828865017479646361979476453851484691304981448346016038824075560134472665066664491496179478999648935490294701429779929315619388575702574357785786090451257694788109101210639982684833459404824653248740920617108408548887935240960839050302685749957466576524637031585237207339666450432711265151975751341773671998379757237804933942228055834687721941426537564376739573344032146862045259319183351508814511830286739243982365210781714974458897247497697002057154545892946110509547543471449083690747604826499673393514629399722431455689436350763458074168064888197070393968390438977228630761766093119655774395698612836974355327985124028054520638396868898892736959571058738421473425384929489113548813840860074487898330414801765855587748553806713906105440614678759954262871936381480236279852264806909516711341688548750501337587387672360221244371172177671200922024952651391556899415437579417011797401592989444457073058275514205956201848924217964835016415954656336252152856491521595231297454269241938277131439704423551330612117358046164730806832601160288390874769930872202629213600971363540576274141782381535247172155304749605615723096656469063547236276388170374855879792917902148058601928565499982491144692486083511159333922403948467825631315716451899262083934011171848498437165726363619725429738272768068275481148343272357717715150724633570307392266973671384031024725364695855198542436416424360582961266612568697466028541562876786082163927073662080043144889766409119138448855762360858613202880414776752522467635049718129289638698721065221925939135759391754085175391096464080040023095105645093813002457184029379826150339976731647337702786957691568399488647262699092137030247089786860088628392311411861836543300617935577226081902113340564338782783648633548985274420679526628794356405839072220764943487632464344256729379647295745097693846466289646792591875466815860796571268171492137772810924090844967592335574781754716685784691014495046993523459358222061397503969885568467212847294389127064062045960751855865770410518730507699373418760658333677112957244072117879293498465127102270950754390673539046312444324669390947895797211606548479473329353848576117136172619357906471019074036841450925640565889945574682536528223276622784642449667081724706674034033565494717346503769515040472385946502596541182491529408987820922111880322587337440286877512839054470637984159200451631314592617512951699433153475235051530534244418897306687989511134122202108387116023928323393685624348550174007518071030991921987960670005320336877725964006729509639764597879335793850991602353340061558978051791300636366553862753724370623567968749783743310780965036384605460691415194433689969011792973782473666950781224341315781450260035537719069704919720787263675816258532654591347236112761126400845251037826580843692724311711333112779225989883101744757245522183925999092166378829399827665359320744176108182791920430631066099517964732943588800249683483552673364253912775513166306788502375427615776030682207304558057915785891170359083003506646568939144125975464897708668342017234594621007650504231529767738963839937251500725868969894569417717880486314264631787016280709740788000085743995949795467514386081601265876195773210554156664380919010352067746586927874956968642069823898907824505385129849954983593151006664078692024277439343794964900380458144271983561819401740504889542906704033311834295862042680157208880708862945239096085854099675739746647198632047949942242766670969367007119626619843275096008868870903165501506054102277734036597006432439849426382928680483878929115980449437248303103730604604592219926788689799174953705421826252975210132506850942122495828640523632088798819600172273825009705603169474652888941308494136146681775574600873672105369458799174990461031795705196541081814131638647046005745470256316096326843752906192320328546785563701780636829801898881528702809091457681100156525220118941327671513095786900017264775058641975182773252443580703006370973152943735735742285548548294699790631541248592989241957243039395060417242697132769629526041535322521567995031721284554356733693331592393104973550169047476203721814936589454528872745901630224615442989086815050052787690939530838859133503778297474896311126790406655466517562847539984021903454365389210667011353422460804557274316638803784710865430830008710699929583983043198766622348864987925050304298262827118935540356738701427925554624732808712109260530989348886248024089487130530404851035088670778246702210209088813805811907431148698396276997459378045504728422691255167219358992301084830132326603177696930466301600864085761755561999092577471792763261997877124626854601292477204157934995386209866950649217732587631957987512932767561879105467656889358094535660718173509156619154285903745112199448970760461006993780614112378281744018991808106630713891427374272023679690978206418934655911079191164789255422133484034273841768693139752423025910110946595652958417442477329430614244980753983362977720871460234864332771053833672737385209965600946595217766006705509026335509477823549003356986161630450925451471756599928476953844115491317427518347142728294936900654063320919079169285734763420505042430799660052417974812293277574774495634371192624279092678522520750496435533666954262462791923797130294327609327848256088663585250685505553614974996756806161687704484071008834742737611940384249653338719817823413378421369601095501312144948495855539403060945885081617073278655682049319069029345671477101366796090736510647364543619064229138844873187388727093530914503627954549241832721488528113846291486541998769962403140919120192937910762917046598457816085658368084945362999807914843368403160449927534613376645197123266144917645477745760744680788271770438533853528044263031585396537896973379066873050363663459138939627619811565049002466703204632171381254017627402046149919219222020468226407743716190862780972009870633237901970906872167286590335348007321748183330880831894517946593143311518075865318361769843573639749478724865189109381609191603639419492707737523586307085883952245365881699264388059523295084962136196858877919464742499682778558150008055864043696561294304075526720560755837319200301322870360611477376950704864996348223704493049371991873583715766288717661124660410740528994164578954884549269315702207501467717456235970416775885723625865136800179170019783518699285177100551996746978063703196484468562083725332025707044434502088998828479479935003802489408559691117390918028532713442605962854364008870636177674215829292274920743064007902408674319602358727755590116931326808886237063800930049816855086360319557479555013074872388376341102936941754783044200240784242710394470642411624545509452881918665007454852507591464153777301531200239259909053527415489780939592604428584244320185608386164260830273792287943771437987254680616514172054163699428650966604299326846676724140554046037026358221667172911863956259956146392339729150490341959475539432842841141291469534887669781319320656658212488599163215819826442113023979743609333804460131078449584535247009672860018797780828507186528033076747945754492845689280056680647094379994572606617159879968580198913830564139884066633170040829394173706681535220794401477997987297977107820559276833700338101970959709324601486316626605489272080540314560766531860937959035948430083007800045007498518871400943035382833985896842761282512388069238975577827426697859409780907813757482456128103770110049604561331276909028069992448008029939400269044378012410359306419624436057392323165033306556216096491999516197862147320234261339461472875683397169521907905600043631231781545801925083891329614246023591374927606105723616711484545890671142513058556377532998707736458954171149864129939436464074335169248506525066785276675491136322415743917982962584043021663863398460998832644169959399215000217933991974541747409945961883326242580638764259996984016881380781908912159725686109466173134328173490210619158958787033625142640585491171826024862706826915229042224704272380700947928026391349311581425246007287881064209097727176917170386929944486570017097816833310615319893425627747705549542341524222988418400819813694851686348251611424033769185244888235358798548729476924616796051964418542426166888025984387570148732403732506194193958217393623861731246348752581987043707580411196754241659650238869269631716706528956281317686833691822617354461178650995225853844606121132325199558969976375822009166098747524107639013101062599029451378959339390202342582736335599652325505465353986683813946071192018081076312208629765395621209488277395784640860911514039728018066531901659516572197637400575476983162933776715620891736835679339575538095711271758873450076801737906029045336800888123127161425737942261238783698288429238591871878369623243006466420827979809623303915097870501405730419021175864637866787640746589858208013269149415851747981650993140293347620441621505600556855327715304808824122988766738348767312367920204976341982114621575157364390735118188857538091797048990788865248803972209514274999813436635362075827698706353693009242065402727925570603883194574478422993054092064842160983021821541991745086159871539488371195275996694643200450371024090799232120447690997852642261610238429040502221826879328337883986261627726469661275043050945235000486318691012267622286024896456957752092888038622148980772634110200921305608258748205519856430442107346888546461133463542594736137007567199019364607312049451945117486753334499685446808143117559430109302310294457260699168509577665465389348009093500969317952850435509882319600829023179999141813601449202487279621273466315052248272311214774245835781000744915320708917707088419286083855697539420164684989694373887539791225273805431250987945559717884299875590380599141739447481123798946068305286992390176788967266661487863056742269454724613458743877244970441960417040989608269799571037982994082675722414785707995176423374816524171512633509935054437801803310248384314285954281462633920453516986844165643310740186901428295734074251032436825760578410365476902843686484707897486327323001802570292298821730078302732901129606491355573740245413060205772816910805639747087366487474436402913952818642505822608211221231677940391464488526521617830036965405717227879288032834017163260707269715179086414548635459287296187665159532791005266513787039098259163867770236806630346145864154316664216357850431592592359357446437001032934265550512830069601314834263788955728577079168572371414522895094750990390037111638813956940038739336834117961630269344815833094571050603534124731144224664253090404674455179570848947414318901227315544465021017836111627574376422404611915266696378634541371628288275606736107092316640721239149189865613035653407405711253689628930932536948673165561694357200020411829896891576446318915146439820526504623011486554989516165667323335693414934814004410278644054000879039077833478222322272172872756103371354890899347688095119987051466357536009129562866823329151434447032893988942430150070946911349522553627858194947768274263084245629745183222615730004776379639668442725598279874930308244088933008485396959917666681610999955901665756196851949672769851203664125707554741540254559589839455890674210549613366744628250073940092320601238917734706503162753930994533684587838945685931212495222992599246372012582151929497212649486853033780275395201624953847297781180136653199208638796247411753539601271520979109694681051203539727904805097294418844970859034890974420496664672055334861261760577417100136846408252492277891862905518897820428967259414938247580001447414510879102374696398833681566184073453099383668886595163928620965172752288672765029891029325085087456675823219540845532470723299624971609531611152834905485995656999320694510613883917811326120587965945992437257752500815632041698885255900054689108235889290415209428332936722366764889127234155667730465019401160065463007229392807541321336673902417329345781330121820189416588185054182834106503659033695040889811794590145458037336891808190609892824794636329808967954256162631834596750615551750885506661417008739876427848834173792022477826960766473390684073275311664976029919411152403305472706182649305024864582120589644917212074489284683189328610953965037460607871739534360932914668243598486662868330241318289838917701751649537035731801559759342829825067798963468992656715072809773251050799601512114788075674879299224408300911146471181524820624990967218578355354523595632118493281309130872723834470866206629973887965161739406193341212336262793271639852531306838133337615718728319588810050542270596956328567969570294887381238958194557914489771335585918386940508644713954522805652967236056982078861155491811377171122930283117015403615649057864389322174134638420880929447094682133107475402227582325798127425448778476048451495428393366905468431691919308127178234473964052772617886621785434581352325198198055102133905256578806269728104359955638474987554997853220494348754346661779775947650590800195501275865742243509974608314470088293937303056528230079665296631935180049276802937989044278604178623082423213142113594479981759246054400064387201884459817337594764911691628527252625205351851767408034075053271423174343509950819755385274072523521130743043892243679459309153516863691890342691490453628793924053747111342564967146040090893591274974111127466787240729067426868324690634630052613037171225116580863468738108996853020180544491645000100174575664012894587507333228928354119713825262406933537472892720657172973712656680598385724687705359141398533994684371207343695251028367425700446320896600152962617022752618119262643853347831915167751822676880325218838130722794593790105951383826557724427909166920523335397976410875362536439098738683685984789647681920089933271389419332348794542537281522986540989318881267423868328272321517940529382711784095183479130385844905903202668137163485645250252636181922893427516074609054230102691384884727058499011448444251554567015759544508413009302584592842680906254129887071647426059491020839771430126624782157841259965956947711701654222689895616224767511443599054979604607211348567169816537828949827685467972847719691791084849022596830103592906915740960569411166874579067131092771723878155546100222088541325901052260690681040153958893918600970285548717664354906966339614995694273180466886605408349453805523472862965155943740978752213097794321902761534688209534705436678922666950115252179355448276882854139279907243975102208610580905971149150181109773352077055509317246966021606859379181045294031105163315
(Miner: 0xe20...Fd0)
2,531.520444759812335151 Eth2,531.525304005812335151 Eth0.004859246
0xF5c27c6f...748153459
(og.pleasrdao.eth)

Execution Trace

Proxy.6a761202( )
  • GnosisSafe.execTransaction( to=0x8D29bE29923b68abfDD21e541b9374737B49cdAD, value=0, data=0x8D80FF0A000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002E4005E29C9BF97C45E55F1C2257D0ECF6909726745F3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044BB278F300C02AAA39B223FE8D0A0E5C4F27EAD9083C756CC200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095EA7B3000000000000000000000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F0000000000000000000000000000000000000000000000A1D13254CACD04000000BAAC2B4491727D78D2B78815144570B9F2FE889900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095EA7B3000000000000000000000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F000000000000000000000000000000000000000002BDD9A7C6B09058B1C0000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104E8E33700000000000000000000000000C02AAA39B223FE8D0A0E5C4F27EAD9083C756CC2000000000000000000000000BAAC2B4491727D78D2B78815144570B9F2FE88990000000000000000000000000000000000000000000000A1D13254CACD040000000000000000000000000000000000000000000002BDD9A7C6B09058B1C000000000000000000000000000000000000000000000000000A1D13254CACD040000000000000000000000000000000000000000000002BDD9A7C6B09058B1C00000000000000000000000000000F5C27C6FE782CBB5C85989EA3E757547481534590000000000000000000000000000000000000000000000000000000061312AA400000000000000000000000000000000000000000000000000000000, operation=1, safeTxGas=0, baseGas=0, gasPrice=0, gasToken=0x0000000000000000000000000000000000000000, refundReceiver=0x0000000000000000000000000000000000000000, signatures=0x03457418D5D4C8D2C31E15F9BC48B8F52ED2475E6E1DC2ACD5EF1525D447245C1F9874E2DB78AFEE86B88F4F574A36644CF6EF3730CE26ECC3945FC5DEAF32D61C393F1F87D81FDBF302F168247BE0A754C5F545E9A3D0FF0C6B3C0549F3B14CFB042035CB5A1BB2F071D124B8F35C9F0B7005BD1A0796E961304449AC42E0B0021B0000000000000000000000009E64B47BBDB9C1F7B599F11987B84C416C0C4110000000000000000000000000000000000000000000000000000000000000000001 ) => ( success=True )
    • Null: 0x000...001.250a007f( )
    • Null: 0x000...001.250a007f( )
    • MultiSend.multiSend( transactions=0x005E29C9BF97C45E55F1C2257D0ECF6909726745F3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044BB278F300C02AAA39B223FE8D0A0E5C4F27EAD9083C756CC200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095EA7B3000000000000000000000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F0000000000000000000000000000000000000000000000A1D13254CACD04000000BAAC2B4491727D78D2B78815144570B9F2FE889900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095EA7B3000000000000000000000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F000000000000000000000000000000000000000002BDD9A7C6B09058B1C0000000D9E1CE17F2641F24AE83637AB66A2CCA9C378B9F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104E8E33700000000000000000000000000C02AAA39B223FE8D0A0E5C4F27EAD9083C756CC2000000000000000000000000BAAC2B4491727D78D2B78815144570B9F2FE88990000000000000000000000000000000000000000000000A1D13254CACD040000000000000000000000000000000000000000000002BDD9A7C6B09058B1C000000000000000000000000000000000000000000000000000A1D13254CACD040000000000000000000000000000000000000000000002BDD9A7C6B09058B1C00000000000000000000000000000F5C27C6FE782CBB5C85989EA3E757547481534590000000000000000000000000000000000000000000000000000000061312AA4 )
      • BatchAuction.CALL( )
        • BatchAuction.DELEGATECALL( )
          • WETH9.transfer( dst=0xF5c27c6fE782cbB5c85989ea3e75754748153459, wad=11942316243591909019948 ) => ( True )
          • WETH9.approve( guy=0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F, wad=2985000000000000000000 ) => ( True )
          • InitializedProxy.095ea7b3( )
            • TokenVault.approve( spender=0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F, amount=848484848000000000000000000 ) => ( True )
            • UniswapV2Router02.addLiquidity( tokenA=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, tokenB=0xBAac2B4491727D78D2b78815144570b9f2Fe8899, amountADesired=2985000000000000000000, amountBDesired=848484848000000000000000000, amountAMin=2985000000000000000000, amountBMin=848484848000000000000000000, to=0xF5c27c6fE782cbB5c85989ea3e75754748153459, deadline=1630612132 ) => ( amountA=2985000000000000000000, amountB=848484848000000000000000000, liquidity=1591454451525396312055925 )
              • UniswapV2Factory.getPair( 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 0xBAac2B4491727D78D2b78815144570b9f2Fe8899 ) => ( 0x0000000000000000000000000000000000000000 )
              • UniswapV2Factory.createPair( tokenA=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, tokenB=0xBAac2B4491727D78D2b78815144570b9f2Fe8899 ) => ( pair=0xc96F20099d96b37D7Ede66fF9E4DE59b9B1065b1 )
                • UniswapV2Pair.60806040( )
                • UniswapV2Pair.initialize( _token0=0xBAac2B4491727D78D2b78815144570b9f2Fe8899, _token1=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 )
                • UniswapV2Pair.STATICCALL( )
                • WETH9.transferFrom( src=0xF5c27c6fE782cbB5c85989ea3e75754748153459, dst=0xc96F20099d96b37D7Ede66fF9E4DE59b9B1065b1, wad=2985000000000000000000 ) => ( True )
                • InitializedProxy.23b872dd( )
                  • TokenVault.transferFrom( sender=0xF5c27c6fE782cbB5c85989ea3e75754748153459, recipient=0xc96F20099d96b37D7Ede66fF9E4DE59b9B1065b1, amount=848484848000000000000000000 ) => ( True )
                  • UniswapV2Pair.mint( to=0xF5c27c6fE782cbB5c85989ea3e75754748153459 ) => ( liquidity=1591454451525396312055925 )
                    • InitializedProxy.70a08231( )
                      • TokenVault.balanceOf( account=0xc96F20099d96b37D7Ede66fF9E4DE59b9B1065b1 ) => ( 848484848000000000000000000 )
                      • WETH9.balanceOf( 0xc96F20099d96b37D7Ede66fF9E4DE59b9B1065b1 ) => ( 2985000000000000000000 )
                      • UniswapV2Factory.STATICCALL( )
                      • UniswapV2Factory.STATICCALL( )
                        File 1 of 11: Proxy
                        pragma solidity ^0.5.3;
                        
                        /// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        contract Proxy {
                        
                            // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
                            // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
                            address internal masterCopy;
                        
                            /// @dev Constructor function sets address of master copy contract.
                            /// @param _masterCopy Master copy address.
                            constructor(address _masterCopy)
                                public
                            {
                                require(_masterCopy != address(0), "Invalid master copy address provided");
                                masterCopy = _masterCopy;
                            }
                        
                            /// @dev Fallback function forwards all transactions and returns all received return data.
                            function ()
                                external
                                payable
                            {
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
                                    // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
                                    if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
                                        mstore(0, masterCopy)
                                        return(0, 0x20)
                                    }
                                    calldatacopy(0, 0, calldatasize())
                                    let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0)
                                    returndatacopy(0, 0, returndatasize())
                                    if eq(success, 0) { revert(0, returndatasize()) }
                                    return(0, returndatasize())
                                }
                            }
                        }

                        File 2 of 11: BatchAuction
                        // File contracts/OpenZeppelin/utils/ReentrancyGuard.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @dev Contract module that helps prevent reentrant calls to a function.
                         *
                         * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                         * available, which can be applied to functions to make sure there are no nested
                         * (reentrant) calls to them.
                         *
                         * Note that because there is a single `nonReentrant` guard, functions marked as
                         * `nonReentrant` may not call one another. This can be worked around by making
                         * those functions `private`, and then adding `external` `nonReentrant` entry
                         * points to them.
                         *
                         * TIP: If you would like to learn more about reentrancy and alternative ways
                         * to protect against it, check out our blog post
                         * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                         */
                        abstract contract ReentrancyGuard {
                            // Booleans are more expensive than uint256 or any type that takes up a full
                            // word because each write operation emits an extra SLOAD to first read the
                            // slot's contents, replace the bits taken up by the boolean, and then write
                            // back. This is the compiler's defense against contract upgrades and
                            // pointer aliasing, and it cannot be disabled.
                        
                            // The values being non-zero value makes deployment a bit more expensive,
                            // but in exchange the refund on every call to nonReentrant will be lower in
                            // amount. Since refunds are capped to a percentage of the total
                            // transaction's gas, it is best to keep them low in cases like this one, to
                            // increase the likelihood of the full refund coming into effect.
                            uint256 private constant _NOT_ENTERED = 1;
                            uint256 private constant _ENTERED = 2;
                        
                            uint256 private _status;
                        
                            constructor () internal {
                                _status = _NOT_ENTERED;
                            }
                        
                            /**
                             * @dev Prevents a contract from calling itself, directly or indirectly.
                             * Calling a `nonReentrant` function from another `nonReentrant`
                             * function is not supported. It is possible to prevent this from happening
                             * by making the `nonReentrant` function external, and make it call a
                             * `private` function that does the actual work.
                             */
                            modifier nonReentrant() {
                                // On the first call to nonReentrant, _notEntered will be true
                                require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                        
                                // Any calls to nonReentrant after this point will fail
                                _status = _ENTERED;
                        
                                _;
                        
                                // By storing the original value once again, a refund is triggered (see
                                // https://eips.ethereum.org/EIPS/eip-2200)
                                _status = _NOT_ENTERED;
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/EnumerableSet.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @dev Library for managing
                         * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
                         * types.
                         *
                         * Sets have the following properties:
                         *
                         * - Elements are added, removed, and checked for existence in constant time
                         * (O(1)).
                         * - Elements are enumerated in O(n). No guarantees are made on the ordering.
                         *
                         * ```
                         * contract Example {
                         *     // Add the library methods
                         *     using EnumerableSet for EnumerableSet.AddressSet;
                         *
                         *     // Declare a set state variable
                         *     EnumerableSet.AddressSet private mySet;
                         * }
                         * ```
                         *
                         * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
                         * and `uint256` (`UintSet`) are supported.
                         */
                        library EnumerableSet {
                            // To implement this library for multiple types with as little code
                            // repetition as possible, we write it in terms of a generic Set type with
                            // bytes32 values.
                            // The Set implementation uses private functions, and user-facing
                            // implementations (such as AddressSet) are just wrappers around the
                            // underlying Set.
                            // This means that we can only create new EnumerableSets for types that fit
                            // in bytes32.
                        
                            struct Set {
                                // Storage of set values
                                bytes32[] _values;
                        
                                // Position of the value in the `values` array, plus 1 because index 0
                                // means a value is not in the set.
                                mapping (bytes32 => uint256) _indexes;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function _add(Set storage set, bytes32 value) private returns (bool) {
                                if (!_contains(set, value)) {
                                    set._values.push(value);
                                    // The value is stored at length-1, but we add 1 to all indexes
                                    // and use 0 as a sentinel value
                                    set._indexes[value] = set._values.length;
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function _remove(Set storage set, bytes32 value) private returns (bool) {
                                // We read and store the value's index to prevent multiple reads from the same storage slot
                                uint256 valueIndex = set._indexes[value];
                        
                                if (valueIndex != 0) { // Equivalent to contains(set, value)
                                    // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
                                    // the array, and then remove the last element (sometimes called as 'swap and pop').
                                    // This modifies the order of the array, as noted in {at}.
                        
                                    uint256 toDeleteIndex = valueIndex - 1;
                                    uint256 lastIndex = set._values.length - 1;
                        
                                    // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
                                    // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
                        
                                    bytes32 lastvalue = set._values[lastIndex];
                        
                                    // Move the last value to the index where the value to delete is
                                    set._values[toDeleteIndex] = lastvalue;
                                    // Update the index for the moved value
                                    set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
                        
                                    // Delete the slot where the moved value was stored
                                    set._values.pop();
                        
                                    // Delete the index for the deleted slot
                                    delete set._indexes[value];
                        
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function _contains(Set storage set, bytes32 value) private view returns (bool) {
                                return set._indexes[value] != 0;
                            }
                        
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function _length(Set storage set) private view returns (uint256) {
                                return set._values.length;
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function _at(Set storage set, uint256 index) private view returns (bytes32) {
                                require(set._values.length > index, "EnumerableSet: index out of bounds");
                                return set._values[index];
                            }
                        
                            // Bytes32Set
                        
                            struct Bytes32Set {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _add(set._inner, value);
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _remove(set._inner, value);
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
                                return _contains(set._inner, value);
                            }
                        
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(Bytes32Set storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
                                return _at(set._inner, index);
                            }
                        
                            // AddressSet
                        
                            struct AddressSet {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(AddressSet storage set, address value) internal returns (bool) {
                                return _add(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(AddressSet storage set, address value) internal returns (bool) {
                                return _remove(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(AddressSet storage set, address value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(AddressSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(AddressSet storage set, uint256 index) internal view returns (address) {
                                return address(uint160(uint256(_at(set._inner, index))));
                            }
                        
                        
                            // UintSet
                        
                            struct UintSet {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(UintSet storage set, uint256 value) internal returns (bool) {
                                return _add(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(UintSet storage set, uint256 value) internal returns (bool) {
                                return _remove(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(UintSet storage set, uint256 value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function length(UintSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(UintSet storage set, uint256 index) internal view returns (uint256) {
                                return uint256(_at(set._inner, index));
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/Address.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @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);
                                    }
                                }
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/Context.sol
                        
                        pragma solidity 0.6.12;
                        
                        /*
                         * @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 GSN 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 payable) {
                                return msg.sender;
                            }
                        
                            function _msgData() internal view virtual returns (bytes memory) {
                                this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                return msg.data;
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/access/AccessControl.sol
                        
                        pragma solidity 0.6.12;
                        
                        
                        
                        /**
                         * @dev Contract module that allows children to implement role-based access
                         * control mechanisms.
                         *
                         * Roles are referred to by their `bytes32` identifier. These should be exposed
                         * in the external API and be unique. The best way to achieve this is by
                         * using `public constant` hash digests:
                         *
                         * ```
                         * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
                         * ```
                         *
                         * Roles can be used to represent a set of permissions. To restrict access to a
                         * function call, use {hasRole}:
                         *
                         * ```
                         * function foo() public {
                         *     require(hasRole(MY_ROLE, msg.sender));
                         *     ...
                         * }
                         * ```
                         *
                         * Roles can be granted and revoked dynamically via the {grantRole} and
                         * {revokeRole} functions. Each role has an associated admin role, and only
                         * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
                         *
                         * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
                         * that only accounts with this role will be able to grant or revoke other
                         * roles. More complex role relationships can be created by using
                         * {_setRoleAdmin}.
                         *
                         * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
                         * grant and revoke this role. Extra precautions should be taken to secure
                         * accounts that have been granted it.
                         */
                        abstract contract AccessControl is Context {
                            using EnumerableSet for EnumerableSet.AddressSet;
                            using Address for address;
                        
                            struct RoleData {
                                EnumerableSet.AddressSet members;
                                bytes32 adminRole;
                            }
                        
                            mapping (bytes32 => RoleData) private _roles;
                        
                            bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
                        
                            /**
                             * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
                             *
                             * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
                             * {RoleAdminChanged} not being emitted signaling this.
                             *
                             * _Available since v3.1._
                             */
                            event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
                        
                            /**
                             * @dev Emitted when `account` is granted `role`.
                             *
                             * `sender` is the account that originated the contract call, an admin role
                             * bearer except when using {_setupRole}.
                             */
                            event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
                        
                            /**
                             * @dev Emitted when `account` is revoked `role`.
                             *
                             * `sender` is the account that originated the contract call:
                             *   - if using `revokeRole`, it is the admin role bearer
                             *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
                             */
                            event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
                        
                            /**
                             * @dev Returns `true` if `account` has been granted `role`.
                             */
                            function hasRole(bytes32 role, address account) public view returns (bool) {
                                return _roles[role].members.contains(account);
                            }
                        
                            /**
                             * @dev Returns the number of accounts that have `role`. Can be used
                             * together with {getRoleMember} to enumerate all bearers of a role.
                             */
                            function getRoleMemberCount(bytes32 role) public view returns (uint256) {
                                return _roles[role].members.length();
                            }
                        
                            /**
                             * @dev Returns one of the accounts that have `role`. `index` must be a
                             * value between 0 and {getRoleMemberCount}, non-inclusive.
                             *
                             * Role bearers are not sorted in any particular way, and their ordering may
                             * change at any point.
                             *
                             * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
                             * you perform all queries on the same block. See the following
                             * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
                             * for more information.
                             */
                            function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
                                return _roles[role].members.at(index);
                            }
                        
                            /**
                             * @dev Returns the admin role that controls `role`. See {grantRole} and
                             * {revokeRole}.
                             *
                             * To change a role's admin, use {_setRoleAdmin}.
                             */
                            function getRoleAdmin(bytes32 role) public view returns (bytes32) {
                                return _roles[role].adminRole;
                            }
                        
                            /**
                             * @dev Grants `role` to `account`.
                             *
                             * If `account` had not been already granted `role`, emits a {RoleGranted}
                             * event.
                             *
                             * Requirements:
                             *
                             * - the caller must have ``role``'s admin role.
                             */
                            function grantRole(bytes32 role, address account) public virtual {
                                require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
                        
                                _grantRole(role, account);
                            }
                        
                            /**
                             * @dev Revokes `role` from `account`.
                             *
                             * If `account` had been granted `role`, emits a {RoleRevoked} event.
                             *
                             * Requirements:
                             *
                             * - the caller must have ``role``'s admin role.
                             */
                            function revokeRole(bytes32 role, address account) public virtual {
                                require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
                        
                                _revokeRole(role, account);
                            }
                        
                            /**
                             * @dev Revokes `role` from the calling account.
                             *
                             * Roles are often managed via {grantRole} and {revokeRole}: this function's
                             * purpose is to provide a mechanism for accounts to lose their privileges
                             * if they are compromised (such as when a trusted device is misplaced).
                             *
                             * If the calling account had been granted `role`, emits a {RoleRevoked}
                             * event.
                             *
                             * Requirements:
                             *
                             * - the caller must be `account`.
                             */
                            function renounceRole(bytes32 role, address account) public virtual {
                                require(account == _msgSender(), "AccessControl: can only renounce roles for self");
                        
                                _revokeRole(role, account);
                            }
                        
                            /**
                             * @dev Grants `role` to `account`.
                             *
                             * If `account` had not been already granted `role`, emits a {RoleGranted}
                             * event. Note that unlike {grantRole}, this function doesn't perform any
                             * checks on the calling account.
                             *
                             * [WARNING]
                             * ====
                             * This function should only be called from the constructor when setting
                             * up the initial roles for the system.
                             *
                             * Using this function in any other way is effectively circumventing the admin
                             * system imposed by {AccessControl}.
                             * ====
                             */
                            function _setupRole(bytes32 role, address account) internal virtual {
                                _grantRole(role, account);
                            }
                        
                            /**
                             * @dev Sets `adminRole` as ``role``'s admin role.
                             *
                             * Emits a {RoleAdminChanged} event.
                             */
                            function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
                                emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
                                _roles[role].adminRole = adminRole;
                            }
                        
                            function _grantRole(bytes32 role, address account) private {
                                if (_roles[role].members.add(account)) {
                                    emit RoleGranted(role, account, _msgSender());
                                }
                            }
                        
                            function _revokeRole(bytes32 role, address account) private {
                                if (_roles[role].members.remove(account)) {
                                    emit RoleRevoked(role, account, _msgSender());
                                }
                            }
                        }
                        
                        
                        // File contracts/Access/MISOAdminAccess.sol
                        
                        pragma solidity 0.6.12;
                        
                        contract MISOAdminAccess is AccessControl {
                        
                            /// @dev Whether access is initialised.
                            bool private initAccess;
                        
                            /// @notice Events for adding and removing various roles.
                            event AdminRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event AdminRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                        
                            /// @notice The deployer is automatically given the admin role which will allow them to then grant roles to other addresses.
                            constructor() public {
                            }
                        
                            /**
                             * @notice Initializes access controls.
                             * @param _admin Admins address.
                             */
                            function initAccessControls(address _admin) public {
                                require(!initAccess, "Already initialised");
                                _setupRole(DEFAULT_ADMIN_ROLE, _admin);
                                initAccess = true;
                            }
                        
                            /////////////
                            // Lookups //
                            /////////////
                        
                            /**
                             * @notice Used to check whether an address has the admin role.
                             * @param _address EOA or contract being checked.
                             * @return bool True if the account has the role or false if it does not.
                             */
                            function hasAdminRole(address _address) public  view returns (bool) {
                                return hasRole(DEFAULT_ADMIN_ROLE, _address);
                            }
                        
                            ///////////////
                            // Modifiers //
                            ///////////////
                        
                            /**
                             * @notice Grants the admin role to an address.
                             * @dev The sender must have the admin role.
                             * @param _address EOA or contract receiving the new role.
                             */
                            function addAdminRole(address _address) external {
                                grantRole(DEFAULT_ADMIN_ROLE, _address);
                                emit AdminRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the admin role from an address.
                             * @dev The sender must have the admin role.
                             * @param _address EOA or contract affected.
                             */
                            function removeAdminRole(address _address) external {
                                revokeRole(DEFAULT_ADMIN_ROLE, _address);
                                emit AdminRoleRemoved(_address, _msgSender());
                            }
                        }
                        
                        
                        // File contracts/Access/MISOAccessControls.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @notice Access Controls
                         * @author Attr: BlockRocket.tech
                         */
                        contract MISOAccessControls is MISOAdminAccess {
                            /// @notice Role definitions
                            bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
                            bytes32 public constant SMART_CONTRACT_ROLE = keccak256("SMART_CONTRACT_ROLE");
                            bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
                        
                            /// @notice Events for adding and removing various roles
                        
                            event MinterRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event MinterRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event OperatorRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event OperatorRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event SmartContractRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event SmartContractRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            /**
                             * @notice The deployer is automatically given the admin role which will allow them to then grant roles to other addresses
                             */
                            constructor() public {
                            }
                        
                        
                            /////////////
                            // Lookups //
                            /////////////
                        
                            /**
                             * @notice Used to check whether an address has the minter role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasMinterRole(address _address) public view returns (bool) {
                                return hasRole(MINTER_ROLE, _address);
                            }
                        
                            /**
                             * @notice Used to check whether an address has the smart contract role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasSmartContractRole(address _address) public view returns (bool) {
                                return hasRole(SMART_CONTRACT_ROLE, _address);
                            }
                        
                            /**
                             * @notice Used to check whether an address has the operator role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasOperatorRole(address _address) public view returns (bool) {
                                return hasRole(OPERATOR_ROLE, _address);
                            }
                        
                            ///////////////
                            // Modifiers //
                            ///////////////
                        
                            /**
                             * @notice Grants the minter role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addMinterRole(address _address) external {
                                grantRole(MINTER_ROLE, _address);
                                emit MinterRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the minter role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeMinterRole(address _address) external {
                                revokeRole(MINTER_ROLE, _address);
                                emit MinterRoleRemoved(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Grants the smart contract role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addSmartContractRole(address _address) external {
                                grantRole(SMART_CONTRACT_ROLE, _address);
                                emit SmartContractRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the smart contract role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeSmartContractRole(address _address) external {
                                revokeRole(SMART_CONTRACT_ROLE, _address);
                                emit SmartContractRoleRemoved(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Grants the operator role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addOperatorRole(address _address) external {
                                grantRole(OPERATOR_ROLE, _address);
                                emit OperatorRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the operator role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeOperatorRole(address _address) external {
                                revokeRole(OPERATOR_ROLE, _address);
                                emit OperatorRoleRemoved(_address, _msgSender());
                            }
                        
                        }
                        
                        
                        // File contracts/Utils/SafeTransfer.sol
                        
                        pragma solidity 0.6.12;
                        
                        contract SafeTransfer {
                        
                            address private constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        
                            /// @dev Helper function to handle both ETH and ERC20 payments
                            function _safeTokenPayment(
                                address _token,
                                address payable _to,
                                uint256 _amount
                            ) internal {
                                if (address(_token) == ETH_ADDRESS) {
                                    _safeTransferETH(_to,_amount );
                                } else {
                                    _safeTransfer(_token, _to, _amount);
                                }
                            }
                        
                        
                            /// @dev Helper function to handle both ETH and ERC20 payments
                            function _tokenPayment(
                                address _token,
                                address payable _to,
                                uint256 _amount
                            ) internal {
                                if (address(_token) == ETH_ADDRESS) {
                                    _to.transfer(_amount);
                                } else {
                                    _safeTransfer(_token, _to, _amount);
                                }
                            }
                        
                        
                            /// @dev Transfer helper from UniswapV2 Router
                            function _safeApprove(address token, address to, uint value) internal {
                                // bytes4(keccak256(bytes('approve(address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
                            }
                        
                        
                            /**
                             * There are many non-compliant ERC20 tokens... this can handle most, adapted from UniSwap V2
                             * Im trying to make it a habit to put external calls last (reentrancy)
                             * You can put this in an internal function if you like.
                             */
                            function _safeTransfer(
                                address token,
                                address to,
                                uint256 amount
                            ) internal virtual {
                                // solium-disable-next-line security/no-low-level-calls
                                (bool success, bytes memory data) =
                                    token.call(
                                        // 0xa9059cbb = bytes4(keccak256("transfer(address,uint256)"))
                                        abi.encodeWithSelector(0xa9059cbb, to, amount)
                                    );
                                require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 Transfer failed
                            }
                        
                            function _safeTransferFrom(
                                address token,
                                address from,
                                uint256 amount
                            ) internal virtual {
                                // solium-disable-next-line security/no-low-level-calls
                                (bool success, bytes memory data) =
                                    token.call(
                                        // 0x23b872dd = bytes4(keccak256("transferFrom(address,address,uint256)"))
                                        abi.encodeWithSelector(0x23b872dd, from, address(this), amount)
                                    );
                                require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 TransferFrom failed
                            }
                        
                            function _safeTransferFrom(address token, address from, address to, uint value) internal {
                                // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
                            }
                        
                            function _safeTransferETH(address to, uint value) internal {
                                (bool success,) = to.call{value:value}(new bytes(0));
                                require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
                            }
                        
                        
                        }
                        
                        
                        // File contracts/interfaces/IERC20.sol
                        
                        pragma solidity 0.6.12;
                        
                        interface IERC20 {
                            function totalSupply() external view returns (uint256);
                            function balanceOf(address account) external view returns (uint256);
                            function allowance(address owner, address spender) external view returns (uint256);
                            function approve(address spender, uint256 amount) external returns (bool);
                            function name() external view returns (string memory);
                            function symbol() external view returns (string memory);
                            function decimals() external view returns (uint8);
                        
                            event Transfer(address indexed from, address indexed to, uint256 value);
                            event Approval(address indexed owner, address indexed spender, uint256 value);
                        
                            function permit(
                                address owner,
                                address spender,
                                uint256 value,
                                uint256 deadline,
                                uint8 v,
                                bytes32 r,
                                bytes32 s
                            ) external;
                        }
                        
                        
                        // File contracts/Utils/BoringERC20.sol
                        
                        pragma solidity 0.6.12;
                        
                        // solhint-disable avoid-low-level-calls
                        
                        library BoringERC20 {
                            bytes4 private constant SIG_SYMBOL = 0x95d89b41; // symbol()
                            bytes4 private constant SIG_NAME = 0x06fdde03; // name()
                            bytes4 private constant SIG_DECIMALS = 0x313ce567; // decimals()
                            bytes4 private constant SIG_TRANSFER = 0xa9059cbb; // transfer(address,uint256)
                            bytes4 private constant SIG_TRANSFER_FROM = 0x23b872dd; // transferFrom(address,address,uint256)
                        
                            /// @notice Provides a safe ERC20.symbol version which returns '???' as fallback string.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (string) Token symbol.
                            function safeSymbol(IERC20 token) internal view returns (string memory) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL));
                                return success && data.length > 0 ? abi.decode(data, (string)) : "???";
                            }
                        
                            /// @notice Provides a safe ERC20.name version which returns '???' as fallback string.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (string) Token name.
                            function safeName(IERC20 token) internal view returns (string memory) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME));
                                return success && data.length > 0 ? abi.decode(data, (string)) : "???";
                            }
                        
                            /// @notice Provides a safe ERC20.decimals version which returns '18' as fallback value.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (uint8) Token decimals.
                            function safeDecimals(IERC20 token) internal view returns (uint8) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_DECIMALS));
                                return success && data.length == 32 ? abi.decode(data, (uint8)) : 18;
                            }
                        
                            /// @notice Provides a safe ERC20.transfer version for different ERC-20 implementations.
                            /// Reverts on a failed transfer.
                            /// @param token The address of the ERC-20 token.
                            /// @param to Transfer tokens to.
                            /// @param amount The token amount.
                            function safeTransfer(
                                IERC20 token,
                                address to,
                                uint256 amount
                            ) internal {
                                (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER, to, amount));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: Transfer failed");
                            }
                        
                            /// @notice Provides a safe ERC20.transferFrom version for different ERC-20 implementations.
                            /// Reverts on a failed transfer.
                            /// @param token The address of the ERC-20 token.
                            /// @param from Transfer tokens from.
                            /// @param to Transfer tokens to.
                            /// @param amount The token amount.
                            function safeTransferFrom(
                                IERC20 token,
                                address from,
                                address to,
                                uint256 amount
                            ) internal {
                                (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER_FROM, from, to, amount));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: TransferFrom failed");
                            }
                        }
                        
                        
                        // File contracts/Utils/BoringBatchable.sol
                        
                        pragma solidity 0.6.12;
                        pragma experimental ABIEncoderV2;
                        
                        // solhint-disable avoid-low-level-calls
                        // solhint-disable no-inline-assembly
                        
                        // Audit on 5-Jan-2021 by Keno and BoringCrypto
                        
                        contract BaseBoringBatchable {
                            /// @dev Helper function to extract a useful revert message from a failed call.
                            /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.
                            function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
                                // If the _res length is less than 68, then the transaction failed silently (without a revert message)
                                if (_returnData.length < 68) return "Transaction reverted silently";
                        
                                assembly {
                                    // Slice the sighash.
                                    _returnData := add(_returnData, 0x04)
                                }
                                return abi.decode(_returnData, (string)); // All that remains is the revert string
                            }
                        
                            /// @notice Allows batched call to self (this contract).
                            /// @param calls An array of inputs for each call.
                            /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.
                            /// @return successes An array indicating the success of a call, mapped one-to-one to `calls`.
                            /// @return results An array with the returned data of each function call, mapped one-to-one to `calls`.
                            // F1: External is ok here because this is the batch function, adding it to a batch makes no sense
                            // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value
                            // C3: The length of the loop is fully under user control, so can't be exploited
                            // C7: Delegatecall is only used on the same contract, so it's safe
                            function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results) {
                                successes = new bool[](calls.length);
                                results = new bytes[](calls.length);
                                for (uint256 i = 0; i < calls.length; i++) {
                                    (bool success, bytes memory result) = address(this).delegatecall(calls[i]);
                                    require(success || !revertOnFail, _getRevertMsg(result));
                                    successes[i] = success;
                                    results[i] = result;
                                }
                            }
                        }
                        
                        contract BoringBatchable is BaseBoringBatchable {
                            /// @notice Call wrapper that performs `ERC20.permit` on `token`.
                            /// Lookup `IERC20.permit`.
                            // F6: Parameters can be used front-run the permit and the user's permit will fail (due to nonce or other revert)
                            //     if part of a batch this could be used to grief once as the second call would not need the permit
                            function permitToken(
                                IERC20 token,
                                address from,
                                address to,
                                uint256 amount,
                                uint256 deadline,
                                uint8 v,
                                bytes32 r,
                                bytes32 s
                            ) public {
                                token.permit(from, to, amount, deadline, v, r, s);
                            }
                        }
                        
                        
                        // File contracts/Utils/BoringMath.sol
                        
                        pragma solidity 0.6.12;
                        
                        /// @notice A library for performing overflow-/underflow-safe math,
                        /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math).
                        library BoringMath {
                            function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        
                            function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow");
                            }
                        
                            function div(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require(b > 0, "BoringMath: Div zero");
                                c = a / b;
                            }
                        
                            function to128(uint256 a) internal pure returns (uint128 c) {
                                require(a <= uint128(-1), "BoringMath: uint128 Overflow");
                                c = uint128(a);
                            }
                        
                            function to64(uint256 a) internal pure returns (uint64 c) {
                                require(a <= uint64(-1), "BoringMath: uint64 Overflow");
                                c = uint64(a);
                            }
                        
                            function to32(uint256 a) internal pure returns (uint32 c) {
                                require(a <= uint32(-1), "BoringMath: uint32 Overflow");
                                c = uint32(a);
                            }
                        
                            function to16(uint256 a) internal pure returns (uint16 c) {
                                require(a <= uint16(-1), "BoringMath: uint16 Overflow");
                                c = uint16(a);
                            }
                        
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128.
                        library BoringMath128 {
                            function add(uint128 a, uint128 b) internal pure returns (uint128 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint128 a, uint128 b) internal pure returns (uint128 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64.
                        library BoringMath64 {
                            function add(uint64 a, uint64 b) internal pure returns (uint64 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32.
                        library BoringMath32 {
                            function add(uint32 a, uint32 b) internal pure returns (uint32 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint32 a, uint32 b) internal pure returns (uint32 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32.
                        library BoringMath16 {
                            function add(uint16 a, uint16 b) internal pure returns (uint16 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint16 a, uint16 b) internal pure returns (uint16 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        
                        // File contracts/Utils/Documents.sol
                        
                        pragma solidity 0.6.12;
                        
                        
                        /**
                         * @title Standard implementation of ERC1643 Document management
                         */
                        contract Documents {
                        
                            struct Document {
                                uint32 docIndex;    // Store the document name indexes
                                uint64 lastModified; // Timestamp at which document details was last modified
                                string data; // data of the document that exist off-chain
                            }
                        
                            // mapping to store the documents details in the document
                            mapping(string => Document) internal _documents;
                            // mapping to store the document name indexes
                            mapping(string => uint32) internal _docIndexes;
                            // Array use to store all the document name present in the contracts
                            string[] _docNames;
                        
                            // Document Events
                            event DocumentRemoved(string indexed _name, string _data);
                            event DocumentUpdated(string indexed _name, string _data);
                        
                            /**
                             * @notice Used to attach a new document to the contract, or update the data or hash of an existing attached document
                             * @dev Can only be executed by the owner of the contract.
                             * @param _name Name of the document. It should be unique always
                             * @param _data Off-chain data of the document from where it is accessible to investors/advisors to read.
                             */
                            function _setDocument(string calldata _name, string calldata _data) internal {
                                require(bytes(_name).length > 0, "Zero name is not allowed");
                                require(bytes(_data).length > 0, "Should not be a empty data");
                                // Document storage document = _documents[_name];
                                if (_documents[_name].lastModified == uint64(0)) {
                                    _docNames.push(_name);
                                    _documents[_name].docIndex = uint32(_docNames.length);
                                }
                                _documents[_name] = Document(_documents[_name].docIndex, uint64(now), _data);
                                emit DocumentUpdated(_name, _data);
                            }
                        
                            /**
                             * @notice Used to remove an existing document from the contract by giving the name of the document.
                             * @dev Can only be executed by the owner of the contract.
                             * @param _name Name of the document. It should be unique always
                             */
                        
                            function _removeDocument(string calldata _name) internal {
                                require(_documents[_name].lastModified != uint64(0), "Document should exist");
                                uint32 index = _documents[_name].docIndex - 1;
                                if (index != _docNames.length - 1) {
                                    _docNames[index] = _docNames[_docNames.length - 1];
                                    _documents[_docNames[index]].docIndex = index + 1; 
                                }
                                _docNames.pop();
                                emit DocumentRemoved(_name, _documents[_name].data);
                                delete _documents[_name];
                            }
                        
                            /**
                             * @notice Used to return the details of a document with a known name (`string`).
                             * @param _name Name of the document
                             * @return string The data associated with the document.
                             * @return uint256 the timestamp at which the document was last modified.
                             */
                            function getDocument(string calldata _name) external view returns (string memory, uint256) {
                                return (
                                    _documents[_name].data,
                                    uint256(_documents[_name].lastModified)
                                );
                            }
                        
                            /**
                             * @notice Used to retrieve a full list of documents attached to the smart contract.
                             * @return string List of all documents names present in the contract.
                             */
                            function getAllDocuments() external view returns (string[] memory) {
                                return _docNames;
                            }
                        
                            /**
                             * @notice Used to retrieve the total documents in the smart contract.
                             * @return uint256 Count of the document names present in the contract.
                             */
                            function getDocumentCount() external view returns (uint256) {
                                return _docNames.length;
                            }
                        
                            /**
                             * @notice Used to retrieve the document name from index in the smart contract.
                             * @return string Name of the document name.
                             */
                            function getDocumentName(uint256 _index) external view returns (string memory) {
                                require(_index < _docNames.length, "Index out of bounds");
                                return _docNames[_index];
                            }
                        
                        }
                        
                        
                        // File contracts/interfaces/IPointList.sol
                        
                        pragma solidity 0.6.12;
                        
                        // ----------------------------------------------------------------------------
                        // White List interface
                        // ----------------------------------------------------------------------------
                        
                        interface IPointList {
                            function isInList(address account) external view returns (bool);
                            function hasPoints(address account, uint256 amount) external view  returns (bool);
                            function setPoints(
                                address[] memory accounts,
                                uint256[] memory amounts
                            ) external; 
                            function initPointList(address accessControl) external ;
                        
                        }
                        
                        
                        // File contracts/interfaces/IMisoMarket.sol
                        
                        pragma solidity 0.6.12;
                        
                        interface IMisoMarket {
                        
                            function init(bytes calldata data) external payable;
                            function initMarket( bytes calldata data ) external;
                            function marketTemplate() external view returns (uint256);
                        
                        }
                        
                        
                        // File contracts/Auctions/BatchAuction.sol
                        
                        pragma solidity 0.6.12;
                        
                        //----------------------------------------------------------------------------------
                        //    I n s t a n t
                        //
                        //        .:mmm.         .:mmm:.       .ii.  .:SSSSSSSSSSSSS.     .oOOOOOOOOOOOo.  
                        //      .mMM'':Mm.     .:MM'':Mm:.     .II:  :SSs..........     .oOO'''''''''''OOo.
                        //    .:Mm'   ':Mm.   .:Mm'   'MM:.    .II:  'sSSSSSSSSSSSSS:.  :OO.           .OO:
                        //  .'mMm'     ':MM:.:MMm'     ':MM:.  .II:  .:...........:SS.  'OOo:.........:oOO'
                        //  'mMm'        ':MMmm'         'mMm:  II:  'sSSSSSSSSSSSSS'     'oOOOOOOOOOOOO'  
                        //
                        //----------------------------------------------------------------------------------
                        //
                        // Chef Gonpachi's Batch Auction
                        //
                        // An auction where contributions are swaped for a batch of tokens pro-rata
                        // 
                        // This program is free software: you can redistribute it and/or modify
                        // it under the terms of the GNU General Public License as published by
                        // the Free Software Foundation, either version 3 of the License
                        //
                        // This program is distributed in the hope that it will be useful,
                        // but WITHOUT ANY WARRANTY; without even the implied warranty of
                        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                        // GNU General Public License for more details.
                        //
                        // The above copyright notice and this permission notice shall be included 
                        // in all copies or substantial portions of the Software.
                        //
                        // Made for Sushi.com 
                        // 
                        // Enjoy. (c) Chef Gonpachi, Kusatoshi, SSMikazu 2021 
                        // <https://github.com/chefgonpachi/MISO/>
                        //
                        // ---------------------------------------------------------------------
                        // SPDX-License-Identifier: GPL-3.0                        
                        // ---------------------------------------------------------------------
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        /// @notice Attribution to delta.financial
                        /// @notice Attribution to dutchswap.com
                        
                        
                        contract BatchAuction is  IMisoMarket, MISOAccessControls, BoringBatchable, SafeTransfer, Documents, ReentrancyGuard  {
                        
                            using BoringMath for uint256;
                            using BoringMath128 for uint128;
                            using BoringMath64 for uint64;
                            using BoringERC20 for IERC20;
                        
                            /// @notice MISOMarket template id for the factory contract.
                            /// @dev For different marketplace types, this must be incremented.
                            uint256 public constant override marketTemplate = 3;
                        
                            /// @dev The multiplier for decimal precision
                            uint256 private constant MISO_PRECISION = 1e18;
                        
                            /// @dev The placeholder ETH address.
                            address private constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        
                            /// @notice Main market variables.
                            struct MarketInfo {
                                uint64 startTime;
                                uint64 endTime; 
                                uint128 totalTokens;
                            }
                            MarketInfo public marketInfo;
                        
                            /// @notice Market dynamic variables.
                            struct MarketStatus {
                                uint128 commitmentsTotal;
                                uint128 minimumCommitmentAmount;
                                bool finalized;
                                bool usePointList;
                            }
                        
                            MarketStatus public marketStatus;
                        
                            address public auctionToken;
                            /// @notice The currency the crowdsale accepts for payment. Can be ETH or token address.
                            address public paymentCurrency;
                            /// @notice Address that manages auction approvals.
                            address public pointList;
                            address payable public wallet; // Where the auction funds will get paid
                        
                            mapping(address => uint256) public commitments;
                            /// @notice Amount of tokens to claim per address.
                            mapping(address => uint256) public claimed;
                        
                            /// @notice Event for updating auction times.  Needs to be before auction starts.
                            event AuctionTimeUpdated(uint256 startTime, uint256 endTime); 
                            /// @notice Event for updating auction prices. Needs to be before auction starts.
                            event AuctionPriceUpdated(uint256 minimumCommitmentAmount); 
                            /// @notice Event for updating auction wallet. Needs to be before auction starts.
                            event AuctionWalletUpdated(address wallet); 
                        
                            /// @notice Event for adding a commitment.
                            event AddedCommitment(address addr, uint256 commitment);
                            /// @notice Event for finalization of the auction.
                            event AuctionFinalized();
                            /// @notice Event for cancellation of the auction.
                            event AuctionCancelled();
                        
                            /**
                             * @notice Initializes main contract variables and transfers funds for the auction.
                             * @dev Init function.
                             * @param _funder The address that funds the token for crowdsale.
                             * @param _token Address of the token being sold.
                             * @param _totalTokens The total number of tokens to sell in auction.
                             * @param _startTime Auction start time.
                             * @param _endTime Auction end time.
                             * @param _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address.
                             * @param _minimumCommitmentAmount Minimum amount collected at which the auction will be successful.
                             * @param _admin Address that can finalize auction.
                             * @param _wallet Address where collected funds will be forwarded to.
                             */
                            function initAuction(
                                address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                            ) public {
                                require(_startTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_endTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_startTime >= block.timestamp, "BatchAuction: start time is before current time");
                                require(_endTime > _startTime, "BatchAuction: end time must be older than start time");
                                require(_totalTokens > 0,"BatchAuction: total tokens must be greater than zero");
                                require(_admin != address(0), "BatchAuction: admin is the zero address");
                                require(_wallet != address(0), "BatchAuction: wallet is the zero address");
                                require(IERC20(_token).decimals() == 18, "BatchAuction: Token does not have 18 decimals");
                                if (_paymentCurrency != ETH_ADDRESS) {
                                    require(IERC20(_paymentCurrency).decimals() > 0, "BatchAuction: Payment currency is not ERC20");
                                }
                        
                                marketStatus.minimumCommitmentAmount = BoringMath.to128(_minimumCommitmentAmount);
                                
                                marketInfo.startTime = BoringMath.to64(_startTime);
                                marketInfo.endTime = BoringMath.to64(_endTime);
                                marketInfo.totalTokens = BoringMath.to128(_totalTokens);
                        
                                auctionToken = _token;
                                paymentCurrency = _paymentCurrency;
                                wallet = _wallet;
                        
                                initAccessControls(_admin);
                        
                                _setList(_pointList);
                                _safeTransferFrom(auctionToken, _funder, _totalTokens);
                            }
                        
                        
                            ///--------------------------------------------------------
                            /// Commit to buying tokens!
                            ///--------------------------------------------------------
                        
                            receive() external payable {
                                revertBecauseUserDidNotProvideAgreement();
                            }
                            
                            /** 
                             * @dev Attribution to the awesome delta.financial contracts
                            */  
                            function marketParticipationAgreement() public pure returns (string memory) {
                                return "I understand that I am interacting with a smart contract. I understand that tokens commited are subject to the token issuer and local laws where applicable. I have reviewed the code of this smart contract and understand it fully. I agree to not hold developers or other people associated with the project liable for any losses or misunderstandings";
                            }
                            /** 
                             * @dev Not using modifiers is a purposeful choice for code readability.
                            */ 
                            function revertBecauseUserDidNotProvideAgreement() internal pure {
                                revert("No agreement provided, please review the smart contract before interacting with it");
                            }
                        
                            /**
                             * @notice Commit ETH to buy tokens on auction.
                             * @param _beneficiary Auction participant ETH address.
                             */
                            function commitEth(address payable _beneficiary, bool readAndAgreedToMarketParticipationAgreement) public payable {
                                require(paymentCurrency == ETH_ADDRESS, "BatchAuction: payment currency is not ETH");
                        
                                require(msg.value > 0, "BatchAuction: Value must be higher than 0");
                                if(readAndAgreedToMarketParticipationAgreement == false) {
                                    revertBecauseUserDidNotProvideAgreement();
                                }
                                _addCommitment(_beneficiary, msg.value);
                            }
                        
                            /**
                             * @notice Buy Tokens by commiting approved ERC20 tokens to this contract address.
                             * @param _amount Amount of tokens to commit.
                             */
                            function commitTokens(uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public {
                                commitTokensFrom(msg.sender, _amount, readAndAgreedToMarketParticipationAgreement);
                            }
                        
                            /**
                             * @notice Checks if amout not 0 and makes the transfer and adds commitment.
                             * @dev Users must approve contract prior to committing tokens to auction.
                             * @param _from User ERC20 address.
                             * @param _amount Amount of approved ERC20 tokens.
                             */
                            function commitTokensFrom(address _from, uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public   nonReentrant  {
                                require(paymentCurrency != ETH_ADDRESS, "BatchAuction: Payment currency is not a token");
                                if(readAndAgreedToMarketParticipationAgreement == false) {
                                    revertBecauseUserDidNotProvideAgreement();
                                }
                                require(_amount> 0, "BatchAuction: Value must be higher than 0");
                                _safeTransferFrom(paymentCurrency, msg.sender, _amount);
                                _addCommitment(_from, _amount);
                        
                            }
                        
                        
                            /// @notice Commits to an amount during an auction
                            /**
                             * @notice Updates commitment for this address and total commitment of the auction.
                             * @param _addr Auction participant address.
                             * @param _commitment The amount to commit.
                             */
                            function _addCommitment(address _addr, uint256 _commitment) internal {
                                require(block.timestamp >= marketInfo.startTime && block.timestamp <= marketInfo.endTime, "BatchAuction: outside auction hours"); 
                        
                                uint256 newCommitment = commitments[_addr].add(_commitment);
                                if (marketStatus.usePointList) {
                                    require(IPointList(pointList).hasPoints(_addr, newCommitment));
                                }
                                commitments[_addr] = newCommitment;
                                marketStatus.commitmentsTotal = BoringMath.to128(uint256(marketStatus.commitmentsTotal).add(_commitment));
                                emit AddedCommitment(_addr, _commitment);
                            }
                        
                            /**
                             * @notice Calculates amount of auction tokens for user to receive.
                             * @param amount Amount of tokens to commit.
                             * @return Auction token amount.
                             */
                            function _getTokenAmount(uint256 amount) internal view returns (uint256) { 
                                if (marketStatus.commitmentsTotal == 0) return 0;
                                return amount.mul(uint256(marketInfo.totalTokens)).div(uint256(marketStatus.commitmentsTotal));
                            }
                        
                            /**
                             * @notice Calculates the price of each token from all commitments.
                             * @return Token price.
                             */
                            function tokenPrice() public view returns (uint256) {
                                return uint256(marketStatus.commitmentsTotal).mul(MISO_PRECISION)
                                    .mul(1e18).div(uint256(marketInfo.totalTokens)).div(MISO_PRECISION);
                            }
                        
                        
                            ///--------------------------------------------------------
                            /// Finalize Auction
                            ///--------------------------------------------------------
                        
                            /// @notice Auction finishes successfully above the reserve
                            /// @dev Transfer contract funds to initialized wallet.
                            function finalize() public    nonReentrant 
                            {
                                require(hasAdminRole(msg.sender) 
                                        || wallet == msg.sender
                                        || hasSmartContractRole(msg.sender) 
                                        || finalizeTimeExpired(),  "BatchAuction: Sender must be admin");
                                require(!marketStatus.finalized, "BatchAuction: Auction has already finalized");
                                require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                if (auctionSuccessful()) {
                                    /// @dev Successful auction
                                    /// @dev Transfer contributed tokens to wallet.
                                    _safeTokenPayment(paymentCurrency, wallet, uint256(marketStatus.commitmentsTotal));
                                } else {
                                    /// @dev Failed auction
                                    /// @dev Return auction tokens back to wallet.
                                    require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                    _safeTokenPayment(auctionToken, wallet, marketInfo.totalTokens);
                                }
                                marketStatus.finalized = true;
                                emit AuctionFinalized();
                            }
                        
                            /**
                             * @notice Cancel Auction
                             * @dev Admin can cancel the auction before it starts
                             */
                            function cancelAuction() public   nonReentrant  
                            {
                                require(hasAdminRole(msg.sender));
                                MarketStatus storage status = marketStatus;
                                require(!status.finalized, "Crowdsale: already finalized");
                                require( uint256(status.commitmentsTotal) == 0, "Crowdsale: Funds already raised" );
                        
                                _safeTokenPayment(auctionToken, wallet, uint256(marketInfo.totalTokens));
                        
                                status.finalized = true;
                                emit AuctionCancelled();
                            }
                        
                            /// @notice Withdraws bought tokens, or returns commitment if the sale is unsuccessful.
                            function withdrawTokens() public  {
                                withdrawTokens(msg.sender);
                            }
                        
                            /// @notice Withdraw your tokens once the Auction has ended.
                            function withdrawTokens(address payable beneficiary) public   nonReentrant  {
                                if (auctionSuccessful()) {
                                    require(marketStatus.finalized, "BatchAuction: not finalized");
                                    /// @dev Successful auction! Transfer claimed tokens.
                                    uint256 tokensToClaim = tokensClaimable(beneficiary);
                                    require(tokensToClaim > 0, "BatchAuction: No tokens to claim");
                                    claimed[beneficiary] = claimed[beneficiary].add(tokensToClaim);
                        
                                    _safeTokenPayment(auctionToken, beneficiary, tokensToClaim);
                                } else {
                                    /// @dev Auction did not meet reserve price.
                                    /// @dev Return committed funds back to user.
                                    require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                    uint256 fundsCommitted = commitments[beneficiary];
                                    require(fundsCommitted > 0, "BatchAuction: No funds committed");
                                    commitments[beneficiary] = 0; // Stop multiple withdrawals and free some gas
                                    _safeTokenPayment(paymentCurrency, beneficiary, fundsCommitted);
                                }
                            }
                        
                        
                            /**
                             * @notice How many tokens the user is able to claim.
                             * @param _user Auction participant address.
                             * @return claimerCommitment Tokens left to claim.
                             */
                            function tokensClaimable(address _user) public view returns (uint256 claimerCommitment) {
                                if (commitments[_user] == 0) return 0;
                                uint256 unclaimedTokens = IERC20(auctionToken).balanceOf(address(this));
                                claimerCommitment = _getTokenAmount(commitments[_user]);
                                claimerCommitment = claimerCommitment.sub(claimed[_user]);
                        
                                if(claimerCommitment > unclaimedTokens){
                                    claimerCommitment = unclaimedTokens;
                                }
                            }
                        
                            /**
                             * @notice Checks if raised more than minimum amount.
                             * @return True if tokens sold greater than or equals to the minimum commitment amount.
                             */
                            function auctionSuccessful() public view returns (bool) {
                                return uint256(marketStatus.commitmentsTotal) >= uint256(marketStatus.minimumCommitmentAmount) && uint256(marketStatus.commitmentsTotal) > 0;
                            }
                        
                            /**
                             * @notice Checks if the auction has ended.
                             * @return bool True if current time is greater than auction end time.
                             */
                            function auctionEnded() public view returns (bool) {
                                return block.timestamp > marketInfo.endTime;
                            }
                        
                            /**
                             * @notice Checks if the auction has been finalised.
                             * @return bool True if auction has been finalised.
                             */
                            function finalized() public view returns (bool) {
                                return marketStatus.finalized;
                            }
                        
                            /// @notice Returns true if 7 days have passed since the end of the auction
                            function finalizeTimeExpired() public view returns (bool) {
                                return uint256(marketInfo.endTime) + 7 days < block.timestamp;
                            }
                        
                        
                            //--------------------------------------------------------
                            // Documents
                            //--------------------------------------------------------
                        
                            function setDocument(string calldata _name, string calldata _data) external {
                                require(hasAdminRole(msg.sender) );
                                _setDocument( _name, _data);
                            }
                        
                            function setDocuments(string[] calldata _name, string[] calldata _data) external {
                                require(hasAdminRole(msg.sender) );
                                uint256 numDocs = _name.length;
                                for (uint256 i = 0; i < numDocs; i++) {
                                    _setDocument( _name[i], _data[i]);
                                }
                            }
                        
                            function removeDocument(string calldata _name) external {
                                require(hasAdminRole(msg.sender));
                                _removeDocument(_name);
                            }
                        
                        
                            //--------------------------------------------------------
                            // Point Lists
                            //--------------------------------------------------------
                        
                        
                            function setList(address _list) external {
                                require(hasAdminRole(msg.sender));
                                _setList(_list);
                            }
                        
                            function enableList(bool _status) external {
                                require(hasAdminRole(msg.sender));
                                marketStatus.usePointList = _status;
                            }
                        
                            function _setList(address _pointList) private {
                                if (_pointList != address(0)) {
                                    pointList = _pointList;
                                    marketStatus.usePointList = true;
                                }
                            }
                        
                            //--------------------------------------------------------
                            // Setter Functions
                            //--------------------------------------------------------
                        
                            /**
                             * @notice Admin can set start and end time through this function.
                             * @param _startTime Auction start time.
                             * @param _endTime Auction end time.
                             */
                            function setAuctionTime(uint256 _startTime, uint256 _endTime) external {
                                require(hasAdminRole(msg.sender));
                                require(_startTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_endTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_startTime >= block.timestamp, "BatchAuction: start time is before current time");
                                require(_endTime > _startTime, "BatchAuction: end time must be older than start price");
                        
                                require(marketStatus.commitmentsTotal == 0, "BatchAuction: auction cannot have already started");
                        
                                marketInfo.startTime = BoringMath.to64(_startTime);
                                marketInfo.endTime = BoringMath.to64(_endTime);
                                
                                emit AuctionTimeUpdated(_startTime,_endTime);
                            }
                        
                            /**
                             * @notice Admin can set start and min price through this function.
                             * @param _minimumCommitmentAmount Auction minimum raised target.
                             */
                            function setAuctionPrice(uint256 _minimumCommitmentAmount) external {
                                require(hasAdminRole(msg.sender));
                        
                                require(marketStatus.commitmentsTotal == 0, "BatchAuction: auction cannot have already started");
                        
                                marketStatus.minimumCommitmentAmount = BoringMath.to128(_minimumCommitmentAmount);
                        
                                emit AuctionPriceUpdated(_minimumCommitmentAmount);
                            }
                        
                            /**
                             * @notice Admin can set the auction wallet through this function.
                             * @param _wallet Auction wallet is where funds will be sent.
                             */
                            function setAuctionWallet(address payable _wallet) external {
                                require(hasAdminRole(msg.sender));
                                require(_wallet != address(0), "BatchAuction: wallet is the zero address");
                        
                                wallet = _wallet;
                        
                                emit AuctionWalletUpdated(_wallet);
                            }
                        
                        
                            //--------------------------------------------------------
                            // Market Launchers
                            //--------------------------------------------------------
                        
                            function init(bytes calldata _data) external override payable {
                            }
                        
                            function initMarket(
                                bytes calldata _data
                            ) public override {
                                (
                                address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                                ) = abi.decode(_data, (
                                    address,
                                    address,
                                    uint256,
                                    uint256,
                                    uint256,
                                    address,
                                    uint256,
                                    address,
                                    address,
                                    address
                                ));
                                initAuction(_funder, _token, _totalTokens, _startTime, _endTime, _paymentCurrency, _minimumCommitmentAmount, _admin, _pointList,  _wallet);
                            }
                        
                             function getBatchAuctionInitData(
                               address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                            )
                                external
                                pure
                                returns (bytes memory _data)
                            {
                                return abi.encode(
                                    _funder,
                                    _token,
                                    _totalTokens,
                                    _startTime,
                                    _endTime,
                                    _paymentCurrency,
                                    _minimumCommitmentAmount,
                                    _admin,
                                    _pointList,
                                    _wallet
                                    );
                            }
                        
                            function getBaseInformation() external view returns(
                                address token, 
                                uint64 startTime,
                                uint64 endTime,
                                bool marketFinalized
                            ) {
                                return (auctionToken, marketInfo.startTime, marketInfo.endTime, marketStatus.finalized);
                            }
                        
                            function getTotalTokens() external view returns(uint256) {
                                return uint256(marketInfo.totalTokens);
                            }
                        
                        }

                        File 3 of 11: WETH9
                        // Copyright (C) 2015, 2016, 2017 Dapphub
                        
                        // This program is free software: you can redistribute it and/or modify
                        // it under the terms of the GNU General Public License as published by
                        // the Free Software Foundation, either version 3 of the License, or
                        // (at your option) any later version.
                        
                        // This program is distributed in the hope that it will be useful,
                        // but WITHOUT ANY WARRANTY; without even the implied warranty of
                        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                        // GNU General Public License for more details.
                        
                        // You should have received a copy of the GNU General Public License
                        // along with this program.  If not, see <http://www.gnu.org/licenses/>.
                        
                        pragma solidity ^0.4.18;
                        
                        contract WETH9 {
                            string public name     = "Wrapped Ether";
                            string public symbol   = "WETH";
                            uint8  public decimals = 18;
                        
                            event  Approval(address indexed src, address indexed guy, uint wad);
                            event  Transfer(address indexed src, address indexed dst, uint wad);
                            event  Deposit(address indexed dst, uint wad);
                            event  Withdrawal(address indexed src, uint wad);
                        
                            mapping (address => uint)                       public  balanceOf;
                            mapping (address => mapping (address => uint))  public  allowance;
                        
                            function() public payable {
                                deposit();
                            }
                            function deposit() public payable {
                                balanceOf[msg.sender] += msg.value;
                                Deposit(msg.sender, msg.value);
                            }
                            function withdraw(uint wad) public {
                                require(balanceOf[msg.sender] >= wad);
                                balanceOf[msg.sender] -= wad;
                                msg.sender.transfer(wad);
                                Withdrawal(msg.sender, wad);
                            }
                        
                            function totalSupply() public view returns (uint) {
                                return this.balance;
                            }
                        
                            function approve(address guy, uint wad) public returns (bool) {
                                allowance[msg.sender][guy] = wad;
                                Approval(msg.sender, guy, wad);
                                return true;
                            }
                        
                            function transfer(address dst, uint wad) public returns (bool) {
                                return transferFrom(msg.sender, dst, wad);
                            }
                        
                            function transferFrom(address src, address dst, uint wad)
                                public
                                returns (bool)
                            {
                                require(balanceOf[src] >= wad);
                        
                                if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
                                    require(allowance[src][msg.sender] >= wad);
                                    allowance[src][msg.sender] -= wad;
                                }
                        
                                balanceOf[src] -= wad;
                                balanceOf[dst] += wad;
                        
                                Transfer(src, dst, wad);
                        
                                return true;
                            }
                        }
                        
                        
                        /*
                                            GNU GENERAL PUBLIC LICENSE
                                               Version 3, 29 June 2007
                        
                         Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
                         Everyone is permitted to copy and distribute verbatim copies
                         of this license document, but changing it is not allowed.
                        
                                                    Preamble
                        
                          The GNU General Public License is a free, copyleft license for
                        software and other kinds of works.
                        
                          The licenses for most software and other practical works are designed
                        to take away your freedom to share and change the works.  By contrast,
                        the GNU General Public License is intended to guarantee your freedom to
                        share and change all versions of a program--to make sure it remains free
                        software for all its users.  We, the Free Software Foundation, use the
                        GNU General Public License for most of our software; it applies also to
                        any other work released this way by its authors.  You can apply it to
                        your programs, too.
                        
                          When we speak of free software, we are referring to freedom, not
                        price.  Our General Public Licenses are designed to make sure that you
                        have the freedom to distribute copies of free software (and charge for
                        them if you wish), that you receive source code or can get it if you
                        want it, that you can change the software or use pieces of it in new
                        free programs, and that you know you can do these things.
                        
                          To protect your rights, we need to prevent others from denying you
                        these rights or asking you to surrender the rights.  Therefore, you have
                        certain responsibilities if you distribute copies of the software, or if
                        you modify it: responsibilities to respect the freedom of others.
                        
                          For example, if you distribute copies of such a program, whether
                        gratis or for a fee, you must pass on to the recipients the same
                        freedoms that you received.  You must make sure that they, too, receive
                        or can get the source code.  And you must show them these terms so they
                        know their rights.
                        
                          Developers that use the GNU GPL protect your rights with two steps:
                        (1) assert copyright on the software, and (2) offer you this License
                        giving you legal permission to copy, distribute and/or modify it.
                        
                          For the developers' and authors' protection, the GPL clearly explains
                        that there is no warranty for this free software.  For both users' and
                        authors' sake, the GPL requires that modified versions be marked as
                        changed, so that their problems will not be attributed erroneously to
                        authors of previous versions.
                        
                          Some devices are designed to deny users access to install or run
                        modified versions of the software inside them, although the manufacturer
                        can do so.  This is fundamentally incompatible with the aim of
                        protecting users' freedom to change the software.  The systematic
                        pattern of such abuse occurs in the area of products for individuals to
                        use, which is precisely where it is most unacceptable.  Therefore, we
                        have designed this version of the GPL to prohibit the practice for those
                        products.  If such problems arise substantially in other domains, we
                        stand ready to extend this provision to those domains in future versions
                        of the GPL, as needed to protect the freedom of users.
                        
                          Finally, every program is threatened constantly by software patents.
                        States should not allow patents to restrict development and use of
                        software on general-purpose computers, but in those that do, we wish to
                        avoid the special danger that patents applied to a free program could
                        make it effectively proprietary.  To prevent this, the GPL assures that
                        patents cannot be used to render the program non-free.
                        
                          The precise terms and conditions for copying, distribution and
                        modification follow.
                        
                                               TERMS AND CONDITIONS
                        
                          0. Definitions.
                        
                          "This License" refers to version 3 of the GNU General Public License.
                        
                          "Copyright" also means copyright-like laws that apply to other kinds of
                        works, such as semiconductor masks.
                        
                          "The Program" refers to any copyrightable work licensed under this
                        License.  Each licensee is addressed as "you".  "Licensees" and
                        "recipients" may be individuals or organizations.
                        
                          To "modify" a work means to copy from or adapt all or part of the work
                        in a fashion requiring copyright permission, other than the making of an
                        exact copy.  The resulting work is called a "modified version" of the
                        earlier work or a work "based on" the earlier work.
                        
                          A "covered work" means either the unmodified Program or a work based
                        on the Program.
                        
                          To "propagate" a work means to do anything with it that, without
                        permission, would make you directly or secondarily liable for
                        infringement under applicable copyright law, except executing it on a
                        computer or modifying a private copy.  Propagation includes copying,
                        distribution (with or without modification), making available to the
                        public, and in some countries other activities as well.
                        
                          To "convey" a work means any kind of propagation that enables other
                        parties to make or receive copies.  Mere interaction with a user through
                        a computer network, with no transfer of a copy, is not conveying.
                        
                          An interactive user interface displays "Appropriate Legal Notices"
                        to the extent that it includes a convenient and prominently visible
                        feature that (1) displays an appropriate copyright notice, and (2)
                        tells the user that there is no warranty for the work (except to the
                        extent that warranties are provided), that licensees may convey the
                        work under this License, and how to view a copy of this License.  If
                        the interface presents a list of user commands or options, such as a
                        menu, a prominent item in the list meets this criterion.
                        
                          1. Source Code.
                        
                          The "source code" for a work means the preferred form of the work
                        for making modifications to it.  "Object code" means any non-source
                        form of a work.
                        
                          A "Standard Interface" means an interface that either is an official
                        standard defined by a recognized standards body, or, in the case of
                        interfaces specified for a particular programming language, one that
                        is widely used among developers working in that language.
                        
                          The "System Libraries" of an executable work include anything, other
                        than the work as a whole, that (a) is included in the normal form of
                        packaging a Major Component, but which is not part of that Major
                        Component, and (b) serves only to enable use of the work with that
                        Major Component, or to implement a Standard Interface for which an
                        implementation is available to the public in source code form.  A
                        "Major Component", in this context, means a major essential component
                        (kernel, window system, and so on) of the specific operating system
                        (if any) on which the executable work runs, or a compiler used to
                        produce the work, or an object code interpreter used to run it.
                        
                          The "Corresponding Source" for a work in object code form means all
                        the source code needed to generate, install, and (for an executable
                        work) run the object code and to modify the work, including scripts to
                        control those activities.  However, it does not include the work's
                        System Libraries, or general-purpose tools or generally available free
                        programs which are used unmodified in performing those activities but
                        which are not part of the work.  For example, Corresponding Source
                        includes interface definition files associated with source files for
                        the work, and the source code for shared libraries and dynamically
                        linked subprograms that the work is specifically designed to require,
                        such as by intimate data communication or control flow between those
                        subprograms and other parts of the work.
                        
                          The Corresponding Source need not include anything that users
                        can regenerate automatically from other parts of the Corresponding
                        Source.
                        
                          The Corresponding Source for a work in source code form is that
                        same work.
                        
                          2. Basic Permissions.
                        
                          All rights granted under this License are granted for the term of
                        copyright on the Program, and are irrevocable provided the stated
                        conditions are met.  This License explicitly affirms your unlimited
                        permission to run the unmodified Program.  The output from running a
                        covered work is covered by this License only if the output, given its
                        content, constitutes a covered work.  This License acknowledges your
                        rights of fair use or other equivalent, as provided by copyright law.
                        
                          You may make, run and propagate covered works that you do not
                        convey, without conditions so long as your license otherwise remains
                        in force.  You may convey covered works to others for the sole purpose
                        of having them make modifications exclusively for you, or provide you
                        with facilities for running those works, provided that you comply with
                        the terms of this License in conveying all material for which you do
                        not control copyright.  Those thus making or running the covered works
                        for you must do so exclusively on your behalf, under your direction
                        and control, on terms that prohibit them from making any copies of
                        your copyrighted material outside their relationship with you.
                        
                          Conveying under any other circumstances is permitted solely under
                        the conditions stated below.  Sublicensing is not allowed; section 10
                        makes it unnecessary.
                        
                          3. Protecting Users' Legal Rights From Anti-Circumvention Law.
                        
                          No covered work shall be deemed part of an effective technological
                        measure under any applicable law fulfilling obligations under article
                        11 of the WIPO copyright treaty adopted on 20 December 1996, or
                        similar laws prohibiting or restricting circumvention of such
                        measures.
                        
                          When you convey a covered work, you waive any legal power to forbid
                        circumvention of technological measures to the extent such circumvention
                        is effected by exercising rights under this License with respect to
                        the covered work, and you disclaim any intention to limit operation or
                        modification of the work as a means of enforcing, against the work's
                        users, your or third parties' legal rights to forbid circumvention of
                        technological measures.
                        
                          4. Conveying Verbatim Copies.
                        
                          You may convey verbatim copies of the Program's source code as you
                        receive it, in any medium, provided that you conspicuously and
                        appropriately publish on each copy an appropriate copyright notice;
                        keep intact all notices stating that this License and any
                        non-permissive terms added in accord with section 7 apply to the code;
                        keep intact all notices of the absence of any warranty; and give all
                        recipients a copy of this License along with the Program.
                        
                          You may charge any price or no price for each copy that you convey,
                        and you may offer support or warranty protection for a fee.
                        
                          5. Conveying Modified Source Versions.
                        
                          You may convey a work based on the Program, or the modifications to
                        produce it from the Program, in the form of source code under the
                        terms of section 4, provided that you also meet all of these conditions:
                        
                            a) The work must carry prominent notices stating that you modified
                            it, and giving a relevant date.
                        
                            b) The work must carry prominent notices stating that it is
                            released under this License and any conditions added under section
                            7.  This requirement modifies the requirement in section 4 to
                            "keep intact all notices".
                        
                            c) You must license the entire work, as a whole, under this
                            License to anyone who comes into possession of a copy.  This
                            License will therefore apply, along with any applicable section 7
                            additional terms, to the whole of the work, and all its parts,
                            regardless of how they are packaged.  This License gives no
                            permission to license the work in any other way, but it does not
                            invalidate such permission if you have separately received it.
                        
                            d) If the work has interactive user interfaces, each must display
                            Appropriate Legal Notices; however, if the Program has interactive
                            interfaces that do not display Appropriate Legal Notices, your
                            work need not make them do so.
                        
                          A compilation of a covered work with other separate and independent
                        works, which are not by their nature extensions of the covered work,
                        and which are not combined with it such as to form a larger program,
                        in or on a volume of a storage or distribution medium, is called an
                        "aggregate" if the compilation and its resulting copyright are not
                        used to limit the access or legal rights of the compilation's users
                        beyond what the individual works permit.  Inclusion of a covered work
                        in an aggregate does not cause this License to apply to the other
                        parts of the aggregate.
                        
                          6. Conveying Non-Source Forms.
                        
                          You may convey a covered work in object code form under the terms
                        of sections 4 and 5, provided that you also convey the
                        machine-readable Corresponding Source under the terms of this License,
                        in one of these ways:
                        
                            a) Convey the object code in, or embodied in, a physical product
                            (including a physical distribution medium), accompanied by the
                            Corresponding Source fixed on a durable physical medium
                            customarily used for software interchange.
                        
                            b) Convey the object code in, or embodied in, a physical product
                            (including a physical distribution medium), accompanied by a
                            written offer, valid for at least three years and valid for as
                            long as you offer spare parts or customer support for that product
                            model, to give anyone who possesses the object code either (1) a
                            copy of the Corresponding Source for all the software in the
                            product that is covered by this License, on a durable physical
                            medium customarily used for software interchange, for a price no
                            more than your reasonable cost of physically performing this
                            conveying of source, or (2) access to copy the
                            Corresponding Source from a network server at no charge.
                        
                            c) Convey individual copies of the object code with a copy of the
                            written offer to provide the Corresponding Source.  This
                            alternative is allowed only occasionally and noncommercially, and
                            only if you received the object code with such an offer, in accord
                            with subsection 6b.
                        
                            d) Convey the object code by offering access from a designated
                            place (gratis or for a charge), and offer equivalent access to the
                            Corresponding Source in the same way through the same place at no
                            further charge.  You need not require recipients to copy the
                            Corresponding Source along with the object code.  If the place to
                            copy the object code is a network server, the Corresponding Source
                            may be on a different server (operated by you or a third party)
                            that supports equivalent copying facilities, provided you maintain
                            clear directions next to the object code saying where to find the
                            Corresponding Source.  Regardless of what server hosts the
                            Corresponding Source, you remain obligated to ensure that it is
                            available for as long as needed to satisfy these requirements.
                        
                            e) Convey the object code using peer-to-peer transmission, provided
                            you inform other peers where the object code and Corresponding
                            Source of the work are being offered to the general public at no
                            charge under subsection 6d.
                        
                          A separable portion of the object code, whose source code is excluded
                        from the Corresponding Source as a System Library, need not be
                        included in conveying the object code work.
                        
                          A "User Product" is either (1) a "consumer product", which means any
                        tangible personal property which is normally used for personal, family,
                        or household purposes, or (2) anything designed or sold for incorporation
                        into a dwelling.  In determining whether a product is a consumer product,
                        doubtful cases shall be resolved in favor of coverage.  For a particular
                        product received by a particular user, "normally used" refers to a
                        typical or common use of that class of product, regardless of the status
                        of the particular user or of the way in which the particular user
                        actually uses, or expects or is expected to use, the product.  A product
                        is a consumer product regardless of whether the product has substantial
                        commercial, industrial or non-consumer uses, unless such uses represent
                        the only significant mode of use of the product.
                        
                          "Installation Information" for a User Product means any methods,
                        procedures, authorization keys, or other information required to install
                        and execute modified versions of a covered work in that User Product from
                        a modified version of its Corresponding Source.  The information must
                        suffice to ensure that the continued functioning of the modified object
                        code is in no case prevented or interfered with solely because
                        modification has been made.
                        
                          If you convey an object code work under this section in, or with, or
                        specifically for use in, a User Product, and the conveying occurs as
                        part of a transaction in which the right of possession and use of the
                        User Product is transferred to the recipient in perpetuity or for a
                        fixed term (regardless of how the transaction is characterized), the
                        Corresponding Source conveyed under this section must be accompanied
                        by the Installation Information.  But this requirement does not apply
                        if neither you nor any third party retains the ability to install
                        modified object code on the User Product (for example, the work has
                        been installed in ROM).
                        
                          The requirement to provide Installation Information does not include a
                        requirement to continue to provide support service, warranty, or updates
                        for a work that has been modified or installed by the recipient, or for
                        the User Product in which it has been modified or installed.  Access to a
                        network may be denied when the modification itself materially and
                        adversely affects the operation of the network or violates the rules and
                        protocols for communication across the network.
                        
                          Corresponding Source conveyed, and Installation Information provided,
                        in accord with this section must be in a format that is publicly
                        documented (and with an implementation available to the public in
                        source code form), and must require no special password or key for
                        unpacking, reading or copying.
                        
                          7. Additional Terms.
                        
                          "Additional permissions" are terms that supplement the terms of this
                        License by making exceptions from one or more of its conditions.
                        Additional permissions that are applicable to the entire Program shall
                        be treated as though they were included in this License, to the extent
                        that they are valid under applicable law.  If additional permissions
                        apply only to part of the Program, that part may be used separately
                        under those permissions, but the entire Program remains governed by
                        this License without regard to the additional permissions.
                        
                          When you convey a copy of a covered work, you may at your option
                        remove any additional permissions from that copy, or from any part of
                        it.  (Additional permissions may be written to require their own
                        removal in certain cases when you modify the work.)  You may place
                        additional permissions on material, added by you to a covered work,
                        for which you have or can give appropriate copyright permission.
                        
                          Notwithstanding any other provision of this License, for material you
                        add to a covered work, you may (if authorized by the copyright holders of
                        that material) supplement the terms of this License with terms:
                        
                            a) Disclaiming warranty or limiting liability differently from the
                            terms of sections 15 and 16 of this License; or
                        
                            b) Requiring preservation of specified reasonable legal notices or
                            author attributions in that material or in the Appropriate Legal
                            Notices displayed by works containing it; or
                        
                            c) Prohibiting misrepresentation of the origin of that material, or
                            requiring that modified versions of such material be marked in
                            reasonable ways as different from the original version; or
                        
                            d) Limiting the use for publicity purposes of names of licensors or
                            authors of the material; or
                        
                            e) Declining to grant rights under trademark law for use of some
                            trade names, trademarks, or service marks; or
                        
                            f) Requiring indemnification of licensors and authors of that
                            material by anyone who conveys the material (or modified versions of
                            it) with contractual assumptions of liability to the recipient, for
                            any liability that these contractual assumptions directly impose on
                            those licensors and authors.
                        
                          All other non-permissive additional terms are considered "further
                        restrictions" within the meaning of section 10.  If the Program as you
                        received it, or any part of it, contains a notice stating that it is
                        governed by this License along with a term that is a further
                        restriction, you may remove that term.  If a license document contains
                        a further restriction but permits relicensing or conveying under this
                        License, you may add to a covered work material governed by the terms
                        of that license document, provided that the further restriction does
                        not survive such relicensing or conveying.
                        
                          If you add terms to a covered work in accord with this section, you
                        must place, in the relevant source files, a statement of the
                        additional terms that apply to those files, or a notice indicating
                        where to find the applicable terms.
                        
                          Additional terms, permissive or non-permissive, may be stated in the
                        form of a separately written license, or stated as exceptions;
                        the above requirements apply either way.
                        
                          8. Termination.
                        
                          You may not propagate or modify a covered work except as expressly
                        provided under this License.  Any attempt otherwise to propagate or
                        modify it is void, and will automatically terminate your rights under
                        this License (including any patent licenses granted under the third
                        paragraph of section 11).
                        
                          However, if you cease all violation of this License, then your
                        license from a particular copyright holder is reinstated (a)
                        provisionally, unless and until the copyright holder explicitly and
                        finally terminates your license, and (b) permanently, if the copyright
                        holder fails to notify you of the violation by some reasonable means
                        prior to 60 days after the cessation.
                        
                          Moreover, your license from a particular copyright holder is
                        reinstated permanently if the copyright holder notifies you of the
                        violation by some reasonable means, this is the first time you have
                        received notice of violation of this License (for any work) from that
                        copyright holder, and you cure the violation prior to 30 days after
                        your receipt of the notice.
                        
                          Termination of your rights under this section does not terminate the
                        licenses of parties who have received copies or rights from you under
                        this License.  If your rights have been terminated and not permanently
                        reinstated, you do not qualify to receive new licenses for the same
                        material under section 10.
                        
                          9. Acceptance Not Required for Having Copies.
                        
                          You are not required to accept this License in order to receive or
                        run a copy of the Program.  Ancillary propagation of a covered work
                        occurring solely as a consequence of using peer-to-peer transmission
                        to receive a copy likewise does not require acceptance.  However,
                        nothing other than this License grants you permission to propagate or
                        modify any covered work.  These actions infringe copyright if you do
                        not accept this License.  Therefore, by modifying or propagating a
                        covered work, you indicate your acceptance of this License to do so.
                        
                          10. Automatic Licensing of Downstream Recipients.
                        
                          Each time you convey a covered work, the recipient automatically
                        receives a license from the original licensors, to run, modify and
                        propagate that work, subject to this License.  You are not responsible
                        for enforcing compliance by third parties with this License.
                        
                          An "entity transaction" is a transaction transferring control of an
                        organization, or substantially all assets of one, or subdividing an
                        organization, or merging organizations.  If propagation of a covered
                        work results from an entity transaction, each party to that
                        transaction who receives a copy of the work also receives whatever
                        licenses to the work the party's predecessor in interest had or could
                        give under the previous paragraph, plus a right to possession of the
                        Corresponding Source of the work from the predecessor in interest, if
                        the predecessor has it or can get it with reasonable efforts.
                        
                          You may not impose any further restrictions on the exercise of the
                        rights granted or affirmed under this License.  For example, you may
                        not impose a license fee, royalty, or other charge for exercise of
                        rights granted under this License, and you may not initiate litigation
                        (including a cross-claim or counterclaim in a lawsuit) alleging that
                        any patent claim is infringed by making, using, selling, offering for
                        sale, or importing the Program or any portion of it.
                        
                          11. Patents.
                        
                          A "contributor" is a copyright holder who authorizes use under this
                        License of the Program or a work on which the Program is based.  The
                        work thus licensed is called the contributor's "contributor version".
                        
                          A contributor's "essential patent claims" are all patent claims
                        owned or controlled by the contributor, whether already acquired or
                        hereafter acquired, that would be infringed by some manner, permitted
                        by this License, of making, using, or selling its contributor version,
                        but do not include claims that would be infringed only as a
                        consequence of further modification of the contributor version.  For
                        purposes of this definition, "control" includes the right to grant
                        patent sublicenses in a manner consistent with the requirements of
                        this License.
                        
                          Each contributor grants you a non-exclusive, worldwide, royalty-free
                        patent license under the contributor's essential patent claims, to
                        make, use, sell, offer for sale, import and otherwise run, modify and
                        propagate the contents of its contributor version.
                        
                          In the following three paragraphs, a "patent license" is any express
                        agreement or commitment, however denominated, not to enforce a patent
                        (such as an express permission to practice a patent or covenant not to
                        sue for patent infringement).  To "grant" such a patent license to a
                        party means to make such an agreement or commitment not to enforce a
                        patent against the party.
                        
                          If you convey a covered work, knowingly relying on a patent license,
                        and the Corresponding Source of the work is not available for anyone
                        to copy, free of charge and under the terms of this License, through a
                        publicly available network server or other readily accessible means,
                        then you must either (1) cause the Corresponding Source to be so
                        available, or (2) arrange to deprive yourself of the benefit of the
                        patent license for this particular work, or (3) arrange, in a manner
                        consistent with the requirements of this License, to extend the patent
                        license to downstream recipients.  "Knowingly relying" means you have
                        actual knowledge that, but for the patent license, your conveying the
                        covered work in a country, or your recipient's use of the covered work
                        in a country, would infringe one or more identifiable patents in that
                        country that you have reason to believe are valid.
                        
                          If, pursuant to or in connection with a single transaction or
                        arrangement, you convey, or propagate by procuring conveyance of, a
                        covered work, and grant a patent license to some of the parties
                        receiving the covered work authorizing them to use, propagate, modify
                        or convey a specific copy of the covered work, then the patent license
                        you grant is automatically extended to all recipients of the covered
                        work and works based on it.
                        
                          A patent license is "discriminatory" if it does not include within
                        the scope of its coverage, prohibits the exercise of, or is
                        conditioned on the non-exercise of one or more of the rights that are
                        specifically granted under this License.  You may not convey a covered
                        work if you are a party to an arrangement with a third party that is
                        in the business of distributing software, under which you make payment
                        to the third party based on the extent of your activity of conveying
                        the work, and under which the third party grants, to any of the
                        parties who would receive the covered work from you, a discriminatory
                        patent license (a) in connection with copies of the covered work
                        conveyed by you (or copies made from those copies), or (b) primarily
                        for and in connection with specific products or compilations that
                        contain the covered work, unless you entered into that arrangement,
                        or that patent license was granted, prior to 28 March 2007.
                        
                          Nothing in this License shall be construed as excluding or limiting
                        any implied license or other defenses to infringement that may
                        otherwise be available to you under applicable patent law.
                        
                          12. No Surrender of Others' Freedom.
                        
                          If conditions are imposed on you (whether by court order, agreement or
                        otherwise) that contradict the conditions of this License, they do not
                        excuse you from the conditions of this License.  If you cannot convey a
                        covered work so as to satisfy simultaneously your obligations under this
                        License and any other pertinent obligations, then as a consequence you may
                        not convey it at all.  For example, if you agree to terms that obligate you
                        to collect a royalty for further conveying from those to whom you convey
                        the Program, the only way you could satisfy both those terms and this
                        License would be to refrain entirely from conveying the Program.
                        
                          13. Use with the GNU Affero General Public License.
                        
                          Notwithstanding any other provision of this License, you have
                        permission to link or combine any covered work with a work licensed
                        under version 3 of the GNU Affero General Public License into a single
                        combined work, and to convey the resulting work.  The terms of this
                        License will continue to apply to the part which is the covered work,
                        but the special requirements of the GNU Affero General Public License,
                        section 13, concerning interaction through a network will apply to the
                        combination as such.
                        
                          14. Revised Versions of this License.
                        
                          The Free Software Foundation may publish revised and/or new versions of
                        the GNU General Public License from time to time.  Such new versions will
                        be similar in spirit to the present version, but may differ in detail to
                        address new problems or concerns.
                        
                          Each version is given a distinguishing version number.  If the
                        Program specifies that a certain numbered version of the GNU General
                        Public License "or any later version" applies to it, you have the
                        option of following the terms and conditions either of that numbered
                        version or of any later version published by the Free Software
                        Foundation.  If the Program does not specify a version number of the
                        GNU General Public License, you may choose any version ever published
                        by the Free Software Foundation.
                        
                          If the Program specifies that a proxy can decide which future
                        versions of the GNU General Public License can be used, that proxy's
                        public statement of acceptance of a version permanently authorizes you
                        to choose that version for the Program.
                        
                          Later license versions may give you additional or different
                        permissions.  However, no additional obligations are imposed on any
                        author or copyright holder as a result of your choosing to follow a
                        later version.
                        
                          15. Disclaimer of Warranty.
                        
                          THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
                        APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
                        HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
                        OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
                        THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                        PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
                        IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
                        ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
                        
                          16. Limitation of Liability.
                        
                          IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
                        WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
                        THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
                        GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
                        USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
                        DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
                        PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
                        EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
                        SUCH DAMAGES.
                        
                          17. Interpretation of Sections 15 and 16.
                        
                          If the disclaimer of warranty and limitation of liability provided
                        above cannot be given local legal effect according to their terms,
                        reviewing courts shall apply local law that most closely approximates
                        an absolute waiver of all civil liability in connection with the
                        Program, unless a warranty or assumption of liability accompanies a
                        copy of the Program in return for a fee.
                        
                                             END OF TERMS AND CONDITIONS
                        
                                    How to Apply These Terms to Your New Programs
                        
                          If you develop a new program, and you want it to be of the greatest
                        possible use to the public, the best way to achieve this is to make it
                        free software which everyone can redistribute and change under these terms.
                        
                          To do so, attach the following notices to the program.  It is safest
                        to attach them to the start of each source file to most effectively
                        state the exclusion of warranty; and each file should have at least
                        the "copyright" line and a pointer to where the full notice is found.
                        
                            <one line to give the program's name and a brief idea of what it does.>
                            Copyright (C) <year>  <name of author>
                        
                            This program is free software: you can redistribute it and/or modify
                            it under the terms of the GNU General Public License as published by
                            the Free Software Foundation, either version 3 of the License, or
                            (at your option) any later version.
                        
                            This program is distributed in the hope that it will be useful,
                            but WITHOUT ANY WARRANTY; without even the implied warranty of
                            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                            GNU General Public License for more details.
                        
                            You should have received a copy of the GNU General Public License
                            along with this program.  If not, see <http://www.gnu.org/licenses/>.
                        
                        Also add information on how to contact you by electronic and paper mail.
                        
                          If the program does terminal interaction, make it output a short
                        notice like this when it starts in an interactive mode:
                        
                            <program>  Copyright (C) <year>  <name of author>
                            This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
                            This is free software, and you are welcome to redistribute it
                            under certain conditions; type `show c' for details.
                        
                        The hypothetical commands `show w' and `show c' should show the appropriate
                        parts of the General Public License.  Of course, your program's commands
                        might be different; for a GUI interface, you would use an "about box".
                        
                          You should also get your employer (if you work as a programmer) or school,
                        if any, to sign a "copyright disclaimer" for the program, if necessary.
                        For more information on this, and how to apply and follow the GNU GPL, see
                        <http://www.gnu.org/licenses/>.
                        
                          The GNU General Public License does not permit incorporating your program
                        into proprietary programs.  If your program is a subroutine library, you
                        may consider it more useful to permit linking proprietary applications with
                        the library.  If this is what you want to do, use the GNU Lesser General
                        Public License instead of this License.  But first, please read
                        <http://www.gnu.org/philosophy/why-not-lgpl.html>.
                        
                        */

                        File 4 of 11: InitializedProxy
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @title InitializedProxy
                         * @author Anna Carroll
                         */
                        contract InitializedProxy {
                            // address of logic contract
                            address public immutable logic;
                            // ======== Constructor =========
                            constructor(
                                address _logic,
                                bytes memory _initializationCalldata
                            ) {
                                logic = _logic;
                                // Delegatecall into the logic contract, supplying initialization calldata
                                (bool _ok, bytes memory returnData) =
                                    _logic.delegatecall(_initializationCalldata);
                                // Revert if delegatecall to implementation reverts
                                require(_ok, string(returnData));
                            }
                            // ======== Fallback =========
                            fallback() external payable {
                                address _impl = logic;
                                assembly {
                                    let ptr := mload(0x40)
                                    calldatacopy(ptr, 0, calldatasize())
                                    let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)
                                    let size := returndatasize()
                                    returndatacopy(ptr, 0, size)
                                    switch result
                                        case 0 {
                                            revert(ptr, size)
                                        }
                                        default {
                                            return(ptr, size)
                                        }
                                }
                            }
                            // ======== Receive =========
                            receive() external payable {} // solhint-disable-line no-empty-blocks
                        }

                        File 5 of 11: UniswapV2Factory
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Factory.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Factory {
                            event PairCreated(address indexed token0, address indexed token1, address pair, uint);
                        
                            function feeTo() external view returns (address);
                            function feeToSetter() external view returns (address);
                            function migrator() external view returns (address);
                        
                            function getPair(address tokenA, address tokenB) external view returns (address pair);
                            function allPairs(uint) external view returns (address pair);
                            function allPairsLength() external view returns (uint);
                        
                            function createPair(address tokenA, address tokenB) external returns (address pair);
                        
                            function setFeeTo(address) external;
                            function setFeeToSetter(address) external;
                            function setMigrator(address) external;
                        }
                        
                        // File: contracts/uniswapv2/libraries/SafeMath.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
                        
                        library SafeMathUniswap {
                            function add(uint x, uint y) internal pure returns (uint z) {
                                require((z = x + y) >= x, 'ds-math-add-overflow');
                            }
                        
                            function sub(uint x, uint y) internal pure returns (uint z) {
                                require((z = x - y) <= x, 'ds-math-sub-underflow');
                            }
                        
                            function mul(uint x, uint y) internal pure returns (uint z) {
                                require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
                            }
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2ERC20.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        contract UniswapV2ERC20 {
                            using SafeMathUniswap for uint;
                        
                            string public constant name = 'SushiSwap LP Token';
                            string public constant symbol = 'SLP';
                            uint8 public constant decimals = 18;
                            uint  public totalSupply;
                            mapping(address => uint) public balanceOf;
                            mapping(address => mapping(address => uint)) public allowance;
                        
                            bytes32 public DOMAIN_SEPARATOR;
                            // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
                            bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
                            mapping(address => uint) public nonces;
                        
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            constructor() public {
                                uint chainId;
                                assembly {
                                    chainId := chainid()
                                }
                                DOMAIN_SEPARATOR = keccak256(
                                    abi.encode(
                                        keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
                                        keccak256(bytes(name)),
                                        keccak256(bytes('1')),
                                        chainId,
                                        address(this)
                                    )
                                );
                            }
                        
                            function _mint(address to, uint value) internal {
                                totalSupply = totalSupply.add(value);
                                balanceOf[to] = balanceOf[to].add(value);
                                emit Transfer(address(0), to, value);
                            }
                        
                            function _burn(address from, uint value) internal {
                                balanceOf[from] = balanceOf[from].sub(value);
                                totalSupply = totalSupply.sub(value);
                                emit Transfer(from, address(0), value);
                            }
                        
                            function _approve(address owner, address spender, uint value) private {
                                allowance[owner][spender] = value;
                                emit Approval(owner, spender, value);
                            }
                        
                            function _transfer(address from, address to, uint value) private {
                                balanceOf[from] = balanceOf[from].sub(value);
                                balanceOf[to] = balanceOf[to].add(value);
                                emit Transfer(from, to, value);
                            }
                        
                            function approve(address spender, uint value) external returns (bool) {
                                _approve(msg.sender, spender, value);
                                return true;
                            }
                        
                            function transfer(address to, uint value) external returns (bool) {
                                _transfer(msg.sender, to, value);
                                return true;
                            }
                        
                            function transferFrom(address from, address to, uint value) external returns (bool) {
                                if (allowance[from][msg.sender] != uint(-1)) {
                                    allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
                                }
                                _transfer(from, to, value);
                                return true;
                            }
                        
                            function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
                                require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
                                bytes32 digest = keccak256(
                                    abi.encodePacked(
                                        '\x19\x01',
                                        DOMAIN_SEPARATOR,
                                        keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                                    )
                                );
                                address recoveredAddress = ecrecover(digest, v, r, s);
                                require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
                                _approve(owner, spender, value);
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/Math.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for performing various math operations
                        
                        library Math {
                            function min(uint x, uint y) internal pure returns (uint z) {
                                z = x < y ? x : y;
                            }
                        
                            // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
                            function sqrt(uint y) internal pure returns (uint z) {
                                if (y > 3) {
                                    z = y;
                                    uint x = y / 2 + 1;
                                    while (x < z) {
                                        z = x;
                                        x = (y / x + x) / 2;
                                    }
                                } else if (y != 0) {
                                    z = 1;
                                }
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/UQ112x112.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
                        
                        // range: [0, 2**112 - 1]
                        // resolution: 1 / 2**112
                        
                        library UQ112x112 {
                            uint224 constant Q112 = 2**112;
                        
                            // encode a uint112 as a UQ112x112
                            function encode(uint112 y) internal pure returns (uint224 z) {
                                z = uint224(y) * Q112; // never overflows
                            }
                        
                            // divide a UQ112x112 by a uint112, returning a UQ112x112
                            function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
                                z = x / uint224(y);
                            }
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IERC20.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IERC20Uniswap {
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            function name() external view returns (string memory);
                            function symbol() external view returns (string memory);
                            function decimals() external view returns (uint8);
                            function totalSupply() external view returns (uint);
                            function balanceOf(address owner) external view returns (uint);
                            function allowance(address owner, address spender) external view returns (uint);
                        
                            function approve(address spender, uint value) external returns (bool);
                            function transfer(address to, uint value) external returns (bool);
                            function transferFrom(address from, address to, uint value) external returns (bool);
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Callee.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Callee {
                            function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2Pair.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        
                        
                        
                        
                        
                        
                        interface IMigrator {
                            // Return the desired amount of liquidity token that the migrator wants.
                            function desiredLiquidity() external view returns (uint256);
                        }
                        
                        contract UniswapV2Pair is UniswapV2ERC20 {
                            using SafeMathUniswap  for uint;
                            using UQ112x112 for uint224;
                        
                            uint public constant MINIMUM_LIQUIDITY = 10**3;
                            bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
                        
                            address public factory;
                            address public token0;
                            address public token1;
                        
                            uint112 private reserve0;           // uses single storage slot, accessible via getReserves
                            uint112 private reserve1;           // uses single storage slot, accessible via getReserves
                            uint32  private blockTimestampLast; // uses single storage slot, accessible via getReserves
                        
                            uint public price0CumulativeLast;
                            uint public price1CumulativeLast;
                            uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
                        
                            uint private unlocked = 1;
                            modifier lock() {
                                require(unlocked == 1, 'UniswapV2: LOCKED');
                                unlocked = 0;
                                _;
                                unlocked = 1;
                            }
                        
                            function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
                                _reserve0 = reserve0;
                                _reserve1 = reserve1;
                                _blockTimestampLast = blockTimestampLast;
                            }
                        
                            function _safeTransfer(address token, address to, uint value) private {
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
                            }
                        
                            event Mint(address indexed sender, uint amount0, uint amount1);
                            event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
                            event Swap(
                                address indexed sender,
                                uint amount0In,
                                uint amount1In,
                                uint amount0Out,
                                uint amount1Out,
                                address indexed to
                            );
                            event Sync(uint112 reserve0, uint112 reserve1);
                        
                            constructor() public {
                                factory = msg.sender;
                            }
                        
                            // called once by the factory at time of deployment
                            function initialize(address _token0, address _token1) external {
                                require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
                                token0 = _token0;
                                token1 = _token1;
                            }
                        
                            // update reserves and, on the first call per block, price accumulators
                            function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
                                require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
                                uint32 blockTimestamp = uint32(block.timestamp % 2**32);
                                uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
                                if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
                                    // * never overflows, and + overflow is desired
                                    price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
                                    price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
                                }
                                reserve0 = uint112(balance0);
                                reserve1 = uint112(balance1);
                                blockTimestampLast = blockTimestamp;
                                emit Sync(reserve0, reserve1);
                            }
                        
                            // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
                            function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
                                address feeTo = IUniswapV2Factory(factory).feeTo();
                                feeOn = feeTo != address(0);
                                uint _kLast = kLast; // gas savings
                                if (feeOn) {
                                    if (_kLast != 0) {
                                        uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
                                        uint rootKLast = Math.sqrt(_kLast);
                                        if (rootK > rootKLast) {
                                            uint numerator = totalSupply.mul(rootK.sub(rootKLast));
                                            uint denominator = rootK.mul(5).add(rootKLast);
                                            uint liquidity = numerator / denominator;
                                            if (liquidity > 0) _mint(feeTo, liquidity);
                                        }
                                    }
                                } else if (_kLast != 0) {
                                    kLast = 0;
                                }
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function mint(address to) external lock returns (uint liquidity) {
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                uint balance0 = IERC20Uniswap(token0).balanceOf(address(this));
                                uint balance1 = IERC20Uniswap(token1).balanceOf(address(this));
                                uint amount0 = balance0.sub(_reserve0);
                                uint amount1 = balance1.sub(_reserve1);
                        
                                bool feeOn = _mintFee(_reserve0, _reserve1);
                                uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
                                if (_totalSupply == 0) {
                                    address migrator = IUniswapV2Factory(factory).migrator();
                                    if (msg.sender == migrator) {
                                        liquidity = IMigrator(migrator).desiredLiquidity();
                                        require(liquidity > 0 && liquidity != uint256(-1), "Bad desired liquidity");
                                    } else {
                                        require(migrator == address(0), "Must not have migrator");
                                        liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
                                        _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
                                    }
                                } else {
                                    liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
                                }
                                require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
                                _mint(to, liquidity);
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
                                emit Mint(msg.sender, amount0, amount1);
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function burn(address to) external lock returns (uint amount0, uint amount1) {
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                address _token0 = token0;                                // gas savings
                                address _token1 = token1;                                // gas savings
                                uint balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                uint balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                                uint liquidity = balanceOf[address(this)];
                        
                                bool feeOn = _mintFee(_reserve0, _reserve1);
                                uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
                                amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
                                amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
                                require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
                                _burn(address(this), liquidity);
                                _safeTransfer(_token0, to, amount0);
                                _safeTransfer(_token1, to, amount1);
                                balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
                                emit Burn(msg.sender, amount0, amount1, to);
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
                                require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
                        
                                uint balance0;
                                uint balance1;
                                { // scope for _token{0,1}, avoids stack too deep errors
                                address _token0 = token0;
                                address _token1 = token1;
                                require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
                                if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
                                if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
                                if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
                                balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                                }
                                uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
                                uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
                                require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
                                { // scope for reserve{0,1}Adjusted, avoids stack too deep errors
                                uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
                                uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
                                require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
                                }
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
                            }
                        
                            // force balances to match reserves
                            function skim(address to) external lock {
                                address _token0 = token0; // gas savings
                                address _token1 = token1; // gas savings
                                _safeTransfer(_token0, to, IERC20Uniswap(_token0).balanceOf(address(this)).sub(reserve0));
                                _safeTransfer(_token1, to, IERC20Uniswap(_token1).balanceOf(address(this)).sub(reserve1));
                            }
                        
                            // force reserves to match balances
                            function sync() external lock {
                                _update(IERC20Uniswap(token0).balanceOf(address(this)), IERC20Uniswap(token1).balanceOf(address(this)), reserve0, reserve1);
                            }
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2Factory.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        
                        contract UniswapV2Factory is IUniswapV2Factory {
                            address public override feeTo;
                            address public override feeToSetter;
                            address public override migrator;
                        
                            mapping(address => mapping(address => address)) public override getPair;
                            address[] public override allPairs;
                        
                            event PairCreated(address indexed token0, address indexed token1, address pair, uint);
                        
                            constructor(address _feeToSetter) public {
                                feeToSetter = _feeToSetter;
                            }
                        
                            function allPairsLength() external override view returns (uint) {
                                return allPairs.length;
                            }
                        
                            function pairCodeHash() external pure returns (bytes32) {
                                return keccak256(type(UniswapV2Pair).creationCode);
                            }
                        
                            function createPair(address tokenA, address tokenB) external override returns (address pair) {
                                require(tokenA != tokenB, 'UniswapV2: IDENTICAL_ADDRESSES');
                                (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
                                require(token0 != address(0), 'UniswapV2: ZERO_ADDRESS');
                                require(getPair[token0][token1] == address(0), 'UniswapV2: PAIR_EXISTS'); // single check is sufficient
                                bytes memory bytecode = type(UniswapV2Pair).creationCode;
                                bytes32 salt = keccak256(abi.encodePacked(token0, token1));
                                assembly {
                                    pair := create2(0, add(bytecode, 32), mload(bytecode), salt)
                                }
                                UniswapV2Pair(pair).initialize(token0, token1);
                                getPair[token0][token1] = pair;
                                getPair[token1][token0] = pair; // populate mapping in the reverse direction
                                allPairs.push(pair);
                                emit PairCreated(token0, token1, pair, allPairs.length);
                            }
                        
                            function setFeeTo(address _feeTo) external override {
                                require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN');
                                feeTo = _feeTo;
                            }
                        
                            function setMigrator(address _migrator) external override {
                                require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN');
                                migrator = _migrator;
                            }
                        
                            function setFeeToSetter(address _feeToSetter) external override {
                                require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN');
                                feeToSetter = _feeToSetter;
                            }
                        
                        }

                        File 6 of 11: UniswapV2Pair
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Factory.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Factory {
                            event PairCreated(address indexed token0, address indexed token1, address pair, uint);
                        
                            function feeTo() external view returns (address);
                            function feeToSetter() external view returns (address);
                            function migrator() external view returns (address);
                        
                            function getPair(address tokenA, address tokenB) external view returns (address pair);
                            function allPairs(uint) external view returns (address pair);
                            function allPairsLength() external view returns (uint);
                        
                            function createPair(address tokenA, address tokenB) external returns (address pair);
                        
                            function setFeeTo(address) external;
                            function setFeeToSetter(address) external;
                            function setMigrator(address) external;
                        }
                        
                        // File: contracts/uniswapv2/libraries/SafeMath.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
                        
                        library SafeMathUniswap {
                            function add(uint x, uint y) internal pure returns (uint z) {
                                require((z = x + y) >= x, 'ds-math-add-overflow');
                            }
                        
                            function sub(uint x, uint y) internal pure returns (uint z) {
                                require((z = x - y) <= x, 'ds-math-sub-underflow');
                            }
                        
                            function mul(uint x, uint y) internal pure returns (uint z) {
                                require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
                            }
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2ERC20.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        contract UniswapV2ERC20 {
                            using SafeMathUniswap for uint;
                        
                            string public constant name = 'SushiSwap LP Token';
                            string public constant symbol = 'SLP';
                            uint8 public constant decimals = 18;
                            uint  public totalSupply;
                            mapping(address => uint) public balanceOf;
                            mapping(address => mapping(address => uint)) public allowance;
                        
                            bytes32 public DOMAIN_SEPARATOR;
                            // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
                            bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
                            mapping(address => uint) public nonces;
                        
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            constructor() public {
                                uint chainId;
                                assembly {
                                    chainId := chainid()
                                }
                                DOMAIN_SEPARATOR = keccak256(
                                    abi.encode(
                                        keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
                                        keccak256(bytes(name)),
                                        keccak256(bytes('1')),
                                        chainId,
                                        address(this)
                                    )
                                );
                            }
                        
                            function _mint(address to, uint value) internal {
                                totalSupply = totalSupply.add(value);
                                balanceOf[to] = balanceOf[to].add(value);
                                emit Transfer(address(0), to, value);
                            }
                        
                            function _burn(address from, uint value) internal {
                                balanceOf[from] = balanceOf[from].sub(value);
                                totalSupply = totalSupply.sub(value);
                                emit Transfer(from, address(0), value);
                            }
                        
                            function _approve(address owner, address spender, uint value) private {
                                allowance[owner][spender] = value;
                                emit Approval(owner, spender, value);
                            }
                        
                            function _transfer(address from, address to, uint value) private {
                                balanceOf[from] = balanceOf[from].sub(value);
                                balanceOf[to] = balanceOf[to].add(value);
                                emit Transfer(from, to, value);
                            }
                        
                            function approve(address spender, uint value) external returns (bool) {
                                _approve(msg.sender, spender, value);
                                return true;
                            }
                        
                            function transfer(address to, uint value) external returns (bool) {
                                _transfer(msg.sender, to, value);
                                return true;
                            }
                        
                            function transferFrom(address from, address to, uint value) external returns (bool) {
                                if (allowance[from][msg.sender] != uint(-1)) {
                                    allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
                                }
                                _transfer(from, to, value);
                                return true;
                            }
                        
                            function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
                                require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
                                bytes32 digest = keccak256(
                                    abi.encodePacked(
                                        '\x19\x01',
                                        DOMAIN_SEPARATOR,
                                        keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                                    )
                                );
                                address recoveredAddress = ecrecover(digest, v, r, s);
                                require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
                                _approve(owner, spender, value);
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/Math.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for performing various math operations
                        
                        library Math {
                            function min(uint x, uint y) internal pure returns (uint z) {
                                z = x < y ? x : y;
                            }
                        
                            // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
                            function sqrt(uint y) internal pure returns (uint z) {
                                if (y > 3) {
                                    z = y;
                                    uint x = y / 2 + 1;
                                    while (x < z) {
                                        z = x;
                                        x = (y / x + x) / 2;
                                    }
                                } else if (y != 0) {
                                    z = 1;
                                }
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/UQ112x112.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
                        
                        // range: [0, 2**112 - 1]
                        // resolution: 1 / 2**112
                        
                        library UQ112x112 {
                            uint224 constant Q112 = 2**112;
                        
                            // encode a uint112 as a UQ112x112
                            function encode(uint112 y) internal pure returns (uint224 z) {
                                z = uint224(y) * Q112; // never overflows
                            }
                        
                            // divide a UQ112x112 by a uint112, returning a UQ112x112
                            function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
                                z = x / uint224(y);
                            }
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IERC20.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IERC20Uniswap {
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            function name() external view returns (string memory);
                            function symbol() external view returns (string memory);
                            function decimals() external view returns (uint8);
                            function totalSupply() external view returns (uint);
                            function balanceOf(address owner) external view returns (uint);
                            function allowance(address owner, address spender) external view returns (uint);
                        
                            function approve(address spender, uint value) external returns (bool);
                            function transfer(address to, uint value) external returns (bool);
                            function transferFrom(address from, address to, uint value) external returns (bool);
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Callee.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Callee {
                            function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2Pair.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        
                        
                        
                        
                        
                        
                        interface IMigrator {
                            // Return the desired amount of liquidity token that the migrator wants.
                            function desiredLiquidity() external view returns (uint256);
                        }
                        
                        contract UniswapV2Pair is UniswapV2ERC20 {
                            using SafeMathUniswap  for uint;
                            using UQ112x112 for uint224;
                        
                            uint public constant MINIMUM_LIQUIDITY = 10**3;
                            bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
                        
                            address public factory;
                            address public token0;
                            address public token1;
                        
                            uint112 private reserve0;           // uses single storage slot, accessible via getReserves
                            uint112 private reserve1;           // uses single storage slot, accessible via getReserves
                            uint32  private blockTimestampLast; // uses single storage slot, accessible via getReserves
                        
                            uint public price0CumulativeLast;
                            uint public price1CumulativeLast;
                            uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
                        
                            uint private unlocked = 1;
                            modifier lock() {
                                require(unlocked == 1, 'UniswapV2: LOCKED');
                                unlocked = 0;
                                _;
                                unlocked = 1;
                            }
                        
                            function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
                                _reserve0 = reserve0;
                                _reserve1 = reserve1;
                                _blockTimestampLast = blockTimestampLast;
                            }
                        
                            function _safeTransfer(address token, address to, uint value) private {
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
                            }
                        
                            event Mint(address indexed sender, uint amount0, uint amount1);
                            event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
                            event Swap(
                                address indexed sender,
                                uint amount0In,
                                uint amount1In,
                                uint amount0Out,
                                uint amount1Out,
                                address indexed to
                            );
                            event Sync(uint112 reserve0, uint112 reserve1);
                        
                            constructor() public {
                                factory = msg.sender;
                            }
                        
                            // called once by the factory at time of deployment
                            function initialize(address _token0, address _token1) external {
                                require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
                                token0 = _token0;
                                token1 = _token1;
                            }
                        
                            // update reserves and, on the first call per block, price accumulators
                            function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
                                require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
                                uint32 blockTimestamp = uint32(block.timestamp % 2**32);
                                uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
                                if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
                                    // * never overflows, and + overflow is desired
                                    price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
                                    price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
                                }
                                reserve0 = uint112(balance0);
                                reserve1 = uint112(balance1);
                                blockTimestampLast = blockTimestamp;
                                emit Sync(reserve0, reserve1);
                            }
                        
                            // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
                            function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
                                address feeTo = IUniswapV2Factory(factory).feeTo();
                                feeOn = feeTo != address(0);
                                uint _kLast = kLast; // gas savings
                                if (feeOn) {
                                    if (_kLast != 0) {
                                        uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
                                        uint rootKLast = Math.sqrt(_kLast);
                                        if (rootK > rootKLast) {
                                            uint numerator = totalSupply.mul(rootK.sub(rootKLast));
                                            uint denominator = rootK.mul(5).add(rootKLast);
                                            uint liquidity = numerator / denominator;
                                            if (liquidity > 0) _mint(feeTo, liquidity);
                                        }
                                    }
                                } else if (_kLast != 0) {
                                    kLast = 0;
                                }
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function mint(address to) external lock returns (uint liquidity) {
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                uint balance0 = IERC20Uniswap(token0).balanceOf(address(this));
                                uint balance1 = IERC20Uniswap(token1).balanceOf(address(this));
                                uint amount0 = balance0.sub(_reserve0);
                                uint amount1 = balance1.sub(_reserve1);
                        
                                bool feeOn = _mintFee(_reserve0, _reserve1);
                                uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
                                if (_totalSupply == 0) {
                                    address migrator = IUniswapV2Factory(factory).migrator();
                                    if (msg.sender == migrator) {
                                        liquidity = IMigrator(migrator).desiredLiquidity();
                                        require(liquidity > 0 && liquidity != uint256(-1), "Bad desired liquidity");
                                    } else {
                                        require(migrator == address(0), "Must not have migrator");
                                        liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
                                        _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
                                    }
                                } else {
                                    liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
                                }
                                require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
                                _mint(to, liquidity);
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
                                emit Mint(msg.sender, amount0, amount1);
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function burn(address to) external lock returns (uint amount0, uint amount1) {
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                address _token0 = token0;                                // gas savings
                                address _token1 = token1;                                // gas savings
                                uint balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                uint balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                                uint liquidity = balanceOf[address(this)];
                        
                                bool feeOn = _mintFee(_reserve0, _reserve1);
                                uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
                                amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
                                amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
                                require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
                                _burn(address(this), liquidity);
                                _safeTransfer(_token0, to, amount0);
                                _safeTransfer(_token1, to, amount1);
                                balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
                                emit Burn(msg.sender, amount0, amount1, to);
                            }
                        
                            // this low-level function should be called from a contract which performs important safety checks
                            function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
                                require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
                                (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
                                require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
                        
                                uint balance0;
                                uint balance1;
                                { // scope for _token{0,1}, avoids stack too deep errors
                                address _token0 = token0;
                                address _token1 = token1;
                                require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
                                if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
                                if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
                                if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
                                balance0 = IERC20Uniswap(_token0).balanceOf(address(this));
                                balance1 = IERC20Uniswap(_token1).balanceOf(address(this));
                                }
                                uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
                                uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
                                require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
                                { // scope for reserve{0,1}Adjusted, avoids stack too deep errors
                                uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
                                uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
                                require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
                                }
                        
                                _update(balance0, balance1, _reserve0, _reserve1);
                                emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
                            }
                        
                            // force balances to match reserves
                            function skim(address to) external lock {
                                address _token0 = token0; // gas savings
                                address _token1 = token1; // gas savings
                                _safeTransfer(_token0, to, IERC20Uniswap(_token0).balanceOf(address(this)).sub(reserve0));
                                _safeTransfer(_token1, to, IERC20Uniswap(_token1).balanceOf(address(this)).sub(reserve1));
                            }
                        
                            // force reserves to match balances
                            function sync() external lock {
                                _update(IERC20Uniswap(token0).balanceOf(address(this)), IERC20Uniswap(token1).balanceOf(address(this)), reserve0, reserve1);
                            }
                        }

                        File 7 of 11: GnosisSafe
                        pragma solidity >=0.5.0 <0.7.0;
                        
                        /// @title SelfAuthorized - authorizes current contract to perform actions
                        /// @author Richard Meissner - <[email protected]>
                        contract SelfAuthorized {
                            modifier authorized() {
                                require(msg.sender == address(this), "Method can only be called from this contract");
                                _;
                            }
                        }
                        
                        
                        
                        /// @title MasterCopy - Base for master copy contracts (should always be first super contract)
                        ///         This contract is tightly coupled to our proxy contract (see `proxies/Proxy.sol`)
                        /// @author Richard Meissner - <[email protected]>
                        contract MasterCopy is SelfAuthorized {
                        
                            event ChangedMasterCopy(address masterCopy);
                        
                            // masterCopy always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.
                            // It should also always be ensured that the address is stored alone (uses a full word)
                            address private masterCopy;
                        
                            /// @dev Allows to upgrade the contract. This can only be done via a Safe transaction.
                            /// @param _masterCopy New contract address.
                            function changeMasterCopy(address _masterCopy)
                                public
                                authorized
                            {
                                // Master copy address cannot be null.
                                require(_masterCopy != address(0), "Invalid master copy address provided");
                                masterCopy = _masterCopy;
                                emit ChangedMasterCopy(_masterCopy);
                            }
                        }
                        
                        
                        /// @title Module - Base class for modules.
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        contract Module is MasterCopy {
                        
                            ModuleManager public manager;
                        
                            modifier authorized() {
                                require(msg.sender == address(manager), "Method can only be called from manager");
                                _;
                            }
                        
                            function setManager()
                                internal
                            {
                                // manager can only be 0 at initalization of contract.
                                // Check ensures that setup function can only be called once.
                                require(address(manager) == address(0), "Manager has already been set");
                                manager = ModuleManager(msg.sender);
                            }
                        }
                        
                        
                        
                        
                        
                        /// @title Enum - Collection of enums
                        /// @author Richard Meissner - <[email protected]>
                        contract Enum {
                            enum Operation {
                                Call,
                                DelegateCall
                            }
                        }
                        
                        
                        
                        
                        
                        /// @title Executor - A contract that can execute transactions
                        /// @author Richard Meissner - <[email protected]>
                        contract Executor {
                        
                            function execute(address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas)
                                internal
                                returns (bool success)
                            {
                                if (operation == Enum.Operation.Call)
                                    success = executeCall(to, value, data, txGas);
                                else if (operation == Enum.Operation.DelegateCall)
                                    success = executeDelegateCall(to, data, txGas);
                                else
                                    success = false;
                            }
                        
                            function executeCall(address to, uint256 value, bytes memory data, uint256 txGas)
                                internal
                                returns (bool success)
                            {
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)
                                }
                            }
                        
                            function executeDelegateCall(address to, bytes memory data, uint256 txGas)
                                internal
                                returns (bool success)
                            {
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)
                                }
                            }
                        }
                        
                        
                        
                        /// @title SecuredTokenTransfer - Secure token transfer
                        /// @author Richard Meissner - <[email protected]>
                        contract SecuredTokenTransfer {
                        
                            /// @dev Transfers a token and returns if it was a success
                            /// @param token Token that should be transferred
                            /// @param receiver Receiver to whom the token should be transferred
                            /// @param amount The amount of tokens that should be transferred
                            function transferToken (
                                address token,
                                address receiver,
                                uint256 amount
                            )
                                internal
                                returns (bool transferred)
                            {
                                bytes memory data = abi.encodeWithSignature("transfer(address,uint256)", receiver, amount);
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    let success := call(sub(gas, 10000), token, 0, add(data, 0x20), mload(data), 0, 0)
                                    let ptr := mload(0x40)
                                    mstore(0x40, add(ptr, returndatasize()))
                                    returndatacopy(ptr, 0, returndatasize())
                                    switch returndatasize()
                                    case 0 { transferred := success }
                                    case 0x20 { transferred := iszero(or(iszero(success), iszero(mload(ptr)))) }
                                    default { transferred := 0 }
                                }
                            }
                        }
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        /// @title Module Manager - A contract that manages modules that can execute transactions via this contract
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        contract ModuleManager is SelfAuthorized, Executor {
                        
                            event EnabledModule(Module module);
                            event DisabledModule(Module module);
                            event ExecutionFromModuleSuccess(address indexed module);
                            event ExecutionFromModuleFailure(address indexed module);
                        
                            address internal constant SENTINEL_MODULES = address(0x1);
                        
                            mapping (address => address) internal modules;
                        
                            function setupModules(address to, bytes memory data)
                                internal
                            {
                                require(modules[SENTINEL_MODULES] == address(0), "Modules have already been initialized");
                                modules[SENTINEL_MODULES] = SENTINEL_MODULES;
                                if (to != address(0))
                                    // Setup has to complete successfully or transaction fails.
                                    require(executeDelegateCall(to, data, gasleft()), "Could not finish initialization");
                            }
                        
                            /// @dev Allows to add a module to the whitelist.
                            ///      This can only be done via a Safe transaction.
                            /// @param module Module to be whitelisted.
                            function enableModule(Module module)
                                public
                                authorized
                            {
                                // Module address cannot be null or sentinel.
                                require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
                                // Module cannot be added twice.
                                require(modules[address(module)] == address(0), "Module has already been added");
                                modules[address(module)] = modules[SENTINEL_MODULES];
                                modules[SENTINEL_MODULES] = address(module);
                                emit EnabledModule(module);
                            }
                        
                            /// @dev Allows to remove a module from the whitelist.
                            ///      This can only be done via a Safe transaction.
                            /// @param prevModule Module that pointed to the module to be removed in the linked list
                            /// @param module Module to be removed.
                            function disableModule(Module prevModule, Module module)
                                public
                                authorized
                            {
                                // Validate module address and check that it corresponds to module index.
                                require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
                                require(modules[address(prevModule)] == address(module), "Invalid prevModule, module pair provided");
                                modules[address(prevModule)] = modules[address(module)];
                                modules[address(module)] = address(0);
                                emit DisabledModule(module);
                            }
                        
                            /// @dev Allows a Module to execute a Safe transaction without any further confirmations.
                            /// @param to Destination address of module transaction.
                            /// @param value Ether value of module transaction.
                            /// @param data Data payload of module transaction.
                            /// @param operation Operation type of module transaction.
                            function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
                                public
                                returns (bool success)
                            {
                                // Only whitelisted modules are allowed.
                                require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "Method can only be called from an enabled module");
                                // Execute transaction without further confirmations.
                                success = execute(to, value, data, operation, gasleft());
                                if (success) emit ExecutionFromModuleSuccess(msg.sender);
                                else emit ExecutionFromModuleFailure(msg.sender);
                            }
                        
                            /// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data
                            /// @param to Destination address of module transaction.
                            /// @param value Ether value of module transaction.
                            /// @param data Data payload of module transaction.
                            /// @param operation Operation type of module transaction.
                            function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
                                public
                                returns (bool success, bytes memory returnData)
                            {
                                success = execTransactionFromModule(to, value, data, operation);
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    // Load free memory location
                                    let ptr := mload(0x40)
                                    // We allocate memory for the return data by setting the free memory location to
                                    // current free memory location + data size + 32 bytes for data size value
                                    mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
                                    // Store the size
                                    mstore(ptr, returndatasize())
                                    // Store the data
                                    returndatacopy(add(ptr, 0x20), 0, returndatasize())
                                    // Point the return data to the correct memory location
                                    returnData := ptr
                                }
                            }
                        
                            /// @dev Returns array of first 10 modules.
                            /// @return Array of modules.
                            function getModules()
                                public
                                view
                                returns (address[] memory)
                            {
                                (address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);
                                return array;
                            }
                        
                            /// @dev Returns array of modules.
                            /// @param start Start of the page.
                            /// @param pageSize Maximum number of modules that should be returned.
                            /// @return Array of modules.
                            function getModulesPaginated(address start, uint256 pageSize)
                                public
                                view
                                returns (address[] memory array, address next)
                            {
                                // Init array with max page size
                                array = new address[](pageSize);
                        
                                // Populate return array
                                uint256 moduleCount = 0;
                                address currentModule = modules[start];
                                while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
                                    array[moduleCount] = currentModule;
                                    currentModule = modules[currentModule];
                                    moduleCount++;
                                }
                                next = currentModule;
                                // Set correct size of returned array
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    mstore(array, moduleCount)
                                }
                            }
                        }
                        
                        
                        
                        
                        /// @title OwnerManager - Manages a set of owners and a threshold to perform actions.
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        contract OwnerManager is SelfAuthorized {
                        
                            event AddedOwner(address owner);
                            event RemovedOwner(address owner);
                            event ChangedThreshold(uint256 threshold);
                        
                            address internal constant SENTINEL_OWNERS = address(0x1);
                        
                            mapping(address => address) internal owners;
                            uint256 ownerCount;
                            uint256 internal threshold;
                        
                            /// @dev Setup function sets initial storage of contract.
                            /// @param _owners List of Safe owners.
                            /// @param _threshold Number of required confirmations for a Safe transaction.
                            function setupOwners(address[] memory _owners, uint256 _threshold)
                                internal
                            {
                                // Threshold can only be 0 at initialization.
                                // Check ensures that setup function can only be called once.
                                require(threshold == 0, "Owners have already been setup");
                                // Validate that threshold is smaller than number of added owners.
                                require(_threshold <= _owners.length, "Threshold cannot exceed owner count");
                                // There has to be at least one Safe owner.
                                require(_threshold >= 1, "Threshold needs to be greater than 0");
                                // Initializing Safe owners.
                                address currentOwner = SENTINEL_OWNERS;
                                for (uint256 i = 0; i < _owners.length; i++) {
                                    // Owner address cannot be null.
                                    address owner = _owners[i];
                                    require(owner != address(0) && owner != SENTINEL_OWNERS, "Invalid owner address provided");
                                    // No duplicate owners allowed.
                                    require(owners[owner] == address(0), "Duplicate owner address provided");
                                    owners[currentOwner] = owner;
                                    currentOwner = owner;
                                }
                                owners[currentOwner] = SENTINEL_OWNERS;
                                ownerCount = _owners.length;
                                threshold = _threshold;
                            }
                        
                            /// @dev Allows to add a new owner to the Safe and update the threshold at the same time.
                            ///      This can only be done via a Safe transaction.
                            /// @param owner New owner address.
                            /// @param _threshold New threshold.
                            function addOwnerWithThreshold(address owner, uint256 _threshold)
                                public
                                authorized
                            {
                                // Owner address cannot be null.
                                require(owner != address(0) && owner != SENTINEL_OWNERS, "Invalid owner address provided");
                                // No duplicate owners allowed.
                                require(owners[owner] == address(0), "Address is already an owner");
                                owners[owner] = owners[SENTINEL_OWNERS];
                                owners[SENTINEL_OWNERS] = owner;
                                ownerCount++;
                                emit AddedOwner(owner);
                                // Change threshold if threshold was changed.
                                if (threshold != _threshold)
                                    changeThreshold(_threshold);
                            }
                        
                            /// @dev Allows to remove an owner from the Safe and update the threshold at the same time.
                            ///      This can only be done via a Safe transaction.
                            /// @param prevOwner Owner that pointed to the owner to be removed in the linked list
                            /// @param owner Owner address to be removed.
                            /// @param _threshold New threshold.
                            function removeOwner(address prevOwner, address owner, uint256 _threshold)
                                public
                                authorized
                            {
                                // Only allow to remove an owner, if threshold can still be reached.
                                require(ownerCount - 1 >= _threshold, "New owner count needs to be larger than new threshold");
                                // Validate owner address and check that it corresponds to owner index.
                                require(owner != address(0) && owner != SENTINEL_OWNERS, "Invalid owner address provided");
                                require(owners[prevOwner] == owner, "Invalid prevOwner, owner pair provided");
                                owners[prevOwner] = owners[owner];
                                owners[owner] = address(0);
                                ownerCount--;
                                emit RemovedOwner(owner);
                                // Change threshold if threshold was changed.
                                if (threshold != _threshold)
                                    changeThreshold(_threshold);
                            }
                        
                            /// @dev Allows to swap/replace an owner from the Safe with another address.
                            ///      This can only be done via a Safe transaction.
                            /// @param prevOwner Owner that pointed to the owner to be replaced in the linked list
                            /// @param oldOwner Owner address to be replaced.
                            /// @param newOwner New owner address.
                            function swapOwner(address prevOwner, address oldOwner, address newOwner)
                                public
                                authorized
                            {
                                // Owner address cannot be null.
                                require(newOwner != address(0) && newOwner != SENTINEL_OWNERS, "Invalid owner address provided");
                                // No duplicate owners allowed.
                                require(owners[newOwner] == address(0), "Address is already an owner");
                                // Validate oldOwner address and check that it corresponds to owner index.
                                require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "Invalid owner address provided");
                                require(owners[prevOwner] == oldOwner, "Invalid prevOwner, owner pair provided");
                                owners[newOwner] = owners[oldOwner];
                                owners[prevOwner] = newOwner;
                                owners[oldOwner] = address(0);
                                emit RemovedOwner(oldOwner);
                                emit AddedOwner(newOwner);
                            }
                        
                            /// @dev Allows to update the number of required confirmations by Safe owners.
                            ///      This can only be done via a Safe transaction.
                            /// @param _threshold New threshold.
                            function changeThreshold(uint256 _threshold)
                                public
                                authorized
                            {
                                // Validate that threshold is smaller than number of owners.
                                require(_threshold <= ownerCount, "Threshold cannot exceed owner count");
                                // There has to be at least one Safe owner.
                                require(_threshold >= 1, "Threshold needs to be greater than 0");
                                threshold = _threshold;
                                emit ChangedThreshold(threshold);
                            }
                        
                            function getThreshold()
                                public
                                view
                                returns (uint256)
                            {
                                return threshold;
                            }
                        
                            function isOwner(address owner)
                                public
                                view
                                returns (bool)
                            {
                                return owner != SENTINEL_OWNERS && owners[owner] != address(0);
                            }
                        
                            /// @dev Returns array of owners.
                            /// @return Array of Safe owners.
                            function getOwners()
                                public
                                view
                                returns (address[] memory)
                            {
                                address[] memory array = new address[](ownerCount);
                        
                                // populate return array
                                uint256 index = 0;
                                address currentOwner = owners[SENTINEL_OWNERS];
                                while(currentOwner != SENTINEL_OWNERS) {
                                    array[index] = currentOwner;
                                    currentOwner = owners[currentOwner];
                                    index ++;
                                }
                                return array;
                            }
                        }
                        
                        
                        
                        
                        
                        /// @title Fallback Manager - A contract that manages fallback calls made to this contract
                        /// @author Richard Meissner - <[email protected]>
                        contract FallbackManager is SelfAuthorized {
                        
                            // keccak256("fallback_manager.handler.address")
                            bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;
                        
                            function internalSetFallbackHandler(address handler) internal {
                                bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    sstore(slot, handler)
                                }
                            }
                        
                            /// @dev Allows to add a contract to handle fallback calls.
                            ///      Only fallback calls without value and with data will be forwarded.
                            ///      This can only be done via a Safe transaction.
                            /// @param handler contract to handle fallbacks calls.
                            function setFallbackHandler(address handler)
                                public
                                authorized
                            {
                                internalSetFallbackHandler(handler);
                            }
                        
                            function ()
                                external
                                payable
                            {
                                // Only calls without value and with data will be forwarded
                                if (msg.value > 0 || msg.data.length == 0) {
                                    return;
                                }
                                bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
                                address handler;
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    handler := sload(slot)
                                }
                        
                                if (handler != address(0)) {
                                    // solium-disable-next-line security/no-inline-assembly
                                    assembly {
                                        calldatacopy(0, 0, calldatasize())
                                        let success := call(gas, handler, 0, 0, calldatasize(), 0, 0)
                                        returndatacopy(0, 0, returndatasize())
                                        if eq(success, 0) { revert(0, returndatasize()) }
                                        return(0, returndatasize())
                                    }
                                }
                            }
                        }
                        
                        
                        
                        
                        
                        
                        
                        /// @title SignatureDecoder - Decodes signatures that a encoded as bytes
                        /// @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
                        /// @author Richard Meissner - <[email protected]>
                        contract SignatureDecoder {
                            
                            /// @dev Recovers address who signed the message
                            /// @param messageHash operation ethereum signed message hash
                            /// @param messageSignature message `txHash` signature
                            /// @param pos which signature to read
                            function recoverKey (
                                bytes32 messageHash,
                                bytes memory messageSignature,
                                uint256 pos
                            )
                                internal
                                pure
                                returns (address)
                            {
                                uint8 v;
                                bytes32 r;
                                bytes32 s;
                                (v, r, s) = signatureSplit(messageSignature, pos);
                                return ecrecover(messageHash, v, r, s);
                            }
                        
                            /// @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`.
                            /// @notice Make sure to peform a bounds check for @param pos, to avoid out of bounds access on @param signatures
                            /// @param pos which signature to read. A prior bounds check of this parameter should be performed, to avoid out of bounds access
                            /// @param signatures concatenated rsv signatures
                            function signatureSplit(bytes memory signatures, uint256 pos)
                                internal
                                pure
                                returns (uint8 v, bytes32 r, bytes32 s)
                            {
                                // The signature format is a compact form of:
                                //   {bytes32 r}{bytes32 s}{uint8 v}
                                // Compact means, uint8 is not padded to 32 bytes.
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    let signaturePos := mul(0x41, pos)
                                    r := mload(add(signatures, add(signaturePos, 0x20)))
                                    s := mload(add(signatures, add(signaturePos, 0x40)))
                                    // Here we are loading the last 32 bytes, including 31 bytes
                                    // of 's'. There is no 'mload8' to do this.
                                    //
                                    // 'byte' is not working due to the Solidity parser, so lets
                                    // use the second best option, 'and'
                                    v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)
                                }
                            }
                        }
                        
                        
                        
                        
                        contract ISignatureValidatorConstants {
                            // bytes4(keccak256("isValidSignature(bytes,bytes)")
                            bytes4 constant internal EIP1271_MAGIC_VALUE = 0x20c13b0b;
                        }
                        
                        contract ISignatureValidator is ISignatureValidatorConstants {
                        
                            /**
                            * @dev Should return whether the signature provided is valid for the provided data
                            * @param _data Arbitrary length data signed on the behalf of address(this)
                            * @param _signature Signature byte array associated with _data
                            *
                            * MUST return the bytes4 magic value 0x20c13b0b when function passes.
                            * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
                            * MUST allow external calls
                            */
                            function isValidSignature(
                                bytes memory _data,
                                bytes memory _signature)
                                public
                                view
                                returns (bytes4);
                        }
                        
                        
                        /**
                         * @title SafeMath
                         * @dev Math operations with safety checks that revert on error
                         * TODO: remove once open zeppelin update to solc 0.5.0
                         */
                        library SafeMath {
                        
                          /**
                          * @dev Multiplies two numbers, reverts on overflow.
                          */
                          function mul(uint256 a, uint256 b) internal pure returns (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-solidity/pull/522
                            if (a == 0) {
                              return 0;
                            }
                        
                            uint256 c = a * b;
                            require(c / a == b);
                        
                            return c;
                          }
                        
                          /**
                          * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
                          */
                          function div(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b > 0); // Solidity only automatically asserts when dividing by 0
                            uint256 c = a / b;
                            // assert(a == b * c + a % b); // There is no case in which this doesn't hold
                        
                            return c;
                          }
                        
                          /**
                          * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
                          */
                          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b <= a);
                            uint256 c = a - b;
                        
                            return c;
                          }
                        
                          /**
                          * @dev Adds two numbers, reverts on overflow.
                          */
                          function add(uint256 a, uint256 b) internal pure returns (uint256) {
                            uint256 c = a + b;
                            require(c >= a);
                        
                            return c;
                          }
                        
                          /**
                          * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
                          * reverts when dividing by zero.
                          */
                          function mod(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b != 0);
                            return a % b;
                          }
                        }
                        
                        /// @title Gnosis Safe - A multisignature wallet with support for confirmations using signed messages based on ERC191.
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        /// @author Ricardo Guilherme Schmidt - (Status Research & Development GmbH) - Gas Token Payment
                        contract GnosisSafe
                            is MasterCopy, ModuleManager, OwnerManager, SignatureDecoder, SecuredTokenTransfer, ISignatureValidatorConstants, FallbackManager {
                        
                            using SafeMath for uint256;
                        
                            string public constant NAME = "Gnosis Safe";
                            string public constant VERSION = "1.1.1";
                        
                            //keccak256(
                            //    "EIP712Domain(address verifyingContract)"
                            //);
                            bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x035aff83d86937d35b32e04f0ddc6ff469290eef2f1b692d8a815c89404d4749;
                        
                            //keccak256(
                            //    "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
                            //);
                            bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;
                        
                            //keccak256(
                            //    "SafeMessage(bytes message)"
                            //);
                            bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;
                        
                            event ApproveHash(
                                bytes32 indexed approvedHash,
                                address indexed owner
                            );
                            event SignMsg(
                                bytes32 indexed msgHash
                            );
                            event ExecutionFailure(
                                bytes32 txHash, uint256 payment
                            );
                            event ExecutionSuccess(
                                bytes32 txHash, uint256 payment
                            );
                        
                            uint256 public nonce;
                            bytes32 public domainSeparator;
                            // Mapping to keep track of all message hashes that have been approve by ALL REQUIRED owners
                            mapping(bytes32 => uint256) public signedMessages;
                            // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners
                            mapping(address => mapping(bytes32 => uint256)) public approvedHashes;
                        
                            // This constructor ensures that this contract can only be used as a master copy for Proxy contracts
                            constructor() public {
                                // By setting the threshold it is not possible to call setup anymore,
                                // so we create a Safe with 0 owners and threshold 1.
                                // This is an unusable Safe, perfect for the mastercopy
                                threshold = 1;
                            }
                        
                            /// @dev Setup function sets initial storage of contract.
                            /// @param _owners List of Safe owners.
                            /// @param _threshold Number of required confirmations for a Safe transaction.
                            /// @param to Contract address for optional delegate call.
                            /// @param data Data payload for optional delegate call.
                            /// @param fallbackHandler Handler for fallback calls to this contract
                            /// @param paymentToken Token that should be used for the payment (0 is ETH)
                            /// @param payment Value that should be paid
                            /// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)
                            function setup(
                                address[] calldata _owners,
                                uint256 _threshold,
                                address to,
                                bytes calldata data,
                                address fallbackHandler,
                                address paymentToken,
                                uint256 payment,
                                address payable paymentReceiver
                            )
                                external
                            {
                                require(domainSeparator == 0, "Domain Separator already set!");
                                domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));
                                setupOwners(_owners, _threshold);
                                if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
                                // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
                                setupModules(to, data);
                        
                                if (payment > 0) {
                                    // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)
                                    // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment
                                    handlePayment(payment, 0, 1, paymentToken, paymentReceiver);
                                }
                            }
                        
                            /// @dev Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction.
                            ///      Note: The fees are always transfered, even if the user transaction fails.
                            /// @param to Destination address of Safe transaction.
                            /// @param value Ether value of Safe transaction.
                            /// @param data Data payload of Safe transaction.
                            /// @param operation Operation type of Safe transaction.
                            /// @param safeTxGas Gas that should be used for the Safe transaction.
                            /// @param baseGas Gas costs for that are indipendent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
                            /// @param gasPrice Gas price that should be used for the payment calculation.
                            /// @param gasToken Token address (or 0 if ETH) that is used for the payment.
                            /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
                            /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
                            function execTransaction(
                                address to,
                                uint256 value,
                                bytes calldata data,
                                Enum.Operation operation,
                                uint256 safeTxGas,
                                uint256 baseGas,
                                uint256 gasPrice,
                                address gasToken,
                                address payable refundReceiver,
                                bytes calldata signatures
                            )
                                external
                                returns (bool success)
                            {
                                bytes32 txHash;
                                // Use scope here to limit variable lifetime and prevent `stack too deep` errors
                                {
                                    bytes memory txHashData = encodeTransactionData(
                                        to, value, data, operation, // Transaction info
                                        safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info
                                        nonce
                                    );
                                    // Increase nonce and execute transaction.
                                    nonce++;
                                    txHash = keccak256(txHashData);
                                    checkSignatures(txHash, txHashData, signatures, true);
                                }
                                require(gasleft() >= safeTxGas, "Not enough gas to execute safe transaction");
                                // Use scope here to limit variable lifetime and prevent `stack too deep` errors
                                {
                                    uint256 gasUsed = gasleft();
                                    // If no safeTxGas has been set and the gasPrice is 0 we assume that all available gas can be used
                                    success = execute(to, value, data, operation, safeTxGas == 0 && gasPrice == 0 ? gasleft() : safeTxGas);
                                    gasUsed = gasUsed.sub(gasleft());
                                    // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls
                                    uint256 payment = 0;
                                    if (gasPrice > 0) {
                                        payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);
                                    }
                                    if (success) emit ExecutionSuccess(txHash, payment);
                                    else emit ExecutionFailure(txHash, payment);
                                }
                            }
                        
                            function handlePayment(
                                uint256 gasUsed,
                                uint256 baseGas,
                                uint256 gasPrice,
                                address gasToken,
                                address payable refundReceiver
                            )
                                private
                                returns (uint256 payment)
                            {
                                // solium-disable-next-line security/no-tx-origin
                                address payable receiver = refundReceiver == address(0) ? tx.origin : refundReceiver;
                                if (gasToken == address(0)) {
                                    // For ETH we will only adjust the gas price to not be higher than the actual used gas price
                                    payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);
                                    // solium-disable-next-line security/no-send
                                    require(receiver.send(payment), "Could not pay gas costs with ether");
                                } else {
                                    payment = gasUsed.add(baseGas).mul(gasPrice);
                                    require(transferToken(gasToken, receiver, payment), "Could not pay gas costs with token");
                                }
                            }
                        
                            /**
                            * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.
                            * @param dataHash Hash of the data (could be either a message hash or transaction hash)
                            * @param data That should be signed (this is passed to an external validator contract)
                            * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.
                            * @param consumeHash Indicates that in case of an approved hash the storage can be freed to save gas
                            */
                            function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, bool consumeHash)
                                internal
                            {
                                // Load threshold to avoid multiple storage loads
                                uint256 _threshold = threshold;
                                // Check that a threshold is set
                                require(_threshold > 0, "Threshold needs to be defined!");
                                // Check that the provided signature data is not too short
                                require(signatures.length >= _threshold.mul(65), "Signatures data too short");
                                // There cannot be an owner with address 0.
                                address lastOwner = address(0);
                                address currentOwner;
                                uint8 v;
                                bytes32 r;
                                bytes32 s;
                                uint256 i;
                                for (i = 0; i < _threshold; i++) {
                                    (v, r, s) = signatureSplit(signatures, i);
                                    // If v is 0 then it is a contract signature
                                    if (v == 0) {
                                        // When handling contract signatures the address of the contract is encoded into r
                                        currentOwner = address(uint256(r));
                        
                                        // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes
                                        // This check is not completely accurate, since it is possible that more signatures than the threshold are send.
                                        // Here we only check that the pointer is not pointing inside the part that is being processed
                                        require(uint256(s) >= _threshold.mul(65), "Invalid contract signature location: inside static part");
                        
                                        // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)
                                        require(uint256(s).add(32) <= signatures.length, "Invalid contract signature location: length not present");
                        
                                        // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length
                                        uint256 contractSignatureLen;
                                        // solium-disable-next-line security/no-inline-assembly
                                        assembly {
                                            contractSignatureLen := mload(add(add(signatures, s), 0x20))
                                        }
                                        require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, "Invalid contract signature location: data not complete");
                        
                                        // Check signature
                                        bytes memory contractSignature;
                                        // solium-disable-next-line security/no-inline-assembly
                                        assembly {
                                            // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s
                                            contractSignature := add(add(signatures, s), 0x20)
                                        }
                                        require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, "Invalid contract signature provided");
                                    // If v is 1 then it is an approved hash
                                    } else if (v == 1) {
                                        // When handling approved hashes the address of the approver is encoded into r
                                        currentOwner = address(uint256(r));
                                        // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction
                                        require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "Hash has not been approved");
                                        // Hash has been marked for consumption. If this hash was pre-approved free storage
                                        if (consumeHash && msg.sender != currentOwner) {
                                            approvedHashes[currentOwner][dataHash] = 0;
                                        }
                                    } else if (v > 30) {
                                        // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover
                                        currentOwner = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash)), v - 4, r, s);
                                    } else {
                                        // Use ecrecover with the messageHash for EOA signatures
                                        currentOwner = ecrecover(dataHash, v, r, s);
                                    }
                                    require (
                                        currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS,
                                        "Invalid owner provided"
                                    );
                                    lastOwner = currentOwner;
                                }
                            }
                        
                            /// @dev Allows to estimate a Safe transaction.
                            ///      This method is only meant for estimation purpose, therefore two different protection mechanism against execution in a transaction have been made:
                            ///      1.) The method can only be called from the safe itself
                            ///      2.) The response is returned with a revert
                            ///      When estimating set `from` to the address of the safe.
                            ///      Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`
                            /// @param to Destination address of Safe transaction.
                            /// @param value Ether value of Safe transaction.
                            /// @param data Data payload of Safe transaction.
                            /// @param operation Operation type of Safe transaction.
                            /// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).
                            function requiredTxGas(address to, uint256 value, bytes calldata data, Enum.Operation operation)
                                external
                                authorized
                                returns (uint256)
                            {
                                uint256 startGas = gasleft();
                                // We don't provide an error message here, as we use it to return the estimate
                                // solium-disable-next-line error-reason
                                require(execute(to, value, data, operation, gasleft()));
                                uint256 requiredGas = startGas - gasleft();
                                // Convert response to string and return via error message
                                revert(string(abi.encodePacked(requiredGas)));
                            }
                        
                            /**
                            * @dev Marks a hash as approved. This can be used to validate a hash that is used by a signature.
                            * @param hashToApprove The hash that should be marked as approved for signatures that are verified by this contract.
                            */
                            function approveHash(bytes32 hashToApprove)
                                external
                            {
                                require(owners[msg.sender] != address(0), "Only owners can approve a hash");
                                approvedHashes[msg.sender][hashToApprove] = 1;
                                emit ApproveHash(hashToApprove, msg.sender);
                            }
                        
                            /**
                            * @dev Marks a message as signed
                            * @param _data Arbitrary length data that should be marked as signed on the behalf of address(this)
                            */
                            function signMessage(bytes calldata _data)
                                external
                                authorized
                            {
                                bytes32 msgHash = getMessageHash(_data);
                                signedMessages[msgHash] = 1;
                                emit SignMsg(msgHash);
                            }
                        
                            /**
                            * Implementation of ISignatureValidator (see `interfaces/ISignatureValidator.sol`)
                            * @dev Should return whether the signature provided is valid for the provided data.
                            *       The save does not implement the interface since `checkSignatures` is not a view method.
                            *       The method will not perform any state changes (see parameters of `checkSignatures`)
                            * @param _data Arbitrary length data signed on the behalf of address(this)
                            * @param _signature Signature byte array associated with _data
                            * @return a bool upon valid or invalid signature with corresponding _data
                            */
                            function isValidSignature(bytes calldata _data, bytes calldata _signature)
                                external
                                returns (bytes4)
                            {
                                bytes32 messageHash = getMessageHash(_data);
                                if (_signature.length == 0) {
                                    require(signedMessages[messageHash] != 0, "Hash not approved");
                                } else {
                                    // consumeHash needs to be false, as the state should not be changed
                                    checkSignatures(messageHash, _data, _signature, false);
                                }
                                return EIP1271_MAGIC_VALUE;
                            }
                        
                            /// @dev Returns hash of a message that can be signed by owners.
                            /// @param message Message that should be hashed
                            /// @return Message hash.
                            function getMessageHash(
                                bytes memory message
                            )
                                public
                                view
                                returns (bytes32)
                            {
                                bytes32 safeMessageHash = keccak256(
                                    abi.encode(SAFE_MSG_TYPEHASH, keccak256(message))
                                );
                                return keccak256(
                                    abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeMessageHash)
                                );
                            }
                        
                            /// @dev Returns the bytes that are hashed to be signed by owners.
                            /// @param to Destination address.
                            /// @param value Ether value.
                            /// @param data Data payload.
                            /// @param operation Operation type.
                            /// @param safeTxGas Fas that should be used for the safe transaction.
                            /// @param baseGas Gas costs for data used to trigger the safe transaction.
                            /// @param gasPrice Maximum gas price that should be used for this transaction.
                            /// @param gasToken Token address (or 0 if ETH) that is used for the payment.
                            /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
                            /// @param _nonce Transaction nonce.
                            /// @return Transaction hash bytes.
                            function encodeTransactionData(
                                address to,
                                uint256 value,
                                bytes memory data,
                                Enum.Operation operation,
                                uint256 safeTxGas,
                                uint256 baseGas,
                                uint256 gasPrice,
                                address gasToken,
                                address refundReceiver,
                                uint256 _nonce
                            )
                                public
                                view
                                returns (bytes memory)
                            {
                                bytes32 safeTxHash = keccak256(
                                    abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce)
                                );
                                return abi.encodePacked(byte(0x19), byte(0x01), domainSeparator, safeTxHash);
                            }
                        
                            /// @dev Returns hash to be signed by owners.
                            /// @param to Destination address.
                            /// @param value Ether value.
                            /// @param data Data payload.
                            /// @param operation Operation type.
                            /// @param safeTxGas Fas that should be used for the safe transaction.
                            /// @param baseGas Gas costs for data used to trigger the safe transaction.
                            /// @param gasPrice Maximum gas price that should be used for this transaction.
                            /// @param gasToken Token address (or 0 if ETH) that is used for the payment.
                            /// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
                            /// @param _nonce Transaction nonce.
                            /// @return Transaction hash.
                            function getTransactionHash(
                                address to,
                                uint256 value,
                                bytes memory data,
                                Enum.Operation operation,
                                uint256 safeTxGas,
                                uint256 baseGas,
                                uint256 gasPrice,
                                address gasToken,
                                address refundReceiver,
                                uint256 _nonce
                            )
                                public
                                view
                                returns (bytes32)
                            {
                                return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));
                            }
                        }

                        File 8 of 11: MultiSend
                        pragma solidity >=0.5.0 <0.7.0;
                        
                        
                        /// @title Multi Send - Allows to batch multiple transactions into one.
                        /// @author Nick Dodson - <[email protected]>
                        /// @author Gonçalo Sá - <[email protected]>
                        /// @author Stefan George - <[email protected]>
                        /// @author Richard Meissner - <[email protected]>
                        contract MultiSend {
                        
                            bytes32 constant private GUARD_VALUE = keccak256("multisend.guard.bytes32");
                        
                            bytes32 guard;
                        
                            constructor() public {
                                guard = GUARD_VALUE;
                            }
                        
                            /// @dev Sends multiple transactions and reverts all if one fails.
                            /// @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of
                            ///                     operation as a uint8 with 0 for a call or 1 for a delegatecall (=> 1 byte),
                            ///                     to as a address (=> 20 bytes),
                            ///                     value as a uint256 (=> 32 bytes),
                            ///                     data length as a uint256 (=> 32 bytes),
                            ///                     data as bytes.
                            ///                     see abi.encodePacked for more information on packed encoding
                            function multiSend(bytes memory transactions)
                                public
                            {
                                require(guard != GUARD_VALUE, "MultiSend should only be called via delegatecall");
                                // solium-disable-next-line security/no-inline-assembly
                                assembly {
                                    let length := mload(transactions)
                                    let i := 0x20
                                    for { } lt(i, length) { } {
                                        // First byte of the data is the operation.
                                        // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word).
                                        // This will also zero out unused data.
                                        let operation := shr(0xf8, mload(add(transactions, i)))
                                        // We offset the load address by 1 byte (operation byte)
                                        // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data.
                                        let to := shr(0x60, mload(add(transactions, add(i, 0x01))))
                                        // We offset the load address by 21 byte (operation byte + 20 address bytes)
                                        let value := mload(add(transactions, add(i, 0x15)))
                                        // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes)
                                        let dataLength := mload(add(transactions, add(i, 0x35)))
                                        // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes)
                                        let data := add(transactions, add(i, 0x55))
                                        let success := 0
                                        switch operation
                                        case 0 { success := call(gas, to, value, data, dataLength, 0, 0) }
                                        case 1 { success := delegatecall(gas, to, data, dataLength, 0, 0) }
                                        if eq(success, 0) { revert(0, 0) }
                                        // Next entry starts at 85 byte + data length
                                        i := add(i, add(0x55, dataLength))
                                    }
                                }
                            }
                        }

                        File 9 of 11: BatchAuction
                        // File contracts/OpenZeppelin/utils/ReentrancyGuard.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @dev Contract module that helps prevent reentrant calls to a function.
                         *
                         * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                         * available, which can be applied to functions to make sure there are no nested
                         * (reentrant) calls to them.
                         *
                         * Note that because there is a single `nonReentrant` guard, functions marked as
                         * `nonReentrant` may not call one another. This can be worked around by making
                         * those functions `private`, and then adding `external` `nonReentrant` entry
                         * points to them.
                         *
                         * TIP: If you would like to learn more about reentrancy and alternative ways
                         * to protect against it, check out our blog post
                         * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                         */
                        abstract contract ReentrancyGuard {
                            // Booleans are more expensive than uint256 or any type that takes up a full
                            // word because each write operation emits an extra SLOAD to first read the
                            // slot's contents, replace the bits taken up by the boolean, and then write
                            // back. This is the compiler's defense against contract upgrades and
                            // pointer aliasing, and it cannot be disabled.
                        
                            // The values being non-zero value makes deployment a bit more expensive,
                            // but in exchange the refund on every call to nonReentrant will be lower in
                            // amount. Since refunds are capped to a percentage of the total
                            // transaction's gas, it is best to keep them low in cases like this one, to
                            // increase the likelihood of the full refund coming into effect.
                            uint256 private constant _NOT_ENTERED = 1;
                            uint256 private constant _ENTERED = 2;
                        
                            uint256 private _status;
                        
                            constructor () internal {
                                _status = _NOT_ENTERED;
                            }
                        
                            /**
                             * @dev Prevents a contract from calling itself, directly or indirectly.
                             * Calling a `nonReentrant` function from another `nonReentrant`
                             * function is not supported. It is possible to prevent this from happening
                             * by making the `nonReentrant` function external, and make it call a
                             * `private` function that does the actual work.
                             */
                            modifier nonReentrant() {
                                // On the first call to nonReentrant, _notEntered will be true
                                require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                        
                                // Any calls to nonReentrant after this point will fail
                                _status = _ENTERED;
                        
                                _;
                        
                                // By storing the original value once again, a refund is triggered (see
                                // https://eips.ethereum.org/EIPS/eip-2200)
                                _status = _NOT_ENTERED;
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/EnumerableSet.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @dev Library for managing
                         * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
                         * types.
                         *
                         * Sets have the following properties:
                         *
                         * - Elements are added, removed, and checked for existence in constant time
                         * (O(1)).
                         * - Elements are enumerated in O(n). No guarantees are made on the ordering.
                         *
                         * ```
                         * contract Example {
                         *     // Add the library methods
                         *     using EnumerableSet for EnumerableSet.AddressSet;
                         *
                         *     // Declare a set state variable
                         *     EnumerableSet.AddressSet private mySet;
                         * }
                         * ```
                         *
                         * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
                         * and `uint256` (`UintSet`) are supported.
                         */
                        library EnumerableSet {
                            // To implement this library for multiple types with as little code
                            // repetition as possible, we write it in terms of a generic Set type with
                            // bytes32 values.
                            // The Set implementation uses private functions, and user-facing
                            // implementations (such as AddressSet) are just wrappers around the
                            // underlying Set.
                            // This means that we can only create new EnumerableSets for types that fit
                            // in bytes32.
                        
                            struct Set {
                                // Storage of set values
                                bytes32[] _values;
                        
                                // Position of the value in the `values` array, plus 1 because index 0
                                // means a value is not in the set.
                                mapping (bytes32 => uint256) _indexes;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function _add(Set storage set, bytes32 value) private returns (bool) {
                                if (!_contains(set, value)) {
                                    set._values.push(value);
                                    // The value is stored at length-1, but we add 1 to all indexes
                                    // and use 0 as a sentinel value
                                    set._indexes[value] = set._values.length;
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function _remove(Set storage set, bytes32 value) private returns (bool) {
                                // We read and store the value's index to prevent multiple reads from the same storage slot
                                uint256 valueIndex = set._indexes[value];
                        
                                if (valueIndex != 0) { // Equivalent to contains(set, value)
                                    // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
                                    // the array, and then remove the last element (sometimes called as 'swap and pop').
                                    // This modifies the order of the array, as noted in {at}.
                        
                                    uint256 toDeleteIndex = valueIndex - 1;
                                    uint256 lastIndex = set._values.length - 1;
                        
                                    // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
                                    // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
                        
                                    bytes32 lastvalue = set._values[lastIndex];
                        
                                    // Move the last value to the index where the value to delete is
                                    set._values[toDeleteIndex] = lastvalue;
                                    // Update the index for the moved value
                                    set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
                        
                                    // Delete the slot where the moved value was stored
                                    set._values.pop();
                        
                                    // Delete the index for the deleted slot
                                    delete set._indexes[value];
                        
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function _contains(Set storage set, bytes32 value) private view returns (bool) {
                                return set._indexes[value] != 0;
                            }
                        
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function _length(Set storage set) private view returns (uint256) {
                                return set._values.length;
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function _at(Set storage set, uint256 index) private view returns (bytes32) {
                                require(set._values.length > index, "EnumerableSet: index out of bounds");
                                return set._values[index];
                            }
                        
                            // Bytes32Set
                        
                            struct Bytes32Set {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _add(set._inner, value);
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _remove(set._inner, value);
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
                                return _contains(set._inner, value);
                            }
                        
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(Bytes32Set storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
                                return _at(set._inner, index);
                            }
                        
                            // AddressSet
                        
                            struct AddressSet {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(AddressSet storage set, address value) internal returns (bool) {
                                return _add(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(AddressSet storage set, address value) internal returns (bool) {
                                return _remove(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(AddressSet storage set, address value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(uint256(uint160(value))));
                            }
                        
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(AddressSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(AddressSet storage set, uint256 index) internal view returns (address) {
                                return address(uint160(uint256(_at(set._inner, index))));
                            }
                        
                        
                            // UintSet
                        
                            struct UintSet {
                                Set _inner;
                            }
                        
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(UintSet storage set, uint256 value) internal returns (bool) {
                                return _add(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(UintSet storage set, uint256 value) internal returns (bool) {
                                return _remove(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(UintSet storage set, uint256 value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(value));
                            }
                        
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function length(UintSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                        
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(UintSet storage set, uint256 index) internal view returns (uint256) {
                                return uint256(_at(set._inner, index));
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/Address.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @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);
                                    }
                                }
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/utils/Context.sol
                        
                        pragma solidity 0.6.12;
                        
                        /*
                         * @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 GSN 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 payable) {
                                return msg.sender;
                            }
                        
                            function _msgData() internal view virtual returns (bytes memory) {
                                this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                return msg.data;
                            }
                        }
                        
                        
                        // File contracts/OpenZeppelin/access/AccessControl.sol
                        
                        pragma solidity 0.6.12;
                        
                        
                        
                        /**
                         * @dev Contract module that allows children to implement role-based access
                         * control mechanisms.
                         *
                         * Roles are referred to by their `bytes32` identifier. These should be exposed
                         * in the external API and be unique. The best way to achieve this is by
                         * using `public constant` hash digests:
                         *
                         * ```
                         * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
                         * ```
                         *
                         * Roles can be used to represent a set of permissions. To restrict access to a
                         * function call, use {hasRole}:
                         *
                         * ```
                         * function foo() public {
                         *     require(hasRole(MY_ROLE, msg.sender));
                         *     ...
                         * }
                         * ```
                         *
                         * Roles can be granted and revoked dynamically via the {grantRole} and
                         * {revokeRole} functions. Each role has an associated admin role, and only
                         * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
                         *
                         * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
                         * that only accounts with this role will be able to grant or revoke other
                         * roles. More complex role relationships can be created by using
                         * {_setRoleAdmin}.
                         *
                         * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
                         * grant and revoke this role. Extra precautions should be taken to secure
                         * accounts that have been granted it.
                         */
                        abstract contract AccessControl is Context {
                            using EnumerableSet for EnumerableSet.AddressSet;
                            using Address for address;
                        
                            struct RoleData {
                                EnumerableSet.AddressSet members;
                                bytes32 adminRole;
                            }
                        
                            mapping (bytes32 => RoleData) private _roles;
                        
                            bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
                        
                            /**
                             * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
                             *
                             * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
                             * {RoleAdminChanged} not being emitted signaling this.
                             *
                             * _Available since v3.1._
                             */
                            event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
                        
                            /**
                             * @dev Emitted when `account` is granted `role`.
                             *
                             * `sender` is the account that originated the contract call, an admin role
                             * bearer except when using {_setupRole}.
                             */
                            event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
                        
                            /**
                             * @dev Emitted when `account` is revoked `role`.
                             *
                             * `sender` is the account that originated the contract call:
                             *   - if using `revokeRole`, it is the admin role bearer
                             *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
                             */
                            event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
                        
                            /**
                             * @dev Returns `true` if `account` has been granted `role`.
                             */
                            function hasRole(bytes32 role, address account) public view returns (bool) {
                                return _roles[role].members.contains(account);
                            }
                        
                            /**
                             * @dev Returns the number of accounts that have `role`. Can be used
                             * together with {getRoleMember} to enumerate all bearers of a role.
                             */
                            function getRoleMemberCount(bytes32 role) public view returns (uint256) {
                                return _roles[role].members.length();
                            }
                        
                            /**
                             * @dev Returns one of the accounts that have `role`. `index` must be a
                             * value between 0 and {getRoleMemberCount}, non-inclusive.
                             *
                             * Role bearers are not sorted in any particular way, and their ordering may
                             * change at any point.
                             *
                             * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
                             * you perform all queries on the same block. See the following
                             * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
                             * for more information.
                             */
                            function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
                                return _roles[role].members.at(index);
                            }
                        
                            /**
                             * @dev Returns the admin role that controls `role`. See {grantRole} and
                             * {revokeRole}.
                             *
                             * To change a role's admin, use {_setRoleAdmin}.
                             */
                            function getRoleAdmin(bytes32 role) public view returns (bytes32) {
                                return _roles[role].adminRole;
                            }
                        
                            /**
                             * @dev Grants `role` to `account`.
                             *
                             * If `account` had not been already granted `role`, emits a {RoleGranted}
                             * event.
                             *
                             * Requirements:
                             *
                             * - the caller must have ``role``'s admin role.
                             */
                            function grantRole(bytes32 role, address account) public virtual {
                                require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
                        
                                _grantRole(role, account);
                            }
                        
                            /**
                             * @dev Revokes `role` from `account`.
                             *
                             * If `account` had been granted `role`, emits a {RoleRevoked} event.
                             *
                             * Requirements:
                             *
                             * - the caller must have ``role``'s admin role.
                             */
                            function revokeRole(bytes32 role, address account) public virtual {
                                require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
                        
                                _revokeRole(role, account);
                            }
                        
                            /**
                             * @dev Revokes `role` from the calling account.
                             *
                             * Roles are often managed via {grantRole} and {revokeRole}: this function's
                             * purpose is to provide a mechanism for accounts to lose their privileges
                             * if they are compromised (such as when a trusted device is misplaced).
                             *
                             * If the calling account had been granted `role`, emits a {RoleRevoked}
                             * event.
                             *
                             * Requirements:
                             *
                             * - the caller must be `account`.
                             */
                            function renounceRole(bytes32 role, address account) public virtual {
                                require(account == _msgSender(), "AccessControl: can only renounce roles for self");
                        
                                _revokeRole(role, account);
                            }
                        
                            /**
                             * @dev Grants `role` to `account`.
                             *
                             * If `account` had not been already granted `role`, emits a {RoleGranted}
                             * event. Note that unlike {grantRole}, this function doesn't perform any
                             * checks on the calling account.
                             *
                             * [WARNING]
                             * ====
                             * This function should only be called from the constructor when setting
                             * up the initial roles for the system.
                             *
                             * Using this function in any other way is effectively circumventing the admin
                             * system imposed by {AccessControl}.
                             * ====
                             */
                            function _setupRole(bytes32 role, address account) internal virtual {
                                _grantRole(role, account);
                            }
                        
                            /**
                             * @dev Sets `adminRole` as ``role``'s admin role.
                             *
                             * Emits a {RoleAdminChanged} event.
                             */
                            function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
                                emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
                                _roles[role].adminRole = adminRole;
                            }
                        
                            function _grantRole(bytes32 role, address account) private {
                                if (_roles[role].members.add(account)) {
                                    emit RoleGranted(role, account, _msgSender());
                                }
                            }
                        
                            function _revokeRole(bytes32 role, address account) private {
                                if (_roles[role].members.remove(account)) {
                                    emit RoleRevoked(role, account, _msgSender());
                                }
                            }
                        }
                        
                        
                        // File contracts/Access/MISOAdminAccess.sol
                        
                        pragma solidity 0.6.12;
                        
                        contract MISOAdminAccess is AccessControl {
                        
                            /// @dev Whether access is initialised.
                            bool private initAccess;
                        
                            /// @notice Events for adding and removing various roles.
                            event AdminRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event AdminRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                        
                            /// @notice The deployer is automatically given the admin role which will allow them to then grant roles to other addresses.
                            constructor() public {
                            }
                        
                            /**
                             * @notice Initializes access controls.
                             * @param _admin Admins address.
                             */
                            function initAccessControls(address _admin) public {
                                require(!initAccess, "Already initialised");
                                _setupRole(DEFAULT_ADMIN_ROLE, _admin);
                                initAccess = true;
                            }
                        
                            /////////////
                            // Lookups //
                            /////////////
                        
                            /**
                             * @notice Used to check whether an address has the admin role.
                             * @param _address EOA or contract being checked.
                             * @return bool True if the account has the role or false if it does not.
                             */
                            function hasAdminRole(address _address) public  view returns (bool) {
                                return hasRole(DEFAULT_ADMIN_ROLE, _address);
                            }
                        
                            ///////////////
                            // Modifiers //
                            ///////////////
                        
                            /**
                             * @notice Grants the admin role to an address.
                             * @dev The sender must have the admin role.
                             * @param _address EOA or contract receiving the new role.
                             */
                            function addAdminRole(address _address) external {
                                grantRole(DEFAULT_ADMIN_ROLE, _address);
                                emit AdminRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the admin role from an address.
                             * @dev The sender must have the admin role.
                             * @param _address EOA or contract affected.
                             */
                            function removeAdminRole(address _address) external {
                                revokeRole(DEFAULT_ADMIN_ROLE, _address);
                                emit AdminRoleRemoved(_address, _msgSender());
                            }
                        }
                        
                        
                        // File contracts/Access/MISOAccessControls.sol
                        
                        pragma solidity 0.6.12;
                        
                        /**
                         * @notice Access Controls
                         * @author Attr: BlockRocket.tech
                         */
                        contract MISOAccessControls is MISOAdminAccess {
                            /// @notice Role definitions
                            bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
                            bytes32 public constant SMART_CONTRACT_ROLE = keccak256("SMART_CONTRACT_ROLE");
                            bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
                        
                            /// @notice Events for adding and removing various roles
                        
                            event MinterRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event MinterRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event OperatorRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event OperatorRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event SmartContractRoleGranted(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            event SmartContractRoleRemoved(
                                address indexed beneficiary,
                                address indexed caller
                            );
                        
                            /**
                             * @notice The deployer is automatically given the admin role which will allow them to then grant roles to other addresses
                             */
                            constructor() public {
                            }
                        
                        
                            /////////////
                            // Lookups //
                            /////////////
                        
                            /**
                             * @notice Used to check whether an address has the minter role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasMinterRole(address _address) public view returns (bool) {
                                return hasRole(MINTER_ROLE, _address);
                            }
                        
                            /**
                             * @notice Used to check whether an address has the smart contract role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasSmartContractRole(address _address) public view returns (bool) {
                                return hasRole(SMART_CONTRACT_ROLE, _address);
                            }
                        
                            /**
                             * @notice Used to check whether an address has the operator role
                             * @param _address EOA or contract being checked
                             * @return bool True if the account has the role or false if it does not
                             */
                            function hasOperatorRole(address _address) public view returns (bool) {
                                return hasRole(OPERATOR_ROLE, _address);
                            }
                        
                            ///////////////
                            // Modifiers //
                            ///////////////
                        
                            /**
                             * @notice Grants the minter role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addMinterRole(address _address) external {
                                grantRole(MINTER_ROLE, _address);
                                emit MinterRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the minter role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeMinterRole(address _address) external {
                                revokeRole(MINTER_ROLE, _address);
                                emit MinterRoleRemoved(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Grants the smart contract role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addSmartContractRole(address _address) external {
                                grantRole(SMART_CONTRACT_ROLE, _address);
                                emit SmartContractRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the smart contract role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeSmartContractRole(address _address) external {
                                revokeRole(SMART_CONTRACT_ROLE, _address);
                                emit SmartContractRoleRemoved(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Grants the operator role to an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract receiving the new role
                             */
                            function addOperatorRole(address _address) external {
                                grantRole(OPERATOR_ROLE, _address);
                                emit OperatorRoleGranted(_address, _msgSender());
                            }
                        
                            /**
                             * @notice Removes the operator role from an address
                             * @dev The sender must have the admin role
                             * @param _address EOA or contract affected
                             */
                            function removeOperatorRole(address _address) external {
                                revokeRole(OPERATOR_ROLE, _address);
                                emit OperatorRoleRemoved(_address, _msgSender());
                            }
                        
                        }
                        
                        
                        // File contracts/Utils/SafeTransfer.sol
                        
                        pragma solidity 0.6.12;
                        
                        contract SafeTransfer {
                        
                            address private constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        
                            /// @dev Helper function to handle both ETH and ERC20 payments
                            function _safeTokenPayment(
                                address _token,
                                address payable _to,
                                uint256 _amount
                            ) internal {
                                if (address(_token) == ETH_ADDRESS) {
                                    _safeTransferETH(_to,_amount );
                                } else {
                                    _safeTransfer(_token, _to, _amount);
                                }
                            }
                        
                        
                            /// @dev Helper function to handle both ETH and ERC20 payments
                            function _tokenPayment(
                                address _token,
                                address payable _to,
                                uint256 _amount
                            ) internal {
                                if (address(_token) == ETH_ADDRESS) {
                                    _to.transfer(_amount);
                                } else {
                                    _safeTransfer(_token, _to, _amount);
                                }
                            }
                        
                        
                            /// @dev Transfer helper from UniswapV2 Router
                            function _safeApprove(address token, address to, uint value) internal {
                                // bytes4(keccak256(bytes('approve(address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
                            }
                        
                        
                            /**
                             * There are many non-compliant ERC20 tokens... this can handle most, adapted from UniSwap V2
                             * Im trying to make it a habit to put external calls last (reentrancy)
                             * You can put this in an internal function if you like.
                             */
                            function _safeTransfer(
                                address token,
                                address to,
                                uint256 amount
                            ) internal virtual {
                                // solium-disable-next-line security/no-low-level-calls
                                (bool success, bytes memory data) =
                                    token.call(
                                        // 0xa9059cbb = bytes4(keccak256("transfer(address,uint256)"))
                                        abi.encodeWithSelector(0xa9059cbb, to, amount)
                                    );
                                require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 Transfer failed
                            }
                        
                            function _safeTransferFrom(
                                address token,
                                address from,
                                uint256 amount
                            ) internal virtual {
                                // solium-disable-next-line security/no-low-level-calls
                                (bool success, bytes memory data) =
                                    token.call(
                                        // 0x23b872dd = bytes4(keccak256("transferFrom(address,address,uint256)"))
                                        abi.encodeWithSelector(0x23b872dd, from, address(this), amount)
                                    );
                                require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 TransferFrom failed
                            }
                        
                            function _safeTransferFrom(address token, address from, address to, uint value) internal {
                                // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
                            }
                        
                            function _safeTransferETH(address to, uint value) internal {
                                (bool success,) = to.call{value:value}(new bytes(0));
                                require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
                            }
                        
                        
                        }
                        
                        
                        // File contracts/interfaces/IERC20.sol
                        
                        pragma solidity 0.6.12;
                        
                        interface IERC20 {
                            function totalSupply() external view returns (uint256);
                            function balanceOf(address account) external view returns (uint256);
                            function allowance(address owner, address spender) external view returns (uint256);
                            function approve(address spender, uint256 amount) external returns (bool);
                            function name() external view returns (string memory);
                            function symbol() external view returns (string memory);
                            function decimals() external view returns (uint8);
                        
                            event Transfer(address indexed from, address indexed to, uint256 value);
                            event Approval(address indexed owner, address indexed spender, uint256 value);
                        
                            function permit(
                                address owner,
                                address spender,
                                uint256 value,
                                uint256 deadline,
                                uint8 v,
                                bytes32 r,
                                bytes32 s
                            ) external;
                        }
                        
                        
                        // File contracts/Utils/BoringERC20.sol
                        
                        pragma solidity 0.6.12;
                        
                        // solhint-disable avoid-low-level-calls
                        
                        library BoringERC20 {
                            bytes4 private constant SIG_SYMBOL = 0x95d89b41; // symbol()
                            bytes4 private constant SIG_NAME = 0x06fdde03; // name()
                            bytes4 private constant SIG_DECIMALS = 0x313ce567; // decimals()
                            bytes4 private constant SIG_TRANSFER = 0xa9059cbb; // transfer(address,uint256)
                            bytes4 private constant SIG_TRANSFER_FROM = 0x23b872dd; // transferFrom(address,address,uint256)
                        
                            /// @notice Provides a safe ERC20.symbol version which returns '???' as fallback string.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (string) Token symbol.
                            function safeSymbol(IERC20 token) internal view returns (string memory) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL));
                                return success && data.length > 0 ? abi.decode(data, (string)) : "???";
                            }
                        
                            /// @notice Provides a safe ERC20.name version which returns '???' as fallback string.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (string) Token name.
                            function safeName(IERC20 token) internal view returns (string memory) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME));
                                return success && data.length > 0 ? abi.decode(data, (string)) : "???";
                            }
                        
                            /// @notice Provides a safe ERC20.decimals version which returns '18' as fallback value.
                            /// @param token The address of the ERC-20 token contract.
                            /// @return (uint8) Token decimals.
                            function safeDecimals(IERC20 token) internal view returns (uint8) {
                                (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_DECIMALS));
                                return success && data.length == 32 ? abi.decode(data, (uint8)) : 18;
                            }
                        
                            /// @notice Provides a safe ERC20.transfer version for different ERC-20 implementations.
                            /// Reverts on a failed transfer.
                            /// @param token The address of the ERC-20 token.
                            /// @param to Transfer tokens to.
                            /// @param amount The token amount.
                            function safeTransfer(
                                IERC20 token,
                                address to,
                                uint256 amount
                            ) internal {
                                (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER, to, amount));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: Transfer failed");
                            }
                        
                            /// @notice Provides a safe ERC20.transferFrom version for different ERC-20 implementations.
                            /// Reverts on a failed transfer.
                            /// @param token The address of the ERC-20 token.
                            /// @param from Transfer tokens from.
                            /// @param to Transfer tokens to.
                            /// @param amount The token amount.
                            function safeTransferFrom(
                                IERC20 token,
                                address from,
                                address to,
                                uint256 amount
                            ) internal {
                                (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER_FROM, from, to, amount));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: TransferFrom failed");
                            }
                        }
                        
                        
                        // File contracts/Utils/BoringBatchable.sol
                        
                        pragma solidity 0.6.12;
                        pragma experimental ABIEncoderV2;
                        
                        // solhint-disable avoid-low-level-calls
                        // solhint-disable no-inline-assembly
                        
                        // Audit on 5-Jan-2021 by Keno and BoringCrypto
                        
                        contract BaseBoringBatchable {
                            /// @dev Helper function to extract a useful revert message from a failed call.
                            /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.
                            function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
                                // If the _res length is less than 68, then the transaction failed silently (without a revert message)
                                if (_returnData.length < 68) return "Transaction reverted silently";
                        
                                assembly {
                                    // Slice the sighash.
                                    _returnData := add(_returnData, 0x04)
                                }
                                return abi.decode(_returnData, (string)); // All that remains is the revert string
                            }
                        
                            /// @notice Allows batched call to self (this contract).
                            /// @param calls An array of inputs for each call.
                            /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.
                            /// @return successes An array indicating the success of a call, mapped one-to-one to `calls`.
                            /// @return results An array with the returned data of each function call, mapped one-to-one to `calls`.
                            // F1: External is ok here because this is the batch function, adding it to a batch makes no sense
                            // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value
                            // C3: The length of the loop is fully under user control, so can't be exploited
                            // C7: Delegatecall is only used on the same contract, so it's safe
                            function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results) {
                                successes = new bool[](calls.length);
                                results = new bytes[](calls.length);
                                for (uint256 i = 0; i < calls.length; i++) {
                                    (bool success, bytes memory result) = address(this).delegatecall(calls[i]);
                                    require(success || !revertOnFail, _getRevertMsg(result));
                                    successes[i] = success;
                                    results[i] = result;
                                }
                            }
                        }
                        
                        contract BoringBatchable is BaseBoringBatchable {
                            /// @notice Call wrapper that performs `ERC20.permit` on `token`.
                            /// Lookup `IERC20.permit`.
                            // F6: Parameters can be used front-run the permit and the user's permit will fail (due to nonce or other revert)
                            //     if part of a batch this could be used to grief once as the second call would not need the permit
                            function permitToken(
                                IERC20 token,
                                address from,
                                address to,
                                uint256 amount,
                                uint256 deadline,
                                uint8 v,
                                bytes32 r,
                                bytes32 s
                            ) public {
                                token.permit(from, to, amount, deadline, v, r, s);
                            }
                        }
                        
                        
                        // File contracts/Utils/BoringMath.sol
                        
                        pragma solidity 0.6.12;
                        
                        /// @notice A library for performing overflow-/underflow-safe math,
                        /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math).
                        library BoringMath {
                            function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        
                            function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow");
                            }
                        
                            function div(uint256 a, uint256 b) internal pure returns (uint256 c) {
                                require(b > 0, "BoringMath: Div zero");
                                c = a / b;
                            }
                        
                            function to128(uint256 a) internal pure returns (uint128 c) {
                                require(a <= uint128(-1), "BoringMath: uint128 Overflow");
                                c = uint128(a);
                            }
                        
                            function to64(uint256 a) internal pure returns (uint64 c) {
                                require(a <= uint64(-1), "BoringMath: uint64 Overflow");
                                c = uint64(a);
                            }
                        
                            function to32(uint256 a) internal pure returns (uint32 c) {
                                require(a <= uint32(-1), "BoringMath: uint32 Overflow");
                                c = uint32(a);
                            }
                        
                            function to16(uint256 a) internal pure returns (uint16 c) {
                                require(a <= uint16(-1), "BoringMath: uint16 Overflow");
                                c = uint16(a);
                            }
                        
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128.
                        library BoringMath128 {
                            function add(uint128 a, uint128 b) internal pure returns (uint128 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint128 a, uint128 b) internal pure returns (uint128 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64.
                        library BoringMath64 {
                            function add(uint64 a, uint64 b) internal pure returns (uint64 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32.
                        library BoringMath32 {
                            function add(uint32 a, uint32 b) internal pure returns (uint32 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint32 a, uint32 b) internal pure returns (uint32 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32.
                        library BoringMath16 {
                            function add(uint16 a, uint16 b) internal pure returns (uint16 c) {
                                require((c = a + b) >= b, "BoringMath: Add Overflow");
                            }
                        
                            function sub(uint16 a, uint16 b) internal pure returns (uint16 c) {
                                require((c = a - b) <= a, "BoringMath: Underflow");
                            }
                        }
                        
                        
                        // File contracts/Utils/Documents.sol
                        
                        pragma solidity 0.6.12;
                        
                        
                        /**
                         * @title Standard implementation of ERC1643 Document management
                         */
                        contract Documents {
                        
                            struct Document {
                                uint32 docIndex;    // Store the document name indexes
                                uint64 lastModified; // Timestamp at which document details was last modified
                                string data; // data of the document that exist off-chain
                            }
                        
                            // mapping to store the documents details in the document
                            mapping(string => Document) internal _documents;
                            // mapping to store the document name indexes
                            mapping(string => uint32) internal _docIndexes;
                            // Array use to store all the document name present in the contracts
                            string[] _docNames;
                        
                            // Document Events
                            event DocumentRemoved(string indexed _name, string _data);
                            event DocumentUpdated(string indexed _name, string _data);
                        
                            /**
                             * @notice Used to attach a new document to the contract, or update the data or hash of an existing attached document
                             * @dev Can only be executed by the owner of the contract.
                             * @param _name Name of the document. It should be unique always
                             * @param _data Off-chain data of the document from where it is accessible to investors/advisors to read.
                             */
                            function _setDocument(string calldata _name, string calldata _data) internal {
                                require(bytes(_name).length > 0, "Zero name is not allowed");
                                require(bytes(_data).length > 0, "Should not be a empty data");
                                // Document storage document = _documents[_name];
                                if (_documents[_name].lastModified == uint64(0)) {
                                    _docNames.push(_name);
                                    _documents[_name].docIndex = uint32(_docNames.length);
                                }
                                _documents[_name] = Document(_documents[_name].docIndex, uint64(now), _data);
                                emit DocumentUpdated(_name, _data);
                            }
                        
                            /**
                             * @notice Used to remove an existing document from the contract by giving the name of the document.
                             * @dev Can only be executed by the owner of the contract.
                             * @param _name Name of the document. It should be unique always
                             */
                        
                            function _removeDocument(string calldata _name) internal {
                                require(_documents[_name].lastModified != uint64(0), "Document should exist");
                                uint32 index = _documents[_name].docIndex - 1;
                                if (index != _docNames.length - 1) {
                                    _docNames[index] = _docNames[_docNames.length - 1];
                                    _documents[_docNames[index]].docIndex = index + 1; 
                                }
                                _docNames.pop();
                                emit DocumentRemoved(_name, _documents[_name].data);
                                delete _documents[_name];
                            }
                        
                            /**
                             * @notice Used to return the details of a document with a known name (`string`).
                             * @param _name Name of the document
                             * @return string The data associated with the document.
                             * @return uint256 the timestamp at which the document was last modified.
                             */
                            function getDocument(string calldata _name) external view returns (string memory, uint256) {
                                return (
                                    _documents[_name].data,
                                    uint256(_documents[_name].lastModified)
                                );
                            }
                        
                            /**
                             * @notice Used to retrieve a full list of documents attached to the smart contract.
                             * @return string List of all documents names present in the contract.
                             */
                            function getAllDocuments() external view returns (string[] memory) {
                                return _docNames;
                            }
                        
                            /**
                             * @notice Used to retrieve the total documents in the smart contract.
                             * @return uint256 Count of the document names present in the contract.
                             */
                            function getDocumentCount() external view returns (uint256) {
                                return _docNames.length;
                            }
                        
                            /**
                             * @notice Used to retrieve the document name from index in the smart contract.
                             * @return string Name of the document name.
                             */
                            function getDocumentName(uint256 _index) external view returns (string memory) {
                                require(_index < _docNames.length, "Index out of bounds");
                                return _docNames[_index];
                            }
                        
                        }
                        
                        
                        // File contracts/interfaces/IPointList.sol
                        
                        pragma solidity 0.6.12;
                        
                        // ----------------------------------------------------------------------------
                        // White List interface
                        // ----------------------------------------------------------------------------
                        
                        interface IPointList {
                            function isInList(address account) external view returns (bool);
                            function hasPoints(address account, uint256 amount) external view  returns (bool);
                            function setPoints(
                                address[] memory accounts,
                                uint256[] memory amounts
                            ) external; 
                            function initPointList(address accessControl) external ;
                        
                        }
                        
                        
                        // File contracts/interfaces/IMisoMarket.sol
                        
                        pragma solidity 0.6.12;
                        
                        interface IMisoMarket {
                        
                            function init(bytes calldata data) external payable;
                            function initMarket( bytes calldata data ) external;
                            function marketTemplate() external view returns (uint256);
                        
                        }
                        
                        
                        // File contracts/Auctions/BatchAuction.sol
                        
                        pragma solidity 0.6.12;
                        
                        //----------------------------------------------------------------------------------
                        //    I n s t a n t
                        //
                        //        .:mmm.         .:mmm:.       .ii.  .:SSSSSSSSSSSSS.     .oOOOOOOOOOOOo.  
                        //      .mMM'':Mm.     .:MM'':Mm:.     .II:  :SSs..........     .oOO'''''''''''OOo.
                        //    .:Mm'   ':Mm.   .:Mm'   'MM:.    .II:  'sSSSSSSSSSSSSS:.  :OO.           .OO:
                        //  .'mMm'     ':MM:.:MMm'     ':MM:.  .II:  .:...........:SS.  'OOo:.........:oOO'
                        //  'mMm'        ':MMmm'         'mMm:  II:  'sSSSSSSSSSSSSS'     'oOOOOOOOOOOOO'  
                        //
                        //----------------------------------------------------------------------------------
                        //
                        // Chef Gonpachi's Batch Auction
                        //
                        // An auction where contributions are swaped for a batch of tokens pro-rata
                        // 
                        // This program is free software: you can redistribute it and/or modify
                        // it under the terms of the GNU General Public License as published by
                        // the Free Software Foundation, either version 3 of the License
                        //
                        // This program is distributed in the hope that it will be useful,
                        // but WITHOUT ANY WARRANTY; without even the implied warranty of
                        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                        // GNU General Public License for more details.
                        //
                        // The above copyright notice and this permission notice shall be included 
                        // in all copies or substantial portions of the Software.
                        //
                        // Made for Sushi.com 
                        // 
                        // Enjoy. (c) Chef Gonpachi, Kusatoshi, SSMikazu 2021 
                        // <https://github.com/chefgonpachi/MISO/>
                        //
                        // ---------------------------------------------------------------------
                        // SPDX-License-Identifier: GPL-3.0                        
                        // ---------------------------------------------------------------------
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        /// @notice Attribution to delta.financial
                        /// @notice Attribution to dutchswap.com
                        
                        
                        contract BatchAuction is  IMisoMarket, MISOAccessControls, BoringBatchable, SafeTransfer, Documents, ReentrancyGuard  {
                        
                            using BoringMath for uint256;
                            using BoringMath128 for uint128;
                            using BoringMath64 for uint64;
                            using BoringERC20 for IERC20;
                        
                            /// @notice MISOMarket template id for the factory contract.
                            /// @dev For different marketplace types, this must be incremented.
                            uint256 public constant override marketTemplate = 3;
                        
                            /// @dev The multiplier for decimal precision
                            uint256 private constant MISO_PRECISION = 1e18;
                        
                            /// @dev The placeholder ETH address.
                            address private constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        
                            /// @notice Main market variables.
                            struct MarketInfo {
                                uint64 startTime;
                                uint64 endTime; 
                                uint128 totalTokens;
                            }
                            MarketInfo public marketInfo;
                        
                            /// @notice Market dynamic variables.
                            struct MarketStatus {
                                uint128 commitmentsTotal;
                                uint128 minimumCommitmentAmount;
                                bool finalized;
                                bool usePointList;
                            }
                        
                            MarketStatus public marketStatus;
                        
                            address public auctionToken;
                            /// @notice The currency the crowdsale accepts for payment. Can be ETH or token address.
                            address public paymentCurrency;
                            /// @notice Address that manages auction approvals.
                            address public pointList;
                            address payable public wallet; // Where the auction funds will get paid
                        
                            mapping(address => uint256) public commitments;
                            /// @notice Amount of tokens to claim per address.
                            mapping(address => uint256) public claimed;
                        
                            /// @notice Event for updating auction times.  Needs to be before auction starts.
                            event AuctionTimeUpdated(uint256 startTime, uint256 endTime); 
                            /// @notice Event for updating auction prices. Needs to be before auction starts.
                            event AuctionPriceUpdated(uint256 minimumCommitmentAmount); 
                            /// @notice Event for updating auction wallet. Needs to be before auction starts.
                            event AuctionWalletUpdated(address wallet); 
                        
                            /// @notice Event for adding a commitment.
                            event AddedCommitment(address addr, uint256 commitment);
                            /// @notice Event for finalization of the auction.
                            event AuctionFinalized();
                            /// @notice Event for cancellation of the auction.
                            event AuctionCancelled();
                        
                            /**
                             * @notice Initializes main contract variables and transfers funds for the auction.
                             * @dev Init function.
                             * @param _funder The address that funds the token for crowdsale.
                             * @param _token Address of the token being sold.
                             * @param _totalTokens The total number of tokens to sell in auction.
                             * @param _startTime Auction start time.
                             * @param _endTime Auction end time.
                             * @param _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address.
                             * @param _minimumCommitmentAmount Minimum amount collected at which the auction will be successful.
                             * @param _admin Address that can finalize auction.
                             * @param _wallet Address where collected funds will be forwarded to.
                             */
                            function initAuction(
                                address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                            ) public {
                                require(_startTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_endTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_startTime >= block.timestamp, "BatchAuction: start time is before current time");
                                require(_endTime > _startTime, "BatchAuction: end time must be older than start time");
                                require(_totalTokens > 0,"BatchAuction: total tokens must be greater than zero");
                                require(_admin != address(0), "BatchAuction: admin is the zero address");
                                require(_wallet != address(0), "BatchAuction: wallet is the zero address");
                                require(IERC20(_token).decimals() == 18, "BatchAuction: Token does not have 18 decimals");
                                if (_paymentCurrency != ETH_ADDRESS) {
                                    require(IERC20(_paymentCurrency).decimals() > 0, "BatchAuction: Payment currency is not ERC20");
                                }
                        
                                marketStatus.minimumCommitmentAmount = BoringMath.to128(_minimumCommitmentAmount);
                                
                                marketInfo.startTime = BoringMath.to64(_startTime);
                                marketInfo.endTime = BoringMath.to64(_endTime);
                                marketInfo.totalTokens = BoringMath.to128(_totalTokens);
                        
                                auctionToken = _token;
                                paymentCurrency = _paymentCurrency;
                                wallet = _wallet;
                        
                                initAccessControls(_admin);
                        
                                _setList(_pointList);
                                _safeTransferFrom(auctionToken, _funder, _totalTokens);
                            }
                        
                        
                            ///--------------------------------------------------------
                            /// Commit to buying tokens!
                            ///--------------------------------------------------------
                        
                            receive() external payable {
                                revertBecauseUserDidNotProvideAgreement();
                            }
                            
                            /** 
                             * @dev Attribution to the awesome delta.financial contracts
                            */  
                            function marketParticipationAgreement() public pure returns (string memory) {
                                return "I understand that I am interacting with a smart contract. I understand that tokens commited are subject to the token issuer and local laws where applicable. I have reviewed the code of this smart contract and understand it fully. I agree to not hold developers or other people associated with the project liable for any losses or misunderstandings";
                            }
                            /** 
                             * @dev Not using modifiers is a purposeful choice for code readability.
                            */ 
                            function revertBecauseUserDidNotProvideAgreement() internal pure {
                                revert("No agreement provided, please review the smart contract before interacting with it");
                            }
                        
                            /**
                             * @notice Commit ETH to buy tokens on auction.
                             * @param _beneficiary Auction participant ETH address.
                             */
                            function commitEth(address payable _beneficiary, bool readAndAgreedToMarketParticipationAgreement) public payable {
                                require(paymentCurrency == ETH_ADDRESS, "BatchAuction: payment currency is not ETH");
                        
                                require(msg.value > 0, "BatchAuction: Value must be higher than 0");
                                if(readAndAgreedToMarketParticipationAgreement == false) {
                                    revertBecauseUserDidNotProvideAgreement();
                                }
                                _addCommitment(_beneficiary, msg.value);
                            }
                        
                            /**
                             * @notice Buy Tokens by commiting approved ERC20 tokens to this contract address.
                             * @param _amount Amount of tokens to commit.
                             */
                            function commitTokens(uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public {
                                commitTokensFrom(msg.sender, _amount, readAndAgreedToMarketParticipationAgreement);
                            }
                        
                            /**
                             * @notice Checks if amout not 0 and makes the transfer and adds commitment.
                             * @dev Users must approve contract prior to committing tokens to auction.
                             * @param _from User ERC20 address.
                             * @param _amount Amount of approved ERC20 tokens.
                             */
                            function commitTokensFrom(address _from, uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public   nonReentrant  {
                                require(paymentCurrency != ETH_ADDRESS, "BatchAuction: Payment currency is not a token");
                                if(readAndAgreedToMarketParticipationAgreement == false) {
                                    revertBecauseUserDidNotProvideAgreement();
                                }
                                require(_amount> 0, "BatchAuction: Value must be higher than 0");
                                _safeTransferFrom(paymentCurrency, msg.sender, _amount);
                                _addCommitment(_from, _amount);
                        
                            }
                        
                        
                            /// @notice Commits to an amount during an auction
                            /**
                             * @notice Updates commitment for this address and total commitment of the auction.
                             * @param _addr Auction participant address.
                             * @param _commitment The amount to commit.
                             */
                            function _addCommitment(address _addr, uint256 _commitment) internal {
                                require(block.timestamp >= marketInfo.startTime && block.timestamp <= marketInfo.endTime, "BatchAuction: outside auction hours"); 
                        
                                uint256 newCommitment = commitments[_addr].add(_commitment);
                                if (marketStatus.usePointList) {
                                    require(IPointList(pointList).hasPoints(_addr, newCommitment));
                                }
                                commitments[_addr] = newCommitment;
                                marketStatus.commitmentsTotal = BoringMath.to128(uint256(marketStatus.commitmentsTotal).add(_commitment));
                                emit AddedCommitment(_addr, _commitment);
                            }
                        
                            /**
                             * @notice Calculates amount of auction tokens for user to receive.
                             * @param amount Amount of tokens to commit.
                             * @return Auction token amount.
                             */
                            function _getTokenAmount(uint256 amount) internal view returns (uint256) { 
                                if (marketStatus.commitmentsTotal == 0) return 0;
                                return amount.mul(uint256(marketInfo.totalTokens)).div(uint256(marketStatus.commitmentsTotal));
                            }
                        
                            /**
                             * @notice Calculates the price of each token from all commitments.
                             * @return Token price.
                             */
                            function tokenPrice() public view returns (uint256) {
                                return uint256(marketStatus.commitmentsTotal).mul(MISO_PRECISION)
                                    .mul(1e18).div(uint256(marketInfo.totalTokens)).div(MISO_PRECISION);
                            }
                        
                        
                            ///--------------------------------------------------------
                            /// Finalize Auction
                            ///--------------------------------------------------------
                        
                            /// @notice Auction finishes successfully above the reserve
                            /// @dev Transfer contract funds to initialized wallet.
                            function finalize() public    nonReentrant 
                            {
                                require(hasAdminRole(msg.sender) 
                                        || wallet == msg.sender
                                        || hasSmartContractRole(msg.sender) 
                                        || finalizeTimeExpired(),  "BatchAuction: Sender must be admin");
                                require(!marketStatus.finalized, "BatchAuction: Auction has already finalized");
                                require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                if (auctionSuccessful()) {
                                    /// @dev Successful auction
                                    /// @dev Transfer contributed tokens to wallet.
                                    _safeTokenPayment(paymentCurrency, wallet, uint256(marketStatus.commitmentsTotal));
                                } else {
                                    /// @dev Failed auction
                                    /// @dev Return auction tokens back to wallet.
                                    require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                    _safeTokenPayment(auctionToken, wallet, marketInfo.totalTokens);
                                }
                                marketStatus.finalized = true;
                                emit AuctionFinalized();
                            }
                        
                            /**
                             * @notice Cancel Auction
                             * @dev Admin can cancel the auction before it starts
                             */
                            function cancelAuction() public   nonReentrant  
                            {
                                require(hasAdminRole(msg.sender));
                                MarketStatus storage status = marketStatus;
                                require(!status.finalized, "Crowdsale: already finalized");
                                require( uint256(status.commitmentsTotal) == 0, "Crowdsale: Funds already raised" );
                        
                                _safeTokenPayment(auctionToken, wallet, uint256(marketInfo.totalTokens));
                        
                                status.finalized = true;
                                emit AuctionCancelled();
                            }
                        
                            /// @notice Withdraws bought tokens, or returns commitment if the sale is unsuccessful.
                            function withdrawTokens() public  {
                                withdrawTokens(msg.sender);
                            }
                        
                            /// @notice Withdraw your tokens once the Auction has ended.
                            function withdrawTokens(address payable beneficiary) public   nonReentrant  {
                                if (auctionSuccessful()) {
                                    require(marketStatus.finalized, "BatchAuction: not finalized");
                                    /// @dev Successful auction! Transfer claimed tokens.
                                    uint256 tokensToClaim = tokensClaimable(beneficiary);
                                    require(tokensToClaim > 0, "BatchAuction: No tokens to claim");
                                    claimed[beneficiary] = claimed[beneficiary].add(tokensToClaim);
                        
                                    _safeTokenPayment(auctionToken, beneficiary, tokensToClaim);
                                } else {
                                    /// @dev Auction did not meet reserve price.
                                    /// @dev Return committed funds back to user.
                                    require(block.timestamp > marketInfo.endTime, "BatchAuction: Auction has not finished yet");
                                    uint256 fundsCommitted = commitments[beneficiary];
                                    require(fundsCommitted > 0, "BatchAuction: No funds committed");
                                    commitments[beneficiary] = 0; // Stop multiple withdrawals and free some gas
                                    _safeTokenPayment(paymentCurrency, beneficiary, fundsCommitted);
                                }
                            }
                        
                        
                            /**
                             * @notice How many tokens the user is able to claim.
                             * @param _user Auction participant address.
                             * @return claimerCommitment Tokens left to claim.
                             */
                            function tokensClaimable(address _user) public view returns (uint256 claimerCommitment) {
                                if (commitments[_user] == 0) return 0;
                                uint256 unclaimedTokens = IERC20(auctionToken).balanceOf(address(this));
                                claimerCommitment = _getTokenAmount(commitments[_user]);
                                claimerCommitment = claimerCommitment.sub(claimed[_user]);
                        
                                if(claimerCommitment > unclaimedTokens){
                                    claimerCommitment = unclaimedTokens;
                                }
                            }
                        
                            /**
                             * @notice Checks if raised more than minimum amount.
                             * @return True if tokens sold greater than or equals to the minimum commitment amount.
                             */
                            function auctionSuccessful() public view returns (bool) {
                                return uint256(marketStatus.commitmentsTotal) >= uint256(marketStatus.minimumCommitmentAmount) && uint256(marketStatus.commitmentsTotal) > 0;
                            }
                        
                            /**
                             * @notice Checks if the auction has ended.
                             * @return bool True if current time is greater than auction end time.
                             */
                            function auctionEnded() public view returns (bool) {
                                return block.timestamp > marketInfo.endTime;
                            }
                        
                            /**
                             * @notice Checks if the auction has been finalised.
                             * @return bool True if auction has been finalised.
                             */
                            function finalized() public view returns (bool) {
                                return marketStatus.finalized;
                            }
                        
                            /// @notice Returns true if 7 days have passed since the end of the auction
                            function finalizeTimeExpired() public view returns (bool) {
                                return uint256(marketInfo.endTime) + 7 days < block.timestamp;
                            }
                        
                        
                            //--------------------------------------------------------
                            // Documents
                            //--------------------------------------------------------
                        
                            function setDocument(string calldata _name, string calldata _data) external {
                                require(hasAdminRole(msg.sender) );
                                _setDocument( _name, _data);
                            }
                        
                            function setDocuments(string[] calldata _name, string[] calldata _data) external {
                                require(hasAdminRole(msg.sender) );
                                uint256 numDocs = _name.length;
                                for (uint256 i = 0; i < numDocs; i++) {
                                    _setDocument( _name[i], _data[i]);
                                }
                            }
                        
                            function removeDocument(string calldata _name) external {
                                require(hasAdminRole(msg.sender));
                                _removeDocument(_name);
                            }
                        
                        
                            //--------------------------------------------------------
                            // Point Lists
                            //--------------------------------------------------------
                        
                        
                            function setList(address _list) external {
                                require(hasAdminRole(msg.sender));
                                _setList(_list);
                            }
                        
                            function enableList(bool _status) external {
                                require(hasAdminRole(msg.sender));
                                marketStatus.usePointList = _status;
                            }
                        
                            function _setList(address _pointList) private {
                                if (_pointList != address(0)) {
                                    pointList = _pointList;
                                    marketStatus.usePointList = true;
                                }
                            }
                        
                            //--------------------------------------------------------
                            // Setter Functions
                            //--------------------------------------------------------
                        
                            /**
                             * @notice Admin can set start and end time through this function.
                             * @param _startTime Auction start time.
                             * @param _endTime Auction end time.
                             */
                            function setAuctionTime(uint256 _startTime, uint256 _endTime) external {
                                require(hasAdminRole(msg.sender));
                                require(_startTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_endTime < 10000000000, "BatchAuction: enter an unix timestamp in seconds, not miliseconds");
                                require(_startTime >= block.timestamp, "BatchAuction: start time is before current time");
                                require(_endTime > _startTime, "BatchAuction: end time must be older than start price");
                        
                                require(marketStatus.commitmentsTotal == 0, "BatchAuction: auction cannot have already started");
                        
                                marketInfo.startTime = BoringMath.to64(_startTime);
                                marketInfo.endTime = BoringMath.to64(_endTime);
                                
                                emit AuctionTimeUpdated(_startTime,_endTime);
                            }
                        
                            /**
                             * @notice Admin can set start and min price through this function.
                             * @param _minimumCommitmentAmount Auction minimum raised target.
                             */
                            function setAuctionPrice(uint256 _minimumCommitmentAmount) external {
                                require(hasAdminRole(msg.sender));
                        
                                require(marketStatus.commitmentsTotal == 0, "BatchAuction: auction cannot have already started");
                        
                                marketStatus.minimumCommitmentAmount = BoringMath.to128(_minimumCommitmentAmount);
                        
                                emit AuctionPriceUpdated(_minimumCommitmentAmount);
                            }
                        
                            /**
                             * @notice Admin can set the auction wallet through this function.
                             * @param _wallet Auction wallet is where funds will be sent.
                             */
                            function setAuctionWallet(address payable _wallet) external {
                                require(hasAdminRole(msg.sender));
                                require(_wallet != address(0), "BatchAuction: wallet is the zero address");
                        
                                wallet = _wallet;
                        
                                emit AuctionWalletUpdated(_wallet);
                            }
                        
                        
                            //--------------------------------------------------------
                            // Market Launchers
                            //--------------------------------------------------------
                        
                            function init(bytes calldata _data) external override payable {
                            }
                        
                            function initMarket(
                                bytes calldata _data
                            ) public override {
                                (
                                address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                                ) = abi.decode(_data, (
                                    address,
                                    address,
                                    uint256,
                                    uint256,
                                    uint256,
                                    address,
                                    uint256,
                                    address,
                                    address,
                                    address
                                ));
                                initAuction(_funder, _token, _totalTokens, _startTime, _endTime, _paymentCurrency, _minimumCommitmentAmount, _admin, _pointList,  _wallet);
                            }
                        
                             function getBatchAuctionInitData(
                               address _funder,
                                address _token,
                                uint256 _totalTokens,
                                uint256 _startTime,
                                uint256 _endTime,
                                address _paymentCurrency,
                                uint256 _minimumCommitmentAmount,
                                address _admin,
                                address _pointList,
                                address payable _wallet
                            )
                                external
                                pure
                                returns (bytes memory _data)
                            {
                                return abi.encode(
                                    _funder,
                                    _token,
                                    _totalTokens,
                                    _startTime,
                                    _endTime,
                                    _paymentCurrency,
                                    _minimumCommitmentAmount,
                                    _admin,
                                    _pointList,
                                    _wallet
                                    );
                            }
                        
                            function getBaseInformation() external view returns(
                                address token, 
                                uint64 startTime,
                                uint64 endTime,
                                bool marketFinalized
                            ) {
                                return (auctionToken, marketInfo.startTime, marketInfo.endTime, marketStatus.finalized);
                            }
                        
                            function getTotalTokens() external view returns(uint256) {
                                return uint256(marketInfo.totalTokens);
                            }
                        
                        }

                        File 10 of 11: TokenVault
                        //SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./Interfaces/IWETH.sol";
                        import "./OpenZeppelin/math/Math.sol";
                        import "./OpenZeppelin/token/ERC20/ERC20.sol";
                        import "./OpenZeppelin/token/ERC721/ERC721.sol";
                        import "./OpenZeppelin/token/ERC721/ERC721Holder.sol";
                        import "./Settings.sol";
                        import "./OpenZeppelin/upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
                        import "./OpenZeppelin/upgradeable/token/ERC20/ERC20Upgradeable.sol";
                        contract TokenVault is ERC20Upgradeable, ERC721HolderUpgradeable {
                            using Address for address;
                            /// -----------------------------------
                            /// -------- BASIC INFORMATION --------
                            /// -----------------------------------
                            /// @notice weth address
                            address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
                            /// -----------------------------------
                            /// -------- TOKEN INFORMATION --------
                            /// -----------------------------------
                            /// @notice the ERC721 token address of the vault's token
                            address public token;
                            /// @notice the ERC721 token ID of the vault's token
                            uint256 public id;
                            /// -------------------------------------
                            /// -------- AUCTION INFORMATION --------
                            /// -------------------------------------
                            /// @notice the unix timestamp end time of the token auction
                            uint256 public auctionEnd;
                            /// @notice the length of auctions
                            uint256 public auctionLength;
                            /// @notice reservePrice * votingTokens
                            uint256 public reserveTotal;
                            /// @notice the current price of the token during an auction
                            uint256 public livePrice;
                            /// @notice the current user winning the token auction
                            address payable public winning;
                            enum State { inactive, live, ended, redeemed }
                            State public auctionState;
                            /// -----------------------------------
                            /// -------- VAULT INFORMATION --------
                            /// -----------------------------------
                            /// @notice the governance contract which gets paid in ETH
                            address public immutable settings;
                            /// @notice the address who initially deposited the NFT
                            address public curator;
                            /// @notice the AUM fee paid to the curator yearly. 3 decimals. ie. 100 = 10%
                            uint256 public fee;
                            /// @notice the last timestamp where fees were claimed
                            uint256 public lastClaimed;
                            /// @notice a boolean to indicate if the vault has closed
                            bool public vaultClosed;
                            /// @notice the number of ownership tokens voting on the reserve price at any given time
                            uint256 public votingTokens;
                            /// @notice a mapping of users to their desired token price
                            mapping(address => uint256) public userPrices;
                            /// ------------------------
                            /// -------- EVENTS --------
                            /// ------------------------
                            /// @notice An event emitted when a user updates their price
                            event PriceUpdate(address indexed user, uint price);
                            /// @notice An event emitted when an auction starts
                            event Start(address indexed buyer, uint price);
                            /// @notice An event emitted when a bid is made
                            event Bid(address indexed buyer, uint price);
                            /// @notice An event emitted when an auction is won
                            event Won(address indexed buyer, uint price);
                            /// @notice An event emitted when someone redeems all tokens for the NFT
                            event Redeem(address indexed redeemer);
                            /// @notice An event emitted when someone cashes in ERC20 tokens for ETH from an ERC721 token sale
                            event Cash(address indexed owner, uint256 shares);
                            constructor(address _settings) {
                                settings = _settings;
                            }
                            function initialize(address _curator, address _token, uint256 _id, uint256 _supply, uint256 _listPrice, uint256 _fee, string memory _name, string memory _symbol) external initializer {
                                // initialize inherited contracts
                                __ERC20_init(_name, _symbol);
                                __ERC721Holder_init();
                                // set storage variables
                                token = _token;
                                id = _id;
                                reserveTotal = _listPrice * _supply;
                                auctionLength = 7 days;
                                curator = _curator;
                                fee = _fee;
                                lastClaimed = block.timestamp;
                                votingTokens = _listPrice == 0 ? 0 : _supply;
                                auctionState = State.inactive;
                                _mint(_curator, _supply);
                                userPrices[_curator] = _listPrice;
                            }
                            /// --------------------------------
                            /// -------- VIEW FUNCTIONS --------
                            /// --------------------------------
                            function reservePrice() public view returns(uint256) {
                                return votingTokens == 0 ? 0 : reserveTotal / votingTokens;
                            }
                            /// -------------------------------
                            /// -------- GOV FUNCTIONS --------
                            /// -------------------------------
                            /// @notice allow governance to boot a bad actor curator
                            /// @param _curator the new curator
                            function kickCurator(address _curator) external {
                                require(msg.sender == Ownable(settings).owner(), "kick:not gov");
                                curator = _curator;
                            }
                            /// @notice allow governance to remove bad reserve prices
                            function removeReserve(address _user) external {
                                require(msg.sender == Ownable(settings).owner(), "remove:not gov");
                                require(auctionState == State.inactive, "update:auction live cannot update price");
                                uint256 old = userPrices[_user];
                                require(0 != old, "update:not an update");
                                uint256 weight = balanceOf(_user);
                                votingTokens -= weight;
                                reserveTotal -= weight * old;
                                
                                userPrices[_user] = 0;
                                emit PriceUpdate(_user, 0);
                            }
                            /// -----------------------------------
                            /// -------- CURATOR FUNCTIONS --------
                            /// -----------------------------------
                            /// @notice allow curator to update the curator address
                            /// @param _curator the new curator
                            function updateCurator(address _curator) external {
                                require(msg.sender == curator, "update:not curator");
                                curator = _curator;
                            }
                            /// @notice allow curator to update the auction length
                            /// @param _length the new base price
                            function updateAuctionLength(uint256 _length) external {
                                require(msg.sender == curator, "update:not curator");
                                require(_length >= ISettings(settings).minAuctionLength() && _length <= ISettings(settings).maxAuctionLength(), "update:invalid auction length");
                                auctionLength = _length;
                            }
                            /// @notice allow the curator to change their fee
                            /// @param _fee the new fee
                            function updateFee(uint256 _fee) external {
                                require(msg.sender == curator, "update:not curator");
                                require(_fee <= ISettings(settings).maxCuratorFee(), "update:cannot increase fee this high");
                                _claimFees();
                                fee = _fee;
                            }
                            /// @notice external function to claim fees for the curator and governance
                            function claimFees() external {
                                _claimFees();
                            }
                            /// @dev interal fuction to calculate and mint fees
                            function _claimFees() internal {
                                require(auctionState != State.ended, "claim:cannot claim after auction ends");
                                // get how much in fees the curator would make in a year
                                uint256 currentAnnualFee = fee * totalSupply() / 1000; 
                                // get how much that is per second;
                                uint256 feePerSecond = currentAnnualFee / 31536000;
                                // get how many seconds they are eligible to claim
                                uint256 sinceLastClaim = block.timestamp - lastClaimed;
                                // get the amount of tokens to mint
                                uint256 curatorMint = sinceLastClaim * feePerSecond;
                                // now lets do the same for governance
                                address govAddress = ISettings(settings).feeReceiver();
                                uint256 govFee = ISettings(settings).governanceFee();
                                currentAnnualFee = govFee * totalSupply() / 1000; 
                                feePerSecond = currentAnnualFee / 31536000;
                                uint256 govMint = sinceLastClaim * feePerSecond;
                                lastClaimed = block.timestamp;
                                _mint(curator, curatorMint);
                                _mint(govAddress, govMint);
                            }
                            /// --------------------------------
                            /// -------- CORE FUNCTIONS --------
                            /// --------------------------------
                            /// @notice a function for an end user to update their desired sale price
                            /// @param _new the desired price in ETH
                            function updateUserPrice(uint256 _new) external {
                                require(auctionState == State.inactive, "update:auction live cannot update price");
                                uint256 old = userPrices[msg.sender];
                                require(_new != old, "update:not an update");
                                uint256 weight = balanceOf(msg.sender);
                                if (votingTokens == 0) {
                                    votingTokens = weight;
                                    reserveTotal = weight * _new;
                                }
                                // they are the only one voting
                                else if (weight == votingTokens && old != 0) {
                                    reserveTotal = weight * _new;
                                }
                                // previously they were not voting
                                else if (old == 0) {
                                    uint256 averageReserve = reserveTotal / votingTokens;
                                    uint256 reservePriceMin = averageReserve * ISettings(settings).minReserveFactor() / 1000;
                                    require(_new >= reservePriceMin, "update:reserve price too low");
                                    uint256 reservePriceMax = averageReserve * ISettings(settings).maxReserveFactor() / 1000;
                                    require(_new <= reservePriceMax, "update:reserve price too high");
                                    votingTokens += weight;
                                    reserveTotal += weight * _new;
                                } 
                                // they no longer want to vote
                                else if (_new == 0) {
                                    votingTokens -= weight;
                                    reserveTotal -= weight * old;
                                } 
                                // they are updating their vote
                                else {
                                    uint256 averageReserve = (reserveTotal - (old * weight)) / (votingTokens - weight);
                                    uint256 reservePriceMin = averageReserve * ISettings(settings).minReserveFactor() / 1000;
                                    require(_new >= reservePriceMin, "update:reserve price too low");
                                    uint256 reservePriceMax = averageReserve * ISettings(settings).maxReserveFactor() / 1000;
                                    require(_new <= reservePriceMax, "update:reserve price too high");
                                    reserveTotal = reserveTotal + (weight * _new) - (weight * old);
                                }
                                userPrices[msg.sender] = _new;
                                emit PriceUpdate(msg.sender, _new);
                            }
                            /// @notice an internal function used to update sender and receivers price on token transfer
                            /// @param _from the ERC20 token sender
                            /// @param _to the ERC20 token receiver
                            /// @param _amount the ERC20 token amount
                            function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal virtual override {
                                if (_from != address(0) && auctionState == State.inactive) {
                                    uint256 fromPrice = userPrices[_from];
                                    uint256 toPrice = userPrices[_to];
                                    // only do something if users have different reserve price
                                    if (toPrice != fromPrice) {
                                        // new holder is not a voter
                                        if (toPrice == 0) {
                                            // get the average reserve price ignoring the senders amount
                                            votingTokens -= _amount;
                                            reserveTotal -= _amount * fromPrice;
                                        }
                                        // old holder is not a voter
                                        else if (fromPrice == 0) {
                                            votingTokens += _amount;
                                            reserveTotal += _amount * toPrice;
                                        }
                                        // both holders are voters
                                        else {
                                            reserveTotal = reserveTotal + (_amount * toPrice) - (_amount * fromPrice);
                                        }
                                    }
                                }
                            }
                            /// @notice kick off an auction. Must send reservePrice in ETH
                            function start() external payable {
                                require(auctionState == State.inactive, "start:no auction starts");
                                require(msg.value >= reservePrice(), "start:too low bid");
                                require(votingTokens * 1000 >= ISettings(settings).minVotePercentage() * totalSupply(), "start:not enough voters");
                                
                                auctionEnd = block.timestamp + auctionLength;
                                auctionState = State.live;
                                livePrice = msg.value;
                                winning = payable(msg.sender);
                                emit Start(msg.sender, msg.value);
                            }
                            /// @notice an external function to bid on purchasing the vaults NFT. The msg.value is the bid amount
                            function bid() external payable {
                                require(auctionState == State.live, "bid:auction is not live");
                                uint256 increase = ISettings(settings).minBidIncrease() + 1000;
                                require(msg.value * 1000 >= livePrice * increase, "bid:too low bid");
                                require(block.timestamp < auctionEnd, "bid:auction ended");
                                // If bid is within 15 minutes of auction end, extend auction
                                if (auctionEnd - block.timestamp <= 15 minutes) {
                                    auctionEnd += 15 minutes;
                                }
                                _sendWETH(winning, livePrice);
                                livePrice = msg.value;
                                winning = payable(msg.sender);
                                emit Bid(msg.sender, msg.value);
                            }
                            /// @notice an external function to end an auction after the timer has run out
                            function end() external {
                                require(auctionState == State.live, "end:vault has already closed");
                                require(block.timestamp >= auctionEnd, "end:auction live");
                                _claimFees();
                                // transfer erc721 to winner
                                IERC721(token).transferFrom(address(this), winning, id);
                                auctionState = State.ended;
                                emit Won(winning, livePrice);
                            }
                            /// @notice an external function to burn all ERC20 tokens to receive the ERC721 token
                            function redeem() external {
                                require(auctionState == State.inactive, "redeem:no redeeming");
                                _burn(msg.sender, totalSupply());
                                
                                // transfer erc721 to redeemer
                                IERC721(token).transferFrom(address(this), msg.sender, id);
                                
                                auctionState = State.redeemed;
                                emit Redeem(msg.sender);
                            }
                            /// @notice an external function to burn ERC20 tokens to receive ETH from ERC721 token purchase
                            function cash() external {
                                require(auctionState == State.ended, "cash:vault not closed yet");
                                uint256 bal = balanceOf(msg.sender);
                                require(bal > 0, "cash:no tokens to cash out");
                                uint256 share = bal * address(this).balance / totalSupply();
                                _burn(msg.sender, bal);
                                _sendETHOrWETH(payable(msg.sender), share);
                                emit Cash(msg.sender, share);
                            }
                            /// @dev internal helper function to send ETH and WETH on failure
                            function _sendWETH(address who, uint256 amount) internal {
                                IWETH(weth).deposit{value: amount}();
                                IWETH(weth).transfer(who, IWETH(weth).balanceOf(address(this)));
                            }
                            /// @dev internal helper function to send ETH and WETH on failure
                            function _sendETHOrWETH(address who, uint256 amount) internal {
                                // contracts get bet WETH because they can be mean
                                if (who.isContract()) {
                                    IWETH(weth).deposit{value: amount}();
                                    IWETH(weth).transfer(who, IWETH(weth).balanceOf(address(this)));
                                } else {
                                    payable(who).transfer(amount);
                                }
                            }
                        }//SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        interface IWETH {
                            function deposit() external payable;
                            function withdraw(uint) external;
                            function approve(address, uint) external returns(bool);
                            function transfer(address, uint) external returns(bool);
                            function transferFrom(address, address, uint) external returns(bool);
                            function balanceOf(address) external view returns(uint);
                        }// SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @dev Standard math utilities missing in the Solidity language.
                         */
                        library Math {
                            /**
                             * @dev Returns the largest of two numbers.
                             */
                            function max(uint256 a, uint256 b) internal pure returns (uint256) {
                                return a >= b ? a : b;
                            }
                            /**
                             * @dev Returns the smallest of two numbers.
                             */
                            function min(uint256 a, uint256 b) internal pure returns (uint256) {
                                return a < b ? a : b;
                            }
                            /**
                             * @dev Returns the average of two numbers. The result is rounded towards
                             * zero.
                             */
                            function average(uint256 a, uint256 b) internal pure returns (uint256) {
                                // (a + b) / 2 can overflow, so we distribute
                                return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "../../utils/Context.sol";
                        import "./IERC20.sol";
                        /**
                         * @dev Implementation of the {IERC20} interface.
                         *
                         * This implementation is agnostic to the way tokens are created. This means
                         * that a supply mechanism has to be added in a derived contract using {_mint}.
                         * For a generic mechanism see {ERC20PresetMinterPauser}.
                         *
                         * TIP: For a detailed writeup see our guide
                         * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
                         * to implement supply mechanisms].
                         *
                         * We have followed general OpenZeppelin guidelines: functions revert instead
                         * of returning `false` on failure. This behavior is nonetheless conventional
                         * and does not conflict with the expectations of ERC20 applications.
                         *
                         * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
                         * This allows applications to reconstruct the allowance for all accounts just
                         * by listening to said events. Other implementations of the EIP may not emit
                         * these events, as it isn't required by the specification.
                         *
                         * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
                         * functions have been added to mitigate the well-known issues around setting
                         * allowances. See {IERC20-approve}.
                         */
                        contract ERC20 is Context, IERC20 {
                            mapping (address => uint256) private _balances;
                            mapping (address => mapping (address => uint256)) private _allowances;
                            uint256 private _totalSupply;
                            string private _name;
                            string private _symbol;
                            /**
                             * @dev Sets the values for {name} and {symbol}.
                             *
                             * The defaut value of {decimals} is 18. To select a different value for
                             * {decimals} you should overload it.
                             *
                             * All three of these values are immutable: they can only be set once during
                             * construction.
                             */
                            constructor (string memory name_, string memory symbol_) {
                                _name = name_;
                                _symbol = symbol_;
                            }
                            /**
                             * @dev Returns the name of the token.
                             */
                            function name() public view virtual returns (string memory) {
                                return _name;
                            }
                            /**
                             * @dev Returns the symbol of the token, usually a shorter version of the
                             * name.
                             */
                            function symbol() public view virtual returns (string memory) {
                                return _symbol;
                            }
                            /**
                             * @dev Returns the number of decimals used to get its user representation.
                             * For example, if `decimals` equals `2`, a balance of `505` tokens should
                             * be displayed to a user as `5,05` (`505 / 10 ** 2`).
                             *
                             * Tokens usually opt for a value of 18, imitating the relationship between
                             * Ether and Wei. This is the value {ERC20} uses, unless this function is
                             * overloaded;
                             *
                             * NOTE: This information is only used for _display_ purposes: it in
                             * no way affects any of the arithmetic of the contract, including
                             * {IERC20-balanceOf} and {IERC20-transfer}.
                             */
                            function decimals() public view virtual returns (uint8) {
                                return 18;
                            }
                            /**
                             * @dev See {IERC20-totalSupply}.
                             */
                            function totalSupply() public view virtual override returns (uint256) {
                                return _totalSupply;
                            }
                            /**
                             * @dev See {IERC20-balanceOf}.
                             */
                            function balanceOf(address account) public view virtual override returns (uint256) {
                                return _balances[account];
                            }
                            /**
                             * @dev See {IERC20-transfer}.
                             *
                             * Requirements:
                             *
                             * - `recipient` cannot be the zero address.
                             * - the caller must have a balance of at least `amount`.
                             */
                            function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
                                _transfer(_msgSender(), recipient, amount);
                                return true;
                            }
                            /**
                             * @dev See {IERC20-allowance}.
                             */
                            function allowance(address owner, address spender) public view virtual override returns (uint256) {
                                return _allowances[owner][spender];
                            }
                            /**
                             * @dev See {IERC20-approve}.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             */
                            function approve(address spender, uint256 amount) public virtual override returns (bool) {
                                _approve(_msgSender(), spender, amount);
                                return true;
                            }
                            /**
                             * @dev See {IERC20-transferFrom}.
                             *
                             * Emits an {Approval} event indicating the updated allowance. This is not
                             * required by the EIP. See the note at the beginning of {ERC20}.
                             *
                             * Requirements:
                             *
                             * - `sender` and `recipient` cannot be the zero address.
                             * - `sender` must have a balance of at least `amount`.
                             * - the caller must have allowance for ``sender``'s tokens of at least
                             * `amount`.
                             */
                            function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
                                _transfer(sender, recipient, amount);
                                uint256 currentAllowance = _allowances[sender][_msgSender()];
                                require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
                                _approve(sender, _msgSender(), currentAllowance - amount);
                                return true;
                            }
                            /**
                             * @dev Atomically increases the allowance granted to `spender` by the caller.
                             *
                             * This is an alternative to {approve} that can be used as a mitigation for
                             * problems described in {IERC20-approve}.
                             *
                             * Emits an {Approval} event indicating the updated allowance.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             */
                            function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
                                _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
                                return true;
                            }
                            /**
                             * @dev Atomically decreases the allowance granted to `spender` by the caller.
                             *
                             * This is an alternative to {approve} that can be used as a mitigation for
                             * problems described in {IERC20-approve}.
                             *
                             * Emits an {Approval} event indicating the updated allowance.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             * - `spender` must have allowance for the caller of at least
                             * `subtractedValue`.
                             */
                            function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
                                uint256 currentAllowance = _allowances[_msgSender()][spender];
                                require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
                                _approve(_msgSender(), spender, currentAllowance - subtractedValue);
                                return true;
                            }
                            /**
                             * @dev Moves tokens `amount` from `sender` to `recipient`.
                             *
                             * This is internal function is equivalent to {transfer}, and can be used to
                             * e.g. implement automatic token fees, slashing mechanisms, etc.
                             *
                             * Emits a {Transfer} event.
                             *
                             * Requirements:
                             *
                             * - `sender` cannot be the zero address.
                             * - `recipient` cannot be the zero address.
                             * - `sender` must have a balance of at least `amount`.
                             */
                            function _transfer(address sender, address recipient, uint256 amount) internal virtual {
                                require(sender != address(0), "ERC20: transfer from the zero address");
                                require(recipient != address(0), "ERC20: transfer to the zero address");
                                _beforeTokenTransfer(sender, recipient, amount);
                                uint256 senderBalance = _balances[sender];
                                require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
                                _balances[sender] = senderBalance - amount;
                                _balances[recipient] += amount;
                                emit Transfer(sender, recipient, amount);
                            }
                            /** @dev Creates `amount` tokens and assigns them to `account`, increasing
                             * the total supply.
                             *
                             * Emits a {Transfer} event with `from` set to the zero address.
                             *
                             * Requirements:
                             *
                             * - `to` cannot be the zero address.
                             */
                            function _mint(address account, uint256 amount) internal virtual {
                                require(account != address(0), "ERC20: mint to the zero address");
                                _beforeTokenTransfer(address(0), account, amount);
                                _totalSupply += amount;
                                _balances[account] += amount;
                                emit Transfer(address(0), account, amount);
                            }
                            /**
                             * @dev Destroys `amount` tokens from `account`, reducing the
                             * total supply.
                             *
                             * Emits a {Transfer} event with `to` set to the zero address.
                             *
                             * Requirements:
                             *
                             * - `account` cannot be the zero address.
                             * - `account` must have at least `amount` tokens.
                             */
                            function _burn(address account, uint256 amount) internal virtual {
                                require(account != address(0), "ERC20: burn from the zero address");
                                _beforeTokenTransfer(account, address(0), amount);
                                uint256 accountBalance = _balances[account];
                                require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
                                _balances[account] = accountBalance - amount;
                                _totalSupply -= amount;
                                emit Transfer(account, address(0), amount);
                            }
                            /**
                             * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
                             *
                             * This internal function is equivalent to `approve`, and can be used to
                             * e.g. set automatic allowances for certain subsystems, etc.
                             *
                             * Emits an {Approval} event.
                             *
                             * Requirements:
                             *
                             * - `owner` cannot be the zero address.
                             * - `spender` cannot be the zero address.
                             */
                            function _approve(address owner, address spender, uint256 amount) internal virtual {
                                require(owner != address(0), "ERC20: approve from the zero address");
                                require(spender != address(0), "ERC20: approve to the zero address");
                                _allowances[owner][spender] = amount;
                                emit Approval(owner, spender, amount);
                            }
                            /**
                             * @dev Hook that is called before any transfer of tokens. This includes
                             * minting and burning.
                             *
                             * Calling conditions:
                             *
                             * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
                             * will be to transferred to `to`.
                             * - when `from` is zero, `amount` tokens will be minted for `to`.
                             * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
                             * - `from` and `to` are never both zero.
                             *
                             * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                             */
                            function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "../../utils/Context.sol";
                        import "./IERC721.sol";
                        import "./IERC721Metadata.sol";
                        import "./IERC721Enumerable.sol";
                        import "./IERC721Receiver.sol";
                        import "../../introspection/ERC165.sol";
                        import "../../utils/Address.sol";
                        import "../../utils/EnumerableSet.sol";
                        import "../../utils/EnumerableMap.sol";
                        import "../../utils/Strings.sol";
                        /**
                         * @title ERC721 Non-Fungible Token Standard basic implementation
                         * @dev see https://eips.ethereum.org/EIPS/eip-721
                         */
                        contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
                            using Address for address;
                            using EnumerableSet for EnumerableSet.UintSet;
                            using EnumerableMap for EnumerableMap.UintToAddressMap;
                            using Strings for uint256;
                            // Mapping from holder address to their (enumerable) set of owned tokens
                            mapping (address => EnumerableSet.UintSet) private _holderTokens;
                            // Enumerable mapping from token ids to their owners
                            EnumerableMap.UintToAddressMap private _tokenOwners;
                            // Mapping from token ID to approved address
                            mapping (uint256 => address) private _tokenApprovals;
                            // Mapping from owner to operator approvals
                            mapping (address => mapping (address => bool)) private _operatorApprovals;
                            // Token name
                            string private _name;
                            // Token symbol
                            string private _symbol;
                            // Optional mapping for token URIs
                            mapping (uint256 => string) private _tokenURIs;
                            // Base URI
                            string private _baseURI;
                            /**
                             * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
                             */
                            constructor (string memory name_, string memory symbol_) {
                                _name = name_;
                                _symbol = symbol_;
                                // register the supported interfaces to conform to ERC721 via ERC165
                                _registerInterface(type(IERC721).interfaceId);
                                _registerInterface(type(IERC721Metadata).interfaceId);
                                _registerInterface(type(IERC721Enumerable).interfaceId);
                            }
                            /**
                             * @dev See {IERC721-balanceOf}.
                             */
                            function balanceOf(address owner) public view virtual override returns (uint256) {
                                require(owner != address(0), "ERC721: balance query for the zero address");
                                return _holderTokens[owner].length();
                            }
                            /**
                             * @dev See {IERC721-ownerOf}.
                             */
                            function ownerOf(uint256 tokenId) public view virtual override returns (address) {
                                return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
                            }
                            /**
                             * @dev See {IERC721Metadata-name}.
                             */
                            function name() public view virtual override returns (string memory) {
                                return _name;
                            }
                            /**
                             * @dev See {IERC721Metadata-symbol}.
                             */
                            function symbol() public view virtual override returns (string memory) {
                                return _symbol;
                            }
                            /**
                             * @dev See {IERC721Metadata-tokenURI}.
                             */
                            function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
                                require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
                                string memory _tokenURI = _tokenURIs[tokenId];
                                string memory base = baseURI();
                                // If there is no base URI, return the token URI.
                                if (bytes(base).length == 0) {
                                    return _tokenURI;
                                }
                                // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
                                if (bytes(_tokenURI).length > 0) {
                                    return string(abi.encodePacked(base, _tokenURI));
                                }
                                // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
                                return string(abi.encodePacked(base, tokenId.toString()));
                            }
                            /**
                            * @dev Returns the base URI set via {_setBaseURI}. This will be
                            * automatically added as a prefix in {tokenURI} to each token's URI, or
                            * to the token ID if no specific URI is set for that token ID.
                            */
                            function baseURI() public view virtual returns (string memory) {
                                return _baseURI;
                            }
                            /**
                             * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
                             */
                            function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
                                return _holderTokens[owner].at(index);
                            }
                            /**
                             * @dev See {IERC721Enumerable-totalSupply}.
                             */
                            function totalSupply() public view virtual override returns (uint256) {
                                // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
                                return _tokenOwners.length();
                            }
                            /**
                             * @dev See {IERC721Enumerable-tokenByIndex}.
                             */
                            function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
                                (uint256 tokenId, ) = _tokenOwners.at(index);
                                return tokenId;
                            }
                            /**
                             * @dev See {IERC721-approve}.
                             */
                            function approve(address to, uint256 tokenId) public virtual override {
                                address owner = ERC721.ownerOf(tokenId);
                                require(to != owner, "ERC721: approval to current owner");
                                require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),
                                    "ERC721: approve caller is not owner nor approved for all"
                                );
                                _approve(to, tokenId);
                            }
                            /**
                             * @dev See {IERC721-getApproved}.
                             */
                            function getApproved(uint256 tokenId) public view virtual override returns (address) {
                                require(_exists(tokenId), "ERC721: approved query for nonexistent token");
                                return _tokenApprovals[tokenId];
                            }
                            /**
                             * @dev See {IERC721-setApprovalForAll}.
                             */
                            function setApprovalForAll(address operator, bool approved) public virtual override {
                                require(operator != _msgSender(), "ERC721: approve to caller");
                                _operatorApprovals[_msgSender()][operator] = approved;
                                emit ApprovalForAll(_msgSender(), operator, approved);
                            }
                            /**
                             * @dev See {IERC721-isApprovedForAll}.
                             */
                            function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
                                return _operatorApprovals[owner][operator];
                            }
                            /**
                             * @dev See {IERC721-transferFrom}.
                             */
                            function transferFrom(address from, address to, uint256 tokenId) public virtual override {
                                //solhint-disable-next-line max-line-length
                                require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
                                _transfer(from, to, tokenId);
                            }
                            /**
                             * @dev See {IERC721-safeTransferFrom}.
                             */
                            function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
                                safeTransferFrom(from, to, tokenId, "");
                            }
                            /**
                             * @dev See {IERC721-safeTransferFrom}.
                             */
                            function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
                                require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
                                _safeTransfer(from, to, tokenId, _data);
                            }
                            /**
                             * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
                             * are aware of the ERC721 protocol to prevent tokens from being forever locked.
                             *
                             * `_data` is additional data, it has no specified format and it is sent in call to `to`.
                             *
                             * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
                             * implement alternative mechanisms to perform token transfer, such as signature-based.
                             *
                             * Requirements:
                             *
                             * - `from` cannot be the zero address.
                             * - `to` cannot be the zero address.
                             * - `tokenId` token must exist and be owned by `from`.
                             * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                             *
                             * Emits a {Transfer} event.
                             */
                            function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
                                _transfer(from, to, tokenId);
                                require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
                            }
                            /**
                             * @dev Returns whether `tokenId` exists.
                             *
                             * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
                             *
                             * Tokens start existing when they are minted (`_mint`),
                             * and stop existing when they are burned (`_burn`).
                             */
                            function _exists(uint256 tokenId) internal view virtual returns (bool) {
                                return _tokenOwners.contains(tokenId);
                            }
                            /**
                             * @dev Returns whether `spender` is allowed to manage `tokenId`.
                             *
                             * Requirements:
                             *
                             * - `tokenId` must exist.
                             */
                            function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
                                require(_exists(tokenId), "ERC721: operator query for nonexistent token");
                                address owner = ERC721.ownerOf(tokenId);
                                return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));
                            }
                            /**
                             * @dev Safely mints `tokenId` and transfers it to `to`.
                             *
                             * Requirements:
                             d*
                             * - `tokenId` must not exist.
                             * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                             *
                             * Emits a {Transfer} event.
                             */
                            function _safeMint(address to, uint256 tokenId) internal virtual {
                                _safeMint(to, tokenId, "");
                            }
                            /**
                             * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
                             * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
                             */
                            function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
                                _mint(to, tokenId);
                                require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
                            }
                            /**
                             * @dev Mints `tokenId` and transfers it to `to`.
                             *
                             * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
                             *
                             * Requirements:
                             *
                             * - `tokenId` must not exist.
                             * - `to` cannot be the zero address.
                             *
                             * Emits a {Transfer} event.
                             */
                            function _mint(address to, uint256 tokenId) internal virtual {
                                require(to != address(0), "ERC721: mint to the zero address");
                                require(!_exists(tokenId), "ERC721: token already minted");
                                _beforeTokenTransfer(address(0), to, tokenId);
                                _holderTokens[to].add(tokenId);
                                _tokenOwners.set(tokenId, to);
                                emit Transfer(address(0), to, tokenId);
                            }
                            /**
                             * @dev Destroys `tokenId`.
                             * The approval is cleared when the token is burned.
                             *
                             * Requirements:
                             *
                             * - `tokenId` must exist.
                             *
                             * Emits a {Transfer} event.
                             */
                            function _burn(uint256 tokenId) internal virtual {
                                address owner = ERC721.ownerOf(tokenId); // internal owner
                                _beforeTokenTransfer(owner, address(0), tokenId);
                                // Clear approvals
                                _approve(address(0), tokenId);
                                // Clear metadata (if any)
                                if (bytes(_tokenURIs[tokenId]).length != 0) {
                                    delete _tokenURIs[tokenId];
                                }
                                _holderTokens[owner].remove(tokenId);
                                _tokenOwners.remove(tokenId);
                                emit Transfer(owner, address(0), tokenId);
                            }
                            /**
                             * @dev Transfers `tokenId` from `from` to `to`.
                             *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
                             *
                             * Requirements:
                             *
                             * - `to` cannot be the zero address.
                             * - `tokenId` token must be owned by `from`.
                             *
                             * Emits a {Transfer} event.
                             */
                            function _transfer(address from, address to, uint256 tokenId) internal virtual {
                                require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner
                                require(to != address(0), "ERC721: transfer to the zero address");
                                _beforeTokenTransfer(from, to, tokenId);
                                // Clear approvals from the previous owner
                                _approve(address(0), tokenId);
                                _holderTokens[from].remove(tokenId);
                                _holderTokens[to].add(tokenId);
                                _tokenOwners.set(tokenId, to);
                                emit Transfer(from, to, tokenId);
                            }
                            /**
                             * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
                             *
                             * Requirements:
                             *
                             * - `tokenId` must exist.
                             */
                            function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
                                require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
                                _tokenURIs[tokenId] = _tokenURI;
                            }
                            /**
                             * @dev Internal function to set the base URI for all token IDs. It is
                             * automatically added as a prefix to the value returned in {tokenURI},
                             * or to the token ID if {tokenURI} is empty.
                             */
                            function _setBaseURI(string memory baseURI_) internal virtual {
                                _baseURI = baseURI_;
                            }
                            /**
                             * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
                             * The call is not executed if the target address is not a contract.
                             *
                             * @param from address representing the previous owner of the given token ID
                             * @param to target address that will receive the tokens
                             * @param tokenId uint256 ID of the token to be transferred
                             * @param _data bytes optional data to send along with the call
                             * @return bool whether the call correctly returned the expected magic value
                             */
                            function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
                                private returns (bool)
                            {
                                if (to.isContract()) {
                                    try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                                        return retval == IERC721Receiver(to).onERC721Received.selector;
                                    } catch (bytes memory reason) {
                                        if (reason.length == 0) {
                                            revert("ERC721: transfer to non ERC721Receiver implementer");
                                        } else {
                                            // solhint-disable-next-line no-inline-assembly
                                            assembly {
                                                revert(add(32, reason), mload(reason))
                                            }
                                        }
                                    }
                                } else {
                                    return true;
                                }
                            }
                            function _approve(address to, uint256 tokenId) private {
                                _tokenApprovals[tokenId] = to;
                                emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
                            }
                            /**
                             * @dev Hook that is called before any token transfer. This includes minting
                             * and burning.
                             *
                             * Calling conditions:
                             *
                             * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
                             * transferred to `to`.
                             * - When `from` is zero, `tokenId` will be minted for `to`.
                             * - When `to` is zero, ``from``'s `tokenId` will be burned.
                             * - `from` cannot be the zero address.
                             * - `to` cannot be the zero address.
                             *
                             * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                             */
                            function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./IERC721Receiver.sol";
                          /**
                           * @dev Implementation of the {IERC721Receiver} interface.
                           *
                           * Accepts all token transfers. 
                           * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
                           */
                        contract ERC721Holder is IERC721Receiver {
                            /**
                             * @dev See {IERC721Receiver-onERC721Received}.
                             *
                             * Always returns `IERC721Receiver.onERC721Received.selector`.
                             */
                            function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
                                return this.onERC721Received.selector;
                            }
                        }
                        //SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./OpenZeppelin/access/Ownable.sol";
                        import "./Interfaces/ISettings.sol";
                        contract Settings is Ownable, ISettings {
                            /// @notice the maximum auction length
                            uint256 public override maxAuctionLength;
                            /// @notice the longest an auction can ever be
                            uint256 public constant maxMaxAuctionLength = 8 weeks;
                            /// @notice the minimum auction length
                            uint256 public override minAuctionLength;
                            /// @notice the shortest an auction can ever be
                            uint256 public constant minMinAuctionLength = 1 days;
                            /// @notice governance fee max
                            uint256 public override governanceFee;
                            /// @notice 10% fee is max
                            uint256 public constant maxGovFee = 100;
                            /// @notice max curator fee
                            uint256 public override maxCuratorFee;
                            /// @notice the % bid increase required for a new bid
                            uint256 public override minBidIncrease;
                            /// @notice 10% bid increase is max 
                            uint256 public constant maxMinBidIncrease = 100;
                            /// @notice 1% bid increase is min
                            uint256 public constant minMinBidIncrease = 10;
                            /// @notice the % of tokens required to be voting for an auction to start
                            uint256 public override minVotePercentage;
                            /// @notice the max % increase over the initial 
                            uint256 public override maxReserveFactor;
                            /// @notice the max % decrease from the initial
                            uint256 public override minReserveFactor;
                            /// @notice the address who receives auction fees
                            address payable public override feeReceiver;
                            event UpdateMaxAuctionLength(uint256 _old, uint256 _new);
                            event UpdateMinAuctionLength(uint256 _old, uint256 _new);
                            event UpdateGovernanceFee(uint256 _old, uint256 _new);
                            event UpdateCuratorFee(uint256 _old, uint256 _new);
                            event UpdateMinBidIncrease(uint256 _old, uint256 _new);
                            event UpdateMinVotePercentage(uint256 _old, uint256 _new);
                            event UpdateMaxReserveFactor(uint256 _old, uint256 _new);
                            event UpdateMinReserveFactor(uint256 _old, uint256 _new);
                            event UpdateFeeReceiver(address _old, address _new);
                            constructor() {
                                maxAuctionLength = 2 weeks;
                                minAuctionLength = 3 days;
                                feeReceiver = payable(msg.sender);
                                minReserveFactor = 500;  // 50%
                                maxReserveFactor = 2000; // 200%
                                minBidIncrease = 50;     // 5%
                                maxCuratorFee = 100;
                                minVotePercentage = 500; // 50%
                            }
                            function setMaxAuctionLength(uint256 _length) external onlyOwner {
                                require(_length <= maxMaxAuctionLength, "max auction length too high");
                                require(_length > minAuctionLength, "max auction length too low");
                                emit UpdateMaxAuctionLength(maxAuctionLength, _length);
                                maxAuctionLength = _length;
                            }
                            function setMinAuctionLength(uint256 _length) external onlyOwner {
                                require(_length >= minMinAuctionLength, "min auction length too low");
                                require(_length < maxAuctionLength, "min auction length too high");
                                emit UpdateMinAuctionLength(minAuctionLength, _length);
                                minAuctionLength = _length;
                            }
                            function setGovernanceFee(uint256 _fee) external onlyOwner {
                                require(_fee <= maxGovFee, "fee too high");
                                emit UpdateGovernanceFee(governanceFee, _fee);
                                governanceFee = _fee;
                            }
                            function setMaxCuratorFee(uint256 _fee) external onlyOwner {
                                emit UpdateCuratorFee(governanceFee, _fee);
                                maxCuratorFee = _fee;
                            }
                            function setMinBidIncrease(uint256 _min) external onlyOwner {
                                require(_min <= maxMinBidIncrease, "min bid increase too high");
                                require(_min >= minMinBidIncrease, "min bid increase too low");
                                emit UpdateMinBidIncrease(minBidIncrease, _min);
                                minBidIncrease = _min;
                            }
                            function setMinVotePercentage(uint256 _min) external onlyOwner {
                                // 1000 is 100%
                                require(_min <= 1000, "min vote percentage too high");
                                emit UpdateMinVotePercentage(minVotePercentage, _min);
                                minVotePercentage = _min;
                            }
                            function setMaxReserveFactor(uint256 _factor) external onlyOwner {
                                require(_factor > minReserveFactor, "max reserve factor too low");
                                emit UpdateMaxReserveFactor(maxReserveFactor, _factor);
                                maxReserveFactor = _factor;
                            }
                            function setMinReserveFactor(uint256 _factor) external onlyOwner {
                                require(_factor < maxReserveFactor, "min reserve factor too high");
                                emit UpdateMinReserveFactor(minReserveFactor, _factor);
                                minReserveFactor = _factor;
                            }
                            function setFeeReceiver(address payable _receiver) external onlyOwner {
                                require(_receiver != address(0), "fees cannot go to 0 address");
                                emit UpdateFeeReceiver(feeReceiver, _receiver);
                                feeReceiver = _receiver;
                            }
                        }// SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "../IERC721ReceiverUpgradeable.sol";
                        import "../../../proxy/utils/Initializable.sol";
                        /**
                         * @dev Implementation of the {IERC721Receiver} interface.
                         *
                         * Accepts all token transfers.
                         * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
                         */
                        contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
                            function __ERC721Holder_init() internal initializer {
                                __ERC721Holder_init_unchained();
                            }
                            function __ERC721Holder_init_unchained() internal initializer {
                            }
                            /**
                             * @dev See {IERC721Receiver-onERC721Received}.
                             *
                             * Always returns `IERC721Receiver.onERC721Received.selector`.
                             */
                            function onERC721Received(
                                address,
                                address,
                                uint256,
                                bytes memory
                            ) public virtual override returns (bytes4) {
                                return this.onERC721Received.selector;
                            }
                            uint256[50] private __gap;
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./IERC20Upgradeable.sol";
                        import "./extensions/IERC20MetadataUpgradeable.sol";
                        import "../../utils/ContextUpgradeable.sol";
                        import "../../proxy/utils/Initializable.sol";
                        /**
                         * @dev Implementation of the {IERC20} interface.
                         *
                         * This implementation is agnostic to the way tokens are created. This means
                         * that a supply mechanism has to be added in a derived contract using {_mint}.
                         * For a generic mechanism see {ERC20PresetMinterPauser}.
                         *
                         * TIP: For a detailed writeup see our guide
                         * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
                         * to implement supply mechanisms].
                         *
                         * We have followed general OpenZeppelin guidelines: functions revert instead
                         * of returning `false` on failure. This behavior is nonetheless conventional
                         * and does not conflict with the expectations of ERC20 applications.
                         *
                         * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
                         * This allows applications to reconstruct the allowance for all accounts just
                         * by listening to said events. Other implementations of the EIP may not emit
                         * these events, as it isn't required by the specification.
                         *
                         * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
                         * functions have been added to mitigate the well-known issues around setting
                         * allowances. See {IERC20-approve}.
                         */
                        contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
                            mapping(address => uint256) private _balances;
                            mapping(address => mapping(address => uint256)) private _allowances;
                            uint256 private _totalSupply;
                            string private _name;
                            string private _symbol;
                            /**
                             * @dev Sets the values for {name} and {symbol}.
                             *
                             * The default value of {decimals} is 18. To select a different value for
                             * {decimals} you should overload it.
                             *
                             * All two of these values are immutable: they can only be set once during
                             * construction.
                             */
                            function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
                                __Context_init_unchained();
                                __ERC20_init_unchained(name_, symbol_);
                            }
                            function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
                                _name = name_;
                                _symbol = symbol_;
                            }
                            /**
                             * @dev Returns the name of the token.
                             */
                            function name() public view virtual override returns (string memory) {
                                return _name;
                            }
                            /**
                             * @dev Returns the symbol of the token, usually a shorter version of the
                             * name.
                             */
                            function symbol() public view virtual override returns (string memory) {
                                return _symbol;
                            }
                            /**
                             * @dev Returns the number of decimals used to get its user representation.
                             * For example, if `decimals` equals `2`, a balance of `505` tokens should
                             * be displayed to a user as `5,05` (`505 / 10 ** 2`).
                             *
                             * Tokens usually opt for a value of 18, imitating the relationship between
                             * Ether and Wei. This is the value {ERC20} uses, unless this function is
                             * overridden;
                             *
                             * NOTE: This information is only used for _display_ purposes: it in
                             * no way affects any of the arithmetic of the contract, including
                             * {IERC20-balanceOf} and {IERC20-transfer}.
                             */
                            function decimals() public view virtual override returns (uint8) {
                                return 18;
                            }
                            /**
                             * @dev See {IERC20-totalSupply}.
                             */
                            function totalSupply() public view virtual override returns (uint256) {
                                return _totalSupply;
                            }
                            /**
                             * @dev See {IERC20-balanceOf}.
                             */
                            function balanceOf(address account) public view virtual override returns (uint256) {
                                return _balances[account];
                            }
                            /**
                             * @dev See {IERC20-transfer}.
                             *
                             * Requirements:
                             *
                             * - `recipient` cannot be the zero address.
                             * - the caller must have a balance of at least `amount`.
                             */
                            function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
                                _transfer(_msgSender(), recipient, amount);
                                return true;
                            }
                            /**
                             * @dev See {IERC20-allowance}.
                             */
                            function allowance(address owner, address spender) public view virtual override returns (uint256) {
                                return _allowances[owner][spender];
                            }
                            /**
                             * @dev See {IERC20-approve}.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             */
                            function approve(address spender, uint256 amount) public virtual override returns (bool) {
                                _approve(_msgSender(), spender, amount);
                                return true;
                            }
                            /**
                             * @dev See {IERC20-transferFrom}.
                             *
                             * Emits an {Approval} event indicating the updated allowance. This is not
                             * required by the EIP. See the note at the beginning of {ERC20}.
                             *
                             * Requirements:
                             *
                             * - `sender` and `recipient` cannot be the zero address.
                             * - `sender` must have a balance of at least `amount`.
                             * - the caller must have allowance for ``sender``'s tokens of at least
                             * `amount`.
                             */
                            function transferFrom(
                                address sender,
                                address recipient,
                                uint256 amount
                            ) public virtual override returns (bool) {
                                _transfer(sender, recipient, amount);
                                uint256 currentAllowance = _allowances[sender][_msgSender()];
                                require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
                                unchecked {
                                    _approve(sender, _msgSender(), currentAllowance - amount);
                                }
                                return true;
                            }
                            /**
                             * @dev Atomically increases the allowance granted to `spender` by the caller.
                             *
                             * This is an alternative to {approve} that can be used as a mitigation for
                             * problems described in {IERC20-approve}.
                             *
                             * Emits an {Approval} event indicating the updated allowance.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             */
                            function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
                                _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
                                return true;
                            }
                            /**
                             * @dev Atomically decreases the allowance granted to `spender` by the caller.
                             *
                             * This is an alternative to {approve} that can be used as a mitigation for
                             * problems described in {IERC20-approve}.
                             *
                             * Emits an {Approval} event indicating the updated allowance.
                             *
                             * Requirements:
                             *
                             * - `spender` cannot be the zero address.
                             * - `spender` must have allowance for the caller of at least
                             * `subtractedValue`.
                             */
                            function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
                                uint256 currentAllowance = _allowances[_msgSender()][spender];
                                require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
                                unchecked {
                                    _approve(_msgSender(), spender, currentAllowance - subtractedValue);
                                }
                                return true;
                            }
                            /**
                             * @dev Moves `amount` of tokens from `sender` to `recipient`.
                             *
                             * This internal function is equivalent to {transfer}, and can be used to
                             * e.g. implement automatic token fees, slashing mechanisms, etc.
                             *
                             * Emits a {Transfer} event.
                             *
                             * Requirements:
                             *
                             * - `sender` cannot be the zero address.
                             * - `recipient` cannot be the zero address.
                             * - `sender` must have a balance of at least `amount`.
                             */
                            function _transfer(
                                address sender,
                                address recipient,
                                uint256 amount
                            ) internal virtual {
                                require(sender != address(0), "ERC20: transfer from the zero address");
                                require(recipient != address(0), "ERC20: transfer to the zero address");
                                _beforeTokenTransfer(sender, recipient, amount);
                                uint256 senderBalance = _balances[sender];
                                require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
                                unchecked {
                                    _balances[sender] = senderBalance - amount;
                                }
                                _balances[recipient] += amount;
                                emit Transfer(sender, recipient, amount);
                                _afterTokenTransfer(sender, recipient, amount);
                            }
                            /** @dev Creates `amount` tokens and assigns them to `account`, increasing
                             * the total supply.
                             *
                             * Emits a {Transfer} event with `from` set to the zero address.
                             *
                             * Requirements:
                             *
                             * - `account` cannot be the zero address.
                             */
                            function _mint(address account, uint256 amount) internal virtual {
                                require(account != address(0), "ERC20: mint to the zero address");
                                _beforeTokenTransfer(address(0), account, amount);
                                _totalSupply += amount;
                                _balances[account] += amount;
                                emit Transfer(address(0), account, amount);
                                _afterTokenTransfer(address(0), account, amount);
                            }
                            /**
                             * @dev Destroys `amount` tokens from `account`, reducing the
                             * total supply.
                             *
                             * Emits a {Transfer} event with `to` set to the zero address.
                             *
                             * Requirements:
                             *
                             * - `account` cannot be the zero address.
                             * - `account` must have at least `amount` tokens.
                             */
                            function _burn(address account, uint256 amount) internal virtual {
                                require(account != address(0), "ERC20: burn from the zero address");
                                _beforeTokenTransfer(account, address(0), amount);
                                uint256 accountBalance = _balances[account];
                                require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
                                unchecked {
                                    _balances[account] = accountBalance - amount;
                                }
                                _totalSupply -= amount;
                                emit Transfer(account, address(0), amount);
                                _afterTokenTransfer(account, address(0), amount);
                            }
                            /**
                             * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
                             *
                             * This internal function is equivalent to `approve`, and can be used to
                             * e.g. set automatic allowances for certain subsystems, etc.
                             *
                             * Emits an {Approval} event.
                             *
                             * Requirements:
                             *
                             * - `owner` cannot be the zero address.
                             * - `spender` cannot be the zero address.
                             */
                            function _approve(
                                address owner,
                                address spender,
                                uint256 amount
                            ) internal virtual {
                                require(owner != address(0), "ERC20: approve from the zero address");
                                require(spender != address(0), "ERC20: approve to the zero address");
                                _allowances[owner][spender] = amount;
                                emit Approval(owner, spender, amount);
                            }
                            /**
                             * @dev Hook that is called before any transfer of tokens. This includes
                             * minting and burning.
                             *
                             * Calling conditions:
                             *
                             * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
                             * will be transferred to `to`.
                             * - when `from` is zero, `amount` tokens will be minted for `to`.
                             * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
                             * - `from` and `to` are never both zero.
                             *
                             * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                             */
                            function _beforeTokenTransfer(
                                address from,
                                address to,
                                uint256 amount
                            ) internal virtual {}
                            /**
                             * @dev Hook that is called after any transfer of tokens. This includes
                             * minting and burning.
                             *
                             * Calling conditions:
                             *
                             * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
                             * has been transferred to `to`.
                             * - when `from` is zero, `amount` tokens have been minted for `to`.
                             * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
                             * - `from` and `to` are never both zero.
                             *
                             * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                             */
                            function _afterTokenTransfer(
                                address from,
                                address to,
                                uint256 amount
                            ) internal virtual {}
                            uint256[45] private __gap;
                        }
                        // SPDX-License-Identifier: MIT
                        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 GSN 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) {
                                this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                return msg.data;
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^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.8.0;
                        import "../../introspection/IERC165.sol";
                        /**
                         * @dev Required interface of an ERC721 compliant contract.
                         */
                        interface IERC721 is IERC165 {
                            /**
                             * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
                             */
                            event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
                            /**
                             * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
                             */
                            event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
                            /**
                             * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
                             */
                            event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
                            /**
                             * @dev Returns the number of tokens in ``owner``'s account.
                             */
                            function balanceOf(address owner) external view returns (uint256 balance);
                            /**
                             * @dev Returns the owner of the `tokenId` token.
                             *
                             * Requirements:
                             *
                             * - `tokenId` must exist.
                             */
                            function ownerOf(uint256 tokenId) external view returns (address owner);
                            /**
                             * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
                             * are aware of the ERC721 protocol to prevent tokens from being forever locked.
                             *
                             * Requirements:
                             *
                             * - `from` cannot be the zero address.
                             * - `to` cannot be the zero address.
                             * - `tokenId` token must exist and be owned by `from`.
                             * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
                             * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                             *
                             * Emits a {Transfer} event.
                             */
                            function safeTransferFrom(address from, address to, uint256 tokenId) external;
                            /**
                             * @dev Transfers `tokenId` token from `from` to `to`.
                             *
                             * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
                             *
                             * Requirements:
                             *
                             * - `from` cannot be the zero address.
                             * - `to` cannot be the zero address.
                             * - `tokenId` token must be owned by `from`.
                             * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
                             *
                             * Emits a {Transfer} event.
                             */
                            function transferFrom(address from, address to, uint256 tokenId) external;
                            /**
                             * @dev Gives permission to `to` to transfer `tokenId` token to another account.
                             * The approval is cleared when the token is transferred.
                             *
                             * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
                             *
                             * Requirements:
                             *
                             * - The caller must own the token or be an approved operator.
                             * - `tokenId` must exist.
                             *
                             * Emits an {Approval} event.
                             */
                            function approve(address to, uint256 tokenId) external;
                            /**
                             * @dev Returns the account approved for `tokenId` token.
                             *
                             * Requirements:
                             *
                             * - `tokenId` must exist.
                             */
                            function getApproved(uint256 tokenId) external view returns (address operator);
                            /**
                             * @dev Approve or remove `operator` as an operator for the caller.
                             * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
                             *
                             * Requirements:
                             *
                             * - The `operator` cannot be the caller.
                             *
                             * Emits an {ApprovalForAll} event.
                             */
                            function setApprovalForAll(address operator, bool _approved) external;
                            /**
                             * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
                             *
                             * See {setApprovalForAll}
                             */
                            function isApprovedForAll(address owner, address operator) external view returns (bool);
                            /**
                              * @dev Safely transfers `tokenId` token from `from` to `to`.
                              *
                              * Requirements:
                              *
                              * - `from` cannot be the zero address.
                              * - `to` cannot be the zero address.
                              * - `tokenId` token must exist and be owned by `from`.
                              * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
                              * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                              *
                              * Emits a {Transfer} event.
                              */
                            function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./IERC721.sol";
                        /**
                         * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
                         * @dev See https://eips.ethereum.org/EIPS/eip-721
                         */
                        interface IERC721Metadata is IERC721 {
                            /**
                             * @dev Returns the token collection name.
                             */
                            function name() external view returns (string memory);
                            /**
                             * @dev Returns the token collection symbol.
                             */
                            function symbol() external view returns (string memory);
                            /**
                             * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
                             */
                            function tokenURI(uint256 tokenId) external view returns (string memory);
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./IERC721.sol";
                        /**
                         * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
                         * @dev See https://eips.ethereum.org/EIPS/eip-721
                         */
                        interface IERC721Enumerable is IERC721 {
                            /**
                             * @dev Returns the total amount of tokens stored by the contract.
                             */
                            function totalSupply() external view returns (uint256);
                            /**
                             * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
                             * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
                             */
                            function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
                            /**
                             * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
                             * Use along with {totalSupply} to enumerate all tokens.
                             */
                            function tokenByIndex(uint256 index) external view returns (uint256);
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @title ERC721 token receiver interface
                         * @dev Interface for any contract that wants to support safeTransfers
                         * from ERC721 asset contracts.
                         */
                        interface IERC721Receiver {
                            /**
                             * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
                             * by `operator` from `from`, this function is called.
                             *
                             * It must return its Solidity selector to confirm the token transfer.
                             * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
                             *
                             * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
                             */
                            function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "./IERC165.sol";
                        /**
                         * @dev Implementation of the {IERC165} interface.
                         *
                         * Contracts may inherit from this and call {_registerInterface} to declare
                         * their support of an interface.
                         */
                        abstract contract ERC165 is IERC165 {
                            /**
                             * @dev Mapping of interface ids to whether or not it's supported.
                             */
                            mapping(bytes4 => bool) private _supportedInterfaces;
                            constructor () {
                                // Derived contracts need only register support for their own interfaces,
                                // we register support for ERC165 itself here
                                _registerInterface(type(IERC165).interfaceId);
                            }
                            /**
                             * @dev See {IERC165-supportsInterface}.
                             *
                             * Time complexity O(1), guaranteed to always use less than 30 000 gas.
                             */
                            function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                                return _supportedInterfaces[interfaceId];
                            }
                            /**
                             * @dev Registers the contract as an implementer of the interface defined by
                             * `interfaceId`. Support of the actual ERC165 interface is automatic and
                             * registering its interface id is not required.
                             *
                             * See {IERC165-supportsInterface}.
                             *
                             * Requirements:
                             *
                             * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
                             */
                            function _registerInterface(bytes4 interfaceId) internal virtual {
                                require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
                                _supportedInterfaces[interfaceId] = true;
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^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.8.0;
                        /**
                         * @dev Library for managing
                         * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
                         * types.
                         *
                         * Sets have the following properties:
                         *
                         * - Elements are added, removed, and checked for existence in constant time
                         * (O(1)).
                         * - Elements are enumerated in O(n). No guarantees are made on the ordering.
                         *
                         * ```
                         * contract Example {
                         *     // Add the library methods
                         *     using EnumerableSet for EnumerableSet.AddressSet;
                         *
                         *     // Declare a set state variable
                         *     EnumerableSet.AddressSet private mySet;
                         * }
                         * ```
                         *
                         * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
                         * and `uint256` (`UintSet`) are supported.
                         */
                        library EnumerableSet {
                            // To implement this library for multiple types with as little code
                            // repetition as possible, we write it in terms of a generic Set type with
                            // bytes32 values.
                            // The Set implementation uses private functions, and user-facing
                            // implementations (such as AddressSet) are just wrappers around the
                            // underlying Set.
                            // This means that we can only create new EnumerableSets for types that fit
                            // in bytes32.
                            struct Set {
                                // Storage of set values
                                bytes32[] _values;
                                // Position of the value in the `values` array, plus 1 because index 0
                                // means a value is not in the set.
                                mapping (bytes32 => uint256) _indexes;
                            }
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function _add(Set storage set, bytes32 value) private returns (bool) {
                                if (!_contains(set, value)) {
                                    set._values.push(value);
                                    // The value is stored at length-1, but we add 1 to all indexes
                                    // and use 0 as a sentinel value
                                    set._indexes[value] = set._values.length;
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function _remove(Set storage set, bytes32 value) private returns (bool) {
                                // We read and store the value's index to prevent multiple reads from the same storage slot
                                uint256 valueIndex = set._indexes[value];
                                if (valueIndex != 0) { // Equivalent to contains(set, value)
                                    // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
                                    // the array, and then remove the last element (sometimes called as 'swap and pop').
                                    // This modifies the order of the array, as noted in {at}.
                                    uint256 toDeleteIndex = valueIndex - 1;
                                    uint256 lastIndex = set._values.length - 1;
                                    // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
                                    // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
                                    bytes32 lastvalue = set._values[lastIndex];
                                    // Move the last value to the index where the value to delete is
                                    set._values[toDeleteIndex] = lastvalue;
                                    // Update the index for the moved value
                                    set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
                                    // Delete the slot where the moved value was stored
                                    set._values.pop();
                                    // Delete the index for the deleted slot
                                    delete set._indexes[value];
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function _contains(Set storage set, bytes32 value) private view returns (bool) {
                                return set._indexes[value] != 0;
                            }
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function _length(Set storage set) private view returns (uint256) {
                                return set._values.length;
                            }
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function _at(Set storage set, uint256 index) private view returns (bytes32) {
                                require(set._values.length > index, "EnumerableSet: index out of bounds");
                                return set._values[index];
                            }
                            // Bytes32Set
                            struct Bytes32Set {
                                Set _inner;
                            }
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _add(set._inner, value);
                            }
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
                                return _remove(set._inner, value);
                            }
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
                                return _contains(set._inner, value);
                            }
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(Bytes32Set storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
                                return _at(set._inner, index);
                            }
                            // AddressSet
                            struct AddressSet {
                                Set _inner;
                            }
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(AddressSet storage set, address value) internal returns (bool) {
                                return _add(set._inner, bytes32(uint256(uint160(value))));
                            }
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(AddressSet storage set, address value) internal returns (bool) {
                                return _remove(set._inner, bytes32(uint256(uint160(value))));
                            }
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(AddressSet storage set, address value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(uint256(uint160(value))));
                            }
                            /**
                             * @dev Returns the number of values in the set. O(1).
                             */
                            function length(AddressSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(AddressSet storage set, uint256 index) internal view returns (address) {
                                return address(uint160(uint256(_at(set._inner, index))));
                            }
                            // UintSet
                            struct UintSet {
                                Set _inner;
                            }
                            /**
                             * @dev Add a value to a set. O(1).
                             *
                             * Returns true if the value was added to the set, that is if it was not
                             * already present.
                             */
                            function add(UintSet storage set, uint256 value) internal returns (bool) {
                                return _add(set._inner, bytes32(value));
                            }
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the value was removed from the set, that is if it was
                             * present.
                             */
                            function remove(UintSet storage set, uint256 value) internal returns (bool) {
                                return _remove(set._inner, bytes32(value));
                            }
                            /**
                             * @dev Returns true if the value is in the set. O(1).
                             */
                            function contains(UintSet storage set, uint256 value) internal view returns (bool) {
                                return _contains(set._inner, bytes32(value));
                            }
                            /**
                             * @dev Returns the number of values on the set. O(1).
                             */
                            function length(UintSet storage set) internal view returns (uint256) {
                                return _length(set._inner);
                            }
                           /**
                            * @dev Returns the value stored at position `index` in the set. O(1).
                            *
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(UintSet storage set, uint256 index) internal view returns (uint256) {
                                return uint256(_at(set._inner, index));
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @dev Library for managing an enumerable variant of Solidity's
                         * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
                         * type.
                         *
                         * Maps have the following properties:
                         *
                         * - Entries are added, removed, and checked for existence in constant time
                         * (O(1)).
                         * - Entries are enumerated in O(n). No guarantees are made on the ordering.
                         *
                         * ```
                         * contract Example {
                         *     // Add the library methods
                         *     using EnumerableMap for EnumerableMap.UintToAddressMap;
                         *
                         *     // Declare a set state variable
                         *     EnumerableMap.UintToAddressMap private myMap;
                         * }
                         * ```
                         *
                         * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
                         * supported.
                         */
                        library EnumerableMap {
                            // To implement this library for multiple types with as little code
                            // repetition as possible, we write it in terms of a generic Map type with
                            // bytes32 keys and values.
                            // The Map implementation uses private functions, and user-facing
                            // implementations (such as Uint256ToAddressMap) are just wrappers around
                            // the underlying Map.
                            // This means that we can only create new EnumerableMaps for types that fit
                            // in bytes32.
                            struct MapEntry {
                                bytes32 _key;
                                bytes32 _value;
                            }
                            struct Map {
                                // Storage of map keys and values
                                MapEntry[] _entries;
                                // Position of the entry defined by a key in the `entries` array, plus 1
                                // because index 0 means a key is not in the map.
                                mapping (bytes32 => uint256) _indexes;
                            }
                            /**
                             * @dev Adds a key-value pair to a map, or updates the value for an existing
                             * key. O(1).
                             *
                             * Returns true if the key was added to the map, that is if it was not
                             * already present.
                             */
                            function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
                                // We read and store the key's index to prevent multiple reads from the same storage slot
                                uint256 keyIndex = map._indexes[key];
                                if (keyIndex == 0) { // Equivalent to !contains(map, key)
                                    map._entries.push(MapEntry({ _key: key, _value: value }));
                                    // The entry is stored at length-1, but we add 1 to all indexes
                                    // and use 0 as a sentinel value
                                    map._indexes[key] = map._entries.length;
                                    return true;
                                } else {
                                    map._entries[keyIndex - 1]._value = value;
                                    return false;
                                }
                            }
                            /**
                             * @dev Removes a key-value pair from a map. O(1).
                             *
                             * Returns true if the key was removed from the map, that is if it was present.
                             */
                            function _remove(Map storage map, bytes32 key) private returns (bool) {
                                // We read and store the key's index to prevent multiple reads from the same storage slot
                                uint256 keyIndex = map._indexes[key];
                                if (keyIndex != 0) { // Equivalent to contains(map, key)
                                    // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
                                    // in the array, and then remove the last entry (sometimes called as 'swap and pop').
                                    // This modifies the order of the array, as noted in {at}.
                                    uint256 toDeleteIndex = keyIndex - 1;
                                    uint256 lastIndex = map._entries.length - 1;
                                    // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
                                    // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
                                    MapEntry storage lastEntry = map._entries[lastIndex];
                                    // Move the last entry to the index where the entry to delete is
                                    map._entries[toDeleteIndex] = lastEntry;
                                    // Update the index for the moved entry
                                    map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
                                    // Delete the slot where the moved entry was stored
                                    map._entries.pop();
                                    // Delete the index for the deleted slot
                                    delete map._indexes[key];
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                            /**
                             * @dev Returns true if the key is in the map. O(1).
                             */
                            function _contains(Map storage map, bytes32 key) private view returns (bool) {
                                return map._indexes[key] != 0;
                            }
                            /**
                             * @dev Returns the number of key-value pairs in the map. O(1).
                             */
                            function _length(Map storage map) private view returns (uint256) {
                                return map._entries.length;
                            }
                           /**
                            * @dev Returns the key-value pair stored at position `index` in the map. O(1).
                            *
                            * Note that there are no guarantees on the ordering of entries inside the
                            * array, and it may change when more entries are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
                                require(map._entries.length > index, "EnumerableMap: index out of bounds");
                                MapEntry storage entry = map._entries[index];
                                return (entry._key, entry._value);
                            }
                            /**
                             * @dev Tries to returns the value associated with `key`.  O(1).
                             * Does not revert if `key` is not in the map.
                             */
                            function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
                                uint256 keyIndex = map._indexes[key];
                                if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
                                return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
                            }
                            /**
                             * @dev Returns the value associated with `key`.  O(1).
                             *
                             * Requirements:
                             *
                             * - `key` must be in the map.
                             */
                            function _get(Map storage map, bytes32 key) private view returns (bytes32) {
                                uint256 keyIndex = map._indexes[key];
                                require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
                                return map._entries[keyIndex - 1]._value; // All indexes are 1-based
                            }
                            /**
                             * @dev Same as {_get}, with a custom error message when `key` is not in the map.
                             *
                             * CAUTION: This function is deprecated because it requires allocating memory for the error
                             * message unnecessarily. For custom revert reasons use {_tryGet}.
                             */
                            function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
                                uint256 keyIndex = map._indexes[key];
                                require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
                                return map._entries[keyIndex - 1]._value; // All indexes are 1-based
                            }
                            // UintToAddressMap
                            struct UintToAddressMap {
                                Map _inner;
                            }
                            /**
                             * @dev Adds a key-value pair to a map, or updates the value for an existing
                             * key. O(1).
                             *
                             * Returns true if the key was added to the map, that is if it was not
                             * already present.
                             */
                            function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
                                return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
                            }
                            /**
                             * @dev Removes a value from a set. O(1).
                             *
                             * Returns true if the key was removed from the map, that is if it was present.
                             */
                            function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
                                return _remove(map._inner, bytes32(key));
                            }
                            /**
                             * @dev Returns true if the key is in the map. O(1).
                             */
                            function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
                                return _contains(map._inner, bytes32(key));
                            }
                            /**
                             * @dev Returns the number of elements in the map. O(1).
                             */
                            function length(UintToAddressMap storage map) internal view returns (uint256) {
                                return _length(map._inner);
                            }
                           /**
                            * @dev Returns the element stored at position `index` in the set. O(1).
                            * Note that there are no guarantees on the ordering of values inside the
                            * array, and it may change when more values are added or removed.
                            *
                            * Requirements:
                            *
                            * - `index` must be strictly less than {length}.
                            */
                            function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
                                (bytes32 key, bytes32 value) = _at(map._inner, index);
                                return (uint256(key), address(uint160(uint256(value))));
                            }
                            /**
                             * @dev Tries to returns the value associated with `key`.  O(1).
                             * Does not revert if `key` is not in the map.
                             *
                             * _Available since v3.4._
                             */
                            function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
                                (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
                                return (success, address(uint160(uint256(value))));
                            }
                            /**
                             * @dev Returns the value associated with `key`.  O(1).
                             *
                             * Requirements:
                             *
                             * - `key` must be in the map.
                             */
                            function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
                                return address(uint160(uint256(_get(map._inner, bytes32(key)))));
                            }
                            /**
                             * @dev Same as {get}, with a custom error message when `key` is not in the map.
                             *
                             * CAUTION: This function is deprecated because it requires allocating memory for the error
                             * message unnecessarily. For custom revert reasons use {tryGet}.
                             */
                            function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
                                return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @dev String operations.
                         */
                        library Strings {
                            bytes16 private constant alphabet = "0123456789abcdef";
                            /**
                             * @dev Converts a `uint256` to its ASCII `string` decimal representation.
                             */
                            function toString(uint256 value) internal pure returns (string memory) {
                                // Inspired by OraclizeAPI's implementation - MIT licence
                                // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
                                if (value == 0) {
                                    return "0";
                                }
                                uint256 temp = value;
                                uint256 digits;
                                while (temp != 0) {
                                    digits++;
                                    temp /= 10;
                                }
                                bytes memory buffer = new bytes(digits);
                                while (value != 0) {
                                    digits -= 1;
                                    buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
                                    value /= 10;
                                }
                                return string(buffer);
                            }
                            /**
                             * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
                             */
                            function toHexString(uint256 value) internal pure returns (string memory) {
                                if (value == 0) {
                                    return "0x00";
                                }
                                uint256 temp = value;
                                uint256 length = 0;
                                while (temp != 0) {
                                    length++;
                                    temp >>= 8;
                                }
                                return toHexString(value, length);
                            }
                            /**
                             * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
                             */
                            function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
                                bytes memory buffer = new bytes(2 * length + 2);
                                buffer[0] = "0";
                                buffer[1] = "x";
                                for (uint256 i = 2 * length + 1; i > 1; --i) {
                                    buffer[i] = alphabet[value & 0xf];
                                    value >>= 4;
                                }
                                require(value == 0, "Strings: hex length insufficient");
                                return string(buffer);
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        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: MIT
                        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 () {
                                address msgSender = _msgSender();
                                _owner = msgSender;
                                emit OwnershipTransferred(address(0), msgSender);
                            }
                            /**
                             * @dev Returns the address of the current owner.
                             */
                            function owner() public view virtual returns (address) {
                                return _owner;
                            }
                            /**
                             * @dev Throws if called by any account other than the owner.
                             */
                            modifier onlyOwner() {
                                require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                _;
                            }
                            /**
                             * @dev Leaves the contract without owner. It will not be possible to call
                             * `onlyOwner` functions anymore. Can only be called by the current owner.
                             *
                             * NOTE: Renouncing ownership will leave the contract without an owner,
                             * thereby removing any functionality that is only available to the owner.
                             */
                            function renounceOwnership() public virtual onlyOwner {
                                emit OwnershipTransferred(_owner, address(0));
                                _owner = 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");
                                emit OwnershipTransferred(_owner, newOwner);
                                _owner = newOwner;
                            }
                        }
                        //SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        interface ISettings {
                            function maxAuctionLength() external returns(uint256);
                            function minAuctionLength() external returns(uint256);
                            function maxCuratorFee() external returns(uint256);
                            function governanceFee() external returns(uint256);
                            function minBidIncrease() external returns(uint256);
                            function minVotePercentage() external returns(uint256);
                            function maxReserveFactor() external returns(uint256);
                            function minReserveFactor() external returns(uint256);
                            function feeReceiver() external returns(address payable);
                        }// SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @title ERC721 token receiver interface
                         * @dev Interface for any contract that wants to support safeTransfers
                         * from ERC721 asset contracts.
                         */
                        interface IERC721ReceiverUpgradeable {
                            /**
                             * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
                             * by `operator` from `from`, this function is called.
                             *
                             * It must return its Solidity selector to confirm the token transfer.
                             * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
                             *
                             * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
                             */
                            function onERC721Received(
                                address operator,
                                address from,
                                uint256 tokenId,
                                bytes calldata data
                            ) external returns (bytes4);
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                         * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                         * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                         * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                         *
                         * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                         * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                         *
                         * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                         * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                         */
                        abstract contract Initializable {
                            /**
                             * @dev Indicates that the contract has been initialized.
                             */
                            bool private _initialized;
                            /**
                             * @dev Indicates that the contract is in the process of being initialized.
                             */
                            bool private _initializing;
                            /**
                             * @dev Modifier to protect an initializer function from being invoked twice.
                             */
                            modifier initializer() {
                                require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                bool isTopLevelCall = !_initializing;
                                if (isTopLevelCall) {
                                    _initializing = true;
                                    _initialized = true;
                                }
                                _;
                                if (isTopLevelCall) {
                                    _initializing = false;
                                }
                            }
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        /**
                         * @dev Interface of the ERC20 standard as defined in the EIP.
                         */
                        interface IERC20Upgradeable {
                            /**
                             * @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.8.0;
                        import "../IERC20Upgradeable.sol";
                        /**
                         * @dev Interface for the optional metadata functions from the ERC20 standard.
                         *
                         * _Available since v4.1._
                         */
                        interface IERC20MetadataUpgradeable is IERC20Upgradeable {
                            /**
                             * @dev Returns the name of the token.
                             */
                            function name() external view returns (string memory);
                            /**
                             * @dev Returns the symbol of the token.
                             */
                            function symbol() external view returns (string memory);
                            /**
                             * @dev Returns the decimals places of the token.
                             */
                            function decimals() external view returns (uint8);
                        }
                        // SPDX-License-Identifier: MIT
                        pragma solidity ^0.8.0;
                        import "../proxy/utils/Initializable.sol";
                        /*
                         * @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 ContextUpgradeable is Initializable {
                            function __Context_init() internal initializer {
                                __Context_init_unchained();
                            }
                            function __Context_init_unchained() internal initializer {
                            }
                            function _msgSender() internal view virtual returns (address) {
                                return msg.sender;
                            }
                            function _msgData() internal view virtual returns (bytes calldata) {
                                return msg.data;
                            }
                            uint256[50] private __gap;
                        }
                        

                        File 11 of 11: UniswapV2Router02
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Pair.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Pair {
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            function name() external pure returns (string memory);
                            function symbol() external pure returns (string memory);
                            function decimals() external pure returns (uint8);
                            function totalSupply() external view returns (uint);
                            function balanceOf(address owner) external view returns (uint);
                            function allowance(address owner, address spender) external view returns (uint);
                        
                            function approve(address spender, uint value) external returns (bool);
                            function transfer(address to, uint value) external returns (bool);
                            function transferFrom(address from, address to, uint value) external returns (bool);
                        
                            function DOMAIN_SEPARATOR() external view returns (bytes32);
                            function PERMIT_TYPEHASH() external pure returns (bytes32);
                            function nonces(address owner) external view returns (uint);
                        
                            function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
                        
                            event Mint(address indexed sender, uint amount0, uint amount1);
                            event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
                            event Swap(
                                address indexed sender,
                                uint amount0In,
                                uint amount1In,
                                uint amount0Out,
                                uint amount1Out,
                                address indexed to
                            );
                            event Sync(uint112 reserve0, uint112 reserve1);
                        
                            function MINIMUM_LIQUIDITY() external pure returns (uint);
                            function factory() external view returns (address);
                            function token0() external view returns (address);
                            function token1() external view returns (address);
                            function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
                            function price0CumulativeLast() external view returns (uint);
                            function price1CumulativeLast() external view returns (uint);
                            function kLast() external view returns (uint);
                        
                            function mint(address to) external returns (uint liquidity);
                            function burn(address to) external returns (uint amount0, uint amount1);
                            function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
                            function skim(address to) external;
                            function sync() external;
                        
                            function initialize(address, address) external;
                        }
                        
                        // File: contracts/uniswapv2/libraries/SafeMath.sol
                        
                        pragma solidity =0.6.12;
                        
                        // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
                        
                        library SafeMathUniswap {
                            function add(uint x, uint y) internal pure returns (uint z) {
                                require((z = x + y) >= x, 'ds-math-add-overflow');
                            }
                        
                            function sub(uint x, uint y) internal pure returns (uint z) {
                                require((z = x - y) <= x, 'ds-math-sub-underflow');
                            }
                        
                            function mul(uint x, uint y) internal pure returns (uint z) {
                                require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/UniswapV2Library.sol
                        
                        pragma solidity >=0.5.0;
                        
                        
                        
                        library UniswapV2Library {
                            using SafeMathUniswap for uint;
                        
                            // returns sorted token addresses, used to handle return values from pairs sorted in this order
                            function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
                                require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
                                (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
                                require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
                            }
                        
                            // calculates the CREATE2 address for a pair without making any external calls
                            function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
                                (address token0, address token1) = sortTokens(tokenA, tokenB);
                                pair = address(uint(keccak256(abi.encodePacked(
                                        hex'ff',
                                        factory,
                                        keccak256(abi.encodePacked(token0, token1)),
                                        hex'e18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303' // init code hash
                                    ))));
                            }
                        
                            // fetches and sorts the reserves for a pair
                            function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
                                (address token0,) = sortTokens(tokenA, tokenB);
                                (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
                                (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
                            }
                        
                            // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
                            function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
                                require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
                                require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
                                amountB = amountA.mul(reserveB) / reserveA;
                            }
                        
                            // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
                            function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
                                require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
                                require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
                                uint amountInWithFee = amountIn.mul(997);
                                uint numerator = amountInWithFee.mul(reserveOut);
                                uint denominator = reserveIn.mul(1000).add(amountInWithFee);
                                amountOut = numerator / denominator;
                            }
                        
                            // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
                            function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
                                require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
                                require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
                                uint numerator = reserveIn.mul(amountOut).mul(1000);
                                uint denominator = reserveOut.sub(amountOut).mul(997);
                                amountIn = (numerator / denominator).add(1);
                            }
                        
                            // performs chained getAmountOut calculations on any number of pairs
                            function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
                                require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
                                amounts = new uint[](path.length);
                                amounts[0] = amountIn;
                                for (uint i; i < path.length - 1; i++) {
                                    (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
                                    amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
                                }
                            }
                        
                            // performs chained getAmountIn calculations on any number of pairs
                            function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
                                require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
                                amounts = new uint[](path.length);
                                amounts[amounts.length - 1] = amountOut;
                                for (uint i = path.length - 1; i > 0; i--) {
                                    (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
                                    amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
                                }
                            }
                        }
                        
                        // File: contracts/uniswapv2/libraries/TransferHelper.sol
                        
                        // SPDX-License-Identifier: GPL-3.0-or-later
                        
                        pragma solidity >=0.6.0;
                        
                        // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
                        library TransferHelper {
                            function safeApprove(address token, address to, uint value) internal {
                                // bytes4(keccak256(bytes('approve(address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
                            }
                        
                            function safeTransfer(address token, address to, uint value) internal {
                                // bytes4(keccak256(bytes('transfer(address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');
                            }
                        
                            function safeTransferFrom(address token, address from, address to, uint value) internal {
                                // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
                                (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
                                require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
                            }
                        
                            function safeTransferETH(address to, uint value) internal {
                                (bool success,) = to.call{value:value}(new bytes(0));
                                require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
                            }
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Router01.sol
                        
                        pragma solidity >=0.6.2;
                        
                        interface IUniswapV2Router01 {
                            function factory() external pure returns (address);
                            function WETH() external pure returns (address);
                        
                            function addLiquidity(
                                address tokenA,
                                address tokenB,
                                uint amountADesired,
                                uint amountBDesired,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline
                            ) external returns (uint amountA, uint amountB, uint liquidity);
                            function addLiquidityETH(
                                address token,
                                uint amountTokenDesired,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
                            function removeLiquidity(
                                address tokenA,
                                address tokenB,
                                uint liquidity,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline
                            ) external returns (uint amountA, uint amountB);
                            function removeLiquidityETH(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) external returns (uint amountToken, uint amountETH);
                            function removeLiquidityWithPermit(
                                address tokenA,
                                address tokenB,
                                uint liquidity,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external returns (uint amountA, uint amountB);
                            function removeLiquidityETHWithPermit(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external returns (uint amountToken, uint amountETH);
                            function swapExactTokensForTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external returns (uint[] memory amounts);
                            function swapTokensForExactTokens(
                                uint amountOut,
                                uint amountInMax,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external returns (uint[] memory amounts);
                            function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
                                external
                                payable
                                returns (uint[] memory amounts);
                            function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
                                external
                                returns (uint[] memory amounts);
                            function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
                                external
                                returns (uint[] memory amounts);
                            function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
                                external
                                payable
                                returns (uint[] memory amounts);
                        
                            function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
                            function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
                            function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
                            function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
                            function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Router02.sol
                        
                        pragma solidity >=0.6.2;
                        
                        
                        interface IUniswapV2Router02 is IUniswapV2Router01 {
                            function removeLiquidityETHSupportingFeeOnTransferTokens(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) external returns (uint amountETH);
                            function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external returns (uint amountETH);
                        
                            function swapExactTokensForTokensSupportingFeeOnTransferTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external;
                            function swapExactETHForTokensSupportingFeeOnTransferTokens(
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external payable;
                            function swapExactTokensForETHSupportingFeeOnTransferTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external;
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IUniswapV2Factory.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IUniswapV2Factory {
                            event PairCreated(address indexed token0, address indexed token1, address pair, uint);
                        
                            function feeTo() external view returns (address);
                            function feeToSetter() external view returns (address);
                            function migrator() external view returns (address);
                        
                            function getPair(address tokenA, address tokenB) external view returns (address pair);
                            function allPairs(uint) external view returns (address pair);
                            function allPairsLength() external view returns (uint);
                        
                            function createPair(address tokenA, address tokenB) external returns (address pair);
                        
                            function setFeeTo(address) external;
                            function setFeeToSetter(address) external;
                            function setMigrator(address) external;
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IERC20.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IERC20Uniswap {
                            event Approval(address indexed owner, address indexed spender, uint value);
                            event Transfer(address indexed from, address indexed to, uint value);
                        
                            function name() external view returns (string memory);
                            function symbol() external view returns (string memory);
                            function decimals() external view returns (uint8);
                            function totalSupply() external view returns (uint);
                            function balanceOf(address owner) external view returns (uint);
                            function allowance(address owner, address spender) external view returns (uint);
                        
                            function approve(address spender, uint value) external returns (bool);
                            function transfer(address to, uint value) external returns (bool);
                            function transferFrom(address from, address to, uint value) external returns (bool);
                        }
                        
                        // File: contracts/uniswapv2/interfaces/IWETH.sol
                        
                        pragma solidity >=0.5.0;
                        
                        interface IWETH {
                            function deposit() external payable;
                            function transfer(address to, uint value) external returns (bool);
                            function withdraw(uint) external;
                        }
                        
                        // File: contracts/uniswapv2/UniswapV2Router02.sol
                        
                        pragma solidity =0.6.12;
                        
                        
                        
                        
                        
                        
                        
                        
                        contract UniswapV2Router02 is IUniswapV2Router02 {
                            using SafeMathUniswap for uint;
                        
                            address public immutable override factory;
                            address public immutable override WETH;
                        
                            modifier ensure(uint deadline) {
                                require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
                                _;
                            }
                        
                            constructor(address _factory, address _WETH) public {
                                factory = _factory;
                                WETH = _WETH;
                            }
                        
                            receive() external payable {
                                assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
                            }
                        
                            // **** ADD LIQUIDITY ****
                            function _addLiquidity(
                                address tokenA,
                                address tokenB,
                                uint amountADesired,
                                uint amountBDesired,
                                uint amountAMin,
                                uint amountBMin
                            ) internal virtual returns (uint amountA, uint amountB) {
                                // create the pair if it doesn't exist yet
                                if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
                                    IUniswapV2Factory(factory).createPair(tokenA, tokenB);
                                }
                                (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
                                if (reserveA == 0 && reserveB == 0) {
                                    (amountA, amountB) = (amountADesired, amountBDesired);
                                } else {
                                    uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
                                    if (amountBOptimal <= amountBDesired) {
                                        require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
                                        (amountA, amountB) = (amountADesired, amountBOptimal);
                                    } else {
                                        uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
                                        assert(amountAOptimal <= amountADesired);
                                        require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
                                        (amountA, amountB) = (amountAOptimal, amountBDesired);
                                    }
                                }
                            }
                            function addLiquidity(
                                address tokenA,
                                address tokenB,
                                uint amountADesired,
                                uint amountBDesired,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline
                            ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
                                (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
                                address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
                                TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
                                TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
                                liquidity = IUniswapV2Pair(pair).mint(to);
                            }
                            function addLiquidityETH(
                                address token,
                                uint amountTokenDesired,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
                                (amountToken, amountETH) = _addLiquidity(
                                    token,
                                    WETH,
                                    amountTokenDesired,
                                    msg.value,
                                    amountTokenMin,
                                    amountETHMin
                                );
                                address pair = UniswapV2Library.pairFor(factory, token, WETH);
                                TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
                                IWETH(WETH).deposit{value: amountETH}();
                                assert(IWETH(WETH).transfer(pair, amountETH));
                                liquidity = IUniswapV2Pair(pair).mint(to);
                                // refund dust eth, if any
                                if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
                            }
                        
                            // **** REMOVE LIQUIDITY ****
                            function removeLiquidity(
                                address tokenA,
                                address tokenB,
                                uint liquidity,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline
                            ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
                                address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
                                IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
                                (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
                                (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
                                (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
                                require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
                                require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
                            }
                            function removeLiquidityETH(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
                                (amountToken, amountETH) = removeLiquidity(
                                    token,
                                    WETH,
                                    liquidity,
                                    amountTokenMin,
                                    amountETHMin,
                                    address(this),
                                    deadline
                                );
                                TransferHelper.safeTransfer(token, to, amountToken);
                                IWETH(WETH).withdraw(amountETH);
                                TransferHelper.safeTransferETH(to, amountETH);
                            }
                            function removeLiquidityWithPermit(
                                address tokenA,
                                address tokenB,
                                uint liquidity,
                                uint amountAMin,
                                uint amountBMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external virtual override returns (uint amountA, uint amountB) {
                                address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
                                uint value = approveMax ? uint(-1) : liquidity;
                                IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
                                (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
                            }
                            function removeLiquidityETHWithPermit(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external virtual override returns (uint amountToken, uint amountETH) {
                                address pair = UniswapV2Library.pairFor(factory, token, WETH);
                                uint value = approveMax ? uint(-1) : liquidity;
                                IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
                                (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
                            }
                        
                            // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
                            function removeLiquidityETHSupportingFeeOnTransferTokens(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline
                            ) public virtual override ensure(deadline) returns (uint amountETH) {
                                (, amountETH) = removeLiquidity(
                                    token,
                                    WETH,
                                    liquidity,
                                    amountTokenMin,
                                    amountETHMin,
                                    address(this),
                                    deadline
                                );
                                TransferHelper.safeTransfer(token, to, IERC20Uniswap(token).balanceOf(address(this)));
                                IWETH(WETH).withdraw(amountETH);
                                TransferHelper.safeTransferETH(to, amountETH);
                            }
                            function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
                                address token,
                                uint liquidity,
                                uint amountTokenMin,
                                uint amountETHMin,
                                address to,
                                uint deadline,
                                bool approveMax, uint8 v, bytes32 r, bytes32 s
                            ) external virtual override returns (uint amountETH) {
                                address pair = UniswapV2Library.pairFor(factory, token, WETH);
                                uint value = approveMax ? uint(-1) : liquidity;
                                IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
                                amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
                                    token, liquidity, amountTokenMin, amountETHMin, to, deadline
                                );
                            }
                        
                            // **** SWAP ****
                            // requires the initial amount to have already been sent to the first pair
                            function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
                                for (uint i; i < path.length - 1; i++) {
                                    (address input, address output) = (path[i], path[i + 1]);
                                    (address token0,) = UniswapV2Library.sortTokens(input, output);
                                    uint amountOut = amounts[i + 1];
                                    (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
                                    address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
                                    IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
                                        amount0Out, amount1Out, to, new bytes(0)
                                    );
                                }
                            }
                            function swapExactTokensForTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external virtual override ensure(deadline) returns (uint[] memory amounts) {
                                amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
                                require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
                                );
                                _swap(amounts, path, to);
                            }
                            function swapTokensForExactTokens(
                                uint amountOut,
                                uint amountInMax,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external virtual override ensure(deadline) returns (uint[] memory amounts) {
                                amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
                                require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
                                );
                                _swap(amounts, path, to);
                            }
                            function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
                                external
                                virtual
                                override
                                payable
                                ensure(deadline)
                                returns (uint[] memory amounts)
                            {
                                require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
                                amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
                                require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
                                IWETH(WETH).deposit{value: amounts[0]}();
                                assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
                                _swap(amounts, path, to);
                            }
                            function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
                                external
                                virtual
                                override
                                ensure(deadline)
                                returns (uint[] memory amounts)
                            {
                                require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
                                amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
                                require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
                                );
                                _swap(amounts, path, address(this));
                                IWETH(WETH).withdraw(amounts[amounts.length - 1]);
                                TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
                            }
                            function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
                                external
                                virtual
                                override
                                ensure(deadline)
                                returns (uint[] memory amounts)
                            {
                                require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
                                amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
                                require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
                                );
                                _swap(amounts, path, address(this));
                                IWETH(WETH).withdraw(amounts[amounts.length - 1]);
                                TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
                            }
                            function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
                                external
                                virtual
                                override
                                payable
                                ensure(deadline)
                                returns (uint[] memory amounts)
                            {
                                require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
                                amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
                                require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
                                IWETH(WETH).deposit{value: amounts[0]}();
                                assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
                                _swap(amounts, path, to);
                                // refund dust eth, if any
                                if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
                            }
                        
                            // **** SWAP (supporting fee-on-transfer tokens) ****
                            // requires the initial amount to have already been sent to the first pair
                            function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
                                for (uint i; i < path.length - 1; i++) {
                                    (address input, address output) = (path[i], path[i + 1]);
                                    (address token0,) = UniswapV2Library.sortTokens(input, output);
                                    IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
                                    uint amountInput;
                                    uint amountOutput;
                                    { // scope to avoid stack too deep errors
                                    (uint reserve0, uint reserve1,) = pair.getReserves();
                                    (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
                                    amountInput = IERC20Uniswap(input).balanceOf(address(pair)).sub(reserveInput);
                                    amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
                                    }
                                    (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
                                    address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
                                    pair.swap(amount0Out, amount1Out, to, new bytes(0));
                                }
                            }
                            function swapExactTokensForTokensSupportingFeeOnTransferTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            ) external virtual override ensure(deadline) {
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
                                );
                                uint balanceBefore = IERC20Uniswap(path[path.length - 1]).balanceOf(to);
                                _swapSupportingFeeOnTransferTokens(path, to);
                                require(
                                    IERC20Uniswap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
                                    'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
                                );
                            }
                            function swapExactETHForTokensSupportingFeeOnTransferTokens(
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            )
                                external
                                virtual
                                override
                                payable
                                ensure(deadline)
                            {
                                require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
                                uint amountIn = msg.value;
                                IWETH(WETH).deposit{value: amountIn}();
                                assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
                                uint balanceBefore = IERC20Uniswap(path[path.length - 1]).balanceOf(to);
                                _swapSupportingFeeOnTransferTokens(path, to);
                                require(
                                    IERC20Uniswap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
                                    'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
                                );
                            }
                            function swapExactTokensForETHSupportingFeeOnTransferTokens(
                                uint amountIn,
                                uint amountOutMin,
                                address[] calldata path,
                                address to,
                                uint deadline
                            )
                                external
                                virtual
                                override
                                ensure(deadline)
                            {
                                require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
                                TransferHelper.safeTransferFrom(
                                    path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
                                );
                                _swapSupportingFeeOnTransferTokens(path, address(this));
                                uint amountOut = IERC20Uniswap(WETH).balanceOf(address(this));
                                require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
                                IWETH(WETH).withdraw(amountOut);
                                TransferHelper.safeTransferETH(to, amountOut);
                            }
                        
                            // **** LIBRARY FUNCTIONS ****
                            function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
                                return UniswapV2Library.quote(amountA, reserveA, reserveB);
                            }
                        
                            function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
                                public
                                pure
                                virtual
                                override
                                returns (uint amountOut)
                            {
                                return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
                            }
                        
                            function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
                                public
                                pure
                                virtual
                                override
                                returns (uint amountIn)
                            {
                                return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
                            }
                        
                            function getAmountsOut(uint amountIn, address[] memory path)
                                public
                                view
                                virtual
                                override
                                returns (uint[] memory amounts)
                            {
                                return UniswapV2Library.getAmountsOut(factory, amountIn, path);
                            }
                        
                            function getAmountsIn(uint amountOut, address[] memory path)
                                public
                                view
                                virtual
                                override
                                returns (uint[] memory amounts)
                            {
                                return UniswapV2Library.getAmountsIn(factory, amountOut, path);
                            }
                        }