Address Contract Verified
Address
0x10c203FbFA80Bb0855b615BA07Ae5d001DcF2c1E
Balance
0 ETH
Nonce
1
Code Size
23789 bytes
Creator
0x49053705...fEdF at tx 0x8955e8ad...ab13ad
Indexed Transactions
0
Contract Bytecode
23789 bytes
0x6080604052600436106103135760003560e01c8063853c75d811610198578063bb0b9830116100e0578063cc1301b21161008f578063e47ad74d1161006c578063e47ad74d146109c3578063f2fde38b146109e3578063f52a919814610a03578063f719413814610a2357005b8063cc1301b214610963578063e10639a014610983578063e134d8b9146109a357005b8063c0d0640e116100bd578063c0d0640e14610902578063c428176114610922578063c60853f61461094357005b8063bb0b983014610887578063bb684c1b146108b4578063bdc949d9146108e257005b80639b4faa8011610147578063ad5c464811610124578063ad5c4648146107f9578063b29a814014610827578063b479a96114610847578063b7f494a41461086757005b80639b4faa801461078b5780639c82f2a4146107ab5780639f18387e146107cb57005b806392ae12fd1161017557806392ae12fd1461070d57806393a013e01461073d578063994527e01461076b57005b8063853c75d81461069e57806389a7d1c2146106cc5780638da5cb5b146106e257005b80634f1ef2861161025b578063678edca31161020a578063715018a6116101e7578063715018a6146105ff57806373717b08146106145780637fae5637146106415780638456cb591461068957005b8063678edca31461059a5780636c8d1864146105ba578063700d85ae146105d157005b80635c195217116102385780635c195217146105425780635c975abb146105625780635f46e7401461057a57005b80634f1ef286146104fa57806352d1902d1461050d578063559b2f651461052257005b80632ee02d7c116102c25780633659cfe61161029f5780633659cfe6146104935780633f4ba83a146104b3578063479d3976146104c85780634f19f06a146104e357005b80632ee02d7c146104295780632f0b07e31461044957806332fe7b261461045e57005b806325de1092116102f057806325de1092146103cd5780632972b0f0146103f25780632ea023691461041257005b80630902f1ac1461031c5780630d0298021461034b57806320bfe3421461039d57005b3661031a57005b005b34801561032857600080fd5b50610331610a43565b604080519283526020830191909152015b60405180910390f35b34801561035757600080fd5b5060fb546103789073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610342565b3480156103a957600080fd5b506103bd6103b8366004614c6b565b610b59565b6040519015158152602001610342565b3480156103d957600080fd5b506103e46101075481565b604051908152602001610342565b3480156103fe57600080fd5b506103bd61040d366004614c6b565b610b9a565b34801561041e57600080fd5b506103e46101025481565b34801561043557600080fd5b5061031a610444366004614ce3565b610bad565b34801561045557600080fd5b5061031a610d96565b34801561046a57600080fd5b5061010354610378906301000000900473ffffffffffffffffffffffffffffffffffffffff1681565b34801561049f57600080fd5b5061031a6104ae366004614d90565b610ed6565b3480156104bf57600080fd5b5061031a6110a4565b3480156104d457600080fd5b50610103546103bd9060ff1681565b3480156104ef57600080fd5b506103e46101055481565b61031a610508366004614ec9565b6110b6565b34801561051957600080fd5b506103e4611278565b34801561052e57600080fd5b5061031a61053d366004614d90565b61134b565b34801561054e57600080fd5b506103e461055d366004614f19565b611435565b34801561056e57600080fd5b5060335460ff166103bd565b34801561058657600080fd5b5061031a610595366004614f74565b6114fd565b3480156105a657600080fd5b5061031a6105b5366004614f19565b611bf5565b3480156105c657600080fd5b506103e46101095481565b3480156105dd57600080fd5b50610108546103789073ffffffffffffffffffffffffffffffffffffffff1681565b34801561060b57600080fd5b5061031a611c33565b34801561062057600080fd5b5060fc546103789073ffffffffffffffffffffffffffffffffffffffff1681565b34801561064d57600080fd5b50610103546106779077010000000000000000000000000000000000000000000000900460ff1681565b60405160ff9091168152602001610342565b34801561069557600080fd5b5061031a611c45565b3480156106aa57600080fd5b50610100546103789073ffffffffffffffffffffffffffffffffffffffff1681565b3480156106d857600080fd5b50610105546103e4565b3480156106ee57600080fd5b5060655473ffffffffffffffffffffffffffffffffffffffff16610378565b34801561071957600080fd5b5061072d610728366004614f19565b611c55565b6040516103429493929190615055565b34801561074957600080fd5b50610104546103789073ffffffffffffffffffffffffffffffffffffffff1681565b34801561077757600080fd5b5061031a6107863660046150af565b611d27565b34801561079757600080fd5b506103e46107a6366004614f19565b611e46565b3480156107b757600080fd5b5061031a6107c6366004614d90565b611ec8565b3480156107d757600080fd5b50610101546103789073ffffffffffffffffffffffffffffffffffffffff1681565b34801561080557600080fd5b50610106546103789073ffffffffffffffffffffffffffffffffffffffff1681565b34801561083357600080fd5b5061031a610842366004614c6b565b611f44565b34801561085357600080fd5b5061031a610862366004614f19565b612159565b34801561087357600080fd5b5061031a610882366004614ce3565b61227c565b34801561089357600080fd5b5060fd546103789073ffffffffffffffffffffffffffffffffffffffff1681565b3480156108c057600080fd5b506108d46108cf3660046150fa565b612487565b604051610342929190615153565b3480156108ee57600080fd5b5061031a6108fd36600461517c565b6125ec565b34801561090e57600080fd5b5061031a61091d366004614f19565b612a45565b34801561092e57600080fd5b50610103546106779062010000900460ff1681565b34801561094f57600080fd5b5061031a61095e366004614d90565b612c47565b34801561096f57600080fd5b506101035461067790610100900460ff1681565b34801561098f57600080fd5b506103e461099e366004615245565b612d80565b3480156109af57600080fd5b5061031a6109be366004614f19565b613291565b3480156109cf57600080fd5b5061031a6109de366004614f19565b613483565b3480156109ef57600080fd5b5061031a6109fe366004614d90565b6135a6565b348015610a0f57600080fd5b5061072d610a1e3660046152b3565b613640565b348015610a2f57600080fd5b5061031a610a3e366004614d90565b613684565b60008060008061010460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610ab7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adb9190615306565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff169150600061010360179054906101000a900460ff1660ff16600114610b235782610b25565b815b9050600061010360179054906101000a900460ff1660ff16600114610b4a5782610b4c565b835b9196919550909350505050565b600081815260ff602052604081205473ffffffffffffffffffffffffffffffffffffffff90811690841603610b9057506001610b94565b5060005b92915050565b6000610ba68383610b59565b9392505050565b6101005473ffffffffffffffffffffffffffffffffffffffff163314610c1a5760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a656400000060448201526064015b60405180910390fd5b8460005b81811015610d8257838382818110610c3857610c38615342565b9050602002016020810190610c4d9190615371565b60ff60008a8a85818110610c6357610c63615342565b90506020020135815260200190815260200160002060020160006101000a81548161ffff021916908361ffff160217905550858582818110610ca757610ca7615342565b9050602002016020810190610cbc9190614d90565b60ff60008a8a85818110610cd257610cd2615342565b90506020020135815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600060ff60008a8a85818110610d4057610d40615342565b90506020020135815260200190815260200160002060020160026101000a81548160ff0219169083151502179055508080610d7a906153c4565b915050610c1e565b50610d8c88613733565b5050505050505050565b6101085473ffffffffffffffffffffffffffffffffffffffff163314610dfe5760405162461bcd60e51b815260206004820152601d60248201527f53656e646572206973206e6f74207377617070657220616464726573730000006044820152606401610c11565b6101095480610e755760405162461bcd60e51b815260206004820152602c60248201527f4e6f7468696e6720746f20737761702e20546865726520617265206e6f20726560448201527f696d62757273656d656e747300000000000000000000000000000000000000006064820152608401610c11565b6000610109556040518181527f5b6b431d4476a211bb7d41c20d1aab9ae2321deee0d20be3d9fc9b1093fa6e3d9060200160405180910390a161010154610ed39073ffffffffffffffffffffffffffffffffffffffff163383613af2565b50565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000010c203fbfa80bb0855b615ba07ae5d001dcf2c1e163003610f815760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c11565b7f00000000000000000000000010c203fbfa80bb0855b615ba07ae5d001dcf2c1e73ffffffffffffffffffffffffffffffffffffffff16610ff67f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461107f5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c11565b61108881613bcb565b60408051600080825260208201909252610ed391839190613bd3565b6110ac613d9e565b6110b4613e05565b565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000010c203fbfa80bb0855b615ba07ae5d001dcf2c1e1630036111615760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610c11565b7f00000000000000000000000010c203fbfa80bb0855b615ba07ae5d001dcf2c1e73ffffffffffffffffffffffffffffffffffffffff166111d67f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461125f5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610c11565b61126882613bcb565b61127482826001613bd3565b5050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000010c203fbfa80bb0855b615ba07ae5d001dcf2c1e16146113255760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c11565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b90565b6101005473ffffffffffffffffffffffffffffffffffffffff1633146113b35760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b61010080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040805133815260208101929092527fe1a25f463c6504824e91268b5b2c05658d5358c9c1698a85346cfae5336a642e91015b60405180910390a150565b6000806000611442610a43565b610103546040517f054d50d4000000000000000000000000000000000000000000000000000000008152600481018890526024810184905260448101839052929450909250600091630100000090910473ffffffffffffffffffffffffffffffffffffffff169063054d50d4906064015b602060405180830381865afa1580156114d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f491906153fc565b95945050505050565b611505613e82565b60fb548590879073ffffffffffffffffffffffffffffffffffffffff1633146115705760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b600081815260ff602052604090205473ffffffffffffffffffffffffffffffffffffffff8381169116146115e65760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b60008080806115f787890189615415565b610103549397509195509350915060009081906301000000900473ffffffffffffffffffffffffffffffffffffffff16158015906116c9575061010754610106546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c791906153fc565b105b1561178557610106546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa15801561173d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176191906153fc565b6101075461176f9190615478565b915081610107546117809190615478565b610107555b81156118255761179482611e46565b90508381111561180c5760405162461bcd60e51b815260206004820152602a60248201527f436f6d7075746564207265696d62757273656d656e74206973206f766572207460448201527f6865206d6178696d756d000000000000000000000000000000000000000000006064820152608401610c11565b80610109600082825461181f919061548b565b90915550505b6101035460ff1615611890576118608661183f8388615478565b6101015473ffffffffffffffffffffffffffffffffffffffff169190613af2565b801561188b576101015461188b9073ffffffffffffffffffffffffffffffffffffffff163083613af2565b6119f3565b6101015473ffffffffffffffffffffffffffffffffffffffff166340c10f19876118ba8489615478565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303816000875af115801561192a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194e919061549e565b5080156119f357610101546040517f40c10f190000000000000000000000000000000000000000000000000000000081523060048201526024810183905273ffffffffffffffffffffffffffffffffffffffff909116906340c10f19906044016020604051808303816000875af11580156119cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f1919061549e565b505b825115611b8d573063bb684c1b87611a0b8489615478565b866040518463ffffffff1660e01b8152600401611a2a939291906154bb565b6000604051808303816000875af1925050508015611a8857506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611a8591908101906154f0565b60015b611b1e577fbc9dddcf9dd73d2ce4918446fe862e01fccce8ff74defe3ecda14ddc0abd84bb604051611b11906020808252602a908201527f466174616c206661696c7572652063616c6c696e672064657374696e6174696f60408201527f6e20636f6e747261637400000000000000000000000000000000000000000000606082015260800190565b60405180910390a1611b8d565b8115611b52576040517f8878cc7f0850bc797105d520d7af207187058fad421a9c9c4769fc3b869579b790600090a1611b8a565b7fbc9dddcf9dd73d2ce4918446fe862e01fccce8ff74defe3ecda14ddc0abd84bb81604051611b819190615588565b60405180910390a15b50505b6040805173ffffffffffffffffffffffffffffffffffffffff88168152602081018790529081018290527fad25ff9cf50a5783db088c77a60f7cf418b08bf6e14f19f9b87b2be5d8cefd1c9060600160405180910390a1505050505050505050505050505050565b611bfd613d9e565b6101058190556040518181527f557809284da7314475b1582804ae28e5f1349efc1fe970ea25d50fce75eb4f439060200161142a565b611c3b613d9e565b6110b46000613ed5565b611c4d613d9e565b6110b4613f4c565b60ff602052600090815260409020805460018201805473ffffffffffffffffffffffffffffffffffffffff9092169291611c8e9061559b565b80601f0160208091040260200160405190810160405280929190818152602001828054611cba9061559b565b8015611d075780601f10611cdc57610100808354040283529160200191611d07565b820191906000526020600020905b815481529060010190602001808311611cea57829003601f168201915b5050506002909301549192505061ffff81169060ff620100009091041684565b611d2f613d9e565b610103805461010480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8681169182179092557fffffffffffffffff000000000000000000000000000000000000000000ffffff909216630100000087831681027fffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffff16919091177701000000000000000000000000000000000000000000000060ff87811682029290921795869055604080519387049094168352602083019490945292909304909116908201527fbbc1c6de389fe48066c8bce0d19bceaf5ec9544033f83f884a1b4a1bb12183ec9060600160405180910390a1505050565b6000806000611e53610a43565b610103546040517f85f8c259000000000000000000000000000000000000000000000000000000008152600481018890526024810184905260448101839052929450909250600091630100000090910473ffffffffffffffffffffffffffffffffffffffff16906385f8c259906064016114b3565b611ed0613d9e565b61010880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527faee2f119a9292f2087745b72e9a0b149ceb52503764bfcc4c40b04c97340a54e9060200161142a565b6101005473ffffffffffffffffffffffffffffffffffffffff163314611fac5760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b73ffffffffffffffffffffffffffffffffffffffff821661206557604051600090339083908381818185875af1925050503d8060008114612009576040519150601f19603f3d011682016040523d82523d6000602084013e61200e565b606091505b505090508061205f5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610c11565b506120fe565b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff83169063a9059cbb906044016020604051808303816000875af11580156120d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120fc919061549e565b505b6040805133815273ffffffffffffffffffffffffffffffffffffffff841660208201529081018290527f16a1412f01b73c390eb2548427101644aa86c1443c272f73df00fb74c48fe499906060015b60405180910390a15050565b6101005473ffffffffffffffffffffffffffffffffffffffff1633146121c15760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b60fb546040517fb479a9610000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063b479a96190602401600060405180830381600087803b15801561222d57600080fd5b505af1158015612241573d6000803e3d6000fd5b505060408051338152602081018590527f7b6bdf5a54b984bdb41e777eb126123085d57633ab56d408d9a1d39dd894e7bb935001905061142a565b6101005473ffffffffffffffffffffffffffffffffffffffff1633146122e45760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b8460005b81811015610d825783838281811061230257612302615342565b90506020020160208101906123179190615371565b60ff60008a8a8581811061232d5761232d615342565b90506020020135815260200190815260200160002060020160006101000a81548161ffff021916908361ffff16021790555085858281811061237157612371615342565b905060200281019061238391906155ee565b60ff60008b8b8681811061239957612399615342565b90506020020135815260200190815260200160002060010191826123be9291906156a1565b50600160ff60008a8a858181106123d7576123d7615342565b90506020020135815260200190815260200160002060020160026101000a81548160ff021916908315150217905550600160ff60008a8a8581811061241e5761241e615342565b90506020020135815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808061247f906153c4565b9150506122e8565b600060603330146124da5760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c7920696e7465726e616c2063616c6c7320616c6c6f77656400000000006044820152606401610c11565b6040517f877abb8400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86169063877abb849061252e90879087906004016157bc565b600060405180830381600087803b15801561254857600080fd5b505af1925050508015612559575060015b6125cf576125656157d5565b806308c379a00361258f57506125796157f0565b806125845750612591565b6000925090506125e4565b505b505060408051808201909152600d81527f666174616c206661696c7572650000000000000000000000000000000000000060208201526000906125e4565b50506040805160208101909152600081526001905b935093915050565b600054610100900460ff161580801561260c5750600054600160ff909116105b806126265750303b158015612626575060005460ff166001145b6126985760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610c11565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156126f657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6126fe613fa7565b61270661402c565b61270e6140b1565b73ffffffffffffffffffffffffffffffffffffffff82166127715760405162461bcd60e51b815260206004820152601e60248201527f5377617070657220616464726573732063616e6e6f74206265207a65726f00006044820152606401610c11565b61010180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8d169081179091556101028b905561010380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168b1515179055604080517f313ce567000000000000000000000000000000000000000000000000000000008152905163313ce567916004808201926020929091908290030181865afa15801561283c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128609190615898565b61010360016101000a81548160ff021916908360ff1602179055508761010360026101000a81548160ff021916908360ff1602179055508b61010060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508661010360036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508561010460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508461010360176101000a81548160ff021916908360ff160217905550836101058190555082610107819055508161010860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000610109819055508015612a3757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050505050565b612a4d613d9e565b60fb60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ade91906158b5565b61010680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905580612bc157610106546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015612b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bbc91906153fc565b612bc3565b805b6101078190556040519081527f29161820a2a44e6b089629305ba747e468d9c5a08774c1afa935954bf6e80bd69060200160405180910390a16101065460405173ffffffffffffffffffffffffffffffffffffffff90911681527f96c4d74012968c9d776349cff57ef97b61990a4aa61d6993479a5d8528994da49060200161142a565b6101005473ffffffffffffffffffffffffffffffffffffffff163314612caf5760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b60fb546040517fc60853f600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529091169063c60853f690602401600060405180830381600087803b158015612d1c57600080fd5b505af1158015612d30573d6000803e3d6000fd5b50506040805133815273ffffffffffffffffffffffffffffffffffffffff851660208201527f3785abad972484d82ebc033d8eb190737cd209b24e7f853dd622e415c3f537a2935001905061142a565b6000612d8a613e82565b73ffffffffffffffffffffffffffffffffffffffff8516612da9573394505b60fb54604080517f647846a5000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163647846a59160048083019260209291908290030181865afa158015612e19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3d91906158b5565b6101015490915073ffffffffffffffffffffffffffffffffffffffff808316911614612ed15760405162461bcd60e51b815260206004820152603660248201527f436f6e747261637420746f6b656e20646f65736e2774206d617463682063757260448201527f72656e74206d6573736167652066656520746f6b656e000000000000000000006064820152608401610c11565b60fb54610102546040517f82cbdacf00000000000000000000000000000000000000000000000000000000815260048101919091526000602482018190529173ffffffffffffffffffffffffffffffffffffffff16906382cbdacf90604401602060405180830381865afa158015612f4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f7191906153fc565b9050858110612fe85760405162461bcd60e51b815260206004820152602960248201527f416d6f756e7420746f2073656e6420646f65736e277420636f7665722074686560448201527f20626173652066656500000000000000000000000000000000000000000000006064820152608401610c11565b6000612ff46101055490565b905060006130028389615478565b6101035490985062010000810460ff90811661010090920416146130b0576130298861412e565b90508181116130a05760405162461bcd60e51b815260206004820152603260248201527f416d6f756e7420746f2073656e6420646f65736e277420636f7665722074686560448201527f20676173207265696d62757273656d656e7400000000000000000000000000006064820152608401610c11565b6130a981614174565b9750613128565b8188116131255760405162461bcd60e51b815260206004820152603260248201527f416d6f756e7420746f2073656e6420646f65736e277420636f7665722074686560448201527f20676173207265696d62757273656d656e7400000000000000000000000000006064820152608401610c11565b50865b6131593330613137868c61548b565b6101015473ffffffffffffffffffffffffffffffffffffffff169291906141a6565b6101035460ff166131ea57610101546040517f42966c68000000000000000000000000000000000000000000000000000000008152600481018a905273ffffffffffffffffffffffffffffffffffffffff909116906342966c6890602401600060405180830381600087803b1580156131d157600080fd5b505af11580156131e5573d6000803e3d6000fd5b505050505b6040805133815273ffffffffffffffffffffffffffffffffffffffff8b16602082015290810189905260608101829052608081018490527fc0587558e3b4c43f0e32e4a561605e5a3e4bcba7e8cd5a965be8a9878bbbb8859060a00160405180910390a1613282610102548a83858b8b60405160200161326e9594939291906158d2565b60405160208183030381529060405261420a565b9450505050505b949350505050565b6101085473ffffffffffffffffffffffffffffffffffffffff1633146132f95760405162461bcd60e51b815260206004820152601d60248201527f53656e646572206973206e6f74207377617070657220616464726573730000006044820152606401610c11565b61010954806133705760405162461bcd60e51b815260206004820152602c60248201527f4e6f7468696e6720746f20737761702e20546865726520617265206e6f20726560448201527f696d62757273656d656e747300000000000000000000000000000000000000006064820152608401610c11565b60006101095560408051828152602081018490527f015fc8ee969fd902d9ebd12a31c54446400a2b512a405366fe14defd6081d220910160405180910390a16133b981836143d3565b50610106546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015613429573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344d91906153fc565b6101078190556040519081527f29161820a2a44e6b089629305ba747e468d9c5a08774c1afa935954bf6e80bd69060200161214d565b6101005473ffffffffffffffffffffffffffffffffffffffff1633146134eb5760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b60fb546040517fe47ad74d0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063e47ad74d90602401600060405180830381600087803b15801561355757600080fd5b505af115801561356b573d6000803e3d6000fd5b505060408051338152602081018590527f83f76efc0c025b2e3779f7bcead5a89ddaf05dc7829157cdab021a8591e7a6f9935001905061142a565b6135ae613d9e565b73ffffffffffffffffffffffffffffffffffffffff81166136375760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c11565b610ed381613ed5565b60fe6020908152600092835260408084209091529082529020805460018201805473ffffffffffffffffffffffffffffffffffffffff9092169291611c8e9061559b565b6101005473ffffffffffffffffffffffffffffffffffffffff1633146136ec5760405162461bcd60e51b815260206004820152601d60248201527f4d657373616765436c69656e743a206e6f7420617574686f72697a65640000006044820152606401610c11565b60fd80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60fb80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155604080517f647846a5000000000000000000000000000000000000000000000000000000008152905163647846a5916004808201926020929091908290030181865afa1580156137ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ee91906158b5565b60fc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff929092169182179055156138f75760fc5460fb546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602482015291169063095ea7b3906044016020604051808303816000875af11580156138d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138f5919061549e565b505b60fb54604080517f3fc8cef3000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691633fc8cef39160048083019260209291908290030181865afa158015613967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061398b91906158b5565b73ffffffffffffffffffffffffffffffffffffffff1614610ed35760fb60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a3791906158b5565b60fb546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602482015291169063095ea7b3906044016020604051808303816000875af1158015613ace573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611274919061549e565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052613bc69084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614610565b505050565b610ed3613d9e565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613c0657613bc683614705565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613c8b575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613c88918101906153fc565b60015b613cfd5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610c11565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114613d925760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610c11565b50613bc68383836147f5565b60655473ffffffffffffffffffffffffffffffffffffffff1633146110b45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c11565b613e0d61481a565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b60335460ff16156110b45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610c11565b6065805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b613f54613e82565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613e583390565b600054610100900460ff166140245760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c11565b6110b461486c565b600054610100900460ff166140a95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c11565b6110b4614913565b600054610100900460ff166110b45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c11565b6101035460009061414890610100900460ff16600a615a6a565b610103546141609062010000900460ff16600a615a6a565b61416a9084615a79565b610b949190615a90565b6101035460009061418f9062010000900460ff16600a615a6a565b6101035461416090610100900460ff16600a615a6a565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526142049085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401613b44565b50505050565b600082815260ff60209081526040808320815160808101909252805473ffffffffffffffffffffffffffffffffffffffff1682526001810180548594840191906142539061559b565b80601f016020809104026020016040519081016040528092919081815260200182805461427f9061559b565b80156142cc5780601f106142a1576101008083540402835291602001916142cc565b820191906000526020600020905b8154815290600101906020018083116142af57829003601f168201915b50505091835250506002919091015461ffff8116602083015262010000900460ff16151560409091015260608101519091501561432c5782816020015160405160200161431a929190615acb565b60405160208183030381529060405292505b60fb54815160408084015190517ffdadc90c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263fdadc90c9261439092909189918991600090600401615af0565b6020604051808303816000875af11580156143af573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061328991906153fc565b6040805160028082526060808301845260009390929190602083019080368337505061010154825192935073ffffffffffffffffffffffffffffffffffffffff169183915060009061442757614427615342565b73ffffffffffffffffffffffffffffffffffffffff92831660209182029290920101526101065482519116908290600190811061446657614466615342565b73ffffffffffffffffffffffffffffffffffffffff928316602091820292909201015261010154610103546040517f095ea7b30000000000000000000000000000000000000000000000000000000081526301000000909104831660048201526024810187905291169063095ea7b3906044016020604051808303816000875af11580156144f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061451c919061549e565b50610103546040517f38ed17390000000000000000000000000000000000000000000000000000000081526000916301000000900473ffffffffffffffffffffffffffffffffffffffff16906338ed1739906145849088908890879030904290600401615b42565b6000604051808303816000875af11580156145a3573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526145e99190810190615bcd565b9050806001815181106145fe576145fe615342565b60200260200101519250505092915050565b6000614672826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166149999092919063ffffffff16565b9050805160001480614693575080806020019051810190614693919061549e565b613bc65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610c11565b73ffffffffffffffffffffffffffffffffffffffff81163b61478f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610c11565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6147fe836149a8565b60008251118061480b5750805b15613bc65761420483836149f5565b60335460ff166110b45760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610c11565b600054610100900460ff166148e95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c11565b603380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b600054610100900460ff166149905760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610c11565b6110b433613ed5565b60606132898484600085614a1a565b6149b181614705565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060610ba68383604051806060016040528060278152602001615c9160279139614b19565b606082471015614a925760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610c11565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051614abb9190615c74565b60006040518083038185875af1925050503d8060008114614af8576040519150601f19603f3d011682016040523d82523d6000602084013e614afd565b606091505b5091509150614b0e87838387614b9e565b979650505050505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff1685604051614b439190615c74565b600060405180830381855af49150503d8060008114614b7e576040519150601f19603f3d011682016040523d82523d6000602084013e614b83565b606091505b5091509150614b9486838387614b9e565b9695505050505050565b60608315614c1a578251600003614c135773ffffffffffffffffffffffffffffffffffffffff85163b614c135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c11565b5081613289565b6132898383815115614c2f5781518083602001fd5b8060405162461bcd60e51b8152600401610c119190615588565b73ffffffffffffffffffffffffffffffffffffffff81168114610ed357600080fd5b60008060408385031215614c7e57600080fd5b8235614c8981614c49565b946020939093013593505050565b60008083601f840112614ca957600080fd5b50813567ffffffffffffffff811115614cc157600080fd5b6020830191508360208260051b8501011115614cdc57600080fd5b9250929050565b60008060008060008060006080888a031215614cfe57600080fd5b8735614d0981614c49565b9650602088013567ffffffffffffffff80821115614d2657600080fd5b614d328b838c01614c97565b909850965060408a0135915080821115614d4b57600080fd5b614d578b838c01614c97565b909650945060608a0135915080821115614d7057600080fd5b50614d7d8a828b01614c97565b989b979a50959850939692959293505050565b600060208284031215614da257600080fd5b8135610ba681614c49565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116810181811067ffffffffffffffff82111715614e2057614e20614dad565b6040525050565b600067ffffffffffffffff821115614e4157614e41614dad565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112614e7e57600080fd5b8135614e8981614e27565b604051614e968282614ddc565b828152856020848701011115614eab57600080fd5b82602086016020830137600092810160200192909252509392505050565b60008060408385031215614edc57600080fd5b8235614ee781614c49565b9150602083013567ffffffffffffffff811115614f0357600080fd5b614f0f85828601614e6d565b9150509250929050565b600060208284031215614f2b57600080fd5b5035919050565b60008083601f840112614f4457600080fd5b50813567ffffffffffffffff811115614f5c57600080fd5b602083019150836020828501011115614cdc57600080fd5b600080600080600080600060c0888a031215614f8f57600080fd5b87359650602088013595506040880135614fa881614c49565b94506060880135614fb881614c49565b93506080880135925060a088013567ffffffffffffffff811115614fdb57600080fd5b614d7d8a828b01614f32565b60005b83811015615002578181015183820152602001614fea565b50506000910152565b60008151808452615023816020860160208601614fe7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff85168152608060208201526000615084608083018661500b565b61ffff9490941660408301525090151560609091015292915050565b60ff81168114610ed357600080fd5b6000806000606084860312156150c457600080fd5b83356150cf81614c49565b925060208401356150df81614c49565b915060408401356150ef816150a0565b809150509250925092565b60008060006060848603121561510f57600080fd5b833561511a81614c49565b925060208401359150604084013567ffffffffffffffff81111561513d57600080fd5b61514986828701614e6d565b9150509250925092565b8215158152604060208201526000613289604083018461500b565b8015158114610ed357600080fd5b60008060008060008060008060008060006101608c8e03121561519e57600080fd5b8b356151a981614c49565b9a5060208c01356151b981614c49565b995060408c0135985060608c01356151d08161516e565b975060808c01356151e0816150a0565b965060a08c01356151f081614c49565b955060c08c013561520081614c49565b945060e08c0135615210816150a0565b93506101008c013592506101208c013591506101408c013561523181614c49565b809150509295989b509295989b9093969950565b6000806000806060858703121561525b57600080fd5b843561526681614c49565b935060208501359250604085013567ffffffffffffffff81111561528957600080fd5b61529587828801614f32565b95989497509550505050565b63ffffffff81168114610ed357600080fd5b600080604083850312156152c657600080fd5b8235915060208301356152d8816152a1565b809150509250929050565b80516dffffffffffffffffffffffffffff8116811461530157600080fd5b919050565b60008060006060848603121561531b57600080fd5b615324846152e3565b9250615332602085016152e3565b915060408401516150ef816152a1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561538357600080fd5b813561ffff81168114610ba657600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036153f5576153f5615395565b5060010190565b60006020828403121561540e57600080fd5b5051919050565b6000806000806080858703121561542b57600080fd5b843561543681614c49565b93506020850135925060408501359150606085013567ffffffffffffffff81111561546057600080fd5b61546c87828801614e6d565b91505092959194509250565b81810381811115610b9457610b94615395565b80820180821115610b9457610b94615395565b6000602082840312156154b057600080fd5b8151610ba68161516e565b73ffffffffffffffffffffffffffffffffffffffff841681528260208201526060604082015260006114f4606083018461500b565b6000806040838503121561550357600080fd5b825161550e8161516e565b602084015190925067ffffffffffffffff81111561552b57600080fd5b8301601f8101851361553c57600080fd5b805161554781614e27565b6040516155548282614ddc565b82815287602084860101111561556957600080fd5b61557a836020830160208701614fe7565b809450505050509250929050565b602081526000610ba6602083018461500b565b600181811c908216806155af57607f821691505b6020821081036155e8577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261562357600080fd5b83018035915067ffffffffffffffff82111561563e57600080fd5b602001915036819003821315614cdc57600080fd5b601f821115613bc657600081815260208120601f850160051c8101602086101561567a5750805b601f850160051c820191505b8181101561569957828155600101615686565b505050505050565b67ffffffffffffffff8311156156b9576156b9614dad565b6156cd836156c7835461559b565b83615653565b6000601f84116001811461571f57600085156156e95750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b1783556157b5565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b8281101561576e578685013582556020948501946001909201910161574e565b50868210156157a9577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b828152604060208201526000613289604083018461500b565b600060033d11156113485760046000803e5060005160e01c90565b600060443d10156157fe5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff816024840111818411171561584c57505050505090565b82850191508151818111156158645750505050505090565b843d870101602082850101111561587e5750505050505090565b61588d60208286010187614ddc565b509095945050505050565b6000602082840312156158aa57600080fd5b8151610ba6816150a0565b6000602082840312156158c757600080fd5b8151610ba681614c49565b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015283604082015260806060820152816080820152818360a0830137600081830160a090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101949350505050565b600181815b808511156159a357817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561598957615989615395565b8085161561599657918102915b93841c939080029061594f565b509250929050565b6000826159ba57506001610b94565b816159c757506000610b94565b81600181146159dd57600281146159e757615a03565b6001915050610b94565b60ff8411156159f8576159f8615395565b50506001821b610b94565b5060208310610133831016604e8410600b8410161715615a26575081810a610b94565b615a30838361594a565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115615a6257615a62615395565b029392505050565b6000610ba660ff8416836159ab565b8082028115828204841417610b9457610b94615395565b600082615ac6577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b604081526000615ade604083018561500b565b82810360208401526114f4818561500b565b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015260a060408201526000615b2560a083018661500b565b61ffff949094166060830152509015156080909101529392505050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015615b9f57845173ffffffffffffffffffffffffffffffffffffffff1683529383019391830191600101615b6d565b505073ffffffffffffffffffffffffffffffffffffffff969096166060850152505050608001529392505050565b60006020808385031215615be057600080fd5b825167ffffffffffffffff80821115615bf857600080fd5b818501915085601f830112615c0c57600080fd5b815181811115615c1e57615c1e614dad565b8060051b9150604051615c3385840182614ddc565b81815291830184019184810188841115615c4c57600080fd5b938501935b83851015615c685784518152938501938501615c51565b50979650505050505050565b60008251615c86818460208701614fe7565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220733ea349473bcf879b4769f299c6eeb607d43da61e961353745c1dbc4d9a629f64736f6c63430008120033
Verified Source Code Full Match
Compiler: v0.8.18+commit.87f61d96
EVM: paris
Optimization: Yes (30000 runs)
IFiatToken.sol 11 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {IERC20Metadata} from "@openzeppelin/contracts-4/token/ERC20/extensions/IERC20Metadata.sol";
interface IFiatToken is IERC20Metadata {
function mint(address to, uint256 amount) external returns (bool);
function burn(uint256 amount) external;
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @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);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
OwnableUpgradeable.sol 95 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
draft-IERC1822Upgradeable.sol 20 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
IERC1967Upgradeable.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967Upgradeable {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
IBeaconUpgradeable.sol 16 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
ERC1967UpgradeUpgradeable.sol 170 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import {Initializable} from "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
Initializable.sol 166 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @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 proxied contracts do not make use of 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.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* 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.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
UUPSUpgradeable.sol 112 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
PausableUpgradeable.sol 117 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
AddressUpgradeable.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
ContextUpgradeable.sol 41 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../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 onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
StorageSlotUpgradeable.sol 138 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}
IERC20cl.sol 21 lines
// SPDX-License-Identifier: MIT // (c)2021-2024 Atlas // security-contact: [email protected] pragma solidity ^0.8.9; interface IERC20cl { 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); }
IMessageV3.sol 42 lines
// SPDX-License-Identifier: MIT // (c)2021-2024 Atlas // security-contact: [email protected] pragma solidity ^0.8.9; interface IMessageV3 { event SendRequested(uint txId, address sender, address recipient, uint chain, bool express, bytes data, uint16 confirmations); event SendProcessed(uint txId, uint sourceChainId, address sender, address recipient); event Success(uint txId, uint sourceChainId, address sender, address recipient, uint amount); event ErrorLog(uint txId, string message); event SetExsig(address caller, address signer); event SetMaxgas(address caller, uint maxGas); event SetMaxfee(address caller, uint maxFee); function chainsig() external view returns (address signer); function weth() external view returns (address wethTokenAddress); function feeToken() external view returns (address feeToken); function feeTokenDecimals() external view returns (uint feeTokenDecimals); function minFee() external view returns (uint minFee); function bridgeEnabled() external view returns (bool bridgeEnabled); function takeFeesOffline() external view returns (bool takeFeesOffline); function whitelistOnly() external view returns (bool whitelistOnly); function enabledChains(uint destChainId) external view returns (bool enabled); function customSourceFee(address caller) external view returns (uint customSourceFee); function maxgas(address caller) external view returns (uint maxgas); function exsig(address caller) external view returns (address signer); // @dev backwards compat with BridgeClient function minTokenForChain(uint chainId) external returns (uint amount); function sendMessage(address recipient, uint chain, bytes calldata data, uint16 confirmations, bool express) external returns (uint txId); // @dev backwards compat with BridgeClient function sendRequest(address recipient, uint chainId, uint amount, address referrer, bytes calldata data, uint16 confirmations) external returns (uint txId); function setExsig(address signer) external; function setMaxgas(uint maxgas) external; function setMaxfee(uint maxfee) external; function getSourceFee(uint _destChainId, bool _express) external view returns (uint _fee); }
MessageClient.sol 255 lines
// SPDX-License-Identifier: MIT // (c)2021-2024 Atlas // security-contact: [email protected] pragma solidity ^0.8.9; import "./IMessageV3.sol"; import "./IERC20cl.sol"; interface IFeature { function getPayload(uint _txId) external view returns (bytes memory); } interface IFeatureGateway { function isFeatureEnabled(uint32) external view returns (bool); function featureAddresses(uint32) external view returns (address); function messageV3() external view returns (IMessageV3); function processForward(uint _txId, uint _sourceChainId, uint _destChainId, address _sender, address _recipient, uint _gas, bytes[] calldata _data) external; function process(uint txId, uint sourceChainId, uint destChainId, address sender, address recipient, uint gas, uint32 featureId, bytes calldata featureReply, bytes[] calldata data) external; } /** * @title MessageV3 Client * @author Atlas <[email protected]> */ abstract contract MessageClient { IMessageV3 public MESSAGEv3; IERC20cl public FEE_TOKEN; IFeatureGateway public FEATURE_GATEWAY; mapping(uint => mapping(uint32 => ChainData)) public FEATURES; struct ChainData { address endpoint; // address of this contract on specified chain bytes endpointExtended; // address of this contract on non EVM uint16 confirmations; // source confirmations bool extended; // are we using extended endpoint? (addresses larger than uint256) } mapping(uint => ChainData) public CHAINS; address public MESSAGE_OWNER; modifier onlySelf(address _sender, uint _sourceChainId) { require(msg.sender == address(MESSAGEv3), "MessageClient: not authorized"); require(_sender == CHAINS[_sourceChainId].endpoint, "MessageClient: not authorized"); _; } modifier onlyActiveChain(uint _destinationChainId) { require(CHAINS[_destinationChainId].endpoint != address(0), "MessageClient: destination chain not active"); _; } modifier onlyMessageOwner() { require(msg.sender == MESSAGE_OWNER, "MessageClient: not authorized"); _; } event MessageOwnershipTransferred(address previousOwner, address newOwner); event RecoverToken(address owner, address token, uint amount); event SetMaxgas(address owner, uint maxGas); event SetMaxfee(address owner, uint maxfee); event SetExsig(address owner, address exsig); event SendMessageWithFeature(uint txId, uint destinationChainId, uint32 featureId, bytes featureData); constructor() { MESSAGE_OWNER = msg.sender; } function transferMessageOwnership(address _newMessageOwner) external onlyMessageOwner { MESSAGE_OWNER = _newMessageOwner; emit MessageOwnershipTransferred(msg.sender, _newMessageOwner); } /** BRIDGE RECEIVER */ // @dev DEPRICATED kept for backwards compatibility function messageProcess( uint _txId, // transaction id uint _sourceChainId, // source chain id address _sender, // corresponding MessageClient address on source chain address, uint, bytes calldata _data // encoded message from source chain ) external virtual onlySelf (_sender, _sourceChainId) { _processMessage(_txId, _sourceChainId, _data); } // @dev PREFERRED if no Features used // this is extended by the implementing class if not using Features function _processMessage(uint _txId, uint _sourceChainId, bytes calldata _data) internal virtual { (uint32 _featureId, bytes memory _featureData, bytes memory _messageData) = abi.decode(_data, (uint32, bytes, bytes)); // call the implementing class to process the message _processMessageWithFeature(_txId, _sourceChainId, _messageData, _featureId, _featureData, _getFeatureResponse(_featureId, _txId)); } // @dev REQUIRED if using Features // this is extended by the implementing class if using Features function _processMessageWithFeature( uint, // transaction id uint, // source chain id bytes memory, // encoded message from source chain uint32, // feature id bytes memory, // encoded feature data bytes memory // reply from feature processing off-chain ) internal virtual { revert("MessageClient: _processMessage or _processMessageWithFeature not implemented"); } function _getFeatureResponse(uint32 _featureId, uint _txId) internal view returns (bytes memory) { return IFeature(FEATURE_GATEWAY.featureAddresses(_featureId)).getPayload(_txId); } /** BRIDGE SENDER */ function _sendMessage(uint _destinationChainId, bytes memory _data) internal returns (uint _txId) { ChainData memory _chain = CHAINS[_destinationChainId]; if(_chain.extended) { // non-evm addresses larger than uint256 _data = abi.encode(_data, _chain.endpointExtended); } return IMessageV3(MESSAGEv3).sendMessage( _chain.endpoint, // corresponding MessageClient contract address on destination chain _destinationChainId, // id of the destination chain _data, // arbitrary data package to send _chain.confirmations, // amount of required transaction confirmations false // send express mode on destination ); } function _sendMessageExpress(uint _destinationChainId, bytes memory _data) internal returns (uint _txId) { ChainData memory _chain = CHAINS[_destinationChainId]; if(_chain.extended) { // non-evm addresses larger than uint256 _data = abi.encode(_data, _chain.endpointExtended); } return IMessageV3(MESSAGEv3).sendMessage( _chain.endpoint, // corresponding MessageV3Client contract address on destination chain _destinationChainId, // id of the destination chain _data, // arbitrary data package to send _chain.confirmations, // amount of required transaction confirmations true // send express mode on destination ); } function _sendMessageWithFeature(uint _destinationChainId, bytes memory _messageData, uint32 _featureId, bytes memory _featureData) internal returns (uint _txId) { require(FEATURE_GATEWAY.isFeatureEnabled(_featureId), "MessageClient: feature not enabled"); // wrap feature data into message data so it can be signed bytes memory _data = abi.encode(_featureId, _featureData, _messageData); ChainData memory _chain = CHAINS[_destinationChainId]; if(_chain.extended) { // non-evm addresses larger than uint256 _data = abi.encode(_data, _chain.endpointExtended); } _txId = IMessageV3(MESSAGEv3).sendMessage( _chain.endpoint, // corresponding MessageV3Client contract address on destination chain _destinationChainId, // id of the destination chain _data, // arbitrary data package to send _chain.confirmations, // amount of required transaction confirmations false // send express mode on destination ); // signal we have feature data included with the message data emit SendMessageWithFeature(_txId, _destinationChainId, _featureId, _featureData); } /** OWNER */ function configureClientExtended( address _messageV3, // MessageV3 bridge address uint[] calldata _chains, // list of chains to accept as valid destinations bytes[] calldata _endpoints, // list of corresponding MessageV3Client addresses on each chain uint16[] calldata _confirmations // confirmations required on each chain before processing ) external onlyMessageOwner { uint _chainsLength = _chains.length; for(uint x=0; x < _chainsLength; x++) { CHAINS[_chains[x]].confirmations = _confirmations[x]; CHAINS[_chains[x]].endpointExtended = _endpoints[x]; CHAINS[_chains[x]].extended = true; CHAINS[_chains[x]].endpoint = address(1); } _configureMessageV3(_messageV3); } function configureClient( address _messageV3, // MessageV3 bridge address uint[] calldata _chains, // list of chains to accept as valid destinations address[] calldata _endpoints, // list of corresponding MessageV3Client addresses on each chain uint16[] calldata _confirmations // confirmations required on each chain before processing ) public onlyMessageOwner { uint _chainsLength = _chains.length; for(uint x=0; x < _chainsLength; x++) { CHAINS[_chains[x]].confirmations = _confirmations[x]; CHAINS[_chains[x]].endpoint = _endpoints[x]; CHAINS[_chains[x]].extended = false; } _configureMessageV3(_messageV3); } function configureFeatureGateway(address _featureGateway) external onlyMessageOwner { FEATURE_GATEWAY = IFeatureGateway(_featureGateway); } function _configureMessageV3(address _messageV3) internal { MESSAGEv3 = IMessageV3(_messageV3); FEE_TOKEN = IERC20cl(MESSAGEv3.feeToken()); // approve bridge for source chain fees (limited per transaction with setMaxfee) if(address(FEE_TOKEN) != address(0)) { FEE_TOKEN.approve(address(MESSAGEv3), type(uint).max); } // approve bridge for destination gas fees (limited per transaction with setMaxgas) if(address(MESSAGEv3.weth()) != address(0)) { IERC20cl(MESSAGEv3.weth()).approve(address(MESSAGEv3), type(uint).max); } } function setExsig(address _signer) public onlyMessageOwner { MESSAGEv3.setExsig(_signer); emit SetExsig(msg.sender, _signer); } function setMaxgas(uint _maxGas) public onlyMessageOwner { MESSAGEv3.setMaxgas(_maxGas); emit SetMaxgas(msg.sender, _maxGas); } function setMaxfee(uint _maxFee) public onlyMessageOwner { MESSAGEv3.setMaxfee(_maxFee); emit SetMaxfee(msg.sender, _maxFee); } function recoverToken(address _token, uint _amount) public onlyMessageOwner { if(_token == address(0)) { // payable(msg.sender).transfer(_amount); // @note Zk needs (bool success, ) = payable(msg.sender).call{value: _amount}(""); require(success, "Transfer failed"); } else { IERC20cl(_token).transfer(msg.sender, _amount); } emit RecoverToken(msg.sender, _token, _amount); } function isSelf(address _sender, uint _sourceChainId) public view returns (bool) { if(_sender == CHAINS[_sourceChainId].endpoint) return true; return false; } function isAuthorized(address _sender, uint _sourceChainId) public view returns (bool) { return isSelf(_sender, _sourceChainId); } receive() external payable {} fallback() external payable {} }
BridgeManagerV1.sol 426 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts-4/token/ERC20/utils/SafeERC20.sol";
import {MessageClient} from "@vialabs/contracts/message/MessageClient.sol";
import {IFiatToken} from "./interfaces/IFiatToken.sol";
import {IUniswapV2Router02} from "./interfaces/IUniswapV2Router.sol";
import {IUniswapV2Pair} from "./interfaces/IUniswapV2Pair.sol";
import {IProcessPathwayMessage} from "./interfaces/IProcessPathwayMessage.sol";
/// @custom:security-contact [email protected]
contract BridgeManagerV1 is
Initializable,
PausableUpgradeable,
OwnableUpgradeable,
UUPSUpgradeable,
MessageClient
{
using SafeERC20 for IFiatToken;
IFiatToken public FIAT_TOKEN;
uint256 public DESTINATION_CHAIN_ID;
bool public IS_NATIVE;
uint8 public SOURCE_DECIMALS;
uint8 public DESTINATION_DECIMALS;
address public ROUTER;
uint8 public STABLE_INDEX;
address public LP_PAIR;
uint256 public DESTINATION_GAS_FEE; // @note Must be sent in DOLLAR value and with proper decimals
address public WETH;
uint256 public BASE_AMOUNT; // @note in WETH units to send to the contract
address public SWAPPER;
uint256 public REIMBURSEMENTS;
event Fee(uint256);
event Router(address, address, uint8);
event Weth(address);
event Base(uint256);
event Swapper(address);
event Swap(uint256, uint256);
event Withdraw(uint256);
event FiatTokenBridged(
address from,
address to,
uint256 amount,
uint256 bridgeAmount,
uint256 fee
);
event FiatTokenReceived(
address to,
uint256 amount,
uint256 computedReimbursementInUSD
);
event PathwayMessageProcessed();
event PathwayMessageFailed(string reason);
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
// @note lock the initialization of the contract
_disableInitializers();
}
modifier onlySwapper() {
require(msg.sender == SWAPPER, "Sender is not swapper address");
_;
}
// @note use initializer instead of constructor
function initialize(
address initialOwner,
address fiatToken_,
uint256 destinationChainId_,
bool isNative_,
uint8 destinationDecimals_,
address router_,
address pair_,
uint8 stableIndex_,
uint256 destGasFee_,
uint256 baseAmount_,
address swapperAddr_
) public initializer {
__Pausable_init();
__Ownable_init();
__UUPSUpgradeable_init();
require(swapperAddr_ != address(0), "Swapper address cannot be zero");
FIAT_TOKEN = IFiatToken(fiatToken_);
DESTINATION_CHAIN_ID = destinationChainId_;
IS_NATIVE = isNative_;
SOURCE_DECIMALS = FIAT_TOKEN.decimals();
DESTINATION_DECIMALS = destinationDecimals_;
MESSAGE_OWNER = initialOwner;
ROUTER = router_;
LP_PAIR = pair_;
STABLE_INDEX = stableIndex_;
DESTINATION_GAS_FEE = destGasFee_; // @note MUST use DESTINATION decimals
BASE_AMOUNT = baseAmount_; // @note Must use this chain WETH's decimals
SWAPPER = swapperAddr_;
REIMBURSEMENTS = 0;
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
// @note MUST use DESTINATION decimals
function setGasFee(uint256 fee) public onlyOwner {
// @note Must cover destination gas costs
DESTINATION_GAS_FEE = fee;
emit Fee(DESTINATION_GAS_FEE);
}
function setSwapper(address swapperAddr) public onlyOwner {
SWAPPER = swapperAddr;
emit Swapper(SWAPPER);
}
function swapGas(uint256 minAmountOutInWETH) public onlySwapper {
uint256 swapAmount = REIMBURSEMENTS;
require(swapAmount > 0, "Nothing to swap. There are no reimbursements");
// @note Reset the count
REIMBURSEMENTS = 0;
emit Swap(swapAmount, minAmountOutInWETH);
_swap(swapAmount, minAmountOutInWETH);
// @note onlySwapper, not owner, so no ability to set any specific value
BASE_AMOUNT = IERC20(WETH).balanceOf(address(this));
emit Base(BASE_AMOUNT);
}
function withdrawReimbursement() public onlySwapper {
uint256 withdrawAmount = REIMBURSEMENTS;
require(
withdrawAmount > 0,
"Nothing to swap. There are no reimbursements"
);
// @note Reset the count
REIMBURSEMENTS = 0;
emit Withdraw(withdrawAmount);
FIAT_TOKEN.safeTransfer(msg.sender, withdrawAmount);
}
// @note MUST use this chain's weth decimals
function setWeth(uint256 customBaseAmount) public onlyOwner {
WETH = MESSAGEv3.weth();
BASE_AMOUNT = customBaseAmount > 0
? customBaseAmount
: IERC20(WETH).balanceOf(address(this));
emit Base(BASE_AMOUNT);
emit Weth(WETH);
}
function getGasFee() public view returns (uint256) {
return DESTINATION_GAS_FEE;
}
function bridge(
address to,
uint256 amount,
bytes calldata data
) external whenNotPaused returns (uint256 txId) {
if (to == address(0)) to = msg.sender;
address feeToken = MESSAGEv3.feeToken();
require(
feeToken == address(FIAT_TOKEN),
"Contract token doesn't match current message fee token"
);
uint256 feeAmount = MESSAGEv3.getSourceFee(DESTINATION_CHAIN_ID, false);
require(
feeAmount < amount,
"Amount to send doesn't cover the base fee"
);
uint256 gasReimbursementInUSD = getGasFee();
uint256 bridgeAmount;
amount = amount - feeAmount;
if (DESTINATION_DECIMALS != SOURCE_DECIMALS) {
bridgeAmount = _convertDecimals(amount);
// @note gasReimbursementInUSD is already in destination format as far as decimals
require(
bridgeAmount > gasReimbursementInUSD,
"Amount to send doesn't cover the gas reimbursement"
);
// Convert back to avoid left-overs
amount = _convertDecimalsBack(bridgeAmount);
} else {
require(
amount > gasReimbursementInUSD,
"Amount to send doesn't cover the gas reimbursement"
);
bridgeAmount = amount;
}
FIAT_TOKEN.safeTransferFrom(
msg.sender,
address(this),
amount + feeAmount
); // @note Restores the original amount sent in the call data
if (!IS_NATIVE) {
FIAT_TOKEN.burn(amount);
}
emit FiatTokenBridged(msg.sender, to, amount, bridgeAmount, feeAmount);
return
_sendMessage(
DESTINATION_CHAIN_ID,
abi.encode(to, bridgeAmount, gasReimbursementInUSD, data)
);
}
function messageProcess(
uint256,
uint256 sourceChainId_,
address sender_,
address,
uint256,
bytes calldata data_
)
external
override(MessageClient)
whenNotPaused
onlySelf(sender_, sourceChainId_)
{
(
address to,
uint256 amount,
uint256 gasReimbursementInUSD,
bytes memory pathwayData
) = abi.decode(data_, (address, uint256, uint256, bytes));
uint256 wethToCollectBack = 0;
uint256 computedReimbursementInUSD = 0;
if (
ROUTER != address(0) &&
IERC20(WETH).balanceOf(address(this)) < BASE_AMOUNT
) {
wethToCollectBack =
BASE_AMOUNT -
IERC20(WETH).balanceOf(address(this));
BASE_AMOUNT = BASE_AMOUNT - wethToCollectBack;
}
// @note DOES NOT perform the swap
if (wethToCollectBack > 0) {
computedReimbursementInUSD = getAmountIn(wethToCollectBack);
require(
computedReimbursementInUSD <= gasReimbursementInUSD,
"Computed reimbursement is over the maximum"
);
REIMBURSEMENTS += computedReimbursementInUSD;
}
if (IS_NATIVE) {
FIAT_TOKEN.safeTransfer(to, amount - computedReimbursementInUSD);
if (computedReimbursementInUSD > 0) {
FIAT_TOKEN.safeTransfer(
address(this),
computedReimbursementInUSD
);
}
} else {
FIAT_TOKEN.mint(to, amount - computedReimbursementInUSD);
if (computedReimbursementInUSD > 0) {
FIAT_TOKEN.mint(address(this), computedReimbursementInUSD);
}
}
// USDC will be delivered to the recipient contract regardless of failure/revert state
if (pathwayData.length > 0) {
try
this._deliver(
to,
amount - computedReimbursementInUSD,
pathwayData
)
returns (bool success, string memory reason) {
if (success) {
emit PathwayMessageProcessed();
} else {
emit PathwayMessageFailed(reason);
}
} catch {
emit PathwayMessageFailed(
"Fatal failure calling destination contract"
);
}
}
emit FiatTokenReceived(to, amount, computedReimbursementInUSD);
}
function _deliver(
address to,
uint amount,
bytes memory pathwayData
) external returns (bool, string memory _reason) {
require(msg.sender == address(this), "Only internal calls allowed");
try
IProcessPathwayMessage(to)._processPathwayMessage(
amount,
pathwayData
)
{
return (true, "");
} catch Error(string memory reason) {
return (false, reason);
} catch {
return (false, "fatal failure");
}
}
function setRouter(
address router,
address pair,
uint8 stableIndex
) external onlyOwner {
ROUTER = router;
LP_PAIR = pair;
STABLE_INDEX = stableIndex;
emit Router(ROUTER, LP_PAIR, STABLE_INDEX);
}
function getReserves() public view returns (uint256, uint256) {
(uint256 _res0, uint256 _res1, ) = IUniswapV2Pair(LP_PAIR)
.getReserves();
uint256 usdReserve = STABLE_INDEX == 1 ? _res1 : _res0;
uint256 wethReserve = STABLE_INDEX == 1 ? _res0 : _res1;
return (usdReserve, wethReserve);
}
function getAmountIn(uint256 amountOut) public view returns (uint256) {
(uint256 usdReserve, uint256 wethReserve) = getReserves();
uint256 amountInMin = IUniswapV2Router02(ROUTER).getAmountIn(
amountOut,
usdReserve,
wethReserve
);
return amountInMin;
}
function getAmountOut(uint256 amountIn) public view returns (uint256) {
(uint256 usdReserve, uint256 wethReserve) = getReserves();
uint256 amountOutMin = IUniswapV2Router02(ROUTER).getAmountOut(
amountIn,
usdReserve,
wethReserve
);
return amountOutMin;
}
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {}
function _convertDecimals(uint256 amount) internal view returns (uint256) {
return
(amount * (10 ** DESTINATION_DECIMALS)) / (10 ** SOURCE_DECIMALS);
}
function _convertDecimalsBack(
uint256 amount
) internal view returns (uint256) {
return
(amount * (10 ** SOURCE_DECIMALS)) / (10 ** DESTINATION_DECIMALS);
}
function _swap(
uint256 amountIn,
uint256 amountOutMin
) internal returns (uint256) {
address[] memory path;
path = new address[](2);
path[0] = address(FIAT_TOKEN);
path[1] = address(WETH);
FIAT_TOKEN.approve(ROUTER, amountIn);
uint[] memory amounts = IUniswapV2Router02(ROUTER)
.swapExactTokensForTokens(
amountIn, // @note Amount to send in
amountOutMin, // @note amount OUT min when giving in amountIn
path, // @note path to take
address(this), // @note to
block.timestamp // @note deadline
);
return amounts[1];
}
}
IProcessPathwayMessage.sol 9 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
interface IProcessPathwayMessage {
function _processPathwayMessage(
uint256 amount,
bytes calldata data
) external;
}
IUniswapV2Pair.sol 58 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.5.0;
/**
* @title PaperDEX Liquidity Pair ERC20 Reciepts
* @author Atlas
* @author Uniswap Labs (original)
*/
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;
}
IUniswapV2Router.sol 135 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.2;
interface IUniswapV2Router02 {
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);
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;
}
Read Contract
BASE_AMOUNT 0x25de1092 → uint256
CHAINS 0x92ae12fd → address, bytes, uint16, bool
DESTINATION_CHAIN_ID 0x2ea02369 → uint256
DESTINATION_DECIMALS 0xc4281761 → uint8
DESTINATION_GAS_FEE 0x4f19f06a → uint256
FEATURES 0xf52a9198 → address, bytes, uint16, bool
FEATURE_GATEWAY 0xbb0b9830 → address
FEE_TOKEN 0x73717b08 → address
FIAT_TOKEN 0x9f18387e → address
IS_NATIVE 0x479d3976 → bool
LP_PAIR 0x93a013e0 → address
MESSAGE_OWNER 0x853c75d8 → address
MESSAGEv3 0x0d029802 → address
REIMBURSEMENTS 0x6c8d1864 → uint256
ROUTER 0x32fe7b26 → address
SOURCE_DECIMALS 0xcc1301b2 → uint8
STABLE_INDEX 0x7fae5637 → uint8
SWAPPER 0x700d85ae → address
WETH 0xad5c4648 → address
getAmountIn 0x9b4faa80 → uint256
getAmountOut 0x5c195217 → uint256
getGasFee 0x89a7d1c2 → uint256
getReserves 0x0902f1ac → uint256, uint256
isAuthorized 0x2972b0f0 → bool
isSelf 0x20bfe342 → bool
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
proxiableUUID 0x52d1902d → bytes32
Write Contract 24 functions
These functions modify contract state and require a wallet transaction to execute.
_deliver 0xbb684c1b
address to
uint256 amount
bytes pathwayData
returns: bool, string
bridge 0xe10639a0
address to
uint256 amount
bytes data
returns: uint256
configureClient 0x2ee02d7c
address _messageV3
uint256[] _chains
address[] _endpoints
uint16[] _confirmations
configureClientExtended 0xb7f494a4
address _messageV3
uint256[] _chains
bytes[] _endpoints
uint16[] _confirmations
configureFeatureGateway 0xf7194138
address _featureGateway
initialize 0xbdc949d9
address initialOwner
address fiatToken_
uint256 destinationChainId_
bool isNative_
uint8 destinationDecimals_
address router_
address pair_
uint8 stableIndex_
uint256 destGasFee_
uint256 baseAmount_
address swapperAddr_
messageProcess 0x5f46e740
uint256
uint256 sourceChainId_
address sender_
address
uint256
bytes data_
pause 0x8456cb59
No parameters
recoverToken 0xb29a8140
address _token
uint256 _amount
renounceOwnership 0x715018a6
No parameters
setExsig 0xc60853f6
address _signer
setGasFee 0x678edca3
uint256 fee
setMaxfee 0xb479a961
uint256 _maxFee
setMaxgas 0xe47ad74d
uint256 _maxGas
setRouter 0x994527e0
address router
address pair
uint8 stableIndex
setSwapper 0x9c82f2a4
address swapperAddr
setWeth 0xc0d0640e
uint256 customBaseAmount
swapGas 0xe134d8b9
uint256 minAmountOutInWETH
transferMessageOwnership 0x559b2f65
address _newMessageOwner
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
upgradeTo 0x3659cfe6
address newImplementation
upgradeToAndCall 0x4f1ef286
address newImplementation
bytes data
withdrawReimbursement 0x2f0b07e3
No parameters
Recent Transactions
No transactions found for this address