Search is not available for this dataset
chain_id
uint64 1
1
| block_number
uint64 19.5M
20M
| block_hash
stringlengths 64
64
| transaction_hash
stringlengths 64
64
| deployer_address
stringlengths 40
40
| factory_address
stringlengths 40
40
| contract_address
stringlengths 40
40
| creation_bytecode
stringlengths 0
98.3k
| runtime_bytecode
stringlengths 0
49.2k
| creation_sourcecode
stringlengths 0
976k
|
---|---|---|---|---|---|---|---|---|---|
1 | 19,500,304 |
775f8a058ca0a5c6532db8bf1ea99da0953839b773b1a6ff3fb3c5b8b2597dc9
|
c463a224f88cab8b28502ea05672b19aa20df7cfe2de39efc7d612f35b4f0f43
|
299e618ebc6a8c0f0a45a6f391d5eff7eecd0863
|
299e618ebc6a8c0f0a45a6f391d5eff7eecd0863
|
72e21fa7bd0aa38ad9e6dcdffddb30fbc60bc0a6
|
6080604052670de0b6b3a76400006000196200001c91906200070e565b6000196200002b919062000775565b600655600060085560016009556000600a556001600b55600a54600c55600b54600d55600c54600e55600d54600f557311b28c469c705a5f5714f7b367661708ce7f2380601260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507311b28c469c705a5f5714f7b367661708ce7f2380601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006015806101000a81548160ff0219169083151502179055506001601560166101000a81548160ff021916908315150217905550662386f26fc1000060165566470de4df8200006017556509184e72a0006018553480156200016657600080fd5b50600062000179620006a460201b60201c565b9050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350600654600260006200022e620006a460201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200033891906200081a565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003a0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003c691906200081a565b6040518363ffffffff1660e01b8152600401620003e59291906200085d565b6020604051808303816000875af115801562000405573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200042b91906200081a565b601560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016005600062000481620006ac60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600560003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600160056000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600160056000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506200062e620006a460201b60201c565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef670de0b6b3a76400006040516200069591906200089b565b60405180910390a350620008b8565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006200071b82620006d5565b91506200072883620006d5565b9250826200073b576200073a620006df565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006200078282620006d5565b91506200078f83620006d5565b9250828203905081811115620007aa57620007a962000746565b5b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620007e282620007b5565b9050919050565b620007f481620007d5565b81146200080057600080fd5b50565b6000815190506200081481620007e9565b92915050565b600060208284031215620008335762000832620007b0565b5b6000620008438482850162000803565b91505092915050565b6200085781620007d5565b82525050565b60006040820190506200087460008301856200084c565b6200088360208301846200084c565b9392505050565b6200089581620006d5565b82525050565b6000602082019050620008b260008301846200088a565b92915050565b61410d80620008c86000396000f3fe6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a2a957bb11610095578063c492f04611610064578063c492f0461461065c578063dd62ed3e14610685578063ea1644d5146106c2578063f2fde38b146106eb576101d7565b8063a2a957bb146105a2578063a9059cbb146105cb578063bfd7928414610608578063c3c8cd8014610645576101d7565b80638f70ccf7116100d15780638f70ccf7146104fa5780638f9a55c01461052357806395d89b411461054e57806398a5c31514610579576101d7565b80637d1db4a5146104675780637f2feddc146104925780638da5cb5b146104cf576101d7565b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec146103d357806370a08231146103ea578063715018a61461042757806374010ece1461043e576101d7565b8063313ce5671461032b57806349bd5a5e146103565780636b999053146103815780636d8aa8f8146103aa576101d7565b80631694505e116101ab5780631694505e1461026d57806318160ddd1461029857806323b872dd146102c35780632fd689e314610300576101d7565b8062b8cf2a146101dc57806306fdde0314610205578063095ea7b314610230576101d7565b366101d757005b600080fd5b3480156101e857600080fd5b5061020360048036038101906101fe9190612e95565b610714565b005b34801561021157600080fd5b5061021a61083e565b6040516102279190612f5d565b60405180910390f35b34801561023c57600080fd5b5061025760048036038101906102529190612fb5565b61087b565b6040516102649190613010565b60405180910390f35b34801561027957600080fd5b50610282610899565b60405161028f919061308a565b60405180910390f35b3480156102a457600080fd5b506102ad6108bf565b6040516102ba91906130b4565b60405180910390f35b3480156102cf57600080fd5b506102ea60048036038101906102e591906130cf565b6108cf565b6040516102f79190613010565b60405180910390f35b34801561030c57600080fd5b506103156109a8565b60405161032291906130b4565b60405180910390f35b34801561033757600080fd5b506103406109ae565b60405161034d919061313e565b60405180910390f35b34801561036257600080fd5b5061036b6109b7565b6040516103789190613168565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a39190613183565b6109dd565b005b3480156103b657600080fd5b506103d160048036038101906103cc91906131dc565b610acd565b005b3480156103df57600080fd5b506103e8610b7f565b005b3480156103f657600080fd5b50610411600480360381019061040c9190613183565b610c50565b60405161041e91906130b4565b60405180910390f35b34801561043357600080fd5b5061043c610ca1565b005b34801561044a57600080fd5b5061046560048036038101906104609190613209565b610df4565b005b34801561047357600080fd5b5061047c610e93565b60405161048991906130b4565b60405180910390f35b34801561049e57600080fd5b506104b960048036038101906104b49190613183565b610e99565b6040516104c691906130b4565b60405180910390f35b3480156104db57600080fd5b506104e4610eb1565b6040516104f19190613168565b60405180910390f35b34801561050657600080fd5b50610521600480360381019061051c91906131dc565b610eda565b005b34801561052f57600080fd5b50610538610f8c565b60405161054591906130b4565b60405180910390f35b34801561055a57600080fd5b50610563610f92565b6040516105709190612f5d565b60405180910390f35b34801561058557600080fd5b506105a0600480360381019061059b9190613209565b610fcf565b005b3480156105ae57600080fd5b506105c960048036038101906105c49190613236565b61106e565b005b3480156105d757600080fd5b506105f260048036038101906105ed9190612fb5565b611269565b6040516105ff9190613010565b60405180910390f35b34801561061457600080fd5b5061062f600480360381019061062a9190613183565b611287565b60405161063c9190613010565b60405180910390f35b34801561065157600080fd5b5061065a6112a7565b005b34801561066857600080fd5b50610683600480360381019061067e91906132f8565b611380565b005b34801561069157600080fd5b506106ac60048036038101906106a79190613358565b6114ba565b6040516106b991906130b4565b60405180910390f35b3480156106ce57600080fd5b506106e960048036038101906106e49190613209565b611541565b005b3480156106f757600080fd5b50610712600480360381019061070d9190613183565b6115e0565b005b61071c6117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a0906133e4565b60405180910390fd5b60005b815181101561083a576001601060008484815181106107ce576107cd613404565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061083290613462565b9150506107ac565b5050565b60606040518060400160405280601481526020017f41726e6f6c64205363687761727a656e69676761000000000000000000000000815250905090565b600061088f6108886117a1565b84846117a9565b6001905092915050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000670de0b6b3a7640000905090565b60006108dc848484611972565b61099d846108e86117a1565b610998856040518060600160405280602881526020016140b060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061094e6117a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121f59092919063ffffffff16565b6117a9565b600190509392505050565b60185481565b60006009905090565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e56117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a69906133e4565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610ad56117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b59906133e4565b60405180910390fd5b80601560166101000a81548160ff02191690831515021790555050565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610bc06117a1565b73ffffffffffffffffffffffffffffffffffffffff161480610c365750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610c1e6117a1565b73ffffffffffffffffffffffffffffffffffffffff16145b610c3f57600080fd5b6000479050610c4d81612259565b50565b6000610c9a600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122c5565b9050919050565b610ca96117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2d906133e4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610dfc6117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e80906133e4565b60405180910390fd5b8060168190555050565b60165481565b60116020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610ee26117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f66906133e4565b60405180910390fd5b80601560146101000a81548160ff02191690831515021790555050565b60175481565b60606040518060400160405280600b81526020017f5343485741524e49474741000000000000000000000000000000000000000000815250905090565b610fd76117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611064576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105b906133e4565b60405180910390fd5b8060188190555050565b6110766117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611103576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fa906133e4565b60405180910390fd5b60008410158015611115575060048411155b611154576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114b9061351c565b60405180910390fd5b60008210158015611166575060628211155b6111a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119c906135ae565b60405180910390fd5b600083101580156111b7575060048311155b6111f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ed90613640565b60405180910390fd5b60008110158015611208575060628111155b611247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123e906136d2565b60405180910390fd5b8360088190555082600a819055508160098190555080600b8190555050505050565b600061127d6112766117a1565b8484611972565b6001905092915050565b60106020528060005260406000206000915054906101000a900460ff1681565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166112e86117a1565b73ffffffffffffffffffffffffffffffffffffffff16148061135e5750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113466117a1565b73ffffffffffffffffffffffffffffffffffffffff16145b61136757600080fd5b600061137230610c50565b905061137d81612333565b50565b6113886117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611415576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140c906133e4565b60405180910390fd5b60005b838390508110156114b457816005600086868581811061143b5761143a613404565b5b90506020020160208101906114509190613183565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806114ac90613462565b915050611418565b50505050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6115496117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115cd906133e4565b60405180910390fd5b8060178190555050565b6115e86117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166c906133e4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036116e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116db90613764565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611818576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180f906137f6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611887576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187e90613888565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161196591906130b4565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036119e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119d89061391a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a47906139ac565b60405180910390fd5b60008111611a93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8a90613a3e565b60405180910390fd5b611a9b610eb1565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611b095750611ad9610eb1565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611ef457601560149054906101000a900460ff16611b9857611b2a610eb1565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611b97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8e90613ad0565b60405180910390fd5b5b601654811115611bdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd490613b3c565b60405180910390fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611c815750601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611cc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cb790613bce565b60405180910390fd5b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611d6d5760175481611d2284610c50565b611d2c9190613bee565b10611d6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6390613c94565b60405180910390fd5b5b6000611d7830610c50565b9050600060185482101590506016548210611d935760165491505b808015611dab575060158054906101000a900460ff16155b8015611e055750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015611e1d5750601560169054906101000a900460ff165b8015611e735750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611ec95750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611ef157611ed782612333565b60004790506000811115611eef57611eee47612259565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611f9b5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061204e5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415801561204d5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b1561205c57600090506121e3565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480156121075750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b1561211f57600854600c81905550600954600d819055505b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156121ca5750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b156121e257600a54600c81905550600b54600d819055505b5b6121ef848484846125aa565b50505050565b600083831115829061223d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122349190612f5d565b60405180910390fd5b506000838561224c9190613cb4565b9050809150509392505050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156122c1573d6000803e3d6000fd5b5050565b600060065482111561230c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230390613d5a565b60405180910390fd5b60006123166125d7565b905061232b818461260290919063ffffffff16565b915050919050565b60016015806101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561236a57612369612cf4565b5b6040519080825280602002602001820160405280156123985781602001602082028036833780820191505090505b50905030816000815181106123b0576123af613404565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247b9190613d8f565b8160018151811061248f5761248e613404565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506124f630601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846117a9565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161255a959493929190613eb5565b600060405180830381600087803b15801561257457600080fd5b505af1158015612588573d6000803e3d6000fd5b505050505060006015806101000a81548160ff02191690831515021790555050565b806125b8576125b761264c565b5b6125c3848484612689565b806125d1576125d0612854565b5b50505050565b60008060006125e4612868565b915091506125fb818361260290919063ffffffff16565b9250505090565b600061264483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506128c7565b905092915050565b6000600c5414801561266057506000600d54145b61268757600c54600e81905550600d54600f819055506000600c819055506000600d819055505b565b60008060008060008061269b8761292a565b9550955095509550955095506126f986600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461299290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061278e85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129dc90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127da81612a3a565b6127e48483612af7565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161284191906130b4565b60405180910390a3505050505050505050565b600e54600c81905550600f54600d81905550565b600080600060065490506000670de0b6b3a7640000905061289c670de0b6b3a764000060065461260290919063ffffffff16565b8210156128ba57600654670de0b6b3a76400009350935050506128c3565b81819350935050505b9091565b6000808311829061290e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129059190612f5d565b60405180910390fd5b506000838561291d9190613f3e565b9050809150509392505050565b60008060008060008060008060006129478a600c54600d54612b31565b92509250925060006129576125d7565b9050600080600061296a8e878787612bc7565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006129d483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506121f5565b905092915050565b60008082846129eb9190613bee565b905083811015612a30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2790613fbb565b60405180910390fd5b8091505092915050565b6000612a446125d7565b90506000612a5b8284612c5090919063ffffffff16565b9050612aaf81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129dc90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612b0c8260065461299290919063ffffffff16565b600681905550612b27816007546129dc90919063ffffffff16565b6007819055505050565b600080600080612b5d6064612b4f888a612c5090919063ffffffff16565b61260290919063ffffffff16565b90506000612b876064612b79888b612c5090919063ffffffff16565b61260290919063ffffffff16565b90506000612bb082612ba2858c61299290919063ffffffff16565b61299290919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612be08589612c5090919063ffffffff16565b90506000612bf78689612c5090919063ffffffff16565b90506000612c0e8789612c5090919063ffffffff16565b90506000612c3782612c29858761299290919063ffffffff16565b61299290919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808303612c625760009050612cc4565b60008284612c709190613fdb565b9050828482612c7f9190613f3e565b14612cbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cb69061408f565b60405180910390fd5b809150505b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d2c82612ce3565b810181811067ffffffffffffffff82111715612d4b57612d4a612cf4565b5b80604052505050565b6000612d5e612cca565b9050612d6a8282612d23565b919050565b600067ffffffffffffffff821115612d8a57612d89612cf4565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612dcb82612da0565b9050919050565b612ddb81612dc0565b8114612de657600080fd5b50565b600081359050612df881612dd2565b92915050565b6000612e11612e0c84612d6f565b612d54565b90508083825260208201905060208402830185811115612e3457612e33612d9b565b5b835b81811015612e5d5780612e498882612de9565b845260208401935050602081019050612e36565b5050509392505050565b600082601f830112612e7c57612e7b612cde565b5b8135612e8c848260208601612dfe565b91505092915050565b600060208284031215612eab57612eaa612cd4565b5b600082013567ffffffffffffffff811115612ec957612ec8612cd9565b5b612ed584828501612e67565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612f18578082015181840152602081019050612efd565b60008484015250505050565b6000612f2f82612ede565b612f398185612ee9565b9350612f49818560208601612efa565b612f5281612ce3565b840191505092915050565b60006020820190508181036000830152612f778184612f24565b905092915050565b6000819050919050565b612f9281612f7f565b8114612f9d57600080fd5b50565b600081359050612faf81612f89565b92915050565b60008060408385031215612fcc57612fcb612cd4565b5b6000612fda85828601612de9565b9250506020612feb85828601612fa0565b9150509250929050565b60008115159050919050565b61300a81612ff5565b82525050565b60006020820190506130256000830184613001565b92915050565b6000819050919050565b600061305061304b61304684612da0565b61302b565b612da0565b9050919050565b600061306282613035565b9050919050565b600061307482613057565b9050919050565b61308481613069565b82525050565b600060208201905061309f600083018461307b565b92915050565b6130ae81612f7f565b82525050565b60006020820190506130c960008301846130a5565b92915050565b6000806000606084860312156130e8576130e7612cd4565b5b60006130f686828701612de9565b935050602061310786828701612de9565b925050604061311886828701612fa0565b9150509250925092565b600060ff82169050919050565b61313881613122565b82525050565b6000602082019050613153600083018461312f565b92915050565b61316281612dc0565b82525050565b600060208201905061317d6000830184613159565b92915050565b60006020828403121561319957613198612cd4565b5b60006131a784828501612de9565b91505092915050565b6131b981612ff5565b81146131c457600080fd5b50565b6000813590506131d6816131b0565b92915050565b6000602082840312156131f2576131f1612cd4565b5b6000613200848285016131c7565b91505092915050565b60006020828403121561321f5761321e612cd4565b5b600061322d84828501612fa0565b91505092915050565b600080600080608085870312156132505761324f612cd4565b5b600061325e87828801612fa0565b945050602061326f87828801612fa0565b935050604061328087828801612fa0565b925050606061329187828801612fa0565b91505092959194509250565b600080fd5b60008083601f8401126132b8576132b7612cde565b5b8235905067ffffffffffffffff8111156132d5576132d461329d565b5b6020830191508360208202830111156132f1576132f0612d9b565b5b9250929050565b60008060006040848603121561331157613310612cd4565b5b600084013567ffffffffffffffff81111561332f5761332e612cd9565b5b61333b868287016132a2565b9350935050602061334e868287016131c7565b9150509250925092565b6000806040838503121561336f5761336e612cd4565b5b600061337d85828601612de9565b925050602061338e85828601612de9565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006133ce602083612ee9565b91506133d982613398565b602082019050919050565b600060208201905081810360008301526133fd816133c1565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061346d82612f7f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361349f5761349e613433565b5b600182019050919050565b7f4275792072657761726473206d757374206265206265747765656e203025206160008201527f6e64203425000000000000000000000000000000000000000000000000000000602082015250565b6000613506602583612ee9565b9150613511826134aa565b604082019050919050565b60006020820190508181036000830152613535816134f9565b9050919050565b7f42757920746178206d757374206265206265747765656e20302520616e64203960008201527f3825000000000000000000000000000000000000000000000000000000000000602082015250565b6000613598602283612ee9565b91506135a38261353c565b604082019050919050565b600060208201905081810360008301526135c78161358b565b9050919050565b7f53656c6c2072657761726473206d757374206265206265747765656e2030252060008201527f616e642034250000000000000000000000000000000000000000000000000000602082015250565b600061362a602683612ee9565b9150613635826135ce565b604082019050919050565b600060208201905081810360008301526136598161361d565b9050919050565b7f53656c6c20746178206d757374206265206265747765656e20302520616e642060008201527f3938250000000000000000000000000000000000000000000000000000000000602082015250565b60006136bc602383612ee9565b91506136c782613660565b604082019050919050565b600060208201905081810360008301526136eb816136af565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061374e602683612ee9565b9150613759826136f2565b604082019050919050565b6000602082019050818103600083015261377d81613741565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006137e0602483612ee9565b91506137eb82613784565b604082019050919050565b6000602082019050818103600083015261380f816137d3565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000613872602283612ee9565b915061387d82613816565b604082019050919050565b600060208201905081810360008301526138a181613865565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000613904602583612ee9565b915061390f826138a8565b604082019050919050565b60006020820190508181036000830152613933816138f7565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000613996602383612ee9565b91506139a18261393a565b604082019050919050565b600060208201905081810360008301526139c581613989565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000613a28602983612ee9565b9150613a33826139cc565b604082019050919050565b60006020820190508181036000830152613a5781613a1b565b9050919050565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b6000613aba603f83612ee9565b9150613ac582613a5e565b604082019050919050565b60006020820190508181036000830152613ae981613aad565b9050919050565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b6000613b26601c83612ee9565b9150613b3182613af0565b602082019050919050565b60006020820190508181036000830152613b5581613b19565b9050919050565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b6000613bb8602383612ee9565b9150613bc382613b5c565b604082019050919050565b60006020820190508181036000830152613be781613bab565b9050919050565b6000613bf982612f7f565b9150613c0483612f7f565b9250828201905080821115613c1c57613c1b613433565b5b92915050565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b6000613c7e602383612ee9565b9150613c8982613c22565b604082019050919050565b60006020820190508181036000830152613cad81613c71565b9050919050565b6000613cbf82612f7f565b9150613cca83612f7f565b9250828203905081811115613ce257613ce1613433565b5b92915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b6000613d44602a83612ee9565b9150613d4f82613ce8565b604082019050919050565b60006020820190508181036000830152613d7381613d37565b9050919050565b600081519050613d8981612dd2565b92915050565b600060208284031215613da557613da4612cd4565b5b6000613db384828501613d7a565b91505092915050565b6000819050919050565b6000613de1613ddc613dd784613dbc565b61302b565b612f7f565b9050919050565b613df181613dc6565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613e2c81612dc0565b82525050565b6000613e3e8383613e23565b60208301905092915050565b6000602082019050919050565b6000613e6282613df7565b613e6c8185613e02565b9350613e7783613e13565b8060005b83811015613ea8578151613e8f8882613e32565b9750613e9a83613e4a565b925050600181019050613e7b565b5085935050505092915050565b600060a082019050613eca60008301886130a5565b613ed76020830187613de8565b8181036040830152613ee98186613e57565b9050613ef86060830185613159565b613f0560808301846130a5565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613f4982612f7f565b9150613f5483612f7f565b925082613f6457613f63613f0f565b5b828204905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b6000613fa5601b83612ee9565b9150613fb082613f6f565b602082019050919050565b60006020820190508181036000830152613fd481613f98565b9050919050565b6000613fe682612f7f565b9150613ff183612f7f565b9250828202613fff81612f7f565b9150828204841483151761401657614015613433565b5b5092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000614079602183612ee9565b91506140848261401d565b604082019050919050565b600060208201905081810360008301526140a88161406c565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122088ed9557cea7f20ec2441bd1b126d874ba4d580ad656c99393824255a780ffa764736f6c63430008120033
|
6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a2a957bb11610095578063c492f04611610064578063c492f0461461065c578063dd62ed3e14610685578063ea1644d5146106c2578063f2fde38b146106eb576101d7565b8063a2a957bb146105a2578063a9059cbb146105cb578063bfd7928414610608578063c3c8cd8014610645576101d7565b80638f70ccf7116100d15780638f70ccf7146104fa5780638f9a55c01461052357806395d89b411461054e57806398a5c31514610579576101d7565b80637d1db4a5146104675780637f2feddc146104925780638da5cb5b146104cf576101d7565b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec146103d357806370a08231146103ea578063715018a61461042757806374010ece1461043e576101d7565b8063313ce5671461032b57806349bd5a5e146103565780636b999053146103815780636d8aa8f8146103aa576101d7565b80631694505e116101ab5780631694505e1461026d57806318160ddd1461029857806323b872dd146102c35780632fd689e314610300576101d7565b8062b8cf2a146101dc57806306fdde0314610205578063095ea7b314610230576101d7565b366101d757005b600080fd5b3480156101e857600080fd5b5061020360048036038101906101fe9190612e95565b610714565b005b34801561021157600080fd5b5061021a61083e565b6040516102279190612f5d565b60405180910390f35b34801561023c57600080fd5b5061025760048036038101906102529190612fb5565b61087b565b6040516102649190613010565b60405180910390f35b34801561027957600080fd5b50610282610899565b60405161028f919061308a565b60405180910390f35b3480156102a457600080fd5b506102ad6108bf565b6040516102ba91906130b4565b60405180910390f35b3480156102cf57600080fd5b506102ea60048036038101906102e591906130cf565b6108cf565b6040516102f79190613010565b60405180910390f35b34801561030c57600080fd5b506103156109a8565b60405161032291906130b4565b60405180910390f35b34801561033757600080fd5b506103406109ae565b60405161034d919061313e565b60405180910390f35b34801561036257600080fd5b5061036b6109b7565b6040516103789190613168565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a39190613183565b6109dd565b005b3480156103b657600080fd5b506103d160048036038101906103cc91906131dc565b610acd565b005b3480156103df57600080fd5b506103e8610b7f565b005b3480156103f657600080fd5b50610411600480360381019061040c9190613183565b610c50565b60405161041e91906130b4565b60405180910390f35b34801561043357600080fd5b5061043c610ca1565b005b34801561044a57600080fd5b5061046560048036038101906104609190613209565b610df4565b005b34801561047357600080fd5b5061047c610e93565b60405161048991906130b4565b60405180910390f35b34801561049e57600080fd5b506104b960048036038101906104b49190613183565b610e99565b6040516104c691906130b4565b60405180910390f35b3480156104db57600080fd5b506104e4610eb1565b6040516104f19190613168565b60405180910390f35b34801561050657600080fd5b50610521600480360381019061051c91906131dc565b610eda565b005b34801561052f57600080fd5b50610538610f8c565b60405161054591906130b4565b60405180910390f35b34801561055a57600080fd5b50610563610f92565b6040516105709190612f5d565b60405180910390f35b34801561058557600080fd5b506105a0600480360381019061059b9190613209565b610fcf565b005b3480156105ae57600080fd5b506105c960048036038101906105c49190613236565b61106e565b005b3480156105d757600080fd5b506105f260048036038101906105ed9190612fb5565b611269565b6040516105ff9190613010565b60405180910390f35b34801561061457600080fd5b5061062f600480360381019061062a9190613183565b611287565b60405161063c9190613010565b60405180910390f35b34801561065157600080fd5b5061065a6112a7565b005b34801561066857600080fd5b50610683600480360381019061067e91906132f8565b611380565b005b34801561069157600080fd5b506106ac60048036038101906106a79190613358565b6114ba565b6040516106b991906130b4565b60405180910390f35b3480156106ce57600080fd5b506106e960048036038101906106e49190613209565b611541565b005b3480156106f757600080fd5b50610712600480360381019061070d9190613183565b6115e0565b005b61071c6117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a0906133e4565b60405180910390fd5b60005b815181101561083a576001601060008484815181106107ce576107cd613404565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061083290613462565b9150506107ac565b5050565b60606040518060400160405280601481526020017f41726e6f6c64205363687761727a656e69676761000000000000000000000000815250905090565b600061088f6108886117a1565b84846117a9565b6001905092915050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000670de0b6b3a7640000905090565b60006108dc848484611972565b61099d846108e86117a1565b610998856040518060600160405280602881526020016140b060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061094e6117a1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121f59092919063ffffffff16565b6117a9565b600190509392505050565b60185481565b60006009905090565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109e56117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a69906133e4565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610ad56117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b59906133e4565b60405180910390fd5b80601560166101000a81548160ff02191690831515021790555050565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610bc06117a1565b73ffffffffffffffffffffffffffffffffffffffff161480610c365750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610c1e6117a1565b73ffffffffffffffffffffffffffffffffffffffff16145b610c3f57600080fd5b6000479050610c4d81612259565b50565b6000610c9a600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122c5565b9050919050565b610ca96117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2d906133e4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610dfc6117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e80906133e4565b60405180910390fd5b8060168190555050565b60165481565b60116020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610ee26117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f66906133e4565b60405180910390fd5b80601560146101000a81548160ff02191690831515021790555050565b60175481565b60606040518060400160405280600b81526020017f5343485741524e49474741000000000000000000000000000000000000000000815250905090565b610fd76117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611064576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105b906133e4565b60405180910390fd5b8060188190555050565b6110766117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611103576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fa906133e4565b60405180910390fd5b60008410158015611115575060048411155b611154576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114b9061351c565b60405180910390fd5b60008210158015611166575060628211155b6111a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119c906135ae565b60405180910390fd5b600083101580156111b7575060048311155b6111f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ed90613640565b60405180910390fd5b60008110158015611208575060628111155b611247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123e906136d2565b60405180910390fd5b8360088190555082600a819055508160098190555080600b8190555050505050565b600061127d6112766117a1565b8484611972565b6001905092915050565b60106020528060005260406000206000915054906101000a900460ff1681565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166112e86117a1565b73ffffffffffffffffffffffffffffffffffffffff16148061135e5750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113466117a1565b73ffffffffffffffffffffffffffffffffffffffff16145b61136757600080fd5b600061137230610c50565b905061137d81612333565b50565b6113886117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611415576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140c906133e4565b60405180910390fd5b60005b838390508110156114b457816005600086868581811061143b5761143a613404565b5b90506020020160208101906114509190613183565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806114ac90613462565b915050611418565b50505050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6115496117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115cd906133e4565b60405180910390fd5b8060178190555050565b6115e86117a1565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166c906133e4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036116e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116db90613764565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611818576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180f906137f6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611887576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187e90613888565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161196591906130b4565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036119e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119d89061391a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a47906139ac565b60405180910390fd5b60008111611a93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8a90613a3e565b60405180910390fd5b611a9b610eb1565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611b095750611ad9610eb1565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611ef457601560149054906101000a900460ff16611b9857611b2a610eb1565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611b97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8e90613ad0565b60405180910390fd5b5b601654811115611bdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd490613b3c565b60405180910390fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611c815750601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611cc0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cb790613bce565b60405180910390fd5b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611d6d5760175481611d2284610c50565b611d2c9190613bee565b10611d6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6390613c94565b60405180910390fd5b5b6000611d7830610c50565b9050600060185482101590506016548210611d935760165491505b808015611dab575060158054906101000a900460ff16155b8015611e055750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015611e1d5750601560169054906101000a900460ff165b8015611e735750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611ec95750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611ef157611ed782612333565b60004790506000811115611eef57611eee47612259565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611f9b5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061204e5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415801561204d5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b1561205c57600090506121e3565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480156121075750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b1561211f57600854600c81905550600954600d819055505b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156121ca5750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b156121e257600a54600c81905550600b54600d819055505b5b6121ef848484846125aa565b50505050565b600083831115829061223d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122349190612f5d565b60405180910390fd5b506000838561224c9190613cb4565b9050809150509392505050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156122c1573d6000803e3d6000fd5b5050565b600060065482111561230c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230390613d5a565b60405180910390fd5b60006123166125d7565b905061232b818461260290919063ffffffff16565b915050919050565b60016015806101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561236a57612369612cf4565b5b6040519080825280602002602001820160405280156123985781602001602082028036833780820191505090505b50905030816000815181106123b0576123af613404565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247b9190613d8f565b8160018151811061248f5761248e613404565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506124f630601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846117a9565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161255a959493929190613eb5565b600060405180830381600087803b15801561257457600080fd5b505af1158015612588573d6000803e3d6000fd5b505050505060006015806101000a81548160ff02191690831515021790555050565b806125b8576125b761264c565b5b6125c3848484612689565b806125d1576125d0612854565b5b50505050565b60008060006125e4612868565b915091506125fb818361260290919063ffffffff16565b9250505090565b600061264483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506128c7565b905092915050565b6000600c5414801561266057506000600d54145b61268757600c54600e81905550600d54600f819055506000600c819055506000600d819055505b565b60008060008060008061269b8761292a565b9550955095509550955095506126f986600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461299290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061278e85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129dc90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127da81612a3a565b6127e48483612af7565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161284191906130b4565b60405180910390a3505050505050505050565b600e54600c81905550600f54600d81905550565b600080600060065490506000670de0b6b3a7640000905061289c670de0b6b3a764000060065461260290919063ffffffff16565b8210156128ba57600654670de0b6b3a76400009350935050506128c3565b81819350935050505b9091565b6000808311829061290e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129059190612f5d565b60405180910390fd5b506000838561291d9190613f3e565b9050809150509392505050565b60008060008060008060008060006129478a600c54600d54612b31565b92509250925060006129576125d7565b9050600080600061296a8e878787612bc7565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006129d483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506121f5565b905092915050565b60008082846129eb9190613bee565b905083811015612a30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2790613fbb565b60405180910390fd5b8091505092915050565b6000612a446125d7565b90506000612a5b8284612c5090919063ffffffff16565b9050612aaf81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129dc90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612b0c8260065461299290919063ffffffff16565b600681905550612b27816007546129dc90919063ffffffff16565b6007819055505050565b600080600080612b5d6064612b4f888a612c5090919063ffffffff16565b61260290919063ffffffff16565b90506000612b876064612b79888b612c5090919063ffffffff16565b61260290919063ffffffff16565b90506000612bb082612ba2858c61299290919063ffffffff16565b61299290919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612be08589612c5090919063ffffffff16565b90506000612bf78689612c5090919063ffffffff16565b90506000612c0e8789612c5090919063ffffffff16565b90506000612c3782612c29858761299290919063ffffffff16565b61299290919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808303612c625760009050612cc4565b60008284612c709190613fdb565b9050828482612c7f9190613f3e565b14612cbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cb69061408f565b60405180910390fd5b809150505b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d2c82612ce3565b810181811067ffffffffffffffff82111715612d4b57612d4a612cf4565b5b80604052505050565b6000612d5e612cca565b9050612d6a8282612d23565b919050565b600067ffffffffffffffff821115612d8a57612d89612cf4565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612dcb82612da0565b9050919050565b612ddb81612dc0565b8114612de657600080fd5b50565b600081359050612df881612dd2565b92915050565b6000612e11612e0c84612d6f565b612d54565b90508083825260208201905060208402830185811115612e3457612e33612d9b565b5b835b81811015612e5d5780612e498882612de9565b845260208401935050602081019050612e36565b5050509392505050565b600082601f830112612e7c57612e7b612cde565b5b8135612e8c848260208601612dfe565b91505092915050565b600060208284031215612eab57612eaa612cd4565b5b600082013567ffffffffffffffff811115612ec957612ec8612cd9565b5b612ed584828501612e67565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612f18578082015181840152602081019050612efd565b60008484015250505050565b6000612f2f82612ede565b612f398185612ee9565b9350612f49818560208601612efa565b612f5281612ce3565b840191505092915050565b60006020820190508181036000830152612f778184612f24565b905092915050565b6000819050919050565b612f9281612f7f565b8114612f9d57600080fd5b50565b600081359050612faf81612f89565b92915050565b60008060408385031215612fcc57612fcb612cd4565b5b6000612fda85828601612de9565b9250506020612feb85828601612fa0565b9150509250929050565b60008115159050919050565b61300a81612ff5565b82525050565b60006020820190506130256000830184613001565b92915050565b6000819050919050565b600061305061304b61304684612da0565b61302b565b612da0565b9050919050565b600061306282613035565b9050919050565b600061307482613057565b9050919050565b61308481613069565b82525050565b600060208201905061309f600083018461307b565b92915050565b6130ae81612f7f565b82525050565b60006020820190506130c960008301846130a5565b92915050565b6000806000606084860312156130e8576130e7612cd4565b5b60006130f686828701612de9565b935050602061310786828701612de9565b925050604061311886828701612fa0565b9150509250925092565b600060ff82169050919050565b61313881613122565b82525050565b6000602082019050613153600083018461312f565b92915050565b61316281612dc0565b82525050565b600060208201905061317d6000830184613159565b92915050565b60006020828403121561319957613198612cd4565b5b60006131a784828501612de9565b91505092915050565b6131b981612ff5565b81146131c457600080fd5b50565b6000813590506131d6816131b0565b92915050565b6000602082840312156131f2576131f1612cd4565b5b6000613200848285016131c7565b91505092915050565b60006020828403121561321f5761321e612cd4565b5b600061322d84828501612fa0565b91505092915050565b600080600080608085870312156132505761324f612cd4565b5b600061325e87828801612fa0565b945050602061326f87828801612fa0565b935050604061328087828801612fa0565b925050606061329187828801612fa0565b91505092959194509250565b600080fd5b60008083601f8401126132b8576132b7612cde565b5b8235905067ffffffffffffffff8111156132d5576132d461329d565b5b6020830191508360208202830111156132f1576132f0612d9b565b5b9250929050565b60008060006040848603121561331157613310612cd4565b5b600084013567ffffffffffffffff81111561332f5761332e612cd9565b5b61333b868287016132a2565b9350935050602061334e868287016131c7565b9150509250925092565b6000806040838503121561336f5761336e612cd4565b5b600061337d85828601612de9565b925050602061338e85828601612de9565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006133ce602083612ee9565b91506133d982613398565b602082019050919050565b600060208201905081810360008301526133fd816133c1565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061346d82612f7f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361349f5761349e613433565b5b600182019050919050565b7f4275792072657761726473206d757374206265206265747765656e203025206160008201527f6e64203425000000000000000000000000000000000000000000000000000000602082015250565b6000613506602583612ee9565b9150613511826134aa565b604082019050919050565b60006020820190508181036000830152613535816134f9565b9050919050565b7f42757920746178206d757374206265206265747765656e20302520616e64203960008201527f3825000000000000000000000000000000000000000000000000000000000000602082015250565b6000613598602283612ee9565b91506135a38261353c565b604082019050919050565b600060208201905081810360008301526135c78161358b565b9050919050565b7f53656c6c2072657761726473206d757374206265206265747765656e2030252060008201527f616e642034250000000000000000000000000000000000000000000000000000602082015250565b600061362a602683612ee9565b9150613635826135ce565b604082019050919050565b600060208201905081810360008301526136598161361d565b9050919050565b7f53656c6c20746178206d757374206265206265747765656e20302520616e642060008201527f3938250000000000000000000000000000000000000000000000000000000000602082015250565b60006136bc602383612ee9565b91506136c782613660565b604082019050919050565b600060208201905081810360008301526136eb816136af565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061374e602683612ee9565b9150613759826136f2565b604082019050919050565b6000602082019050818103600083015261377d81613741565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006137e0602483612ee9565b91506137eb82613784565b604082019050919050565b6000602082019050818103600083015261380f816137d3565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000613872602283612ee9565b915061387d82613816565b604082019050919050565b600060208201905081810360008301526138a181613865565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000613904602583612ee9565b915061390f826138a8565b604082019050919050565b60006020820190508181036000830152613933816138f7565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000613996602383612ee9565b91506139a18261393a565b604082019050919050565b600060208201905081810360008301526139c581613989565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000613a28602983612ee9565b9150613a33826139cc565b604082019050919050565b60006020820190508181036000830152613a5781613a1b565b9050919050565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b6000613aba603f83612ee9565b9150613ac582613a5e565b604082019050919050565b60006020820190508181036000830152613ae981613aad565b9050919050565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b6000613b26601c83612ee9565b9150613b3182613af0565b602082019050919050565b60006020820190508181036000830152613b5581613b19565b9050919050565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b6000613bb8602383612ee9565b9150613bc382613b5c565b604082019050919050565b60006020820190508181036000830152613be781613bab565b9050919050565b6000613bf982612f7f565b9150613c0483612f7f565b9250828201905080821115613c1c57613c1b613433565b5b92915050565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b6000613c7e602383612ee9565b9150613c8982613c22565b604082019050919050565b60006020820190508181036000830152613cad81613c71565b9050919050565b6000613cbf82612f7f565b9150613cca83612f7f565b9250828203905081811115613ce257613ce1613433565b5b92915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b6000613d44602a83612ee9565b9150613d4f82613ce8565b604082019050919050565b60006020820190508181036000830152613d7381613d37565b9050919050565b600081519050613d8981612dd2565b92915050565b600060208284031215613da557613da4612cd4565b5b6000613db384828501613d7a565b91505092915050565b6000819050919050565b6000613de1613ddc613dd784613dbc565b61302b565b612f7f565b9050919050565b613df181613dc6565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613e2c81612dc0565b82525050565b6000613e3e8383613e23565b60208301905092915050565b6000602082019050919050565b6000613e6282613df7565b613e6c8185613e02565b9350613e7783613e13565b8060005b83811015613ea8578151613e8f8882613e32565b9750613e9a83613e4a565b925050600181019050613e7b565b5085935050505092915050565b600060a082019050613eca60008301886130a5565b613ed76020830187613de8565b8181036040830152613ee98186613e57565b9050613ef86060830185613159565b613f0560808301846130a5565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613f4982612f7f565b9150613f5483612f7f565b925082613f6457613f63613f0f565b5b828204905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b6000613fa5601b83612ee9565b9150613fb082613f6f565b602082019050919050565b60006020820190508181036000830152613fd481613f98565b9050919050565b6000613fe682612f7f565b9150613ff183612f7f565b9250828202613fff81612f7f565b9150828204841483151761401657614015613433565b5b5092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000614079602183612ee9565b91506140848261401d565b604082019050919050565b600060208201905081810360008301526140a88161406c565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122088ed9557cea7f20ec2441bd1b126d874ba4d580ad656c99393824255a780ffa764736f6c63430008120033
|
/**
*Submitted for verification at Etherscan.io on 2023-04-17
*/
/**
Portal: https://t.me/schwarnigga
**/
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.18;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
}
contract SCHWARNIGGA is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "Arnold Schwarzenigga";
string private constant _symbol = "SCHWARNIGGA";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 1;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 1;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0x11B28C469C705a5F5714f7B367661708CE7f2380);
address payable private _marketingAddress = payable(0x11B28C469C705a5F5714f7B367661708CE7f2380);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 10000000 * 10**9;
uint256 public _maxWalletSize = 20000000 * 10**9;
uint256 public _swapTokensAtAmount = 10000 * 10**9;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function removeAllFee() private {
if (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_transferStandard(sender, recipient, amount);
if (!takeFee) restoreAllFee();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tTeam
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(
uint256 tAmount,
uint256 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
require(redisFeeOnBuy >= 0 && redisFeeOnBuy <= 4, "Buy rewards must be between 0% and 4%");
require(taxFeeOnBuy >= 0 && taxFeeOnBuy <= 98, "Buy tax must be between 0% and 98%");
require(redisFeeOnSell >= 0 && redisFeeOnSell <= 4, "Sell rewards must be between 0% and 4%");
require(taxFeeOnSell >= 0 && taxFeeOnSell <= 98, "Sell tax must be between 0% and 98%");
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
_maxTxAmount = maxTxAmount;
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
}
|
1 | 19,500,304 |
775f8a058ca0a5c6532db8bf1ea99da0953839b773b1a6ff3fb3c5b8b2597dc9
|
c463a224f88cab8b28502ea05672b19aa20df7cfe2de39efc7d612f35b4f0f43
|
299e618ebc6a8c0f0a45a6f391d5eff7eecd0863
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
833e7302289e0bb9bbb36d77cc421a0d5dc9b388
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
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;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,500,305 |
814e5a305dd4ec49cabc6a8ad87d2c3fd03134a15d8b7682c50b578fce3fbd07
|
62fdb49612c0f29cbd0bf83f307f31e5e0c428c2c2d92c0cb1b61683af3b05c9
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
f713c9907c7478478a9109ca5a25cb131a968f00
|
6080604052348015600f57600080fd5b50604051610211380380610211833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b61017b806100966000396000f3fe60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c634300081900330000000000000000000000008906668094934bbfd0f787010fac65d8438019f5
|
60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c63430008190033
| |
1 | 19,500,307 |
95cb7ffe336fdfaf6bfbcfa77b74286ca3e7f48ee223d3e390f2f02525d5c20c
|
a198761157ea66668a3494f80a4f75d3254be38a2ade6b020c8def83dca1b4cf
|
b62d24e7c9c08ddee7a093d4020301927a0b6005
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
0ce530b52748d8f07ee112978225ae54bb164f8a
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,313 |
4fc5d1f714eac555e37a4d4216c4e040ebd9d5fc8051074334687e705a46325c
|
d163931bff42c7f593609f4385718acd3b05b455d3fb458bd67b7f355c5f7c96
|
b62d24e7c9c08ddee7a093d4020301927a0b6005
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
c0d75f6a21c213109598f2864fbeef8de4bb2afc
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,313 |
4fc5d1f714eac555e37a4d4216c4e040ebd9d5fc8051074334687e705a46325c
|
f94c26464a8d8190469fa0c9100f67344ae27a872dca2611702e774493ab585f
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
3901605385e772d55494ad58a2cebb7dc3e76734
|
6080604052348015600f57600080fd5b506040516101bb3803806101bb833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b610125806100966000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c6343000819003300000000000000000000000033c99c0323adc0b7bd4ddd2ac4d4de2c28722fb0
|
6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c63430008190033
| |
1 | 19,500,313 |
4fc5d1f714eac555e37a4d4216c4e040ebd9d5fc8051074334687e705a46325c
|
6afc9281ae35df5f0fee620ab9e6ad30e74aaa0d148e3fd01470898db7661a4b
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
dccfe70a14c06ef15ec7e16a306302b70b6ef6b6
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,314 |
7db295f83f93f56a994b3a9d852b82f213e016c5285d13d2cee3863b0eef6e37
|
0e80c580658db1e19ff2d38f4566e93dbd1f6457f3ce62c496f72989f4de2410
|
0000db5c8b030ae20308ac975898e09741e70000
|
ed0e416e0feea5b484ba5c95d375545ac2b60572
|
e7e5952685a6c872e05117956acc73f2f6411e10
|
608060405234801561001057600080fd5b50604051610a1a380380610a1a8339818101604052810190610032919061011c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550326000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610149565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100e9826100be565b9050919050565b6100f9816100de565b811461010457600080fd5b50565b600081519050610116816100f0565b92915050565b600060208284031215610132576101316100b9565b5b600061014084828501610107565b91505092915050565b6108c2806101586000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063caa5c23f1461003b578063cce3d5d314610057575b600080fd5b610055600480360381019061005091906105fa565b610073565b005b610071600480360381019061006c9190610679565b6101ca565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610703565b60405180910390fd5b60005b81518110156101c6578181815181106101205761011f610723565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1682828151811061015557610154610723565b5b60200260200101516020015160405161016e91906107c3565b6000604051808303816000865af19150503d80600081146101ab576040519150601f19603f3d011682016040523d82523d6000602084013e6101b0565b606091505b50505080806101be90610809565b915050610104565b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024f90610703565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160405161029e90610877565b60006040518083038185875af1925050503d80600081146102db576040519150601f19603f3d011682016040523d82523d6000602084013e6102e0565b606091505b50505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610348826102ff565b810181811067ffffffffffffffff8211171561036757610366610310565b5b80604052505050565b600061037a6102e6565b9050610386828261033f565b919050565b600067ffffffffffffffff8211156103a6576103a5610310565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103f1826103c6565b9050919050565b610401816103e6565b811461040c57600080fd5b50565b60008135905061041e816103f8565b92915050565b600080fd5b600067ffffffffffffffff82111561044457610443610310565b5b61044d826102ff565b9050602081019050919050565b82818337600083830152505050565b600061047c61047784610429565b610370565b90508281526020810184848401111561049857610497610424565b5b6104a384828561045a565b509392505050565b600082601f8301126104c0576104bf6102fa565b5b81356104d0848260208601610469565b91505092915050565b6000604082840312156104ef576104ee6103bc565b5b6104f96040610370565b905060006105098482850161040f565b600083015250602082013567ffffffffffffffff81111561052d5761052c6103c1565b5b610539848285016104ab565b60208301525092915050565b60006105586105538461038b565b610370565b9050808382526020820190506020840283018581111561057b5761057a6103b7565b5b835b818110156105c257803567ffffffffffffffff8111156105a05761059f6102fa565b5b8086016105ad89826104d9565b8552602085019450505060208101905061057d565b5050509392505050565b600082601f8301126105e1576105e06102fa565b5b81356105f1848260208601610545565b91505092915050565b6000602082840312156106105761060f6102f0565b5b600082013567ffffffffffffffff81111561062e5761062d6102f5565b5b61063a848285016105cc565b91505092915050565b6000819050919050565b61065681610643565b811461066157600080fd5b50565b6000813590506106738161064d565b92915050565b60006020828403121561068f5761068e6102f0565b5b600061069d84828501610664565b91505092915050565b600082825260208201905092915050565b7f43616c6c6572206973206e6f7420746865206f776e6572000000000000000000600082015250565b60006106ed6017836106a6565b91506106f8826106b7565b602082019050919050565b6000602082019050818103600083015261071c816106e0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600081905092915050565b60005b8381101561078657808201518184015260208101905061076b565b60008484015250505050565b600061079d82610752565b6107a7818561075d565b93506107b7818560208601610768565b80840191505092915050565b60006107cf8284610792565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061081482610643565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610846576108456107da565b5b600182019050919050565b50565b600061086160008361075d565b915061086c82610851565b600082019050919050565b600061088282610854565b915081905091905056fea264697066735822122036692b46567a60a4f6844f8be0961cccba9ff2777bd37b4ea35791aba4c5159b64736f6c63430008120033000000000000000000000000000037bb05b2cef17c6469f4bcdb198826ce0000
|
608060405234801561001057600080fd5b50600436106100365760003560e01c8063caa5c23f1461003b578063cce3d5d314610057575b600080fd5b610055600480360381019061005091906105fa565b610073565b005b610071600480360381019061006c9190610679565b6101ca565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610703565b60405180910390fd5b60005b81518110156101c6578181815181106101205761011f610723565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1682828151811061015557610154610723565b5b60200260200101516020015160405161016e91906107c3565b6000604051808303816000865af19150503d80600081146101ab576040519150601f19603f3d011682016040523d82523d6000602084013e6101b0565b606091505b50505080806101be90610809565b915050610104565b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024f90610703565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160405161029e90610877565b60006040518083038185875af1925050503d80600081146102db576040519150601f19603f3d011682016040523d82523d6000602084013e6102e0565b606091505b50505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610348826102ff565b810181811067ffffffffffffffff8211171561036757610366610310565b5b80604052505050565b600061037a6102e6565b9050610386828261033f565b919050565b600067ffffffffffffffff8211156103a6576103a5610310565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103f1826103c6565b9050919050565b610401816103e6565b811461040c57600080fd5b50565b60008135905061041e816103f8565b92915050565b600080fd5b600067ffffffffffffffff82111561044457610443610310565b5b61044d826102ff565b9050602081019050919050565b82818337600083830152505050565b600061047c61047784610429565b610370565b90508281526020810184848401111561049857610497610424565b5b6104a384828561045a565b509392505050565b600082601f8301126104c0576104bf6102fa565b5b81356104d0848260208601610469565b91505092915050565b6000604082840312156104ef576104ee6103bc565b5b6104f96040610370565b905060006105098482850161040f565b600083015250602082013567ffffffffffffffff81111561052d5761052c6103c1565b5b610539848285016104ab565b60208301525092915050565b60006105586105538461038b565b610370565b9050808382526020820190506020840283018581111561057b5761057a6103b7565b5b835b818110156105c257803567ffffffffffffffff8111156105a05761059f6102fa565b5b8086016105ad89826104d9565b8552602085019450505060208101905061057d565b5050509392505050565b600082601f8301126105e1576105e06102fa565b5b81356105f1848260208601610545565b91505092915050565b6000602082840312156106105761060f6102f0565b5b600082013567ffffffffffffffff81111561062e5761062d6102f5565b5b61063a848285016105cc565b91505092915050565b6000819050919050565b61065681610643565b811461066157600080fd5b50565b6000813590506106738161064d565b92915050565b60006020828403121561068f5761068e6102f0565b5b600061069d84828501610664565b91505092915050565b600082825260208201905092915050565b7f43616c6c6572206973206e6f7420746865206f776e6572000000000000000000600082015250565b60006106ed6017836106a6565b91506106f8826106b7565b602082019050919050565b6000602082019050818103600083015261071c816106e0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600081905092915050565b60005b8381101561078657808201518184015260208101905061076b565b60008484015250505050565b600061079d82610752565b6107a7818561075d565b93506107b7818560208601610768565b80840191505092915050565b60006107cf8284610792565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061081482610643565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610846576108456107da565b5b600182019050919050565b50565b600061086160008361075d565b915061086c82610851565b600082019050919050565b600061088282610854565b915081905091905056fea264697066735822122036692b46567a60a4f6844f8be0961cccba9ff2777bd37b4ea35791aba4c5159b64736f6c63430008120033
| |
1 | 19,500,315 |
7f68fe51058484c88bef2cd194bf4b85de41bbdf119290f340753ded7577d74e
|
b04cf0ede6ce9a7c62088da26fc8b6e1186500e37e821ed97dde50781d8b6957
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
fb21a64b53fc0120745ab6d80b9fbdf8cf85cced
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,322 |
9b52c2a5b42bc923f58973c33f053d95128a8024f63317fa25cd96bc72187c45
|
1cda2b56f697f0c8654dac2142cf450237ff3a2107b17dad5e5ee5872ef822ec
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
9969db513aa2c23dec03e1dcf02425150d8c718e
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,322 |
9b52c2a5b42bc923f58973c33f053d95128a8024f63317fa25cd96bc72187c45
|
255009d0afadd13903330e115f02892206ef0fd5b0176693579f5428f012f922
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
94c59f7510a397bacd3d0a9c8b2f305f6363235a
|
6080604052348015600f57600080fd5b50604051610211380380610211833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b61017b806100966000396000f3fe60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c634300081900330000000000000000000000008906668094934bbfd0f787010fac65d8438019f5
|
60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c63430008190033
| |
1 | 19,500,325 |
0d1e49e9e772bfb0b65f989d51fa3edcd5738270d6634ff7211449e092c081e3
|
a9d3f0ff4c2fc3182af6db42275388e76a4e2134c557fdb6ed8dda85a26c22fe
|
4337003fcd2f56de3977ccb806383e9161628d0e
|
4bb74fe4001099fe2a61683df4def8ef57f14b42
|
fc2d8626a9fccd5fea0059d82ee85461b25907fa
|
607f3d8160093d39f33d3d33734bb74fe4001099fe2a61683df4def8ef57f14b4214605757363d3d37363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6052573d6000fd5b3d6000f35b3d356020355560408036111560525736038060403d373d3d355af43d6000803e6052573d6000fd00
|
3d3d33734bb74fe4001099fe2a61683df4def8ef57f14b4214605757363d3d37363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6052573d6000fd5b3d6000f35b3d356020355560408036111560525736038060403d373d3d355af43d6000803e6052573d6000fd
| |
1 | 19,500,326 |
7b3beed1da06be58c81dea5964032023c8c30ca5613ed31e03a17295dc666267
|
0b324ca001019310a6c3a2203bda1774d07f5cba739617bc57bc96fe26d4d3d0
|
5ccafcfa1949a247e2f936e9afb6a8b89cebaaca
|
5c5708c6f9aaa28ddb9ec5bed1c972a612be5a90
|
79edf416d4b7beeae4ef6275cf7401392c6cd17f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73f35f82081c9f00f956c2d921e8157e0bb8936e255af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73f35f82081c9f00f956c2d921e8157e0bb8936e255af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,326 |
7b3beed1da06be58c81dea5964032023c8c30ca5613ed31e03a17295dc666267
|
4a35a7888845ac3cd6227c48b34dbd2ae8d19fd43e0e6f9a66c075fd0827aeea
|
4bd26b25a30ed2e82e65bdff2105a4a4b8664fa4
|
000000008924d42d98026c656545c3c1fb3ad31c
|
4ca5b49f12215065d361d48fa12392bb9e512a29
|
3d602d80600a3d3981f3363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"lib/ERC721A/contracts/IERC721A.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\n/**\n * @dev Interface of ERC721A.\n */\ninterface IERC721A {\n /**\n * The caller must own the token or be an approved operator.\n */\n error ApprovalCallerNotOwnerNorApproved();\n\n /**\n * The token does not exist.\n */\n error ApprovalQueryForNonexistentToken();\n\n /**\n * Cannot query the balance for the zero address.\n */\n error BalanceQueryForZeroAddress();\n\n /**\n * Cannot mint to the zero address.\n */\n error MintToZeroAddress();\n\n /**\n * The quantity of tokens minted must be more than zero.\n */\n error MintZeroQuantity();\n\n /**\n * The token does not exist.\n */\n error OwnerQueryForNonexistentToken();\n\n /**\n * The caller must own the token or be an approved operator.\n */\n error TransferCallerNotOwnerNorApproved();\n\n /**\n * The token must be owned by `from`.\n */\n error TransferFromIncorrectOwner();\n\n /**\n * Cannot safely transfer to a contract that does not implement the\n * ERC721Receiver interface.\n */\n error TransferToNonERC721ReceiverImplementer();\n\n /**\n * Cannot transfer to the zero address.\n */\n error TransferToZeroAddress();\n\n /**\n * The token does not exist.\n */\n error URIQueryForNonexistentToken();\n\n /**\n * The `quantity` minted with ERC2309 exceeds the safety limit.\n */\n error MintERC2309QuantityExceedsLimit();\n\n /**\n * The `extraData` cannot be set on an unintialized ownership slot.\n */\n error OwnershipNotInitializedForExtraData();\n\n // =============================================================\n // STRUCTS\n // =============================================================\n\n struct TokenOwnership {\n // The address of the owner.\n address addr;\n // Stores the start time of ownership with minimal overhead for tokenomics.\n uint64 startTimestamp;\n // Whether the token has been burned.\n bool burned;\n // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.\n uint24 extraData;\n }\n\n // =============================================================\n // TOKEN COUNTERS\n // =============================================================\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() external view returns (uint256);\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n // =============================================================\n // IERC721\n // =============================================================\n\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables\n * (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`,\n * checking first that contract recipients are aware of the ERC721 protocol\n * to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move\n * this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom}\n * whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n // =============================================================\n // IERC2309\n // =============================================================\n\n /**\n * @dev Emitted when tokens in `fromTokenId` to `toTokenId`\n * (inclusive) is transferred from `from` to `to`, as defined in the\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.\n *\n * See {_mintERC2309} for more details.\n */\n event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"lib/operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n /**\n * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns\n * true if supplied registrant address is not registered.\n */\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n\n /**\n * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.\n */\n function register(address registrant) external;\n\n /**\n * @notice Registers an address with the registry and \"subscribes\" to another address's filtered operators and codeHashes.\n */\n function registerAndSubscribe(address registrant, address subscription) external;\n\n /**\n * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another\n * address without subscribing.\n */\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.\n * Note that this does not remove any filtered addresses or codeHashes.\n * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.\n */\n function unregister(address addr) external;\n\n /**\n * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.\n */\n function updateOperator(address registrant, address operator, bool filtered) external;\n\n /**\n * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.\n */\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n\n /**\n * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.\n */\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n\n /**\n * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.\n */\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n\n /**\n * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous\n * subscription if present.\n * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,\n * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be\n * used.\n */\n function subscribe(address registrant, address registrantToSubscribe) external;\n\n /**\n * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.\n */\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n\n /**\n * @notice Get the subscription address of a given registrant, if any.\n */\n function subscriptionOf(address addr) external returns (address registrant);\n\n /**\n * @notice Get the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscribers(address registrant) external returns (address[] memory);\n\n /**\n * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscriberAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.\n */\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Returns true if operator is filtered by a given address or its subscription.\n */\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n\n /**\n * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.\n */\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n\n /**\n * @notice Returns true if a codeHash is filtered by a given address or its subscription.\n */\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n\n /**\n * @notice Returns a list of filtered operators for a given address or its subscription.\n */\n function filteredOperators(address addr) external returns (address[] memory);\n\n /**\n * @notice Returns the set of filtered codeHashes for a given address or its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n\n /**\n * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n\n /**\n * @notice Returns true if an address has registered\n */\n function isRegistered(address addr) external returns (bool);\n\n /**\n * @dev Convenience method to compute the code hash of an arbitrary contract\n */\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"lib/operator-filter-registry/src/lib/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\naddress constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E;\naddress constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;\n"
},
"lib/operator-filter-registry/src/upgradeable/DefaultOperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFiltererUpgradeable} from \"./OperatorFiltererUpgradeable.sol\";\nimport {CANONICAL_CORI_SUBSCRIPTION} from \"../lib/Constants.sol\";\n\n/**\n * @title DefaultOperatorFiltererUpgradeable\n * @notice Inherits from OperatorFiltererUpgradeable and automatically subscribes to the default OpenSea subscription\n * when the init function is called.\n */\nabstract contract DefaultOperatorFiltererUpgradeable is OperatorFiltererUpgradeable {\n /// @dev The upgradeable initialize function that should be called when the contract is being deployed.\n function __DefaultOperatorFilterer_init() internal onlyInitializing {\n OperatorFiltererUpgradeable.__OperatorFilterer_init(CANONICAL_CORI_SUBSCRIPTION, true);\n }\n}\n"
},
"lib/operator-filter-registry/src/upgradeable/OperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"../IOperatorFilterRegistry.sol\";\nimport {Initializable} from \"../../../../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title OperatorFiltererUpgradeable\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry when the init function is called.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFiltererUpgradeable is Initializable {\n /// @notice Emitted when an operator is not allowed.\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n /// @dev The upgradeable initialize function that should be called when the contract is being upgraded.\n function __OperatorFilterer_init(address subscriptionOrRegistrantToCopy, bool subscribe)\n internal\n onlyInitializing\n {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isRegistered(address(this))) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n }\n\n /**\n * @dev A helper modifier to check if the operator is allowed.\n */\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n /**\n * @dev A helper modifier to check if the operator approval is allowed.\n */\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n /**\n * @dev A helper function to check if the operator is allowed.\n */\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n // under normal circumstances, this function will revert rather than return false, but inheriting or\n // upgraded contracts may specify their own OperatorFilterRegistry implementations, which may behave\n // differently\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"lib/utility-contracts/src/ConstructorInitializable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\n/**\n * @author emo.eth\n * @notice Abstract smart contract that provides an onlyUninitialized modifier which only allows calling when\n * from within a constructor of some sort, whether directly instantiating an inherting contract,\n * or when delegatecalling from a proxy\n */\nabstract contract ConstructorInitializable {\n error AlreadyInitialized();\n\n modifier onlyConstructor() {\n if (address(this).code.length != 0) {\n revert AlreadyInitialized();\n }\n _;\n }\n}\n"
},
"lib/utility-contracts/src/TwoStepOwnable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\nimport {ConstructorInitializable} from \"./ConstructorInitializable.sol\";\n\n/**\n@notice A two-step extension of Ownable, where the new owner must claim ownership of the contract after owner initiates transfer\nOwner can cancel the transfer at any point before the new owner claims ownership.\nHelpful in guarding against transferring ownership to an address that is unable to act as the Owner.\n*/\nabstract contract TwoStepOwnable is ConstructorInitializable {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n address internal potentialOwner;\n\n event PotentialOwnerUpdated(address newPotentialAdministrator);\n\n error NewOwnerIsZeroAddress();\n error NotNextOwner();\n error OnlyOwner();\n\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n constructor() {\n _initialize();\n }\n\n function _initialize() private onlyConstructor {\n _transferOwnership(msg.sender);\n }\n\n ///@notice Initiate ownership transfer to newPotentialOwner. Note: new owner will have to manually acceptOwnership\n ///@param newPotentialOwner address of potential new owner\n function transferOwnership(address newPotentialOwner)\n public\n virtual\n onlyOwner\n {\n if (newPotentialOwner == address(0)) {\n revert NewOwnerIsZeroAddress();\n }\n potentialOwner = newPotentialOwner;\n emit PotentialOwnerUpdated(newPotentialOwner);\n }\n\n ///@notice Claim ownership of smart contract, after the current owner has initiated the process with transferOwnership\n function acceptOwnership() public virtual {\n address _potentialOwner = potentialOwner;\n if (msg.sender != _potentialOwner) {\n revert NotNextOwner();\n }\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n _transferOwnership(_potentialOwner);\n }\n\n ///@notice cancel ownership transfer\n function cancelOwnershipTransfer() public virtual onlyOwner {\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (_owner != msg.sender) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"src/clones/ERC721ACloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport { IERC721A } from \"ERC721A/IERC721A.sol\";\n\nimport {\n Initializable\n} from \"openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Interface of ERC721 token receiver.\n */\ninterface ERC721A__IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\n/**\n * @title ERC721A\n *\n * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)\n * Non-Fungible Token Standard, including the Metadata extension.\n * Optimized for lower gas during batch mints.\n *\n * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)\n * starting from `_startTokenId()`.\n *\n * Assumptions:\n *\n * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721ACloneable is IERC721A, Initializable {\n // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).\n struct TokenApprovalRef {\n address value;\n }\n\n // =============================================================\n // CONSTANTS\n // =============================================================\n\n // Mask of an entry in packed address data.\n uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;\n\n // The bit position of `numberMinted` in packed address data.\n uint256 private constant _BITPOS_NUMBER_MINTED = 64;\n\n // The bit position of `numberBurned` in packed address data.\n uint256 private constant _BITPOS_NUMBER_BURNED = 128;\n\n // The bit position of `aux` in packed address data.\n uint256 private constant _BITPOS_AUX = 192;\n\n // Mask of all 256 bits in packed address data except the 64 bits for `aux`.\n uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;\n\n // The bit position of `startTimestamp` in packed ownership.\n uint256 private constant _BITPOS_START_TIMESTAMP = 160;\n\n // The bit mask of the `burned` bit in packed ownership.\n uint256 private constant _BITMASK_BURNED = 1 << 224;\n\n // The bit position of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;\n\n // The bit mask of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;\n\n // The bit position of `extraData` in packed ownership.\n uint256 private constant _BITPOS_EXTRA_DATA = 232;\n\n // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.\n uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;\n\n // The mask of the lower 160 bits for addresses.\n uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;\n\n // The maximum `quantity` that can be minted with {_mintERC2309}.\n // This limit is to prevent overflows on the address data entries.\n // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}\n // is required to cause an overflow, which is unrealistic.\n uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;\n\n // The `Transfer` event signature is given by:\n // `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n bytes32 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n // =============================================================\n // STORAGE\n // =============================================================\n\n // The next token ID to be minted.\n uint256 private _currentIndex;\n\n // The number of tokens burned.\n uint256 private _burnCounter;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to ownership details\n // An empty struct value does not necessarily mean the token is unowned.\n // See {_packedOwnershipOf} implementation for details.\n //\n // Bits Layout:\n // - [0..159] `addr`\n // - [160..223] `startTimestamp`\n // - [224] `burned`\n // - [225] `nextInitialized`\n // - [232..255] `extraData`\n mapping(uint256 => uint256) private _packedOwnerships;\n\n // Mapping owner address to address data.\n //\n // Bits Layout:\n // - [0..63] `balance`\n // - [64..127] `numberMinted`\n // - [128..191] `numberBurned`\n // - [192..255] `aux`\n mapping(address => uint256) private _packedAddressData;\n\n // Mapping from token ID to approved address.\n mapping(uint256 => TokenApprovalRef) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n // =============================================================\n // CONSTRUCTOR\n // =============================================================\n\n function __ERC721ACloneable__init(\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n _currentIndex = _startTokenId();\n }\n\n // =============================================================\n // TOKEN COUNTING OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the starting token ID.\n * To change the starting token ID, please override this function.\n */\n function _startTokenId() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev Returns the next token ID to be minted.\n */\n function _nextTokenId() internal view virtual returns (uint256) {\n return _currentIndex;\n }\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // Counter underflow is impossible as _burnCounter cannot be incremented\n // more than `_currentIndex - _startTokenId()` times.\n unchecked {\n return _currentIndex - _burnCounter - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total amount of tokens minted in the contract.\n */\n function _totalMinted() internal view virtual returns (uint256) {\n // Counter underflow is impossible as `_currentIndex` does not decrement,\n // and it is initialized to `_startTokenId()`.\n unchecked {\n return _currentIndex - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total number of tokens burned.\n */\n function _totalBurned() internal view virtual returns (uint256) {\n return _burnCounter;\n }\n\n // =============================================================\n // ADDRESS DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens burned by or on behalf of `owner`.\n */\n function _numberBurned(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n return uint64(_packedAddressData[owner] >> _BITPOS_AUX);\n }\n\n /**\n * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal virtual {\n uint256 packed = _packedAddressData[owner];\n uint256 auxCasted;\n // Cast `aux` with assembly to avoid redundant masking.\n assembly {\n auxCasted := aux\n }\n packed =\n (packed & _BITMASK_AUX_COMPLEMENT) |\n (auxCasted << _BITPOS_AUX);\n _packedAddressData[owner] = packed;\n }\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n // The interface IDs are constants representing the first 4 bytes\n // of the XOR of all function selectors in the interface.\n // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)\n // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)\n return\n interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.\n interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.\n interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.\n }\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length != 0\n ? string(abi.encodePacked(baseURI, _toString(tokenId)))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, it can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n // =============================================================\n // OWNERSHIPS OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n return address(uint160(_packedOwnershipOf(tokenId)));\n }\n\n /**\n * @dev Gas spent here starts off proportional to the maximum mint batch size.\n * It gradually moves to O(1) as tokens get transferred around over time.\n */\n function _ownershipOf(uint256 tokenId)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnershipOf(tokenId));\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct at `index`.\n */\n function _ownershipAt(uint256 index)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnerships[index]);\n }\n\n /**\n * @dev Initializes the ownership slot minted at `index` for efficiency purposes.\n */\n function _initializeOwnershipAt(uint256 index) internal virtual {\n if (_packedOwnerships[index] == 0) {\n _packedOwnerships[index] = _packedOwnershipOf(index);\n }\n }\n\n /**\n * Returns the packed ownership data of `tokenId`.\n */\n function _packedOwnershipOf(uint256 tokenId)\n private\n view\n returns (uint256)\n {\n uint256 curr = tokenId;\n\n unchecked {\n if (_startTokenId() <= curr) {\n if (curr < _currentIndex) {\n uint256 packed = _packedOwnerships[curr];\n // If not burned.\n if (packed & _BITMASK_BURNED == 0) {\n // Invariant:\n // There will always be an initialized ownership slot\n // (i.e. `ownership.addr != address(0) && ownership.burned == false`)\n // before an unintialized ownership slot\n // (i.e. `ownership.addr == address(0) && ownership.burned == false`)\n // Hence, `curr` will not underflow.\n //\n // We can directly compare the packed value.\n // If the address is zero, packed will be zero.\n while (packed == 0) {\n packed = _packedOwnerships[--curr];\n }\n return packed;\n }\n }\n }\n }\n revert OwnerQueryForNonexistentToken();\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct from `packed`.\n */\n function _unpackedOwnership(uint256 packed)\n private\n pure\n returns (TokenOwnership memory ownership)\n {\n ownership.addr = address(uint160(packed));\n ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);\n ownership.burned = packed & _BITMASK_BURNED != 0;\n ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);\n }\n\n /**\n * @dev Packs ownership data into a single uint256.\n */\n function _packOwnershipData(address owner, uint256 flags)\n private\n view\n returns (uint256 result)\n {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.\n result := or(\n owner,\n or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)\n )\n }\n }\n\n /**\n * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.\n */\n function _nextInitializedFlag(uint256 quantity)\n private\n pure\n returns (uint256 result)\n {\n // For branchless setting of the `nextInitialized` flag.\n assembly {\n // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.\n result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))\n }\n }\n\n // =============================================================\n // APPROVAL OPERATIONS\n // =============================================================\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ownerOf(tokenId);\n\n if (_msgSenderERC721A() != owner) {\n if (!isApprovedForAll(owner, _msgSenderERC721A())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n }\n\n _tokenApprovals[tokenId].value = to;\n emit Approval(owner, to, tokenId);\n }\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return _tokenApprovals[tokenId].value;\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n virtual\n override\n {\n _operatorApprovals[_msgSenderERC721A()][operator] = approved;\n emit ApprovalForAll(_msgSenderERC721A(), operator, approved);\n }\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted. See {_mint}.\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return\n _startTokenId() <= tokenId &&\n tokenId < _currentIndex && // If within bounds,\n _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.\n }\n\n /**\n * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.\n */\n function _isSenderApprovedOrOwner(\n address approvedAddress,\n address owner,\n address msgSender\n ) private pure returns (bool result) {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.\n msgSender := and(msgSender, _BITMASK_ADDRESS)\n // `msgSender == owner || msgSender == approvedAddress`.\n result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))\n }\n }\n\n /**\n * @dev Returns the storage slot and value for the approved address of `tokenId`.\n */\n function _getApprovedSlotAndAddress(uint256 tokenId)\n private\n view\n returns (uint256 approvedAddressSlot, address approvedAddress)\n {\n TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];\n // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.\n assembly {\n approvedAddressSlot := tokenApproval.slot\n approvedAddress := sload(approvedAddressSlot)\n }\n }\n\n // =============================================================\n // TRANSFER OPERATIONS\n // =============================================================\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n if (address(uint160(prevOwnershipPacked)) != from)\n revert TransferFromIncorrectOwner();\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n\n if (to == address(0)) revert TransferToZeroAddress();\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // We can directly increment and decrement the balances.\n --_packedAddressData[from]; // Updates: `balance -= 1`.\n ++_packedAddressData[to]; // Updates: `balance += 1`.\n\n // Updates:\n // - `address` to the next owner.\n // - `startTimestamp` to the timestamp of transfering.\n // - `burned` to `false`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n to,\n _BITMASK_NEXT_INITIALIZED |\n _nextExtraData(from, to, prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n transferFrom(from, to, tokenId);\n if (to.code.length != 0) {\n if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n }\n\n /**\n * @dev Hook that is called before a set of serially-ordered token IDs\n * are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token IDs\n * have been transferred. This includes minting.\n * And also called after one token has been burned.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.\n *\n * `from` - Previous owner of the given token ID.\n * `to` - Target address that will receive the token.\n * `tokenId` - Token ID to be transferred.\n * `_data` - Optional data to send along with the call.\n *\n * Returns whether the call correctly returned the expected magic value.\n */\n function _checkContractOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n try\n ERC721A__IERC721Receiver(to).onERC721Received(\n _msgSenderERC721A(),\n from,\n tokenId,\n _data\n )\n returns (bytes4 retval) {\n return\n retval ==\n ERC721A__IERC721Receiver(to).onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert TransferToNonERC721ReceiverImplementer();\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n\n // =============================================================\n // MINT OPERATIONS\n // =============================================================\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _mint(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are incredibly unrealistic.\n // `balance` and `numberMinted` have a maximum limit of 2**64.\n // `tokenId` has a maximum limit of 2**256.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n uint256 toMasked;\n uint256 end = startTokenId + quantity;\n\n // Use assembly to loop and emit the `Transfer` event for gas savings.\n // The duplicated `log4` removes an extra check and reduces stack juggling.\n // The assembly, together with the surrounding Solidity code, have been\n // delicately arranged to nudge the compiler into producing optimized opcodes.\n assembly {\n // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.\n toMasked := and(to, _BITMASK_ADDRESS)\n // Emit the `Transfer` event.\n log4(\n 0, // Start of data (0, since no data).\n 0, // End of data (0, since no data).\n _TRANSFER_EVENT_SIGNATURE, // Signature.\n 0, // `address(0)`.\n toMasked, // `to`.\n startTokenId // `tokenId`.\n )\n\n // The `iszero(eq(,))` check ensures that large values of `quantity`\n // that overflows uint256 will make the loop run out of gas.\n // The compiler will optimize the `iszero` away for performance.\n for {\n let tokenId := add(startTokenId, 1)\n } iszero(eq(tokenId, end)) {\n tokenId := add(tokenId, 1)\n } {\n // Emit the `Transfer` event. Similar to above.\n log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)\n }\n }\n if (toMasked == 0) revert MintToZeroAddress();\n\n _currentIndex = end;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * This function is intended for efficient minting only during contract creation.\n *\n * It emits only one {ConsecutiveTransfer} as defined in\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),\n * instead of a sequence of {Transfer} event(s).\n *\n * Calling this function outside of contract creation WILL make your contract\n * non-compliant with the ERC721 standard.\n * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309\n * {ConsecutiveTransfer} event is only permissible during contract creation.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {ConsecutiveTransfer} event.\n */\n function _mintERC2309(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT)\n revert MintERC2309QuantityExceedsLimit();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are unrealistic due to the above check for `quantity` to be below the limit.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n emit ConsecutiveTransfer(\n startTokenId,\n startTokenId + quantity - 1,\n address(0),\n to\n );\n\n _currentIndex = startTokenId + quantity;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n * - `quantity` must be greater than 0.\n *\n * See {_mint}.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal virtual {\n _mint(to, quantity);\n\n unchecked {\n if (to.code.length != 0) {\n uint256 end = _currentIndex;\n uint256 index = end - quantity;\n do {\n if (\n !_checkContractOnERC721Received(\n address(0),\n to,\n index++,\n _data\n )\n ) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n } while (index < end);\n // Reentrancy protection.\n if (_currentIndex != end) revert();\n }\n }\n }\n\n /**\n * @dev Equivalent to `_safeMint(to, quantity, '')`.\n */\n function _safeMint(address to, uint256 quantity) internal virtual {\n _safeMint(to, quantity, \"\");\n }\n\n // =============================================================\n // BURN OPERATIONS\n // =============================================================\n\n /**\n * @dev Equivalent to `_burn(tokenId, false)`.\n */\n function _burn(uint256 tokenId) internal virtual {\n _burn(tokenId, false);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId, bool approvalCheck) internal virtual {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n address from = address(uint160(prevOwnershipPacked));\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n if (approvalCheck) {\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n }\n\n _beforeTokenTransfers(from, address(0), tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // Updates:\n // - `balance -= 1`.\n // - `numberBurned += 1`.\n //\n // We can directly decrement the balance, and increment the number burned.\n // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.\n _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;\n\n // Updates:\n // - `address` to the last owner.\n // - `startTimestamp` to the timestamp of burning.\n // - `burned` to `true`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n from,\n (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) |\n _nextExtraData(from, address(0), prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, address(0), tokenId);\n _afterTokenTransfers(from, address(0), tokenId, 1);\n\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n unchecked {\n _burnCounter++;\n }\n }\n\n // =============================================================\n // EXTRA DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Directly sets the extra data for the ownership data `index`.\n */\n function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {\n uint256 packed = _packedOwnerships[index];\n if (packed == 0) revert OwnershipNotInitializedForExtraData();\n uint256 extraDataCasted;\n // Cast `extraData` with assembly to avoid redundant masking.\n assembly {\n extraDataCasted := extraData\n }\n packed =\n (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) |\n (extraDataCasted << _BITPOS_EXTRA_DATA);\n _packedOwnerships[index] = packed;\n }\n\n /**\n * @dev Called during each token transfer to set the 24bit `extraData` field.\n * Intended to be overridden by the cosumer contract.\n *\n * `previousExtraData` - the value of `extraData` before transfer.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _extraData(\n address from,\n address to,\n uint24 previousExtraData\n ) internal view virtual returns (uint24) {}\n\n /**\n * @dev Returns the next extra data for the packed ownership data.\n * The returned result is shifted into position.\n */\n function _nextExtraData(\n address from,\n address to,\n uint256 prevOwnershipPacked\n ) private view returns (uint256) {\n uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);\n return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;\n }\n\n // =============================================================\n // OTHER OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the message sender (defaults to `msg.sender`).\n *\n * If you are writing GSN compatible contracts, you need to override this function.\n */\n function _msgSenderERC721A() internal view virtual returns (address) {\n return msg.sender;\n }\n\n /**\n * @dev Converts a uint256 to its ASCII string decimal representation.\n */\n function _toString(uint256 value)\n internal\n pure\n virtual\n returns (string memory str)\n {\n assembly {\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\n // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.\n let m := add(mload(0x40), 0xa0)\n // Update the free memory pointer to allocate.\n mstore(0x40, m)\n // Assign the `str` to the end.\n str := sub(m, 0x20)\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end of the memory to calculate the length later.\n let end := str\n\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n // prettier-ignore\n for { let temp := value } 1 {} {\n str := sub(str, 1)\n // Write the character to the pointer.\n // The ASCII index of the '0' character is 48.\n mstore8(str, add(48, mod(temp, 10)))\n // Keep dividing `temp` until zero.\n temp := div(temp, 10)\n // prettier-ignore\n if iszero(temp) { break }\n }\n\n let length := sub(end, str)\n // Move the pointer 32 bytes leftwards to make room for the length.\n str := sub(str, 0x20)\n // Store the length.\n mstore(str, length)\n }\n }\n}\n"
},
"src/clones/ERC721ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"../interfaces/ISeaDropTokenContractMetadata.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport { TwoStepOwnable } from \"utility-contracts/TwoStepOwnable.sol\";\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC721ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721ContractMetadata is a token contract that extends ERC721A\n * with additional metadata and ownership capabilities.\n */\ncontract ERC721ContractMetadataCloneable is\n ERC721ACloneable,\n TwoStepOwnable,\n ISeaDropTokenContractMetadata\n{\n /// @notice Track the max supply.\n uint256 _maxSupply;\n\n /// @notice Track the base URI for token metadata.\n string _tokenBaseURI;\n\n /// @notice Track the contract URI for contract metadata.\n string _contractURI;\n\n /// @notice Track the provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 _provenanceHash;\n\n /// @notice Track the royalty info: address to receive royalties, and\n /// royalty basis points.\n RoyaltyInfo _royaltyInfo;\n\n /**\n * @dev Reverts if the sender is not the owner or the contract itself.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n */\n function _onlyOwnerOrSelf() internal view {\n if (\n _cast(msg.sender == owner()) | _cast(msg.sender == address(this)) ==\n 0\n ) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new base URI.\n _tokenBaseURI = newBaseURI;\n\n // Emit an event with the update.\n if (totalSupply() != 0) {\n emit BatchMetadataUpdate(1, _nextTokenId() - 1);\n }\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId)\n external\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the max supply does not exceed the maximum value of uint64.\n if (newMaxSupply > 2**64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _maxSupply = newMaxSupply;\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if any items have been minted.\n if (_totalMinted() > 0) {\n revert ProvenanceHashCannotBeSetAfterMintStarted();\n }\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if the new royalty address is the zero address.\n if (newInfo.royaltyAddress == address(0)) {\n revert RoyaltyAddressCannotBeZeroAddress();\n }\n\n // Revert if the new basis points is greater than 10_000.\n if (newInfo.royaltyBps > 10_000) {\n revert InvalidRoyaltyBasisPoints(newInfo.royaltyBps);\n }\n\n // Set the new royalty info.\n _royaltyInfo = newInfo;\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(newInfo.royaltyAddress, newInfo.royaltyBps);\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI();\n }\n\n /**\n * @notice Returns the base URI for the contract, which ERC721A uses\n * to return tokenURI.\n */\n function _baseURI() internal view virtual override returns (string memory) {\n return _tokenBaseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() public view returns (uint256) {\n return _maxSupply;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address) {\n return _royaltyInfo.royaltyAddress;\n }\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256) {\n return _royaltyInfo.royaltyBps;\n }\n\n /**\n * @notice Called with the sale price to determine how much royalty\n * is owed and to whom.\n *\n * @ param _tokenId The NFT asset queried for royalty information.\n * @param _salePrice The sale price of the NFT asset specified by\n * _tokenId.\n *\n * @return receiver Address of who should be sent the royalty payment.\n * @return royaltyAmount The royalty payment amount for _salePrice.\n */\n function royaltyInfo(\n uint256,\n /* _tokenId */\n uint256 _salePrice\n ) external view returns (address receiver, uint256 royaltyAmount) {\n // Put the royalty info on the stack for more efficient access.\n RoyaltyInfo storage info = _royaltyInfo;\n\n // Set the royalty amount to the sale price times the royalty basis\n // points divided by 10_000.\n royaltyAmount = (_salePrice * info.royaltyBps) / 10_000;\n\n // Set the receiver of the royalty.\n receiver = info.royaltyAddress;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ACloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal pure function to cast a `bool` value to a `uint256` value.\n *\n * @param b The `bool` value to cast.\n *\n * @return u The `uint256` value.\n */\n function _cast(bool b) internal pure returns (uint256 u) {\n assembly {\n u := b\n }\n }\n}\n"
},
"src/clones/ERC721SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ERC721ContractMetadataCloneable,\n ISeaDropTokenContractMetadata\n} from \"./ERC721ContractMetadataCloneable.sol\";\n\nimport {\n INonFungibleSeaDropToken\n} from \"../interfaces/INonFungibleSeaDropToken.sol\";\n\nimport { ISeaDrop } from \"../interfaces/ISeaDrop.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC721SeaDropStructsErrorsAndEvents\n} from \"../lib/ERC721SeaDropStructsErrorsAndEvents.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport {\n ReentrancyGuardUpgradeable\n} from \"openzeppelin-contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\nimport {\n DefaultOperatorFiltererUpgradeable\n} from \"operator-filter-registry/upgradeable/DefaultOperatorFiltererUpgradeable.sol\";\n\n/**\n * @title ERC721SeaDrop\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721SeaDrop is a token contract that contains methods\n * to properly interact with SeaDrop.\n */\ncontract ERC721SeaDropCloneable is\n ERC721ContractMetadataCloneable,\n INonFungibleSeaDropToken,\n ERC721SeaDropStructsErrorsAndEvents,\n ReentrancyGuardUpgradeable,\n DefaultOperatorFiltererUpgradeable\n{\n /// @notice Track the allowed SeaDrop addresses.\n mapping(address => bool) internal _allowedSeaDrop;\n\n /// @notice Track the enumerated allowed SeaDrop addresses.\n address[] internal _enumeratedAllowedSeaDrop;\n\n /**\n * @dev Reverts if not an allowed SeaDrop contract.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n *\n * @param seaDrop The SeaDrop address to check if allowed.\n */\n function _onlyAllowedSeaDrop(address seaDrop) internal view {\n if (_allowedSeaDrop[seaDrop] != true) {\n revert OnlyAllowedSeaDrop();\n }\n }\n\n /**\n * @notice Deploy the token contract with its name, symbol,\n * and allowed SeaDrop addresses.\n */\n function initialize(\n string calldata __name,\n string calldata __symbol,\n address[] calldata allowedSeaDrop,\n address initialOwner\n ) public initializer {\n __ERC721ACloneable__init(__name, __symbol);\n __ReentrancyGuard_init();\n __DefaultOperatorFilterer_init();\n _updateAllowedSeaDrop(allowedSeaDrop);\n _transferOwnership(initialOwner);\n emit SeaDropTokenDeployed();\n }\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop)\n external\n virtual\n override\n onlyOwner\n {\n _updateAllowedSeaDrop(allowedSeaDrop);\n }\n\n /**\n * @notice Internal function to update the allowed SeaDrop contracts.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function _updateAllowedSeaDrop(address[] calldata allowedSeaDrop) internal {\n // Put the length on the stack for more efficient access.\n uint256 enumeratedAllowedSeaDropLength = _enumeratedAllowedSeaDrop\n .length;\n uint256 allowedSeaDropLength = allowedSeaDrop.length;\n\n // Reset the old mapping.\n for (uint256 i = 0; i < enumeratedAllowedSeaDropLength; ) {\n _allowedSeaDrop[_enumeratedAllowedSeaDrop[i]] = false;\n unchecked {\n ++i;\n }\n }\n\n // Set the new mapping for allowed SeaDrop contracts.\n for (uint256 i = 0; i < allowedSeaDropLength; ) {\n _allowedSeaDrop[allowedSeaDrop[i]] = true;\n unchecked {\n ++i;\n }\n }\n\n // Set the enumeration.\n _enumeratedAllowedSeaDrop = allowedSeaDrop;\n\n // Emit an event for the update.\n emit AllowedSeaDropUpdated(allowedSeaDrop);\n }\n\n /**\n * @dev Overrides the `_startTokenId` function from ERC721A\n * to start at token id `1`.\n *\n * This is to avoid future possible problems since `0` is usually\n * used to signal values that have not been set or have been removed.\n */\n function _startTokenId() internal view virtual override returns (uint256) {\n return 1;\n }\n\n /**\n * @dev Overrides the `tokenURI()` function from ERC721A\n * to return just the base URI if it is implied to not be a directory.\n *\n * This is to help with ERC721 contracts in which the same token URI\n * is desired for each token, such as when the tokenURI is 'unrevealed'.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n\n // Exit early if the baseURI is empty.\n if (bytes(baseURI).length == 0) {\n return \"\";\n }\n\n // Check if the last character in baseURI is a slash.\n if (bytes(baseURI)[bytes(baseURI).length - 1] != bytes(\"/\")[0]) {\n return baseURI;\n }\n\n return string(abi.encodePacked(baseURI, _toString(tokenId)));\n }\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * ERC721A tracks these values automatically, but this note and\n * nonReentrant modifier are left here to encourage best-practices\n * when referencing this contract.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity)\n external\n virtual\n override\n nonReentrant\n {\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(msg.sender);\n\n // Extra safety check to ensure the max supply is not exceeded.\n if (_totalMinted() + quantity > maxSupply()) {\n revert MintQuantityExceedsMaxSupply(\n _totalMinted() + quantity,\n maxSupply()\n );\n }\n\n // Mint the quantity of tokens to the minter.\n _safeMint(minter, quantity);\n }\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the public drop data on SeaDrop.\n ISeaDrop(seaDropImpl).updatePublicDrop(publicDrop);\n }\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allow list on SeaDrop.\n ISeaDrop(seaDropImpl).updateAllowList(allowListData);\n }\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the token gated drop stage.\n ISeaDrop(seaDropImpl).updateTokenGatedDrop(allowedNftToken, dropStage);\n }\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external\n virtual\n override\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the drop URI.\n ISeaDrop(seaDropImpl).updateDropURI(dropURI);\n }\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the creator payout address.\n ISeaDrop(seaDropImpl).updateCreatorPayoutAddress(payoutAddress);\n }\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the owner can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external virtual {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allowed fee recipient.\n ISeaDrop(seaDropImpl).updateAllowedFeeRecipient(feeRecipient, allowed);\n }\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters to\n * enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the signer.\n ISeaDrop(seaDropImpl).updateSignedMintValidationParams(\n signer,\n signedMintValidationParams\n );\n }\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the payer.\n ISeaDrop(seaDropImpl).updatePayer(payer, allowed);\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n override\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n )\n {\n minterNumMinted = _numberMinted(minter);\n currentTotalSupply = _totalMinted();\n maxSupply = _maxSupply;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(INonFungibleSeaDropToken).interfaceId ||\n interfaceId == type(ISeaDropTokenContractMetadata).interfaceId ||\n // ERC721ContractMetadata returns supportsInterface true for\n // EIP-2981\n // ERC721A returns supportsInterface true for\n // ERC165, ERC721, ERC721Metadata\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n * - The `operator` must be allowed.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n * - The `operator` mut be allowed.\n *\n * Emits an {Approval} event.\n */\n function approve(address operator, uint256 tokenId)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.approve(operator, tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n /**\n * @notice Configure multiple properties at a time.\n *\n * Note: The individual configure methods should be used\n * to unset or reset any properties to zero, as this method\n * will ignore zero-value properties in the config struct.\n *\n * @param config The configuration struct.\n */\n function multiConfigure(MultiConfigureStruct calldata config)\n external\n onlyOwner\n {\n if (config.maxSupply > 0) {\n this.setMaxSupply(config.maxSupply);\n }\n if (bytes(config.baseURI).length != 0) {\n this.setBaseURI(config.baseURI);\n }\n if (bytes(config.contractURI).length != 0) {\n this.setContractURI(config.contractURI);\n }\n if (\n _cast(config.publicDrop.startTime != 0) |\n _cast(config.publicDrop.endTime != 0) ==\n 1\n ) {\n this.updatePublicDrop(config.seaDropImpl, config.publicDrop);\n }\n if (bytes(config.dropURI).length != 0) {\n this.updateDropURI(config.seaDropImpl, config.dropURI);\n }\n if (config.allowListData.merkleRoot != bytes32(0)) {\n this.updateAllowList(config.seaDropImpl, config.allowListData);\n }\n if (config.creatorPayoutAddress != address(0)) {\n this.updateCreatorPayoutAddress(\n config.seaDropImpl,\n config.creatorPayoutAddress\n );\n }\n if (config.provenanceHash != bytes32(0)) {\n this.setProvenanceHash(config.provenanceHash);\n }\n if (config.allowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.allowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.allowedFeeRecipients[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.disallowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.disallowedFeeRecipients[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.allowedPayers.length > 0) {\n for (uint256 i = 0; i < config.allowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.allowedPayers[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedPayers.length > 0) {\n for (uint256 i = 0; i < config.disallowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.disallowedPayers[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.tokenGatedDropStages.length > 0) {\n if (\n config.tokenGatedDropStages.length !=\n config.tokenGatedAllowedNftTokens.length\n ) {\n revert TokenGatedMismatch();\n }\n for (uint256 i = 0; i < config.tokenGatedDropStages.length; ) {\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.tokenGatedAllowedNftTokens[i],\n config.tokenGatedDropStages[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedTokenGatedAllowedNftTokens.length > 0) {\n for (\n uint256 i = 0;\n i < config.disallowedTokenGatedAllowedNftTokens.length;\n\n ) {\n TokenGatedDropStage memory emptyStage;\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.disallowedTokenGatedAllowedNftTokens[i],\n emptyStage\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.signedMintValidationParams.length > 0) {\n if (\n config.signedMintValidationParams.length !=\n config.signers.length\n ) {\n revert SignersMismatch();\n }\n for (\n uint256 i = 0;\n i < config.signedMintValidationParams.length;\n\n ) {\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.signers[i],\n config.signedMintValidationParams[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedSigners.length > 0) {\n for (uint256 i = 0; i < config.disallowedSigners.length; ) {\n SignedMintValidationParams memory emptyParams;\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.disallowedSigners[i],\n emptyParams\n );\n unchecked {\n ++i;\n }\n }\n }\n }\n}\n"
},
"src/interfaces/INonFungibleSeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\ninterface INonFungibleSeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @dev Revert with an error if a contract is not an allowed\n * SeaDrop address.\n */\n error OnlyAllowedSeaDrop();\n\n /**\n * @dev Emit an event when allowed SeaDrop contracts are updated.\n */\n event AllowedSeaDropUpdated(address[] allowedSeaDrop);\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop) external;\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity) external;\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n );\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator can only update `feeBps`.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external;\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external;\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator, when present, must first set `feeBps`.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external;\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external;\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the administrator can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external;\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external;\n}\n"
},
"src/interfaces/ISeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n MintParams,\n PublicDrop,\n TokenGatedDropStage,\n TokenGatedMintParams,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"../lib/SeaDropErrorsAndEvents.sol\";\n\ninterface ISeaDrop is SeaDropErrorsAndEvents {\n /**\n * @notice Mint a public drop.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n */\n function mintPublic(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity\n ) external payable;\n\n /**\n * @notice Mint from an allow list.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param proof The proof for the leaf of the allow list.\n */\n function mintAllowList(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n bytes32[] calldata proof\n ) external payable;\n\n /**\n * @notice Mint with a server-side signature.\n * Note that a signature can only be used once.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param salt The sale for the signed mint.\n * @param signature The server-side signature, must be an allowed\n * signer.\n */\n function mintSigned(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n uint256 salt,\n bytes calldata signature\n ) external payable;\n\n /**\n * @notice Mint as an allowed token holder.\n * This will mark the token id as redeemed and will revert if the\n * same token id is attempted to be redeemed twice.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param mintParams The token gated mint params.\n */\n function mintAllowedTokenHolder(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n TokenGatedMintParams calldata mintParams\n ) external payable;\n\n /**\n * @notice Emits an event to notify update of the drop URI.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Updates the public drop data for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(PublicDrop calldata publicDrop) external;\n\n /**\n * @notice Updates the allow list merkle root for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param allowListData The allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Updates the token gated drop stage for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during\n * the `dropStage` time period.\n *\n * @param allowedNftToken The token gated nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Updates the creator payout address and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payoutAddress The creator payout address.\n */\n function updateCreatorPayoutAddress(address payoutAddress) external;\n\n /**\n * @notice Updates the allowed fee recipient and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param feeRecipient The fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(address feeRecipient, bool allowed)\n external;\n\n /**\n * @notice Updates the allowed server-side signers and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address signer,\n SignedMintValidationParams calldata signedMintValidationParams\n ) external;\n\n /**\n * @notice Updates the allowed payer and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payer The payer to add or remove.\n * @param allowed Whether to add or remove the payer.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Returns the public drop data for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPublicDrop(address nftContract)\n external\n view\n returns (PublicDrop memory);\n\n /**\n * @notice Returns the creator payout address for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getCreatorPayoutAddress(address nftContract)\n external\n view\n returns (address);\n\n /**\n * @notice Returns the allow list merkle root for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getAllowListMerkleRoot(address nftContract)\n external\n view\n returns (bytes32);\n\n /**\n * @notice Returns if the specified fee recipient is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param feeRecipient The fee recipient.\n */\n function getFeeRecipientIsAllowed(address nftContract, address feeRecipient)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns an enumeration of allowed fee recipients for an\n * nft contract when fee recipients are enforced\n *\n * @param nftContract The nft contract.\n */\n function getAllowedFeeRecipients(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the server-side signers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getSigners(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the struct of SignedMintValidationParams for a signer.\n *\n * @param nftContract The nft contract.\n * @param signer The signer.\n */\n function getSignedMintValidationParams(address nftContract, address signer)\n external\n view\n returns (SignedMintValidationParams memory);\n\n /**\n * @notice Returns the payers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPayers(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns if the specified payer is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param payer The payer.\n */\n function getPayerIsAllowed(address nftContract, address payer)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns the allowed token gated drop tokens for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getTokenGatedAllowedTokens(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the token gated drop data for the nft contract\n * and token gated nft.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n */\n function getTokenGatedDrop(address nftContract, address allowedNftToken)\n external\n view\n returns (TokenGatedDropStage memory);\n\n /**\n * @notice Returns whether the token id for a token gated drop has been\n * redeemed.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n * @param allowedNftTokenId The token gated nft token id to check.\n */\n function getAllowedNftTokenIdIsRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n ) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\ninterface ISeaDropTokenContractMetadata is IERC2981 {\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables in ERC721A.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert if the royalty basis points is greater than 10_000.\n */\n error InvalidRoyaltyBasisPoints(uint256 basisPoints);\n\n /**\n * @dev Revert if the royalty address is being set to the zero address.\n */\n error RoyaltyAddressCannotBeZeroAddress();\n\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event when the max token supply is updated.\n */\n event MaxSupplyUpdated(uint256 newMaxSupply);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the royalties info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 bps);\n\n /**\n * @notice A struct defining royalty info for the contract.\n */\n struct RoyaltyInfo {\n address royaltyAddress;\n uint96 royaltyBps;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the max supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() external view returns (uint256);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address);\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256);\n}\n"
},
"src/lib/ERC721SeaDropStructsErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n PublicDrop,\n SignedMintValidationParams,\n TokenGatedDropStage\n} from \"./SeaDropStructs.sol\";\n\ninterface ERC721SeaDropStructsErrorsAndEvents {\n /**\n * @notice Revert with an error if mint exceeds the max supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Revert with an error if the number of token gated \n * allowedNftTokens doesn't match the length of supplied\n * drop stages.\n */\n error TokenGatedMismatch();\n\n /**\n * @notice Revert with an error if the number of signers doesn't match\n * the length of supplied signedMintValidationParams\n */\n error SignersMismatch();\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed();\n\n /**\n * @notice A struct to configure multiple contract options at a time.\n */\n struct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n address seaDropImpl;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n address creatorPayoutAddress;\n bytes32 provenanceHash;\n\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n\n address[] allowedPayers;\n address[] disallowedPayers;\n\n // Token-gated\n address[] tokenGatedAllowedNftTokens;\n TokenGatedDropStage[] tokenGatedDropStages;\n address[] disallowedTokenGatedAllowedNftTokens;\n\n // Server-signed\n address[] signers;\n SignedMintValidationParams[] signedMintValidationParams;\n address[] disallowedSigners;\n }\n}"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { PublicDrop, TokenGatedDropStage, SignedMintValidationParams } from \"./SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity is zero.\n */\n error MintQuantityCannotBeZero();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total, \n uint256 maxTokenSupplyForStage\n );\n \n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed();\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the received payment is incorrect.\n */\n error IncorrectPayment(uint256 got, uint256 want);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if signer's signature is invalid.\n */\n error InvalidSignature(address recoveredSigner);\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n * Note: only applies when adding a single payer, as duplicates in\n * enumeration can be removed with updatePayer.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed();\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the sender does not\n * match the INonFungibleSeaDropToken interface.\n */\n error OnlyINonFungibleSeaDropToken(address sender);\n\n /**\n * @dev Revert with an error if the sender of a token gated supplied\n * drop stage redeem is not the owner of the token.\n */\n error TokenGatedNotTokenOwner(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if the token id has already been used to\n * redeem a token gated drop stage.\n */\n error TokenGatedTokenIdAlreadyRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if an empty TokenGatedDropStage is provided\n * for an already-empty TokenGatedDropStage.\n */\n error TokenGatedDropStageNotPresent();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the zero address.\n */\n error TokenGatedDropAllowedNftTokenCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the drop token itself.\n */\n error TokenGatedDropAllowedNftTokenCannotBeDropToken();\n\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n \n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n \n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n * \n * @param nftContract The nft contract.\n * @param minter The mint recipient.\n * @param feeRecipient The fee recipient.\n * @param payer The address who payed for the tx.\n * @param quantityMinted The number of tokens minted.\n * @param unitMintPrice The amount paid for each token.\n * @param feeBps The fee out of 10_000 basis points collected.\n * @param dropStageIndex The drop stage index. Items minted\n * through mintPublic() have\n * dropStageIndex of 0.\n */\n event SeaDropMint(\n address indexed nftContract,\n address indexed minter,\n address indexed feeRecipient,\n address payer,\n uint256 quantityMinted,\n uint256 unitMintPrice,\n uint256 feeBps,\n uint256 dropStageIndex\n );\n\n /**\n * @dev An event with updated public drop data for an nft contract.\n */\n event PublicDropUpdated(\n address indexed nftContract,\n PublicDrop publicDrop\n );\n\n /**\n * @dev An event with updated token gated drop stage data\n * for an nft contract.\n */\n event TokenGatedDropStageUpdated(\n address indexed nftContract,\n address indexed allowedNftToken,\n TokenGatedDropStage dropStage\n );\n\n /**\n * @dev An event with updated allow list data for an nft contract.\n * \n * @param nftContract The nft contract.\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n address indexed nftContract,\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI for an nft contract.\n */\n event DropURIUpdated(address indexed nftContract, string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address for an nft\n * contract.\n */\n event CreatorPayoutAddressUpdated(\n address indexed nftContract,\n address indexed newPayoutAddress\n );\n\n /**\n * @dev An event with the updated allowed fee recipient for an nft\n * contract.\n */\n event AllowedFeeRecipientUpdated(\n address indexed nftContract,\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated validation parameters for server-side\n * signers.\n */\n event SignedMintValidationParamsUpdated(\n address indexed nftContract,\n address indexed signer,\n SignedMintValidationParams signedMintValidationParams\n ); \n\n /**\n * @dev An event with the updated payer for an nft contract.\n */\n event PayerUpdated(\n address indexed nftContract,\n address indexed payer,\n bool indexed allowed\n );\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param startTime The start time, ensure this is not zero.\n * @param endTIme The end time, ensure this is not zero.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 mintPrice; // 80/256 bits\n uint48 startTime; // 128/256 bits\n uint48 endTime; // 176/256 bits\n uint16 maxTotalMintableByWallet; // 224/256 bits\n uint16 feeBps; // 240/256 bits\n bool restrictFeeRecipients; // 248/256 bits\n}\n\n/**\n * @notice A struct defining token gated drop stage data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m \n * of native token, e.g.: ETH, MATIC)\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be \n * non-zero since the public mint emits\n * with index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct TokenGatedDropStage {\n uint80 mintPrice; // 80/256 bits\n uint16 maxTotalMintableByWallet; // 96/256 bits\n uint48 startTime; // 144/256 bits\n uint48 endTime; // 192/256 bits\n uint8 dropStageIndex; // non-zero. 200/256 bits\n uint32 maxTokenSupplyForStage; // 232/256 bits\n uint16 feeBps; // 248/256 bits\n bool restrictFeeRecipients; // 256/256 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n * \n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n * \n * @param mintPrice The mint price per token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 mintPrice; \n uint256 maxTotalMintableByWallet;\n uint256 startTime;\n uint256 endTime;\n uint256 dropStageIndex; // non-zero\n uint256 maxTokenSupplyForStage;\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @notice A struct defining token gated mint params.\n * \n * @param allowedNftToken The allowed nft token contract address.\n * @param allowedNftTokenIds The token ids to redeem.\n */\nstruct TokenGatedMintParams {\n address allowedNftToken;\n uint256[] allowedNftTokenIds;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n * \n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n\n/**\n * @notice A struct defining minimum and maximum parameters to validate for \n * signed mints, to minimize negative effects of a compromised signer.\n *\n * @param minMintPrice The minimum mint price allowed.\n * @param maxMaxTotalMintableByWallet The maximum total number of mints allowed\n * by a wallet.\n * @param minStartTime The minimum start time allowed.\n * @param maxEndTime The maximum end time allowed.\n * @param maxMaxTokenSupplyForStage The maximum token supply allowed.\n * @param minFeeBps The minimum fee allowed.\n * @param maxFeeBps The maximum fee allowed.\n */\nstruct SignedMintValidationParams {\n uint80 minMintPrice; // 80/256 bits\n uint24 maxMaxTotalMintableByWallet; // 104/256 bits\n uint40 minStartTime; // 144/256 bits\n uint40 maxEndTime; // 184/256 bits\n uint40 maxMaxTokenSupplyForStage; // 224/256 bits\n uint16 minFeeBps; // 240/256 bits\n uint16 maxFeeBps; // 256/256 bits\n}"
}
},
"settings": {
"remappings": [
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"ERC721A/=lib/ERC721A/contracts/",
"create2-helpers/=lib/create2-helpers/src/",
"create2-scripts/=lib/create2-helpers/script/",
"ds-test/=lib/ds-test/src/",
"erc4626-tests/=lib/operator-filter-registry/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"murky/=lib/murky/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"operator-filter-registry/=lib/operator-filter-registry/src/",
"seadrop/=src/",
"solmate/=lib/solmate/src/",
"utility-contracts/=lib/utility-contracts/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"bytecodeHash": "none"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}}
|
1 | 19,500,328 |
70b4716e65cb4bd9c892e5da3a25bde2071aad0e546adfe10bd724c3ecd4ad9a
|
77f5a14d16646b0a79ceb4b4601ab27efa4b9ebbbcb90a75c2de1dd19cac486f
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
9eb6fb5df9f2b7ecf19ba4c42cefe5d91d4a58f9
|
6080604052610017670429d069189e00005f19610345565b610022905f19610364565b6006555f60088190556019600955600a819055602d600b819055600c829055600d819055600e91909155600f55601280546001600160a01b0319908116735e647f6027800dce1f93b8a09ff8b8ee78f913349081179092556013805490911690911790556015805462ffffff60a01b1916600160b01b179055661550f7dca700006016819055601755660aa87bee5380006018553480156100c1575f80fd5b505f80546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600654335f9081526002602090815260409182902092909255601480546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d908117909155815163c45a015560e01b815291519092839263c45a015592600480830193928290030181865afa15801561017a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061019e9190610389565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061020d9190610389565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af1158015610257573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061027b9190610389565b601580546001600160a01b0319166001600160a01b039283161790555f80548216815260056020526040808220805460ff1990811660019081179092553084528284208054821683179055601254851684528284208054821683179055601354909416835291208054909216179055336001600160a01b03165f6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef670429d069189e000060405161033791815260200190565b60405180910390a3506103b6565b5f8261035f57634e487b7160e01b5f52601260045260245ffd5b500690565b8181038181111561038357634e487b7160e01b5f52601160045260245ffd5b92915050565b5f60208284031215610399575f80fd5b81516001600160a01b03811681146103af575f80fd5b9392505050565b611ce3806103c35f395ff3fe6080604052600436106101c8575f3560e01c8063715018a6116100f2578063a9059cbb11610092578063cfbdad8e11610062578063cfbdad8e1461052f578063dd62ed3e1461054e578063e2ee677d14610592578063f2fde38b146105b1575f80fd5b8063a9059cbb146104af578063ad69489e146104ce578063bfd79284146104ed578063c3c8cd801461051b575f80fd5b80638da5cb5b116100cd5780638da5cb5b146104335780638ebc7ec61461044f5780638f9a55c01461046e57806395d89b4114610483575f80fd5b8063715018a6146103df5780637d1db4a5146103f35780637f2feddc14610408575f80fd5b80632fd689e31161016857806366eb37851161013857806366eb37851461036e5780636d8aa8f8146103825780636fcba377146103a157806370a08231146103c0575f80fd5b80632fd689e314610300578063313ce5671461031557806349bd5a5e1461033057806351a7fe561461034f575f80fd5b806318160ddd116101a357806318160ddd1461027d57806323b872dd146102a15780632a9b8072146102c05780632f6c493c146102e1575f80fd5b806306fdde03146101d3578063095ea7b3146102175780631694505e14610246575f80fd5b366101cf57005b5f80fd5b3480156101de575f80fd5b5060408051808201909152600a81526941492d5363616e2d495160b01b60208201525b60405161020e919061186e565b60405180910390f35b348015610222575f80fd5b506102366102313660046118c7565b6105d0565b604051901515815260200161020e565b348015610251575f80fd5b50601454610265906001600160a01b031681565b6040516001600160a01b03909116815260200161020e565b348015610288575f80fd5b50670429d069189e00005b60405190815260200161020e565b3480156102ac575f80fd5b506102366102bb3660046118f1565b6105e6565b3480156102cb575f80fd5b506102df6102da36600461193e565b61064d565b005b3480156102ec575f80fd5b506102df6102fb366004611957565b61069d565b34801561030b575f80fd5b5061029360185481565b348015610320575f80fd5b506040516009815260200161020e565b34801561033b575f80fd5b50601554610265906001600160a01b031681565b34801561035a575f80fd5b506102df610369366004611972565b6106e6565b348015610379575f80fd5b506102df610714565b34801561038d575f80fd5b506102df61039c36600461193e565b61075e565b3480156103ac575f80fd5b506102df6103bb366004611989565b6107a5565b3480156103cb575f80fd5b506102936103da366004611957565b6107e2565b3480156103ea575f80fd5b506102df610803565b3480156103fe575f80fd5b5061029360165481565b348015610413575f80fd5b50610293610422366004611957565b60116020525f908152604090205481565b34801561043e575f80fd5b505f546001600160a01b0316610265565b34801561045a575f80fd5b506102df6104693660046119b8565b610874565b348015610479575f80fd5b5061029360175481565b34801561048e575f80fd5b50604080518082019091526004815263544e414960e01b6020820152610201565b3480156104ba575f80fd5b506102366104c93660046118c7565b610907565b3480156104d9575f80fd5b506102df6104e8366004611972565b610913565b3480156104f8575f80fd5b50610236610507366004611957565b60106020525f908152604090205460ff1681565b348015610526575f80fd5b506102df610941565b34801561053a575f80fd5b506102df610549366004611a49565b610993565b348015610559575f80fd5b50610293610568366004611b09565b6001600160a01b039182165f90815260046020908152604080832093909416825291909152205490565b34801561059d575f80fd5b506102df6105ac366004611972565b610a1b565b3480156105bc575f80fd5b506102df6105cb366004611957565b610a49565b5f6105dc338484610b30565b5060015b92915050565b5f6105f2848484610c53565b610643843361063e85604051806060016040528060288152602001611c86602891396001600160a01b038a165f9081526004602090815260408083203384529091529020549190611183565b610b30565b5060019392505050565b5f546001600160a01b0316331461067f5760405162461bcd60e51b815260040161067690611b40565b60405180910390fd5b60158054911515600160a01b0260ff60a01b19909216919091179055565b5f546001600160a01b031633146106c65760405162461bcd60e51b815260040161067690611b40565b6001600160a01b03165f908152601060205260409020805460ff19169055565b5f546001600160a01b0316331461070f5760405162461bcd60e51b815260040161067690611b40565b601655565b6012546001600160a01b0316336001600160a01b0316148061074957506013546001600160a01b0316336001600160a01b0316145b610751575f80fd5b4761075b816111bb565b50565b5f546001600160a01b031633146107875760405162461bcd60e51b815260040161067690611b40565b60158054911515600160b01b0260ff60b01b19909216919091179055565b5f546001600160a01b031633146107ce5760405162461bcd60e51b815260040161067690611b40565b600893909355600a91909155600955600b55565b6001600160a01b0381165f908152600260205260408120546105e0906111f2565b5f546001600160a01b0316331461082c5760405162461bcd60e51b815260040161067690611b40565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b0316331461089d5760405162461bcd60e51b815260040161067690611b40565b5f5b82811015610901578160055f8686858181106108bd576108bd611b75565b90506020020160208101906108d29190611957565b6001600160a01b0316815260208101919091526040015f20805460ff191691151591909117905560010161089f565b50505050565b5f6105dc338484610c53565b5f546001600160a01b0316331461093c5760405162461bcd60e51b815260040161067690611b40565b601755565b6012546001600160a01b0316336001600160a01b0316148061097657506013546001600160a01b0316336001600160a01b0316145b61097e575f80fd5b5f610988306107e2565b905061075b81611274565b5f546001600160a01b031633146109bc5760405162461bcd60e51b815260040161067690611b40565b5f5b8151811015610a1757600160105f8484815181106109de576109de611b75565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff19169115159190911790556001016109be565b5050565b5f546001600160a01b03163314610a445760405162461bcd60e51b815260040161067690611b40565b601855565b5f546001600160a01b03163314610a725760405162461bcd60e51b815260040161067690611b40565b6001600160a01b038116610ad75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610676565b5f80546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610b925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b038216610bf35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b038381165f8181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cb75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b038216610d195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b5f8111610d7a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610676565b5f546001600160a01b03848116911614801590610da457505f546001600160a01b03838116911614155b1561107f57601554600160a01b900460ff16610e3c575f546001600160a01b03848116911614610e3c5760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564006064820152608401610676565b601654811115610e8e5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d6974000000006044820152606401610676565b6001600160a01b0383165f9081526010602052604090205460ff16158015610ece57506001600160a01b0382165f9081526010602052604090205460ff16155b610f265760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b6064820152608401610676565b6015546001600160a01b03838116911614610fab5760175481610f48846107e2565b610f529190611b9d565b10610fab5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b6064820152608401610676565b5f610fb5306107e2565b601854601654919250821015908210610fce5760165491505b808015610fe55750601554600160a81b900460ff16155b8015610fff57506015546001600160a01b03868116911614155b80156110145750601554600160b01b900460ff165b801561103857506001600160a01b0385165f9081526005602052604090205460ff16155b801561105c57506001600160a01b0384165f9081526005602052604090205460ff16155b1561107c5761106a82611274565b47801561107a5761107a476111bb565b505b50505b6001600160a01b0383165f9081526005602052604090205460019060ff16806110bf57506001600160a01b0383165f9081526005602052604090205460ff165b806110f157506015546001600160a01b038581169116148015906110f157506015546001600160a01b03848116911614155b156110fd57505f611177565b6015546001600160a01b03858116911614801561112857506014546001600160a01b03848116911614155b1561113a57600854600c55600954600d555b6015546001600160a01b03848116911614801561116557506014546001600160a01b03858116911614155b1561117757600a54600c55600b54600d555b610901848484846113e4565b5f81848411156111a65760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611bb0565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015610a17573d5f803e3d5ffd5b5f6006548211156112585760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610676565b5f611261611409565b905061126d838261142a565b9392505050565b6015805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112ba576112ba611b75565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611311573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113359190611bc3565b8160018151811061134857611348611b75565b6001600160a01b03928316602091820292909201015260145461136e9130911684610b30565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac947906113a69085905f90869030904290600401611bde565b5f604051808303815f87803b1580156113bd575f80fd5b505af11580156113cf573d5f803e3d5ffd5b50506015805460ff60a81b1916905550505050565b806113f1576113f161146b565b6113fc848484611498565b806109015761090161146b565b5f805f611414611589565b9092509050611423828261142a565b9250505090565b5f61126d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115c8565b600c5415801561147b5750600d54155b1561148257565b600c8054600e55600d8054600f555f9182905555565b5f805f805f806114a7876115f4565b6001600160a01b038f165f90815260026020526040902054959b509399509197509550935091506114d89087611649565b6001600160a01b03808b165f9081526002602052604080822093909355908a1681522054611506908661168a565b6001600160a01b0389165f90815260026020526040902055611527816116e8565b611531848361172e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161157691815260200190565b60405180910390a3505050505050505050565b6006545f908190670429d069189e00006115a3828261142a565b8210156115bf57505060065492670429d069189e000092509050565b90939092509050565b5f81836115e85760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611c4f565b5f805f805f805f805f61160c8a600c54600d54611752565b9250925092505f61161b611409565b90505f805f61162c8e8787876117a4565b919e509c509a509598509396509194505050505091939550919395565b5f61126d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611183565b5f806116968385611b9d565b90508381101561126d5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610676565b5f6116f1611409565b90505f6116fe83836117f0565b305f9081526002602052604090205490915061171a908261168a565b305f90815260026020526040902055505050565b60065461173b9083611649565b60065560075461174b908261168a565b6007555050565b5f80808061176b606461176589896117f0565b9061142a565b90505f61177d60646117658a896117f0565b90505f6117948261178e8b86611649565b90611649565b9992985090965090945050505050565b5f8080806117b288866117f0565b90505f6117bf88876117f0565b90505f6117cc88886117f0565b90505f6117dd8261178e8686611649565b939b939a50919850919650505050505050565b5f825f036117ff57505f6105e0565b5f61180a8385611c6e565b9050826118178583611c4f565b1461126d5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610676565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461075b575f80fd5b80356118c2816118a3565b919050565b5f80604083850312156118d8575f80fd5b82356118e3816118a3565b946020939093013593505050565b5f805f60608486031215611903575f80fd5b833561190e816118a3565b9250602084013561191e816118a3565b929592945050506040919091013590565b803580151581146118c2575f80fd5b5f6020828403121561194e575f80fd5b61126d8261192f565b5f60208284031215611967575f80fd5b813561126d816118a3565b5f60208284031215611982575f80fd5b5035919050565b5f805f806080858703121561199c575f80fd5b5050823594602084013594506040840135936060013592509050565b5f805f604084860312156119ca575f80fd5b833567ffffffffffffffff808211156119e1575f80fd5b818601915086601f8301126119f4575f80fd5b813581811115611a02575f80fd5b8760208260051b8501011115611a16575f80fd5b602092830195509350611a2c918601905061192f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b5f6020808385031215611a5a575f80fd5b823567ffffffffffffffff80821115611a71575f80fd5b818501915085601f830112611a84575f80fd5b813581811115611a9657611a96611a35565b8060051b604051601f19603f83011681018181108582111715611abb57611abb611a35565b604052918252848201925083810185019188831115611ad8575f80fd5b938501935b82851015611afd57611aee856118b7565b84529385019392850192611add565b98975050505050505050565b5f8060408385031215611b1a575f80fd5b8235611b25816118a3565b91506020830135611b35816118a3565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156105e0576105e0611b89565b818103818111156105e0576105e0611b89565b5f60208284031215611bd3575f80fd5b815161126d816118a3565b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015611c2e5784516001600160a01b031683529383019391830191600101611c09565b50506001600160a01b03969096166060850152505050608001529392505050565b5f82611c6957634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176105e0576105e0611b8956fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122009d0fee4a9f67eb64655618c3a11acc22840a5cf7cf9163651a435d60145268364736f6c63430008190033
|
6080604052600436106101c8575f3560e01c8063715018a6116100f2578063a9059cbb11610092578063cfbdad8e11610062578063cfbdad8e1461052f578063dd62ed3e1461054e578063e2ee677d14610592578063f2fde38b146105b1575f80fd5b8063a9059cbb146104af578063ad69489e146104ce578063bfd79284146104ed578063c3c8cd801461051b575f80fd5b80638da5cb5b116100cd5780638da5cb5b146104335780638ebc7ec61461044f5780638f9a55c01461046e57806395d89b4114610483575f80fd5b8063715018a6146103df5780637d1db4a5146103f35780637f2feddc14610408575f80fd5b80632fd689e31161016857806366eb37851161013857806366eb37851461036e5780636d8aa8f8146103825780636fcba377146103a157806370a08231146103c0575f80fd5b80632fd689e314610300578063313ce5671461031557806349bd5a5e1461033057806351a7fe561461034f575f80fd5b806318160ddd116101a357806318160ddd1461027d57806323b872dd146102a15780632a9b8072146102c05780632f6c493c146102e1575f80fd5b806306fdde03146101d3578063095ea7b3146102175780631694505e14610246575f80fd5b366101cf57005b5f80fd5b3480156101de575f80fd5b5060408051808201909152600a81526941492d5363616e2d495160b01b60208201525b60405161020e919061186e565b60405180910390f35b348015610222575f80fd5b506102366102313660046118c7565b6105d0565b604051901515815260200161020e565b348015610251575f80fd5b50601454610265906001600160a01b031681565b6040516001600160a01b03909116815260200161020e565b348015610288575f80fd5b50670429d069189e00005b60405190815260200161020e565b3480156102ac575f80fd5b506102366102bb3660046118f1565b6105e6565b3480156102cb575f80fd5b506102df6102da36600461193e565b61064d565b005b3480156102ec575f80fd5b506102df6102fb366004611957565b61069d565b34801561030b575f80fd5b5061029360185481565b348015610320575f80fd5b506040516009815260200161020e565b34801561033b575f80fd5b50601554610265906001600160a01b031681565b34801561035a575f80fd5b506102df610369366004611972565b6106e6565b348015610379575f80fd5b506102df610714565b34801561038d575f80fd5b506102df61039c36600461193e565b61075e565b3480156103ac575f80fd5b506102df6103bb366004611989565b6107a5565b3480156103cb575f80fd5b506102936103da366004611957565b6107e2565b3480156103ea575f80fd5b506102df610803565b3480156103fe575f80fd5b5061029360165481565b348015610413575f80fd5b50610293610422366004611957565b60116020525f908152604090205481565b34801561043e575f80fd5b505f546001600160a01b0316610265565b34801561045a575f80fd5b506102df6104693660046119b8565b610874565b348015610479575f80fd5b5061029360175481565b34801561048e575f80fd5b50604080518082019091526004815263544e414960e01b6020820152610201565b3480156104ba575f80fd5b506102366104c93660046118c7565b610907565b3480156104d9575f80fd5b506102df6104e8366004611972565b610913565b3480156104f8575f80fd5b50610236610507366004611957565b60106020525f908152604090205460ff1681565b348015610526575f80fd5b506102df610941565b34801561053a575f80fd5b506102df610549366004611a49565b610993565b348015610559575f80fd5b50610293610568366004611b09565b6001600160a01b039182165f90815260046020908152604080832093909416825291909152205490565b34801561059d575f80fd5b506102df6105ac366004611972565b610a1b565b3480156105bc575f80fd5b506102df6105cb366004611957565b610a49565b5f6105dc338484610b30565b5060015b92915050565b5f6105f2848484610c53565b610643843361063e85604051806060016040528060288152602001611c86602891396001600160a01b038a165f9081526004602090815260408083203384529091529020549190611183565b610b30565b5060019392505050565b5f546001600160a01b0316331461067f5760405162461bcd60e51b815260040161067690611b40565b60405180910390fd5b60158054911515600160a01b0260ff60a01b19909216919091179055565b5f546001600160a01b031633146106c65760405162461bcd60e51b815260040161067690611b40565b6001600160a01b03165f908152601060205260409020805460ff19169055565b5f546001600160a01b0316331461070f5760405162461bcd60e51b815260040161067690611b40565b601655565b6012546001600160a01b0316336001600160a01b0316148061074957506013546001600160a01b0316336001600160a01b0316145b610751575f80fd5b4761075b816111bb565b50565b5f546001600160a01b031633146107875760405162461bcd60e51b815260040161067690611b40565b60158054911515600160b01b0260ff60b01b19909216919091179055565b5f546001600160a01b031633146107ce5760405162461bcd60e51b815260040161067690611b40565b600893909355600a91909155600955600b55565b6001600160a01b0381165f908152600260205260408120546105e0906111f2565b5f546001600160a01b0316331461082c5760405162461bcd60e51b815260040161067690611b40565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b0316331461089d5760405162461bcd60e51b815260040161067690611b40565b5f5b82811015610901578160055f8686858181106108bd576108bd611b75565b90506020020160208101906108d29190611957565b6001600160a01b0316815260208101919091526040015f20805460ff191691151591909117905560010161089f565b50505050565b5f6105dc338484610c53565b5f546001600160a01b0316331461093c5760405162461bcd60e51b815260040161067690611b40565b601755565b6012546001600160a01b0316336001600160a01b0316148061097657506013546001600160a01b0316336001600160a01b0316145b61097e575f80fd5b5f610988306107e2565b905061075b81611274565b5f546001600160a01b031633146109bc5760405162461bcd60e51b815260040161067690611b40565b5f5b8151811015610a1757600160105f8484815181106109de576109de611b75565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff19169115159190911790556001016109be565b5050565b5f546001600160a01b03163314610a445760405162461bcd60e51b815260040161067690611b40565b601855565b5f546001600160a01b03163314610a725760405162461bcd60e51b815260040161067690611b40565b6001600160a01b038116610ad75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610676565b5f80546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610b925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b038216610bf35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b038381165f8181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cb75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b038216610d195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b5f8111610d7a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610676565b5f546001600160a01b03848116911614801590610da457505f546001600160a01b03838116911614155b1561107f57601554600160a01b900460ff16610e3c575f546001600160a01b03848116911614610e3c5760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564006064820152608401610676565b601654811115610e8e5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d6974000000006044820152606401610676565b6001600160a01b0383165f9081526010602052604090205460ff16158015610ece57506001600160a01b0382165f9081526010602052604090205460ff16155b610f265760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b6064820152608401610676565b6015546001600160a01b03838116911614610fab5760175481610f48846107e2565b610f529190611b9d565b10610fab5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b6064820152608401610676565b5f610fb5306107e2565b601854601654919250821015908210610fce5760165491505b808015610fe55750601554600160a81b900460ff16155b8015610fff57506015546001600160a01b03868116911614155b80156110145750601554600160b01b900460ff165b801561103857506001600160a01b0385165f9081526005602052604090205460ff16155b801561105c57506001600160a01b0384165f9081526005602052604090205460ff16155b1561107c5761106a82611274565b47801561107a5761107a476111bb565b505b50505b6001600160a01b0383165f9081526005602052604090205460019060ff16806110bf57506001600160a01b0383165f9081526005602052604090205460ff165b806110f157506015546001600160a01b038581169116148015906110f157506015546001600160a01b03848116911614155b156110fd57505f611177565b6015546001600160a01b03858116911614801561112857506014546001600160a01b03848116911614155b1561113a57600854600c55600954600d555b6015546001600160a01b03848116911614801561116557506014546001600160a01b03858116911614155b1561117757600a54600c55600b54600d555b610901848484846113e4565b5f81848411156111a65760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611bb0565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015610a17573d5f803e3d5ffd5b5f6006548211156112585760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610676565b5f611261611409565b905061126d838261142a565b9392505050565b6015805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112ba576112ba611b75565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611311573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113359190611bc3565b8160018151811061134857611348611b75565b6001600160a01b03928316602091820292909201015260145461136e9130911684610b30565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac947906113a69085905f90869030904290600401611bde565b5f604051808303815f87803b1580156113bd575f80fd5b505af11580156113cf573d5f803e3d5ffd5b50506015805460ff60a81b1916905550505050565b806113f1576113f161146b565b6113fc848484611498565b806109015761090161146b565b5f805f611414611589565b9092509050611423828261142a565b9250505090565b5f61126d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115c8565b600c5415801561147b5750600d54155b1561148257565b600c8054600e55600d8054600f555f9182905555565b5f805f805f806114a7876115f4565b6001600160a01b038f165f90815260026020526040902054959b509399509197509550935091506114d89087611649565b6001600160a01b03808b165f9081526002602052604080822093909355908a1681522054611506908661168a565b6001600160a01b0389165f90815260026020526040902055611527816116e8565b611531848361172e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161157691815260200190565b60405180910390a3505050505050505050565b6006545f908190670429d069189e00006115a3828261142a565b8210156115bf57505060065492670429d069189e000092509050565b90939092509050565b5f81836115e85760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611c4f565b5f805f805f805f805f61160c8a600c54600d54611752565b9250925092505f61161b611409565b90505f805f61162c8e8787876117a4565b919e509c509a509598509396509194505050505091939550919395565b5f61126d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611183565b5f806116968385611b9d565b90508381101561126d5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610676565b5f6116f1611409565b90505f6116fe83836117f0565b305f9081526002602052604090205490915061171a908261168a565b305f90815260026020526040902055505050565b60065461173b9083611649565b60065560075461174b908261168a565b6007555050565b5f80808061176b606461176589896117f0565b9061142a565b90505f61177d60646117658a896117f0565b90505f6117948261178e8b86611649565b90611649565b9992985090965090945050505050565b5f8080806117b288866117f0565b90505f6117bf88876117f0565b90505f6117cc88886117f0565b90505f6117dd8261178e8686611649565b939b939a50919850919650505050505050565b5f825f036117ff57505f6105e0565b5f61180a8385611c6e565b9050826118178583611c4f565b1461126d5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610676565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461075b575f80fd5b80356118c2816118a3565b919050565b5f80604083850312156118d8575f80fd5b82356118e3816118a3565b946020939093013593505050565b5f805f60608486031215611903575f80fd5b833561190e816118a3565b9250602084013561191e816118a3565b929592945050506040919091013590565b803580151581146118c2575f80fd5b5f6020828403121561194e575f80fd5b61126d8261192f565b5f60208284031215611967575f80fd5b813561126d816118a3565b5f60208284031215611982575f80fd5b5035919050565b5f805f806080858703121561199c575f80fd5b5050823594602084013594506040840135936060013592509050565b5f805f604084860312156119ca575f80fd5b833567ffffffffffffffff808211156119e1575f80fd5b818601915086601f8301126119f4575f80fd5b813581811115611a02575f80fd5b8760208260051b8501011115611a16575f80fd5b602092830195509350611a2c918601905061192f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b5f6020808385031215611a5a575f80fd5b823567ffffffffffffffff80821115611a71575f80fd5b818501915085601f830112611a84575f80fd5b813581811115611a9657611a96611a35565b8060051b604051601f19603f83011681018181108582111715611abb57611abb611a35565b604052918252848201925083810185019188831115611ad8575f80fd5b938501935b82851015611afd57611aee856118b7565b84529385019392850192611add565b98975050505050505050565b5f8060408385031215611b1a575f80fd5b8235611b25816118a3565b91506020830135611b35816118a3565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156105e0576105e0611b89565b818103818111156105e0576105e0611b89565b5f60208284031215611bd3575f80fd5b815161126d816118a3565b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015611c2e5784516001600160a01b031683529383019391830191600101611c09565b50506001600160a01b03969096166060850152505050608001529392505050565b5f82611c6957634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176105e0576105e0611b8956fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122009d0fee4a9f67eb64655618c3a11acc22840a5cf7cf9163651a435d60145268364736f6c63430008190033
|
/**
_---~~(~~-_.
_{ ) )
, ) -~~- ( ,-' )_
( `-,_..`., )-- '_,)
( ` _) ( -~( -_ `, }
(_- _ ~_-~~~~`, ,' )
`~ -^( __;-,((()))
~~~~ {_ -_(())
`\ }
{ }
Advanced Smart Contract Scanner tailored for all EVM Networks
Socials:
https://t.me/AISCANIQ
https://aiscaniq.com/
https://twitter.com/aiscaniq
https://ai-scan-iq.gitbook.io/ai-scan-iq
*/
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.25;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
}
contract AI_SCAN_IQ is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = unicode"AI-Scan-IQ";
string private constant _symbol = unicode"TNAI";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 300000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 25;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 45;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0x5e647F6027800dCe1F93b8a09FF8B8ee78f91334);
address payable private _marketingAddress = payable(0x5e647F6027800dCe1F93b8a09FF8B8ee78f91334);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 6000000 * 10**9;
uint256 public _maxWalletSize = 6000000 * 10**9;
uint256 public _swapTokensAtAmount = 3000000 * 10**9;
event MaxTxAmountUpdate(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function ToggleSwapBack() private {
if (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function openTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSwapBack() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function Isbot(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unlock(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) ToggleSwapBack();
_transferStandard(sender, recipient, amount);
if (!takeFee) ToggleSwapBack();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tTeam
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(
uint256 tAmount,
uint256 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setFees(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function MinSwapTokenThresh(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function MaxTxAmmount(uint256 maxTxAmount) public onlyOwner {
_maxTxAmount = maxTxAmount;
}
function MaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeAccountFromFee(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
}
|
1 | 19,500,328 |
70b4716e65cb4bd9c892e5da3a25bde2071aad0e546adfe10bd724c3ecd4ad9a
|
77f5a14d16646b0a79ceb4b4601ab27efa4b9ebbbcb90a75c2de1dd19cac486f
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
581277c4b88df71612c792cbe1782c6d6fd38904
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
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;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,500,340 |
8f278ec989fcd2b6b3605587afe1fb4a3d5b48184358d0d526dd7426ce5197b6
|
7d6ec86ac47d732e6db0a3c182631a5fc4298baae56dfda42c9e4c4e1e2fca88
|
2792294b92afd603602a03f831f2775d5cf04d8c
|
2792294b92afd603602a03f831f2775d5cf04d8c
|
26f3f252e5286f7931dcec6ef2bb071e1901006a
|
6080604052348015600e575f80fd5b5061014e8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c806313bdfacd1461002d575b5f80fd5b61003561004b565b60405161004291906100f8565b60405180910390f35b60606040518060400160405280600c81526020017f48656c6c6f20576f726c64210000000000000000000000000000000000000000815250905090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6100ca82610088565b6100d48185610092565b93506100e48185602086016100a2565b6100ed816100b0565b840191505092915050565b5f6020820190508181035f83015261011081846100c0565b90509291505056fea2646970667358221220f547b39c1ac7ab00ddd4bcf1b194a40ea7069ecae4ebc5a680097b5072ac06d864736f6c63430008190033
|
608060405234801561000f575f80fd5b5060043610610029575f3560e01c806313bdfacd1461002d575b5f80fd5b61003561004b565b60405161004291906100f8565b60405180910390f35b60606040518060400160405280600c81526020017f48656c6c6f20576f726c64210000000000000000000000000000000000000000815250905090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6100ca82610088565b6100d48185610092565b93506100e48185602086016100a2565b6100ed816100b0565b840191505092915050565b5f6020820190508181035f83015261011081846100c0565b90509291505056fea2646970667358221220f547b39c1ac7ab00ddd4bcf1b194a40ea7069ecae4ebc5a680097b5072ac06d864736f6c63430008190033
| |
1 | 19,500,342 |
3bf4d00c372928a3a87a58a641f13ea45b118c46bb6cee661029beba58d58655
|
9c911210d18149337d95758af5d1dfddf6af101811b29738557e2a107d976f20
|
3aeb5831f91d29b3992d659821a7fed7b805a107
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
6d1a21a46f580f4988c888ce99a6ef4e81285411
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,500,344 |
64fdb81ba05af40b8f9b50377dd0313c2c0e9408ec6d65f95cfbe0cb8ba45d0e
|
d8623988b4f3590660eb319a17708e68c5a8ac8b9e128c6b821c1f30ee829c1f
|
2e05a304d3040f1399c8c20d2a9f659ae7521058
|
5be1de8021cc883456fd11dc5cd3806dbc48d304
|
411fedd777f280b89d26c94e76eb5d33810aac1c
|
608060405273af1931c20ee0c11bea17a41bfbbad299b2763bc06000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600047905060008111156100cf576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156100cd573d6000803e3d6000fd5b505b5060b4806100de6000396000f3fe6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
|
6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
| |
1 | 19,500,344 |
64fdb81ba05af40b8f9b50377dd0313c2c0e9408ec6d65f95cfbe0cb8ba45d0e
|
4495e75680906964c12f86ca46e426aee8f5a774d330978b6e35800477240414
|
2e05a304d3040f1399c8c20d2a9f659ae7521058
|
5be1de8021cc883456fd11dc5cd3806dbc48d304
|
97557bd46f05d1c0db2e254532802773cc0f377d
|
608060405273af1931c20ee0c11bea17a41bfbbad299b2763bc06000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600047905060008111156100cf576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156100cd573d6000803e3d6000fd5b505b5060b4806100de6000396000f3fe6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
|
6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
| |
1 | 19,500,344 |
64fdb81ba05af40b8f9b50377dd0313c2c0e9408ec6d65f95cfbe0cb8ba45d0e
|
f48ef2b7cbd611f58e141aecb313c0141828f81b20d415a18b012d04a783132e
|
2e05a304d3040f1399c8c20d2a9f659ae7521058
|
5be1de8021cc883456fd11dc5cd3806dbc48d304
|
cdb005e31a6a277657e7303d7b9ce6189d3b756f
|
608060405273af1931c20ee0c11bea17a41bfbbad299b2763bc06000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600047905060008111156100cf576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156100cd573d6000803e3d6000fd5b505b5060b4806100de6000396000f3fe6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
|
6080604052600047905060008111601557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015607b573d6000803e3d6000fd5b505000fea265627a7a72315820b3e69ef9c4f661d59ada7e4a2a73e978652e4bfd9ebdfca6642edb185642883c64736f6c63430005110032
| |
1 | 19,500,344 |
64fdb81ba05af40b8f9b50377dd0313c2c0e9408ec6d65f95cfbe0cb8ba45d0e
|
84e82138dc55e0d6c36143ad461b87c8e753bd27a2f33de9517743bae679d4eb
|
6f3b66dba3c318c405a0733d5d2cd67bfd57aa08
|
fcf68515aa6540dcd77f136dcb4f4ccd9967769a
|
0689b8050b0a06a1f69505bc8bda5f0441e34a56
|
6300001d7380600e6000396000f3006dba59afb35c1a9e799c2dedfff0f67716912ac08cae4e75b498e7196c38693199799efdebc357c9415a6a4b1618e3c55a3cc37ddd16fffd7f9c5dfb67cfe7a51afa7fff85fe13f9eb4fdea74356f5c5bfffdad6cf3fe8bffec7fff3fbf3dfffaf7ffce38f98f7f91cafc3fcaf3f201b92fc8fdcb6dbb2fee7d09f07fd4fec9fc87ffbe306e21ffe1c8779fd63b55bf10fb9fff3cfff1c0cfed745fef587fc2782fc61b6aacdfe20fff5cf9f7ffce3eff197bdf83fa781fef5a7cafefd97165ff9fcffde1fee59f6cbbfff2ad775fc170c1fc7f1cf03fbe73017f0034110f8fef1ff3ee55f675bf5cdffdf89e8f3f984fff3ed7deabfff42c6f3af3fd7ffdafefefc973f7b951fccf0f7177f903f04faf8fbfdf7ad889336ff4712a74d310f5b7f4fa9cf8f3fff9f73eeebfe6b19e334fff75fe39c2ff9bce77ffdbda2aa8b8bfccf702fead30ec7bfffdaaba5ba07fbebcf51656bf9efbffef3e332af8a72fddf1ffe33bb7f9573fef9f75f59bcc6fffacf10f0d817ff77122f3989ffb72a604ce74054b118c0fd325cbfe4fde2defbfb0d64006cfdde72e6dac4c4df479896d103deff7b17c00778d888fbbc77e3a169f9df1f3b70f0c7f67dd931eee9f605700f1a793f5c74f60398372f657311f0edf2c2e49c668e753b1c1e0743a5155cc93c5c917f0fece4c71fcf634beaf7c76a5f8170ea3d8e5515cdd0cd1222e1c1513809c1c2fa9950af49a61ea6016ed5e902f9feeb83c423828430bbd7fcceef6c4cf275e23261d387bf3f3cfb38689cd3af4c6763625c7651349276b0235ad24c098905657a99145a208e25f712d8c18015437f94d5dc0ed76e15c9f01659c9d47d822a7f7fe0144d5a7008fd9159a19634c768b79246d952f8e55c0497d34375de156858f1c8274e0c4c4147d844e842d7ca3ac1ecf4f9cb806db39887a5fffeb06e916cdb2e0dc2f74522cae76ae22f2cd7fda262df76c886cbcd199d88745f25829759b0960093f227a45c17503622db429bb09eebf75ea1dd51809ce5ad78ea972281508326a275d765f8e218cc554752f765559b6eca8ca71bd1f4a2f8994e1144b728f3d5af1f3c165f913301dd89765e17bfbf3ff8db69dcdcd8bc913d20c475932ae7753226244f14d301793fbd431938ae1179a2614b2de31fcd0210990dece9fb08e03a40277d995d137028f2fbd37c17c15c69b790bf94ccb245c3239707adfb8698eec833930a61f6713a42004a2d55e18d8ab90263454da7e4e7a80b0ad8e3422a4b561ec4f3f7874022ab98318a076af3d8aec74b91a43992148e2b1a5da5103b460c460b27475da1d02d5bdf9c9df6ebc71286375ae5aa29b5e4b0eb7153518bbf3f8e7d5cf39db0e04508acf289e9a934a9a0ee4f853f890991ba7299bb523307b98e627e747234b004a1d488867321317ee9c44ac6550ed24aac7f7fa85468a44b6142a233bf1fd7a413cf6c8c777aee999c7c9a737aeb9f6750918e02613023cee69e1af537a61615a4f49621334d3d7bfdc839d0abbf3f083689ad245e00949c984fc47dd30babab79837c88988af5d9149a8d0e54fb4cac184596a20191400832074d84789ef243b23fbddbf70b1f3d7f7f026f5579ffb3db0fa7ccb5a28d97e75bac5f64291b0195f50e2360eeb7b99eeff70a5db318f432ee520946b22f1cf88ca38a0902f669cccab7b4fefe78c6da427db24245a116ca6e376eb556ca73fe521ffebd34ba1224fb7d052c0c79de9087817d2e40cf50b927b00b1e964387ba4cb66b0e5221f2f7a7bbc8d393db829f142de13ffc115354f2ed28b3296c4c6eb8eaf556f966a95cdd63ec4f01ac017889dd9a1b3ff1ebe2ba2f3e4c3963a2c349b9a340e6f3b9d194af13013911543f47130a8cc4b92b9f1fcef6f848ef828643a096b336a82b01d716384458a9d297ad4fdc01697bb5624ce114947bf7909e8e64d99a96f261c36f6458533f076fce131f893dc013fa3557cdfebc15d88e197a8144744ce536af205f8e536665e6f2fb8a19130982fdb4ef0cb195ac4275e0a5110fce7df1cbf6d10b67ad8a3e7f284b8ed181867e0560bc27e63b30fb97809e340e7dba207da2e220731c79a171597b4f54f9fda10376d80ee0080b837f7d4762b8e489cf0e7ed73a3eb6d505f5b9a65b62f554b08b453cfa70a5c90a743edac20ccaf1614c096f853c2b79acd9efcff772d92e61dee9c2624cddd9518824ac0e5c55e159a7dfd92b44689bf37b7708b4c8b30a3eada5ec58323fe20975b8c66a619dce2503c9aa9b3ba6a93478f587fa92262343e72a16f5f204d5b1ea195ca5eb9816464830a2ccd5b920b69e9e282f6f5f695ea7839a81c459956539050f2d66b9f1f7e7ecd1a389616bdba9721085e122973b3ad9337bd74b4cd0fba7d9b6e1ec4c6fd91ae75b43f39a85f3e9e3d1f9355edcd82245504c685e54937357fdacb859e1739d1144358c7d5613be3b3ec5f73cd97941f5312147378699bdbcca87c0eb03ec26acf7c3eebca292206d2abba06a18c30dc72771af544c7330085dabbc65a130d5e3ae2e0307ca4253c6a476296e8f4ef4a1410e1acedb013912fc09f63c56b29367c19d2fa779b9455319a0a3ef5ab0ec90d5746471f0410e3a0f324b0aa6601f1e5b7352b232255308c51da88128f82c258f44e8f57c9c289e74e40ce4a31e466158e9fa595cfbebf7477a05e93be798698f6009d7fc501d7a8dca9e3a06d43bb640d5a0f1fd1e2abaf1736983c9b721183bc196136d3493aa8bfa555009ea98c2e4a2bf3fa1521cf33276857ef6d37ef8b9e02f790e6b6dbb470c1f7331423e628e9d20f8aa1981c550d79a78bb3952bae076a4e5dfd34968f5e373778cf8f747271e60882f95c8da2e2909b9bfbbfff926ce682b3f1e9a716430b3c956ce9ddea6cef3901f25a40b1d23421a727cb5195e3be749b9b5b805337cdfb7385518b29ad3fca97597364a473d7f4aaf0f13a26004fbc9b96345c6730e669f109cb45d9daee9dca138eac89775cec95efcf979514ef33eefdefb2aad61b19c6e3853410588757d13024496d53ed384847ab2725ffb6115adc14cb63fea7bc71fcb6e23d9e4ddc54c158698cd9f41a8425587ef95f2709eb6e3968c9a4ba0261bad1d46bf3456bf0cf3f18e6235465af842c411cf09300520e6689cb0abf695081b4e913990d4c8a3be1caf54ef9b6ab669190b99b1e9ea7d6e8926a3c396fad5c352736278fa58d63287cdfbfcc23304f57a330e6150d1b6304fc899b1c2e1f59bb56d668b035dcd83df9f04a71ed5f744b1ee54a142704af913883cf9ee14ff8de5c98b8d24b73bced6a50192982f3d28696f46d8ccaa60b73f3172999056ac98ef33446ead1fba4239d94da50defac8beaf42e10b40f5ea11559d634f2119ab3f2097bb90b5cda64dc8d9896413f99633432f1c466418f846dc08121482ffff707dd8f026bcf3cbcba4ab78820238c498f9d647e14db2979c401d24db218e654caedfd5d19f8e0180830197bb7c5a7aa762ad5334818a447f8607f7f72e1816766ef3a28525be5e7dddb6365ae84f0163bcbcf2cc72d212a3f8f8078da3aa9cb5654c81c9c6e91357da640797e89c90b5c1eaf8e59beabde6c4c1a2b32765150afcc6c7619687953ae542fea94781eeaadcc7ac3b035d4b453203af6db58ceebf0aee010f78d0e9c6fe1335c4fcc8031cdbb5bcebde8b26d0d644d7a7703a367cb412f32c83f421fb1af14dc6ced002bbf09dc1e24d91d441cc8ec2ce9949e9f9e1935fe8ecf140004408adf9f4a330c65161afd4e638f2a24a159e4949c0a7d0e0be9601e1190f93721a62c6cd2d75a2fda3abf5f5883de424fea8e60ad145f0d9c4d8184257e7f76598eb20b9ba35bda20ab9cd80b3e764d7acab2c976ca6a7c2dd6dbdefcfe903df363cef365ca9f772887f9ec68df2192ca01cc1245f418e8a1bbea13931a485fb8d11971961b6a86c25cd2e94e4bef55a06f1b0c5c8f2b9cfd1e33d2d3c700a9a978c6d5a6ecd907d985c5d33e48253cdee75d5fbf3f1aae4c130f389c5bf2e51c8482ebd34b78df2ec98a93e346c64f2951970fce00c96451625dc6e963ffae56ad4b095cf87a2a2dcd1200da37b92bcb95eb5b278a53a6e25721b87bed426dca98a1998c46a153452be7891131901ee17eade1196b92466c0ea963c7cb9e9acb39ea585c1d3efbea6f264fd5fa2e873c3ff5815eaf1c1a25918beddb1459c3eb10ba27ce4e59bfc9e04546f4be94ca06af4d8412d2fc7c267b3bf5d85705aff1a86a273e6e72a84a252fe940cf88bb0be5af6658ddac31083b7a4aa3f01e325e70a0bbb753de4aed252ec1620c58b673d2f7623f4954dc9eab566357fe2162ebbe6f64b275ca8215f29d0343b8444ae8069f9d9fe2c3961f3873597667524be93e24d96fba749e9a176f9add2e501a645ef11430f16c3d8b38e5ee987e28c82506e96b21fd6cbaf5e18faabe63fb006e3a7d675e92471800f462df5324eb935b69f18d1201bb7cf64cc87b8c7d63f869f0de73553ef74a1d428f5d7652307b7521633e21e6c4f1c5070eda82ddaee51ed3ecab7ee1a87da72833f9dbb6deb429de64ea49e5ee6ce5a68b3b2fa3e062aadf1f6087727f1261a9d20a0bd09cad49b0169c11c84e4930da241a6403353ea83f2064c992d6428ce6262c65ba8aae51f600e6048b65376ea47673482b53b392ad448faf5c572174264c828df3f276d71673154de033b4565c7cd9ac278907f311cc76fe916f4f9703916014d202a764b94a9322e0a668d2eb3efb076517b9107376e169bc133ef29d78e69c2bace0da5329631fcbb8d020badba50c32d2777d7a005c977aeed48a4e62bd24aca9e2db51ee99212e652ccb8b151dd518d1a6998179ccd827e9588b6d61d2f48a18cf6f76599b5b1fff8834a087ce2a0c5dc77500dfea16245f924fbef63db7f3153ce643e0c71c30ad5739c84225f4f68a840fa7860d677cbf502c5807113c43a2772538c81c1bc7d2426434be2598e6e58332797da496926fe2b26fdff2662456433780175cd77666a6d18770374823eb07c4617b2afff803f3e422e2f5604baa77e4d5b631b16a15885e87da7cdf72cc61d13bb9dd2e3795692ca019a890a23ddd2b66374eb0e8455de5eaaedc5c8fae00fbc82f1dafb5b8a77d0fbc5445c728ac93a5c785656ed959f4d8d9937b9303211b9f998cceea1d1baf7ef8eeabc1d2e27a82b3400a737d5482d1a3ae1499ea44624ecaf84fd3cf9112dedfaec6f80e9f7976717b3a56328dee66cbe1705c4321ea6057866084ec366e82c1f49006688b02369b0d6019df7cc36485d0b019b7fa140b2f73fc5d5c5df1e001c37a2019dcfce13a37bf89b540b8a9518207b8b402bc2c0dbbc2195a002658bd8116265c90ebd71afe8e14b2f01fecb61ee6b693059ba4d267d3ae3c5138f8780fa5f4fb23d4df1994ae852f942aefb4386bb283f3563303581636a57bb19e5657ee278c75ee23433e67cbaaccb92f3db266513b59d7652f6e61bd0367ee1ec2aedae21703805877d8c71d66f7202b9431b383e15907b13abf366f323e1ba9be3632cc28f6ab8c96fdccc5b27d952af2cebb23d00ee3b0c8f2cedef75bf77597bd3d2e6e1d0d773d32346970756aa508a1cc222a67b69a3410d259ff1ceb81400a45354d877901a1a86d63086f4b79a23b98b16bfefd89ef2340a88fecfd485f4795af28ec544e740c46ef2c2d27bc6c436e282dc71b8a1a22285d861505df12a99b43e242b66a8a471de47ebbf4537e577dab5e9529ba82eb545ccf1dcf11952ec80188f11917c9a0be6b4d2886cef856eb17b64597bb1b9b15e40857e3581ae30aa4e8469c249537a3dd8c64982fb6e50250708c776763c10c8c7f34e9c5d9997f8b3670476eb8f5067ad95a675ad5643db7bd790597b78009f38b4335dddb22a407f7bc099f7a8aa5180c05d88170d844612fa4717d1e884779d1ab05b5a4d10a18789773d9ea51e892cdab14cabf2b4446cafc4b80f990103bbc4c1e7bdf19e23d1726eca3fc4eb8b5b006520ec2ba908338a2699c2dd1c27f621c400922414b7fb52e715985e7a300f4d7811ed2911b80210ef6f101890fb8df9f3b8c053935e5c021f5ed5cca55f68644c2d36b2fac3e2fc0d268ba4ccba52cd98068e35ae819be6d4087df7dc188f06451daf315a72b90f0f3f787634da83400186ae2d43b7888812d83e63a64ab5398b010346f0388c09e349642b1ad17c1bc6bef908b52949a0ff71134bd0fc8ce6aaf179ffefe18805b7b26327bc0510f537af0020752f4f80082d75289c1abaee02b9d9f0b22f2699b7922c7876055e01c932f1e6c8455f447bf80cca9dadf6e973eef1507d12ecdbe66b891ecdfec97e8b731dc435430ae4aaf3291653918285f51012f0210dc6c1dcc57751315b8e555b17c315b7430a87f573d932ad5b0aaac693eec7a080194d3a0ac930651050f330b8f43ab3e83e9c416b4270a2ae03a0a5708fbc7b17cff507ba500d0bd2c60f87cf8b83b79e11090e3823a8e89d49e8a7aa67847419e42c82afc4e919fdbc890122d546c03c4b3d5d15d1885aed4db9a360a8b4e74391dbba51d8b9abafde99ed85f3612f3cad4f09d1aab91f6f1d8c90ed41011161a99c1a637701163007b45d6ca5658999554da3c874faaeab48e778d241dc7f9fe2eecdf9f406215139771b6238b7bb52c4b954dc03195d24064d35c9157bd466fa74decebd018fca5d0787dcf28f90cacfc6d16219b3f7afb9db2a737457727dff7782cd72efa1695910855519f30eaafdaf7793e1fe4c9e12556cb5e5c8959c16bed0196b1449ffd479598843de0c0fa34f1734daecfed7098bfffcdd3a6060f2d459c6c81b2b587d0bee73973c9e5b6f25e307472b3e819ca3541e1a5ef367a89a770a746ff52bd47984247371efed10285130dfe736708f03dbe3a94ecda32894f89c54167da31ae90e6d874fd52f2d5df35fa555833db1b57cec2ae093fd85c9af62ea53d6b099abe817b48d9b16e75760bf5112c80762108427c11b40ef4ce42f6e13ecdc3d2e008a22524a952cdda98ddf771ebfdae6c9a8283fdb398acb23ddb64245c92d696061d6e0524a4d039525c3783e8fba1f418aa45da3d3c48d26f0f58dc2eeed127e5293475f612ecda11bde71c4b819495f7113dbbdee8d300128a39b688dffc66f2be4a034bf68e39287910ba376b30b51da9a615d86d3debe1ce07313b3b8362ec0fa22b3827e95266a7aa37fa6a679fbe2aaddc6679eeef7cf33e66305c7adeb5cd33549d7ead63012418bafd6d6df45342e4d01beaa7eeda5b92c6565c0f745d630e1fc05171b2dcf5b4b56d7d842a46bbccef0f367cf20e5ac4fccbdb093c92e0435b2ba76660cfb9d5fa16f0a32f8e2f71ac15783a5fbaaff58121cfedc9a12a24a42a0fc84a7cdabb538fd51d8504d50ddce1564f174dd62f2c4f6301768b2f5cd759c496476f902cc1a4e1a1c9fa58e9d921780cfa372c7fc1cbd4eaa08c30f26ef262af4237d59465ddd51ab6a98e7f332b095785efd95a497583d3241c6d2f2d6a586d27af576cf250e6951fc54d1a623b8e761bdc25617c82b1623e3dab66bb35eb53e48a33d0fa38b35db9cb1df695c5c21571522ed48835169b7e6b638565910a6c15ad9dd9cd5a362fdd176bdc4d64177885cfc9274032fcd67a1c9522f890b215ed9ed304490a3bb82156b070273f4cfb327ab57cc9d077893726cf3df1537983b97d000a0d609d2b85d29d2dad9999e4e3cbbbeb941ff8857f312aca4add02c68ff652dd423653e63985b6968b4420e06a66f760900d53099adb0cb1a5fb5e8bf2f09ce4885a96f71ce4996c527bfb2cb2a9707b5e8e93903c3c581f0773515f7ec84165827eb7dff4257333bc6b0d12fb5959922f32e7d1f411502924e40997da40306cba9cc1b0dcfca6065fc6f1583e3e16709b08330ec8db0bdddd9c806ddf1dd7410edbc3d19c9e58ad1766b3271544537acefa203f0af7f0b90a67f63d1a45efceb78f8db043c8036ac8d92ef0db307b8c963642781d138bc4c21328064c8fe3500df9cc3207a3f202e8a9adb17a2c8be5db828e6845fa444e5bea7f7f8ede2e1f4a078a537dba4981b357ef9534cfd833bdd7996b66be51a7efd27eb61107f946329fdf2b7f1a77dd8de3f0d62b44c8999497ec4816df37bfa1b6951ffedb28739c2045e1dd352efc414e827b1e1e8c100a9ea2289979a804a4748818db82a7b26367d708cf496ca951e86f652c42d0b1e8edb31a92789356f2b8e61ca5a1da214c4e9a367fe2cfb07b6328d6a66ccb6a329c7f3aabae02d68762a4b94db57b9dc01ab3d3556959585e02c9df54e37b754141e095d846573ea28223e69bed945861d4ba77daa3ef6ef12d91b381a4c264c3d76e62c1db9079980e58117b7a6e3db897d5d0d88d943745476a33e6026fb23273d4c28447ac5c680e4f3332df71a15cf2a839b27dba05bc870aaa0c615b633f6c7445c0b3c37d6be58b3a7c864d0ac8bbea2f9aec1d75b3a3f9d30d7cd66ea764d64e2a646d07c9da39ed41a2dc49d88fe3e53f9b1db55488b89d990ebee9f2f98a28e104fd67a66d5e316fbf1027f58cb60acb631ce660cf2fada47e6e869121b2303e1e831631506fbe1358a115a2196bf54318e9a1af1beee17949919bcd65c5bbe16bd3bbbdf3def8b545b7b0a096126ad98eabce9df758b1aeddc83ddc5639029a072609ae84cf6934b4151222d6f360d428125db96792f6562fa54b3777377159779e5b3e5a1e45a0438c6e52cde3fb992e5ba8dca9ae3db055547628c888f11ffa185a617ce3622d152806180d7d25a0ed111a322a4a44b8db894fcf3bdeb49d42286a614bec1300eedbd2c2b3c16cafe88d7c0f942781fa395c5f80457f0d25084c7424f8d359a568c13bc388c7f6625fdf99f8fd9173a9b7e9da2bbc5e61aa8cdc8471a68fb2eb399dd70789a2e19804a20d338f78e13ce990d0c8b4f8ca8c404f9217e57c61682a15e70d61f89d21fab73c0801a92c4cbb754249a6b266ebcd3f51fec3e2fb7638cf4cdd32c6c6b920b7aa122f03cf315e376008163413a33975f074e1b7427d23e5f7a760d927d4cc04e87507bdaa6dc4e2dcdb32985187a84b07461c8b135fa1cfd60623ee57bb55c6f18b031b96685022cb44e91a6b015f08d7e0d1dd7b1f6739d4402a02517c1d9ffc737e5fe3d377b518dc66a19200f60c6145dbddb7a8767ea71d75c8549b186075f7a99d0687fddec15e35233bf2cde4fe7ce4c7687dbfc7b93f617f7fa64bbf36766e38ce9a6c5e78b05272d2ac060cd51d4ae13d692999e9b2a9b524f789f197531a0fa42f8d1cd87fff8fe47f5368b43058a5abe6e9fbaeba12447e11c4ec53fc4be7e9a0bf66777aca46d608e3c9f95e410d601041b7cf22479836965438c6d29692dca43a7b356bab00b619463bbf92aa26e174b005fc3a6f39d66dfa54794f14189ac5e186ae4f3291b93e8fe355394916f9defe022b7b930f6be2d6e59b91e2f08a52a8e6fdb09d5b441e1fac280c090c978f6a33bc4925f76f31f87ce330667188384b33abbc2f4fef34044758555bffc466780c858b7d7f7f3635ae0d711803f2cb60d4caf3e18445aa0bdcabab57f66143063668d93df070672aa906f5e78b8b84c17eb62c109b9d7bc96517190a2121f4ed76af27e6f438901f98ce14761c0269cb9e1ceb8da074cc999052cdb79275ab75fb94e5bb5b56e203591ed4de8031f7f7b36e047efaa2737011de9dbd8fe30dbaf121037b7c6d69c2e06698e0b79d4c1ee8fa8d397b2c46452ac3037f91db2bac36da61559ebf0203799f6ad316b71b8fb606718571bcfda98b6c43cd616ff1e383101710d002c10e9b35aee0f3636575b2b18123ed89232d711172cb0c8d64e89d3ee58df08a578c47524a300a96ea839b06a1e35e799f14a2a2ddc2e6ecef4c3b6d0df1f273c72d3c879df30de536b372863b5387a18a6ecf73ef45441fddf279afe6e149def6143013856f52dde269c004cee5259cd791e825d4b6afbf442fed54d6e9a700268d8abed8988610c33116fe7908353819169fb5a790775d6a48e2c2318521bff8df1f015a06d0ec0c17e24f26d78fe02a247e7889f4a32ca7a921d10e988fab4e79c7a52022f8b20f1991af59ec59cef2731a06f4253560089703bfe7a62185b523a41c8684c7dffee95a12413c4158294791093da91e6c7fdb63b97ba01c4c2e177a83ae60e788f15a94d3bb6b5b77de6ef4b6bf665cfcfee49ba95d88657320cf21e935c39995f38ccfba8548f4d511a6b982db3133b0348fb4dc475d0f9b0e5c9161c077180ecf72517f2c3b3ff498cf7cd3a0c369c7db643a2665e1e2ab1decf0f2e5c284d47153067e8be437d4a2f0864b0472c053a5aa9cdddb0d8943e47bcbf9f1c56863a62dc31a2ab7ca088d504a8abdf01883913212b58bada1be0d412df956f5aa8272f05e901c2375200371bb79fb4b3a1c122d0ec8c477777ab05eddd193309e316fbf2065e11461efcc7f892f99af83f95518d887452ee1d5210d530b51dcdc74e8ee8714ca0de7953085f3f67f9e4772fdc07454820d65f9dfff79600afecfe34effd95bf6e2defe4f
|
006dba59afb35c1a9e799c2dedfff0f67716912ac08cae4e75b498e7196c38693199799efdebc357c9415a6a4b1618e3c55a3cc37ddd16fffd7f9c5dfb67cfe7a51afa7fff85fe13f9eb4fdea74356f5c5bfffdad6cf3fe8bffec7fff3fbf3dfffaf7ffce38f98f7f91cafc3fcaf3f201b92fc8fdcb6dbb2fee7d09f07fd4fec9fc87ffbe306e21ffe1c8779fd63b55bf10fb9fff3cfff1c0cfed745fef587fc2782fc61b6aacdfe20fff5cf9f7ffce3eff197bdf83fa781fef5a7cafefd97165ff9fcffde1fee59f6cbbfff2ad775fc170c1fc7f1cf03fbe73017f0034110f8fef1ff3ee55f675bf5cdffdf89e8f3f984fff3ed7deabfff42c6f3af3fd7ffdafefefc973f7b951fccf0f7177f903f04faf8fbfdf7ad889336ff4712a74d310f5b7f4fa9cf8f3fff9f73eeebfe6b19e334fff75fe39c2ff9bce77ffdbda2aa8b8bfccf702fead30ec7bfffdaaba5ba07fbebcf51656bf9efbffef3e332af8a72fddf1ffe33bb7f9573fef9f75f59bcc6fffacf10f0d817ff77122f3989ffb72a604ce74054b118c0fd325cbfe4fde2defbfb0d64006cfdde72e6dac4c4df479896d103deff7b17c00778d888fbbc77e3a169f9df1f3b70f0c7f67dd931eee9f605700f1a793f5c74f60398372f657311f0edf2c2e49c668e753b1c1e0743a5155cc93c5c917f0fece4c71fcf634beaf7c76a5f8170ea3d8e5515cdd0cd1222e1c1513809c1c2fa9950af49a61ea6016ed5e902f9feeb83c423828430bbd7fcceef6c4cf275e23261d387bf3f3cfb38689cd3af4c6763625c7651349276b0235ad24c098905657a99145a208e25f712d8c18015437f94d5dc0ed76e15c9f01659c9d47d822a7f7fe0144d5a7008fd9159a19634c768b79246d952f8e55c0497d34375de156858f1c8274e0c4c4147d844e842d7ca3ac1ecf4f9cb806db39887a5fffeb06e916cdb2e0dc2f74522cae76ae22f2cd7fda262df76c886cbcd199d88745f25829759b0960093f227a45c17503622db429bb09eebf75ea1dd51809ce5ad78ea972281508326a275d765f8e218cc554752f765559b6eca8ca71bd1f4a2f8994e1144b728f3d5af1f3c165f913301dd89765e17bfbf3ff8db69dcdcd8bc913d20c475932ae7753226244f14d301793fbd431938ae1179a2614b2de31fcd0210990dece9fb08e03a40277d995d137028f2fbd37c17c15c69b790bf94ccb245c3239707adfb8698eec833930a61f6713a42004a2d55e18d8ab90263454da7e4e7a80b0ad8e3422a4b561ec4f3f7874022ab98318a076af3d8aec74b91a43992148e2b1a5da5103b460c460b27475da1d02d5bdf9c9df6ebc71286375ae5aa29b5e4b0eb7153518bbf3f8e7d5cf39db0e04508acf289e9a934a9a0ee4f853f890991ba7299bb523307b98e627e747234b004a1d488867321317ee9c44ac6550ed24aac7f7fa85468a44b6142a233bf1fd7a413cf6c8c777aee999c7c9a737aeb9f6750918e02613023cee69e1af537a61615a4f49621334d3d7bfdc839d0abbf3f083689ad245e00949c984fc47dd30babab79837c88988af5d9149a8d0e54fb4cac184596a20191400832074d84789ef243b23fbddbf70b1f3d7f7f026f5579ffb3db0fa7ccb5a28d97e75bac5f64291b0195f50e2360eeb7b99eeff70a5db318f432ee520946b22f1cf88ca38a0902f669cccab7b4fefe78c6da427db24245a116ca6e376eb556ca73fe521ffebd34ba1224fb7d052c0c79de9087817d2e40cf50b927b00b1e964387ba4cb66b0e5221f2f7a7bbc8d393db829f142de13ffc115354f2ed28b3296c4c6eb8eaf556f966a95cdd63ec4f01ac017889dd9a1b3ff1ebe2ba2f3e4c3963a2c349b9a340e6f3b9d194af13013911543f47130a8cc4b92b9f1fcef6f848ef828643a096b336a82b01d716384458a9d297ad4fdc01697bb5624ce114947bf7909e8e64d99a96f261c36f6458533f076fce131f893dc013fa3557cdfebc15d88e197a8144744ce536af205f8e536665e6f2fb8a19130982fdb4ef0cb195ac4275e0a5110fce7df1cbf6d10b67ad8a3e7f284b8ed181867e0560bc27e63b30fb97809e340e7dba207da2e220731c79a171597b4f54f9fda10376d80ee0080b837f7d4762b8e489cf0e7ed73a3eb6d505f5b9a65b62f554b08b453cfa70a5c90a743edac20ccaf1614c096f853c2b79acd9efcff772d92e61dee9c2624cddd9518824ac0e5c55e159a7dfd92b44689bf37b7708b4c8b30a3eada5ec58323fe20975b8c66a619dce2503c9aa9b3ba6a93478f587fa92262343e72a16f5f204d5b1ea195ca5eb9816464830a2ccd5b920b69e9e282f6f5f695ea7839a81c459956539050f2d66b9f1f7e7ecd1a389616bdba9721085e122973b3ad9337bd74b4cd0fba7d9b6e1ec4c6fd91ae75b43f39a85f3e9e3d1f9355edcd82245504c685e54937357fdacb859e1739d1144358c7d5613be3b3ec5f73cd97941f5312147378699bdbcca87c0eb03ec26acf7c3eebca292206d2abba06a18c30dc72771af544c7330085dabbc65a130d5e3ae2e0307ca4253c6a476296e8f4ef4a1410e1acedb013912fc09f63c56b29367c19d2fa779b9455319a0a3ef5ab0ec90d5746471f0410e3a0f324b0aa6601f1e5b7352b232255308c51da88128f82c258f44e8f57c9c289e74e40ce4a31e466158e9fa595cfbebf7477a05e93be798698f6009d7fc501d7a8dca9e3a06d43bb640d5a0f1fd1e2abaf1736983c9b721183bc196136d3493aa8bfa555009ea98c2e4a2bf3fa1521cf33276857ef6d37ef8b9e02f790e6b6dbb470c1f7331423e628e9d20f8aa1981c550d79a78bb3952bae076a4e5dfd34968f5e373778cf8f747271e60882f95c8da2e2909b9bfbbfff926ce682b3f1e9a716430b3c956ce9ddea6cef3901f25a40b1d23421a727cb5195e3be749b9b5b805337cdfb7385518b29ad3fca97597364a473d7f4aaf0f13a26004fbc9b96345c6730e669f109cb45d9daee9dca138eac89775cec95efcf979514ef33eefdefb2aad61b19c6e3853410588757d13024496d53ed384847ab2725ffb6115adc14cb63fea7bc71fcb6e23d9e4ddc54c158698cd9f41a8425587ef95f2709eb6e3968c9a4ba0261bad1d46bf3456bf0cf3f18e6235465af842c411cf09300520e6689cb0abf695081b4e913990d4c8a3be1caf54ef9b6ab669190b99b1e9ea7d6e8926a3c396fad5c352736278fa58d63287cdfbfcc23304f57a330e6150d1b6304fc899b1c2e1f59bb56d668b035dcd83df9f04a71ed5f744b1ee54a142704af913883cf9ee14ff8de5c98b8d24b73bced6a50192982f3d28696f46d8ccaa60b73f3172999056ac98ef33446ead1fba4239d94da50defac8beaf42e10b40f5ea11559d634f2119ab3f2097bb90b5cda64dc8d9896413f99633432f1c466418f846dc08121482ffff707dd8f026bcf3cbcba4ab78820238c498f9d647e14db2979c401d24db218e654caedfd5d19f8e0180830197bb7c5a7aa762ad5334818a447f8607f7f72e1816766ef3a28525be5e7dddb6365ae84f0163bcbcf2cc72d212a3f8f8078da3aa9cb5654c81c9c6e91357da640797e89c90b5c1eaf8e59beabde6c4c1a2b32765150afcc6c7619687953ae542fea94781eeaadcc7ac3b035d4b453203af6db58ceebf0aee010f78d0e9c6fe1335c4fcc8031cdbb5bcebde8b26d0d644d7a7703a367cb412f32c83f421fb1af14dc6ced002bbf09dc1e24d91d441cc8ec2ce9949e9f9e1935fe8ecf140004408adf9f4a330c65161afd4e638f2a24a159e4949c0a7d0e0be9601e1190f93721a62c6cd2d75a2fda3abf5f5883de424fea8e60ad145f0d9c4d8184257e7f76598eb20b9ba35bda20ab9cd80b3e764d7acab2c976ca6a7c2dd6dbdefcfe903df363cef365ca9f772887f9ec68df2192ca01cc1245f418e8a1bbea13931a485fb8d11971961b6a86c25cd2e94e4bef55a06f1b0c5c8f2b9cfd1e33d2d3c700a9a978c6d5a6ecd907d985c5d33e48253cdee75d5fbf3f1aae4c130f389c5bf2e51c8482ebd34b78df2ec98a93e346c64f2951970fce00c96451625dc6e963ffae56ad4b095cf87a2a2dcd1200da37b92bcb95eb5b278a53a6e25721b87bed426dca98a1998c46a153452be7891131901ee17eade1196b92466c0ea963c7cb9e9acb39ea585c1d3efbea6f264fd5fa2e873c3ff5815eaf1c1a25918beddb1459c3eb10ba27ce4e59bfc9e04546f4be94ca06af4d8412d2fc7c267b3bf5d85705aff1a86a273e6e72a84a252fe940cf88bb0be5af6658ddac31083b7a4aa3f01e325e70a0bbb753de4aed252ec1620c58b673d2f7623f4954dc9eab566357fe2162ebbe6f64b275ca8215f29d0343b8444ae8069f9d9fe2c3961f3873597667524be93e24d96fba749e9a176f9add2e501a645ef11430f16c3d8b38e5ee987e28c82506e96b21fd6cbaf5e18faabe63fb006e3a7d675e92471800f462df5324eb935b69f18d1201bb7cf64cc87b8c7d63f869f0de73553ef74a1d428f5d7652307b7521633e21e6c4f1c5070eda82ddaee51ed3ecab7ee1a87da72833f9dbb6deb429de64ea49e5ee6ce5a68b3b2fa3e062aadf1f6087727f1261a9d20a0bd09cad49b0169c11c84e4930da241a6403353ea83f2064c992d6428ce6262c65ba8aae51f600e6048b65376ea47673482b53b392ad448faf5c572174264c828df3f276d71673154de033b4565c7cd9ac278907f311cc76fe916f4f9703916014d202a764b94a9322e0a668d2eb3efb076517b9107376e169bc133ef29d78e69c2bace0da5329631fcbb8d020badba50c32d2777d7a005c977aeed48a4e62bd24aca9e2db51ee99212e652ccb8b151dd518d1a6998179ccd827e9588b6d61d2f48a18cf6f76599b5b1fff8834a087ce2a0c5dc77500dfea16245f924fbef63db7f3153ce643e0c71c30ad5739c84225f4f68a840fa7860d677cbf502c5807113c43a2772538c81c1bc7d2426434be2598e6e58332797da496926fe2b26fdff2662456433780175cd77666a6d18770374823eb07c4617b2afff803f3e422e2f5604baa77e4d5b631b16a15885e87da7cdf72cc61d13bb9dd2e3795692ca019a890a23ddd2b66374eb0e8455de5eaaedc5c8fae00fbc82f1dafb5b8a77d0fbc5445c728ac93a5c785656ed959f4d8d9937b9303211b9f998cceea1d1baf7ef8eeabc1d2e27a82b3400a737d5482d1a3ae1499ea44624ecaf84fd3cf9112dedfaec6f80e9f7976717b3a56328dee66cbe1705c4321ea6057866084ec366e82c1f49006688b02369b0d6019df7cc36485d0b019b7fa140b2f73fc5d5c5df1e001c37a2019dcfce13a37bf89b540b8a9518207b8b402bc2c0dbbc2195a002658bd8116265c90ebd71afe8e14b2f01fecb61ee6b693059ba4d267d3ae3c5138f8780fa5f4fb23d4df1994ae852f942aefb4386bb283f3563303581636a57bb19e5657ee278c75ee23433e67cbaaccb92f3db266513b59d7652f6e61bd0367ee1ec2aedae21703805877d8c71d66f7202b9431b383e15907b13abf366f323e1ba9be3632cc28f6ab8c96fdccc5b27d952af2cebb23d00ee3b0c8f2cedef75bf77597bd3d2e6e1d0d773d32346970756aa508a1cc222a67b69a3410d259ff1ceb81400a45354d877901a1a86d63086f4b79a23b98b16bfefd89ef2340a88fecfd485f4795af28ec544e740c46ef2c2d27bc6c436e282dc71b8a1a22285d861505df12a99b43e242b66a8a471de47ebbf4537e577dab5e9529ba82eb545ccf1dcf11952ec80188f11917c9a0be6b4d2886cef856eb17b64597bb1b9b15e40857e3581ae30aa4e8469c249537a3dd8c64982fb6e50250708c776763c10c8c7f34e9c5d9997f8b3670476eb8f5067ad95a675ad5643db7bd790597b78009f38b4335dddb22a407f7bc099f7a8aa5180c05d88170d844612fa4717d1e884779d1ab05b5a4d10a18789773d9ea51e892cdab14cabf2b4446cafc4b80f990103bbc4c1e7bdf19e23d1726eca3fc4eb8b5b006520ec2ba908338a2699c2dd1c27f621c400922414b7fb52e715985e7a300f4d7811ed2911b80210ef6f101890fb8df9f3b8c053935e5c021f5ed5cca55f68644c2d36b2fac3e2fc0d268ba4ccba52cd98068e35ae819be6d4087df7dc188f06451daf315a72b90f0f3f787634da83400186ae2d43b7888812d83e63a64ab5398b010346f0388c09e349642b1ad17c1bc6bef908b52949a0ff71134bd0fc8ce6aaf179ffefe18805b7b26327bc0510f537af0020752f4f80082d75289c1abaee02b9d9f0b22f2699b7922c7876055e01c932f1e6c8455f447bf80cca9dadf6e973eef1507d12ecdbe66b891ecdfec97e8b731dc435430ae4aaf3291653918285f51012f0210dc6c1dcc57751315b8e555b17c315b7430a87f573d932ad5b0aaac693eec7a080194d3a0ac930651050f330b8f43ab3e83e9c416b4270a2ae03a0a5708fbc7b17cff507ba500d0bd2c60f87cf8b83b79e11090e3823a8e89d49e8a7aa67847419e42c82afc4e919fdbc890122d546c03c4b3d5d15d1885aed4db9a360a8b4e74391dbba51d8b9abafde99ed85f3612f3cad4f09d1aab91f6f1d8c90ed41011161a99c1a637701163007b45d6ca5658999554da3c874faaeab48e778d241dc7f9fe2eecdf9f406215139771b6238b7bb52c4b954dc03195d24064d35c9157bd466fa74decebd018fca5d0787dcf28f90cacfc6d16219b3f7afb9db2a737457727dff7782cd72efa1695910855519f30eaafdaf7793e1fe4c9e12556cb5e5c8959c16bed0196b1449ffd479598843de0c0fa34f1734daecfed7098bfffcdd3a6060f2d459c6c81b2b587d0bee73973c9e5b6f25e307472b3e819ca3541e1a5ef367a89a770a746ff52bd47984247371efed10285130dfe736708f03dbe3a94ecda32894f89c54167da31ae90e6d874fd52f2d5df35fa555833db1b57cec2ae093fd85c9af62ea53d6b099abe817b48d9b16e75760bf5112c80762108427c11b40ef4ce42f6e13ecdc3d2e008a22524a952cdda98ddf771ebfdae6c9a8283fdb398acb23ddb64245c92d696061d6e0524a4d039525c3783e8fba1f418aa45da3d3c48d26f0f58dc2eeed127e5293475f612ecda11bde71c4b819495f7113dbbdee8d300128a39b688dffc66f2be4a034bf68e39287910ba376b30b51da9a615d86d3debe1ce07313b3b8362ec0fa22b3827e95266a7aa37fa6a679fbe2aaddc6679eeef7cf33e66305c7adeb5cd33549d7ead63012418bafd6d6df45342e4d01beaa7eeda5b92c6565c0f745d630e1fc05171b2dcf5b4b56d7d842a46bbccef0f367cf20e5ac4fccbdb093c92e0435b2ba76660cfb9d5fa16f0a32f8e2f71ac15783a5fbaaff58121cfedc9a12a24a42a0fc84a7cdabb538fd51d8504d50ddce1564f174dd62f2c4f6301768b2f5cd759c496476f902cc1a4e1a1c9fa58e9d921780cfa372c7fc1cbd4eaa08c30f26ef262af4237d59465ddd51ab6a98e7f332b095785efd95a497583d3241c6d2f2d6a586d27af576cf250e6951fc54d1a623b8e761bdc25617c82b1623e3dab66bb35eb53e48a33d0fa38b35db9cb1df695c5c21571522ed48835169b7e6b638565910a6c15ad9dd9cd5a362fdd176bdc4d64177885cfc9274032fcd67a1c9522f890b215ed9ed304490a3bb82156b070273f4cfb327ab57cc9d077893726cf3df1537983b97d000a0d609d2b85d29d2dad9999e4e3cbbbeb941ff8857f312aca4add02c68ff652dd423653e63985b6968b4420e06a66f760900d53099adb0cb1a5fb5e8bf2f09ce4885a96f71ce4996c527bfb2cb2a9707b5e8e93903c3c581f0773515f7ec84165827eb7dff4257333bc6b0d12fb5959922f32e7d1f411502924e40997da40306cba9cc1b0dcfca6065fc6f1583e3e16709b08330ec8db0bdddd9c806ddf1dd7410edbc3d19c9e58ad1766b3271544537acefa203f0af7f0b90a67f63d1a45efceb78f8db043c8036ac8d92ef0db307b8c963642781d138bc4c21328064c8fe3500df9cc3207a3f202e8a9adb17a2c8be5db828e6845fa444e5bea7f7f8ede2e1f4a078a537dba4981b357ef9534cfd833bdd7996b66be51a7efd27eb61107f946329fdf2b7f1a77dd8de3f0d62b44c8999497ec4816df37bfa1b6951ffedb28739c2045e1dd352efc414e827b1e1e8c100a9ea2289979a804a4748818db82a7b26367d708cf496ca951e86f652c42d0b1e8edb31a92789356f2b8e61ca5a1da214c4e9a367fe2cfb07b6328d6a66ccb6a329c7f3aabae02d68762a4b94db57b9dc01ab3d3556959585e02c9df54e37b754141e095d846573ea28223e69bed945861d4ba77daa3ef6ef12d91b381a4c264c3d76e62c1db9079980e58117b7a6e3db897d5d0d88d943745476a33e6026fb23273d4c28447ac5c680e4f3332df71a15cf2a839b27dba05bc870aaa0c615b633f6c7445c0b3c37d6be58b3a7c864d0ac8bbea2f9aec1d75b3a3f9d30d7cd66ea764d64e2a646d07c9da39ed41a2dc49d88fe3e53f9b1db55488b89d990ebee9f2f98a28e104fd67a66d5e316fbf1027f58cb60acb631ce660cf2fada47e6e869121b2303e1e831631506fbe1358a115a2196bf54318e9a1af1beee17949919bcd65c5bbe16bd3bbbdf3def8b545b7b0a096126ad98eabce9df758b1aeddc83ddc5639029a072609ae84cf6934b4151222d6f360d428125db96792f6562fa54b3777377159779e5b3e5a1e45a0438c6e52cde3fb992e5ba8dca9ae3db055547628c888f11ffa185a617ce3622d152806180d7d25a0ed111a322a4a44b8db894fcf3bdeb49d42286a614bec1300eedbd2c2b3c16cafe88d7c0f942781fa395c5f80457f0d25084c7424f8d359a568c13bc388c7f6625fdf99f8fd9173a9b7e9da2bbc5e61aa8cdc8471a68fb2eb399dd70789a2e19804a20d338f78e13ce990d0c8b4f8ca8c404f9217e57c61682a15e70d61f89d21fab73c0801a92c4cbb754249a6b266ebcd3f51fec3e2fb7638cf4cdd32c6c6b920b7aa122f03cf315e376008163413a33975f074e1b7427d23e5f7a760d927d4cc04e87507bdaa6dc4e2dcdb32985187a84b07461c8b135fa1cfd60623ee57bb55c6f18b031b96685022cb44e91a6b015f08d7e0d1dd7b1f6739d4402a02517c1d9ffc737e5fe3d377b518dc66a19200f60c6145dbddb7a8767ea71d75c8549b186075f7a99d0687fddec15e35233bf2cde4fe7ce4c7687dbfc7b93f617f7fa64bbf36766e38ce9a6c5e78b05272d2ac060cd51d4ae13d692999e9b2a9b524f789f197531a0fa42f8d1cd87fff8fe47f5368b43058a5abe6e9fbaeba12447e11c4ec53fc4be7e9a0bf66777aca46d608e3c9f95e410d601041b7cf22479836965438c6d29692dca43a7b356bab00b619463bbf92aa26e174b005fc3a6f39d66dfa54794f14189ac5e186ae4f3291b93e8fe355394916f9defe022b7b930f6be2d6e59b91e2f08a52a8e6fdb09d5b441e1fac280c090c978f6a33bc4925f76f31f87ce330667188384b33abbc2f4fef34044758555bffc466780c858b7d7f7f3635ae0d711803f2cb60d4caf3e18445aa0bdcabab57f66143063668d93df070672aa906f5e78b8b84c17eb62c109b9d7bc96517190a2121f4ed76af27e6f438901f98ce14761c0269cb9e1ceb8da074cc999052cdb79275ab75fb94e5bb5b56e203591ed4de8031f7f7b36e047efaa2737011de9dbd8fe30dbaf121037b7c6d69c2e06698e0b79d4c1ee8fa8d397b2c46452ac3037f91db2bac36da61559ebf0203799f6ad316b71b8fb606718571bcfda98b6c43cd616ff1e383101710d002c10e9b35aee0f3636575b2b18123ed89232d711172cb0c8d64e89d3ee58df08a578c47524a300a96ea839b06a1e35e799f14a2a2ddc2e6ecef4c3b6d0df1f273c72d3c879df30de536b372863b5387a18a6ecf73ef45441fddf279afe6e149def6143013856f52dde269c004cee5259cd791e825d4b6afbf442fed54d6e9a700268d8abed8988610c33116fe7908353819169fb5a790775d6a48e2c2318521bff8df1f015a06d0ec0c17e24f26d78fe02a247e7889f4a32ca7a921d10e988fab4e79c7a52022f8b20f1991af59ec59cef2731a06f4253560089703bfe7a62185b523a41c8684c7dffee95a12413c4158294791093da91e6c7fdb63b97ba01c4c2e177a83ae60e788f15a94d3bb6b5b77de6ef4b6bf665cfcfee49ba95d88657320cf21e935c39995f38ccfba8548f4d511a6b982db3133b0348fb4dc475d0f9b0e5c9161c077180ecf72517f2c3b3ff498cf7cd3a0c369c7db643a2665e1e2ab1decf0f2e5c284d47153067e8be437d4a2f0864b0472c053a5aa9cdddb0d8943e47bcbf9f1c56863a62dc31a2ab7ca088d504a8abdf01883913212b58bada1be0d412df956f5aa8272f05e901c2375200371bb79fb4b3a1c122d0ec8c477777ab05eddd193309e316fbf2065e11461efcc7f892f99af83f95518d887452ee1d5210d530b51dcdc74e8ee8714ca0de7953085f3f67f9e4772fdc07454820d65f9dfff79600afecfe34effd95bf6e2defe4f
| |
1 | 19,500,345 |
af35df0720ea47d909ce96bee88dd533a878bec8a7dd761a689c90f5216fe49f
|
cd5f71a192d52287ec1505e3973812a993e75307499942e4d9bbbeb473a66cff
|
20977658df98841d72d001bae43c5501553eabe9
|
612e2daddc89d91409e40f946f9f7cfe422e777e
|
43ef070c2ae63a5dd93e3d46d77f778e76212a62
|
3d602d80600a3d3981f3363d3d373d3d3d363d730532fd6e1109756be1503dabe7194b70df0257a75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730532fd6e1109756be1503dabe7194b70df0257a75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC721_init_unchained(name_, symbol_);\n }\n\n function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _ownerOf(tokenId);\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner or approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n */\n function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n return _owners[tokenId];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _ownerOf(tokenId) != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n unchecked {\n // Will not overflow unless all 2**256 token ids are minted to the same owner.\n // Given that tokens are minted one by one, it is impossible in practice that\n // this ever happens. Might change if we allow batch minting.\n // The ERC fails to describe this case.\n _balances[to] += 1;\n }\n\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n * This is an internal function that does not check if the sender is authorized to operate on the token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n owner = ERC721Upgradeable.ownerOf(tokenId);\n\n // Clear approvals\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // Cannot overflow, as that would require more tokens to be burned/transferred\n // out than the owner initially received through minting and transferring in.\n _balances[owner] -= 1;\n }\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId, 1);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId, 1);\n\n // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n // Clear approvals from the previous owner\n delete _tokenApprovals[tokenId];\n\n unchecked {\n // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n // `from`'s balance is the number of token held, which is at least one before the current\n // transfer.\n // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n // all 2**256 token ids to be minted, which in practice is impossible.\n _balances[from] -= 1;\n _balances[to] += 1;\n }\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n * - When `from` is zero, the tokens will be minted for `to`.\n * - When `to` is zero, ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n * - When `from` is zero, the tokens were minted for `to`.\n * - When `to` is zero, ``from``'s tokens were burned.\n * - `from` and `to` are never both zero.\n * - `batchSize` is non-zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n /**\n * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n *\n * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n * that `ownerOf(tokenId)` is `a`.\n */\n // solhint-disable-next-line func-name-mixedcase\n function __unsafe_increaseBalance(address account, uint256 amount) internal {\n _balances[account] += amount;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[44] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721Upgradeable.sol\";\nimport \"../../../utils/ContextUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @title ERC721 Burnable Token\n * @dev ERC721 Token that can be burned (destroyed).\n */\nabstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable {\n function __ERC721Burnable_init() internal onlyInitializing {\n }\n\n function __ERC721Burnable_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Burns `tokenId`. See {ERC721-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n _burn(tokenId);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMathUpgradeable {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMathUpgradeable.abs(value))));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"
},
"@openzeppelin/contracts/utils/ShortStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.8;\n\nimport \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(_FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/StorageSlot.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n"
},
"contracts/collectionTemplates/NFTCollection.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\n\nimport \"../interfaces/internal/INFTCollectionInitializer.sol\";\n\nimport \"../libraries/AddressLibrary.sol\";\n\nimport \"../mixins/collections/CollectionRoyalties.sol\";\nimport \"../mixins/collections/NFTCollectionType.sol\";\nimport \"../mixins/collections/SequentialMintCollection.sol\";\nimport \"../mixins/collections/TokenLimitedCollection.sol\";\nimport \"../mixins/shared/ContractFactory.sol\";\n\nerror NFTCollection_Max_Token_Id_Has_Already_Been_Minted(uint256 maxTokenId);\nerror NFTCollection_Token_CID_Already_Minted();\nerror NFTCollection_Token_CID_Required();\nerror NFTCollection_Token_Creator_Payment_Address_Required();\n\n/**\n * @title A collection of 1:1 NFTs by a single creator.\n * @notice A 10% royalty to the creator is included which may be split with collaborators on a per-NFT basis.\n * @author batu-inal & HardlyDifficult\n */\ncontract NFTCollection is\n INFTCollectionInitializer,\n ContractFactory,\n Initializable,\n ERC165Upgradeable,\n ERC721Upgradeable,\n ERC721BurnableUpgradeable,\n NFTCollectionType,\n SequentialMintCollection,\n TokenLimitedCollection,\n CollectionRoyalties\n{\n using AddressLibrary for address;\n using AddressUpgradeable for address;\n\n /**\n * @notice The baseURI to use for the tokenURI, if undefined then `ipfs://` is used.\n */\n string private baseURI_;\n\n /**\n * @notice Stores hashes minted to prevent duplicates.\n * @dev 0 means not yet minted, set to 1 when minted.\n * For why using uint is better than using bool here:\n * github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.3/contracts/security/ReentrancyGuard.sol#L23-L27\n */\n mapping(string => uint256) private cidToMinted;\n\n /**\n * @dev Stores an optional alternate address to receive creator revenue and royalty payments.\n * The target address may be a contract which could split or escrow payments.\n */\n mapping(uint256 => address payable) private tokenIdToCreatorPaymentAddress;\n\n /**\n * @dev Stores a CID for each NFT.\n */\n mapping(uint256 => string) private _tokenCIDs;\n\n /**\n * @notice Emitted when the owner changes the base URI to be used for NFTs in this collection.\n * @param baseURI The new base URI to use.\n */\n event BaseURIUpdated(string baseURI);\n\n /**\n * @notice Emitted when a new NFT is minted.\n * @param creator The address of the collection owner at this time this NFT was minted.\n * @param tokenId The tokenId of the newly minted NFT.\n * @param indexedTokenCID The CID of the newly minted NFT, indexed to enable watching for mint events by the tokenCID.\n * @param tokenCID The actual CID of the newly minted NFT.\n */\n event Minted(address indexed creator, uint256 indexed tokenId, string indexed indexedTokenCID, string tokenCID);\n\n /**\n * @notice Emitted when the payment address for creator royalties is set.\n * @param fromPaymentAddress The original address used for royalty payments.\n * @param toPaymentAddress The new address used for royalty payments.\n * @param tokenId The NFT which had the royalty payment address updated.\n */\n event TokenCreatorPaymentAddressSet(\n address indexed fromPaymentAddress,\n address indexed toPaymentAddress,\n uint256 indexed tokenId\n );\n\n /**\n * @notice Initialize the template's immutable variables.\n * @param _contractFactory The factory which will be used to create collection contracts.\n */\n constructor(address _contractFactory) ContractFactory(_contractFactory) NFTCollectionType(NFT_COLLECTION_TYPE) {\n // The template will be initialized by the factory when it's registered for use.\n }\n\n /**\n * @notice Called by the contract factory on creation.\n * @param _creator The creator of this collection.\n * @param _name The collection's `name`.\n * @param _symbol The collection's `symbol`.\n */\n function initialize(\n address payable _creator,\n string calldata _name,\n string calldata _symbol\n ) external initializer onlyContractFactory {\n __ERC721_init(_name, _symbol);\n _initializeSequentialMintCollection(_creator);\n // maxTokenId defaults to 0 but may be assigned later on.\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path.\n * @dev This is only callable by the collection creator/owner.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mint(string calldata tokenCID) external returns (uint256 tokenId) {\n tokenId = _mint(tokenCID);\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path and approves the provided operator address.\n * @dev This is only callable by the collection creator/owner.\n * It can be used the first time they mint to save having to issue a separate approval\n * transaction before listing the NFT for sale.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @param operator The address to set as an approved operator for the creator's account.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mintAndApprove(string calldata tokenCID, address operator) external returns (uint256 tokenId) {\n tokenId = _mint(tokenCID);\n setApprovalForAll(operator, true);\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path and have creator revenue/royalties sent to an alternate address.\n * @dev This is only callable by the collection creator/owner.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @param tokenCreatorPaymentAddress The royalty recipient address to use for this NFT.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mintWithCreatorPaymentAddress(\n string calldata tokenCID,\n address payable tokenCreatorPaymentAddress\n ) public returns (uint256 tokenId) {\n if (tokenCreatorPaymentAddress == address(0)) {\n revert NFTCollection_Token_Creator_Payment_Address_Required();\n }\n tokenId = _mint(tokenCID);\n tokenIdToCreatorPaymentAddress[tokenId] = tokenCreatorPaymentAddress;\n emit TokenCreatorPaymentAddressSet(address(0), tokenCreatorPaymentAddress, tokenId);\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path and approves the provided operator address.\n * @dev This is only callable by the collection creator/owner.\n * It can be used the first time they mint to save having to issue a separate approval\n * transaction before listing the NFT for sale.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @param tokenCreatorPaymentAddress The royalty recipient address to use for this NFT.\n * @param operator The address to set as an approved operator for the creator's account.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mintWithCreatorPaymentAddressAndApprove(\n string calldata tokenCID,\n address payable tokenCreatorPaymentAddress,\n address operator\n ) external returns (uint256 tokenId) {\n tokenId = mintWithCreatorPaymentAddress(tokenCID, tokenCreatorPaymentAddress);\n setApprovalForAll(operator, true);\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path and have creator revenue/royalties sent to an alternate address\n * which is defined by a contract call, typically a proxy contract address representing the payment terms.\n * @dev This is only callable by the collection creator/owner.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @param paymentAddressFactory The contract to call which will return the address to use for payments.\n * @param paymentAddressCall The call details to send to the factory provided.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mintWithCreatorPaymentFactory(\n string calldata tokenCID,\n address paymentAddressFactory,\n bytes calldata paymentAddressCall\n ) public returns (uint256 tokenId) {\n address payable tokenCreatorPaymentAddress = paymentAddressFactory.callAndReturnContractAddress(paymentAddressCall);\n tokenId = mintWithCreatorPaymentAddress(tokenCID, tokenCreatorPaymentAddress);\n }\n\n /**\n * @notice Mint an NFT defined by its metadata path and have creator revenue/royalties sent to an alternate address\n * which is defined by a contract call, typically a proxy contract address representing the payment terms.\n * @dev This is only callable by the collection creator/owner.\n * It can be used the first time they mint to save having to issue a separate approval\n * transaction before listing the NFT for sale.\n * @param tokenCID The CID for the metadata json of the NFT to mint.\n * @param paymentAddressFactory The contract to call which will return the address to use for payments.\n * @param paymentAddressCall The call details to send to the factory provided.\n * @param operator The address to set as an approved operator for the creator's account.\n * @return tokenId The tokenId of the newly minted NFT.\n */\n function mintWithCreatorPaymentFactoryAndApprove(\n string calldata tokenCID,\n address paymentAddressFactory,\n bytes calldata paymentAddressCall,\n address operator\n ) external returns (uint256 tokenId) {\n tokenId = mintWithCreatorPaymentFactory(tokenCID, paymentAddressFactory, paymentAddressCall);\n setApprovalForAll(operator, true);\n }\n\n /**\n * @notice Allows the collection creator to destroy this contract only if\n * no NFTs have been minted yet or the minted NFTs have been burned.\n * @dev Once destructed, a new collection could be deployed to this address (although that's discouraged).\n */\n function selfDestruct() external onlyOwner {\n _selfDestruct();\n }\n\n /**\n * @notice Allows the owner to assign a baseURI to use for the tokenURI instead of the default `ipfs://`.\n * @param baseURIOverride The new base URI to use for all NFTs in this collection.\n */\n function updateBaseURI(string calldata baseURIOverride) external onlyOwner {\n baseURI_ = baseURIOverride;\n\n emit BaseURIUpdated(baseURIOverride);\n }\n\n /**\n * @notice Allows the owner to set a max tokenID.\n * This provides a guarantee to collectors about the limit of this collection contract, if applicable.\n * @dev Once this value has been set, it may be decreased but can never be increased.\n * This max may be more than the final `totalSupply` if 1 or more tokens were burned.\n * @param _maxTokenId The max tokenId to set, all NFTs must have a tokenId less than or equal to this value.\n */\n function updateMaxTokenId(uint32 _maxTokenId) external onlyOwner {\n _updateMaxTokenId(_maxTokenId);\n }\n\n /**\n * @inheritdoc ERC721Upgradeable\n * @dev The function here asserts `onlyOwner` while the super confirms ownership.\n */\n function _burn(uint256 tokenId) internal override(ERC721Upgradeable, SequentialMintCollection) onlyOwner {\n delete cidToMinted[_tokenCIDs[tokenId]];\n delete tokenIdToCreatorPaymentAddress[tokenId];\n delete _tokenCIDs[tokenId];\n super._burn(tokenId);\n }\n\n function _mint(string calldata tokenCID) private onlyOwner returns (uint256 tokenId) {\n if (bytes(tokenCID).length == 0) {\n revert NFTCollection_Token_CID_Required();\n }\n if (cidToMinted[tokenCID] != 0) {\n revert NFTCollection_Token_CID_Already_Minted();\n }\n // If the mint will exceed uint32, the addition here will overflow. But it's not realistic to mint that many tokens.\n tokenId = ++latestTokenId;\n if (maxTokenId != 0 && tokenId > maxTokenId) {\n revert NFTCollection_Max_Token_Id_Has_Already_Been_Minted(maxTokenId);\n }\n cidToMinted[tokenCID] = 1;\n _tokenCIDs[tokenId] = tokenCID;\n _safeMint(msg.sender, tokenId);\n emit Minted(msg.sender, tokenId, tokenCID, tokenCID);\n }\n\n /**\n * @notice The base URI used for all NFTs in this collection.\n * @dev The `tokenCID` is appended to this to obtain an NFT's `tokenURI`.\n * e.g. The URI for a token with the `tokenCID`: \"foo\" and `baseURI`: \"ipfs://\" is \"ipfs://foo\".\n * @return uri The base URI used by this collection.\n */\n function baseURI() external view returns (string memory uri) {\n uri = _baseURI();\n }\n\n /**\n * @notice Checks if the creator has already minted a given NFT using this collection contract.\n * @param tokenCID The CID to check for.\n * @return hasBeenMinted True if the creator has already minted an NFT with this CID.\n */\n function getHasMintedCID(string calldata tokenCID) external view returns (bool hasBeenMinted) {\n hasBeenMinted = cidToMinted[tokenCID] != 0;\n }\n\n /**\n * @inheritdoc CollectionRoyalties\n */\n function getTokenCreatorPaymentAddress(\n uint256 tokenId\n ) public view override returns (address payable creatorPaymentAddress) {\n creatorPaymentAddress = tokenIdToCreatorPaymentAddress[tokenId];\n if (creatorPaymentAddress == address(0)) {\n creatorPaymentAddress = owner;\n }\n }\n\n /**\n * @inheritdoc IERC165Upgradeable\n */\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n override(ERC165Upgradeable, ERC721Upgradeable, NFTCollectionType, CollectionRoyalties)\n returns (bool interfaceSupported)\n {\n interfaceSupported = super.supportsInterface(interfaceId);\n }\n\n /**\n * @inheritdoc IERC721MetadataUpgradeable\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory uri) {\n _requireMinted(tokenId);\n\n uri = string.concat(_baseURI(), _tokenCIDs[tokenId]);\n }\n\n function _baseURI() internal view override returns (string memory uri) {\n uri = baseURI_;\n if (bytes(uri).length == 0) {\n uri = \"ipfs://\";\n }\n }\n}\n"
},
"contracts/interfaces/internal/INFTCollectionInitializer.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\n/**\n * @title Declares the interface for initializing an NFTCollection contract.\n * @author batu-inal & HardlyDifficult\n */\ninterface INFTCollectionInitializer {\n function initialize(address payable _creator, string memory _name, string memory _symbol) external;\n}\n"
},
"contracts/interfaces/internal/INFTCollectionType.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\n/**\n * @title Declares the type of the collection contract.\n * @dev This interface is declared as an ERC-165 interface.\n * @author reggieag\n */\ninterface INFTCollectionType {\n function getNFTCollectionType() external view returns (string memory collectionType);\n}\n"
},
"contracts/interfaces/standards/royalties/IGetFees.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\n/**\n * @notice An interface for communicating fees to 3rd party marketplaces.\n * @dev Originally implemented in mainnet contract 0x44d6e8933f8271abcf253c72f9ed7e0e4c0323b3\n */\ninterface IGetFees {\n /**\n * @notice Get the recipient addresses to which creator royalties should be sent.\n * @dev The expected royalty amounts are communicated with `getFeeBps`.\n * @param tokenId The ID of the NFT to get royalties for.\n * @return recipients An array of addresses to which royalties should be sent.\n */\n function getFeeRecipients(uint256 tokenId) external view returns (address payable[] memory recipients);\n\n /**\n * @notice Get the creator royalty amounts to be sent to each recipient, in basis points.\n * @dev The expected recipients are communicated with `getFeeRecipients`.\n * @param tokenId The ID of the NFT to get royalties for.\n * @return royaltiesInBasisPoints The array of fees to be sent to each recipient, in basis points.\n */\n function getFeeBps(uint256 tokenId) external view returns (uint256[] memory royaltiesInBasisPoints);\n}\n"
},
"contracts/interfaces/standards/royalties/IGetRoyalties.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\ninterface IGetRoyalties {\n /**\n * @notice Get the creator royalties to be sent.\n * @dev The data is the same as when calling `getFeeRecipients` and `getFeeBps` separately.\n * @param tokenId The ID of the NFT to get royalties for.\n * @return recipients An array of addresses to which royalties should be sent.\n * @return royaltiesInBasisPoints The array of fees to be sent to each recipient, in basis points.\n */\n function getRoyalties(\n uint256 tokenId\n ) external view returns (address payable[] memory recipients, uint256[] memory royaltiesInBasisPoints);\n}\n"
},
"contracts/interfaces/standards/royalties/IRoyaltyInfo.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\n/**\n * @notice Interface for EIP-2981: NFT Royalty Standard.\n * For more see: https://eips.ethereum.org/EIPS/eip-2981.\n */\ninterface IRoyaltyInfo {\n /**\n * @notice Get the creator royalties to be sent.\n * @param tokenId The ID of the NFT to get royalties for.\n * @param salePrice The total price of the sale.\n * @return receiver The address to which royalties should be sent.\n * @return royaltyAmount The total amount that should be sent to the `receiver`.\n */\n function royaltyInfo(\n uint256 tokenId,\n uint256 salePrice\n ) external view returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"contracts/interfaces/standards/royalties/ITokenCreator.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\ninterface ITokenCreator {\n /**\n * @notice Returns the creator of this NFT collection.\n * @param tokenId The ID of the NFT to get the creator payment address for.\n * @return creator The creator of this collection.\n */\n function tokenCreator(uint256 tokenId) external view returns (address payable creator);\n}\n"
},
"contracts/libraries/AddressLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nstruct CallWithoutValue {\n address target;\n bytes callData;\n}\n\nerror AddressLibrary_Proxy_Call_Did_Not_Return_A_Contract(address addressReturned);\n\n/**\n * @title A library for address helpers not already covered by the OZ library.\n * @author batu-inal & HardlyDifficult\n */\nlibrary AddressLibrary {\n using AddressUpgradeable for address;\n using AddressUpgradeable for address payable;\n\n /**\n * @notice Calls an external contract with arbitrary data and parse the return value into an address.\n * @param externalContract The address of the contract to call.\n * @param callData The data to send to the contract.\n * @return contractAddress The address of the contract returned by the call.\n */\n function callAndReturnContractAddress(\n address externalContract,\n bytes calldata callData\n ) internal returns (address payable contractAddress) {\n bytes memory returnData = externalContract.functionCall(callData);\n contractAddress = abi.decode(returnData, (address));\n if (!contractAddress.isContract()) {\n revert AddressLibrary_Proxy_Call_Did_Not_Return_A_Contract(contractAddress);\n }\n }\n\n function callAndReturnContractAddress(\n CallWithoutValue calldata call\n ) internal returns (address payable contractAddress) {\n contractAddress = callAndReturnContractAddress(call.target, call.callData);\n }\n}\n"
},
"contracts/mixins/collections/CollectionRoyalties.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\n\nimport \"../../interfaces/standards/royalties/IGetFees.sol\";\nimport \"../../interfaces/standards/royalties/IGetRoyalties.sol\";\nimport \"../../interfaces/standards/royalties/IRoyaltyInfo.sol\";\nimport \"../../interfaces/standards/royalties/ITokenCreator.sol\";\n\nimport \"../shared/Constants.sol\";\n\n/**\n * @title Defines various royalty APIs for broad marketplace support.\n * @author batu-inal & HardlyDifficult\n */\nabstract contract CollectionRoyalties is IGetRoyalties, IGetFees, IRoyaltyInfo, ITokenCreator, ERC165Upgradeable {\n /**\n * @inheritdoc IGetFees\n */\n function getFeeRecipients(uint256 tokenId) external view returns (address payable[] memory recipients) {\n recipients = new address payable[](1);\n recipients[0] = getTokenCreatorPaymentAddress(tokenId);\n }\n\n /**\n * @inheritdoc IGetFees\n * @dev The tokenId param is ignored since all NFTs return the same value.\n */\n function getFeeBps(uint256 /* tokenId */) external pure returns (uint256[] memory royaltiesInBasisPoints) {\n royaltiesInBasisPoints = new uint256[](1);\n royaltiesInBasisPoints[0] = ROYALTY_IN_BASIS_POINTS;\n }\n\n /**\n * @inheritdoc IGetRoyalties\n */\n function getRoyalties(\n uint256 tokenId\n ) external view returns (address payable[] memory recipients, uint256[] memory royaltiesInBasisPoints) {\n recipients = new address payable[](1);\n recipients[0] = getTokenCreatorPaymentAddress(tokenId);\n royaltiesInBasisPoints = new uint256[](1);\n royaltiesInBasisPoints[0] = ROYALTY_IN_BASIS_POINTS;\n }\n\n /**\n * @notice The address to pay the creator proceeds/royalties for the collection.\n * @param tokenId The ID of the NFT to get the creator payment address for.\n * @return creatorPaymentAddress The address to which royalties should be paid.\n */\n function getTokenCreatorPaymentAddress(\n uint256 tokenId\n ) public view virtual returns (address payable creatorPaymentAddress);\n\n /**\n * @inheritdoc IRoyaltyInfo\n */\n function royaltyInfo(\n uint256 tokenId,\n uint256 salePrice\n ) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = getTokenCreatorPaymentAddress(tokenId);\n unchecked {\n royaltyAmount = salePrice / ROYALTY_RATIO;\n }\n }\n\n /**\n * @inheritdoc IERC165Upgradeable\n * @dev Checks the supported royalty interfaces.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool interfaceSupported) {\n interfaceSupported = (interfaceId == type(IRoyaltyInfo).interfaceId ||\n interfaceId == type(ITokenCreator).interfaceId ||\n interfaceId == type(IGetRoyalties).interfaceId ||\n interfaceId == type(IGetFees).interfaceId ||\n super.supportsInterface(interfaceId));\n }\n}\n"
},
"contracts/mixins/collections/NFTCollectionType.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/ShortStrings.sol\";\n\nimport \"../../interfaces/internal/INFTCollectionType.sol\";\n\n/**\n * @title A mixin to add the NFTCollectionType interface to a contract.\n * @author HardlyDifficult & reggieag\n */\nabstract contract NFTCollectionType is INFTCollectionType, ERC165Upgradeable {\n using ShortStrings for string;\n using ShortStrings for ShortString;\n\n ShortString private immutable _collectionTypeName;\n\n constructor(string memory collectionTypeName) {\n _collectionTypeName = collectionTypeName.toShortString();\n }\n\n /**\n * @notice Returns a name of the type of collection this contract represents.\n * @return collectionType The collection type.\n */\n function getNFTCollectionType() external view returns (string memory collectionType) {\n collectionType = _collectionTypeName.toString();\n }\n\n /**\n * @inheritdoc IERC165Upgradeable\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool interfaceSupported) {\n interfaceSupported = interfaceId == type(INFTCollectionType).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/mixins/collections/SequentialMintCollection.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol\";\n\nimport \"../../interfaces/standards/royalties/ITokenCreator.sol\";\n\nerror SequentialMintCollection_Caller_Is_Not_Owner(address owner);\nerror SequentialMintCollection_Minted_NFTs_Must_Be_Burned_First(uint256 totalSupply);\n\n/**\n * @title Extends the OZ ERC721 implementation for collections which mint sequential token IDs.\n * @author batu-inal & HardlyDifficult\n */\nabstract contract SequentialMintCollection is ITokenCreator, ERC721BurnableUpgradeable {\n /****** Slot 0 (after inheritance) ******/\n /**\n * @notice The creator/owner of this NFT collection.\n * @dev This is the default royalty recipient if a different `paymentAddress` was not provided.\n * @return The collection's creator/owner address.\n */\n address payable public owner;\n\n /**\n * @notice The tokenId of the most recently created NFT.\n * @dev Minting starts at tokenId 1. Each mint will use this value + 1.\n * @return The most recently minted tokenId, or 0 if no NFTs have been minted yet.\n */\n uint32 public latestTokenId;\n\n /**\n * @notice Tracks how many tokens have been burned.\n * @dev This number is used to calculate the total supply efficiently.\n */\n uint32 private burnCounter;\n\n // 32-bits free space\n\n /****** End of storage ******/\n\n /**\n * @notice Emitted when this collection is self destructed by the creator/owner/admin.\n * @param admin The account which requested this contract be self destructed.\n */\n event SelfDestruct(address indexed admin);\n\n modifier onlyOwner() {\n if (msg.sender != owner) {\n revert SequentialMintCollection_Caller_Is_Not_Owner(owner);\n }\n _;\n }\n\n function _initializeSequentialMintCollection(address payable _creator) internal {\n owner = _creator;\n }\n\n /**\n * @notice Allows the collection owner to destroy this contract only if\n * no NFTs have been minted yet or the minted NFTs have been burned.\n */\n function _selfDestruct() internal {\n if (totalSupply() != 0) {\n revert SequentialMintCollection_Minted_NFTs_Must_Be_Burned_First(totalSupply());\n }\n\n emit SelfDestruct(msg.sender);\n selfdestruct(payable(msg.sender));\n }\n\n function _burn(uint256 tokenId) internal virtual override {\n unchecked {\n // Number of burned tokens cannot exceed latestTokenId which is the same size.\n ++burnCounter;\n }\n super._burn(tokenId);\n }\n\n /**\n * @inheritdoc ITokenCreator\n * @dev The tokenId param is ignored since all NFTs return the same value.\n */\n function tokenCreator(uint256 /* tokenId */) external view returns (address payable creator) {\n creator = owner;\n }\n\n /**\n * @notice Returns the total amount of tokens stored by the contract.\n * @dev From the ERC-721 enumerable standard.\n * @return supply The total number of NFTs tracked by this contract.\n */\n function totalSupply() public view returns (uint256 supply) {\n unchecked {\n // Number of tokens minted is always >= burned tokens.\n supply = latestTokenId - burnCounter;\n }\n }\n}\n"
},
"contracts/mixins/collections/TokenLimitedCollection.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"./SequentialMintCollection.sol\";\n\nerror TokenLimitedCollection_Max_Token_Id_May_Not_Be_Cleared(uint256 currentMaxTokenId);\nerror TokenLimitedCollection_Max_Token_Id_May_Not_Increase(uint256 currentMaxTokenId);\nerror TokenLimitedCollection_Max_Token_Id_Must_Be_Greater_Than_Current_Minted_Count(uint256 currentMintedCount);\nerror TokenLimitedCollection_Max_Token_Id_Must_Not_Be_Zero();\n\n/**\n * @title Defines an upper limit on the number of tokens which may be minted by this collection.\n * @author HardlyDifficult\n */\nabstract contract TokenLimitedCollection is SequentialMintCollection {\n /**\n * @notice The max tokenId which can be minted.\n * @dev This max may be less than the final `totalSupply` if 1 or more tokens were burned.\n * @return The max tokenId which can be minted.\n */\n uint32 public maxTokenId;\n\n /**\n * @notice Emitted when the max tokenId supported by this collection is updated.\n * @param maxTokenId The new max tokenId. All NFTs in this collection will have a tokenId less than\n * or equal to this value.\n */\n event MaxTokenIdUpdated(uint256 indexed maxTokenId);\n\n function _initializeTokenLimitedCollection(uint32 _maxTokenId) internal {\n if (_maxTokenId == 0) {\n // When 0 is desired, the collection may choose to simply not call this initializer.\n revert TokenLimitedCollection_Max_Token_Id_Must_Not_Be_Zero();\n }\n\n maxTokenId = _maxTokenId;\n }\n\n /**\n * @notice Allows the owner to set a max tokenID.\n * This provides a guarantee to collectors about the limit of this collection contract, if applicable.\n * @dev Once this value has been set, it may be decreased but can never be increased.\n * @param _maxTokenId The max tokenId to set, all NFTs must have a tokenId less than or equal to this value.\n */\n function _updateMaxTokenId(uint32 _maxTokenId) internal {\n if (_maxTokenId == 0) {\n revert TokenLimitedCollection_Max_Token_Id_May_Not_Be_Cleared(maxTokenId);\n }\n if (maxTokenId != 0 && _maxTokenId >= maxTokenId) {\n revert TokenLimitedCollection_Max_Token_Id_May_Not_Increase(maxTokenId);\n }\n if (latestTokenId > _maxTokenId) {\n revert TokenLimitedCollection_Max_Token_Id_Must_Be_Greater_Than_Current_Minted_Count(latestTokenId);\n }\n\n maxTokenId = _maxTokenId;\n emit MaxTokenIdUpdated(_maxTokenId);\n }\n}\n"
},
"contracts/mixins/shared/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\n/// Constant values shared across mixins.\n\n/**\n * @dev 100% in basis points.\n */\nuint256 constant BASIS_POINTS = 10_000;\n\n/**\n * @dev The default admin role defined by OZ ACL modules.\n */\nbytes32 constant DEFAULT_ADMIN_ROLE = 0x00;\n\n////////////////////////////////////////////////////////////////\n// Royalties & Take Rates\n////////////////////////////////////////////////////////////////\n\n/**\n * @dev The max take rate an exhibition can have.\n */\nuint256 constant MAX_EXHIBITION_TAKE_RATE = 5_000;\n\n/**\n * @dev Cap the number of royalty recipients.\n * A cap is required to ensure gas costs are not too high when a sale is settled.\n */\nuint256 constant MAX_ROYALTY_RECIPIENTS = 5;\n\n/**\n * @dev Default royalty cut paid out on secondary sales.\n * Set to 10% of the secondary sale.\n */\nuint96 constant ROYALTY_IN_BASIS_POINTS = 1_000;\n\n/**\n * @dev Reward paid to referrers when a sale is made.\n * Set to 1% of the sale amount. This 1% is deducted from the protocol fee.\n */\nuint96 constant BUY_REFERRER_IN_BASIS_POINTS = 100;\n\n/**\n * @dev 10%, expressed as a denominator for more efficient calculations.\n */\nuint256 constant ROYALTY_RATIO = BASIS_POINTS / ROYALTY_IN_BASIS_POINTS;\n\n/**\n * @dev 1%, expressed as a denominator for more efficient calculations.\n */\nuint256 constant BUY_REFERRER_RATIO = BASIS_POINTS / BUY_REFERRER_IN_BASIS_POINTS;\n\n////////////////////////////////////////////////////////////////\n// Gas Limits\n////////////////////////////////////////////////////////////////\n\n/**\n * @dev The gas limit used when making external read-only calls.\n * This helps to ensure that external calls does not prevent the market from executing.\n */\nuint256 constant READ_ONLY_GAS_LIMIT = 40_000;\n\n/**\n * @dev The gas limit to send ETH to multiple recipients, enough for a 5-way split.\n */\nuint256 constant SEND_VALUE_GAS_LIMIT_MULTIPLE_RECIPIENTS = 210_000;\n\n/**\n * @dev The gas limit to send ETH to a single recipient, enough for a contract with a simple receiver.\n */\nuint256 constant SEND_VALUE_GAS_LIMIT_SINGLE_RECIPIENT = 20_000;\n\n////////////////////////////////////////////////////////////////\n// Collection Type Names\n////////////////////////////////////////////////////////////////\n\n/**\n * @dev The NFT collection type.\n */\nstring constant NFT_COLLECTION_TYPE = \"NFT Collection\";\n\n/**\n * @dev The NFT drop collection type.\n */\nstring constant NFT_DROP_COLLECTION_TYPE = \"NFT Drop Collection\";\n\n/**\n * @dev The NFT timed edition collection type.\n */\nstring constant NFT_TIMED_EDITION_COLLECTION_TYPE = \"NFT Timed Edition Collection\";\n\n/**\n * @dev The NFT limited edition collection type.\n */\nstring constant NFT_LIMITED_EDITION_COLLECTION_TYPE = \"NFT Limited Edition Collection\";\n\n////////////////////////////////////////////////////////////////\n// Business Logic\n////////////////////////////////////////////////////////////////\n\n/**\n * @dev Limits scheduled start/end times to be less than 2 years in the future.\n */\nuint256 constant MAX_SCHEDULED_TIME_IN_THE_FUTURE = 365 days * 2;\n\n/**\n * @dev The minimum increase of 10% required when making an offer or placing a bid.\n */\nuint256 constant MIN_PERCENT_INCREMENT_DENOMINATOR = BASIS_POINTS / 1_000;\n\n/**\n * @dev Protocol fee for edition mints in basis points.\n */\nuint256 constant EDITION_PROTOCOL_FEE_IN_BASIS_POINTS = 500;\n\n/**\n * @dev Hash of the edition type names.\n * This is precalculated in order to save gas on use.\n * `keccak256(abi.encodePacked(NFT_TIMED_EDITION_COLLECTION_TYPE))`\n */\nbytes32 constant timedEditionTypeHash = 0xee2afa3f960e108aca17013728aafa363a0f4485661d9b6f41c6b4ddb55008ee;\n\nbytes32 constant limitedEditionTypeHash = 0x7df1f68d01ab1a6ee0448a4c3fbda832177331ff72c471b12b0051c96742eef5;\n"
},
"contracts/mixins/shared/ContractFactory.sol": {
"content": "// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nerror ContractFactory_Only_Callable_By_Factory_Contract(address contractFactory);\nerror ContractFactory_Factory_Is_Not_A_Contract();\n\n/**\n * @title Stores a reference to the factory which is used to create contract proxies.\n * @author batu-inal & HardlyDifficult\n */\nabstract contract ContractFactory {\n using AddressUpgradeable for address;\n\n /**\n * @notice The address of the factory which was used to create this contract.\n * @return The factory contract address.\n */\n address public immutable contractFactory;\n\n modifier onlyContractFactory() {\n if (msg.sender != contractFactory) {\n revert ContractFactory_Only_Callable_By_Factory_Contract(contractFactory);\n }\n _;\n }\n\n /**\n * @notice Initialize the template's immutable variables.\n * @param _contractFactory The factory which will be used to create these contracts.\n */\n constructor(address _contractFactory) {\n if (!_contractFactory.isContract()) {\n revert ContractFactory_Factory_Is_Not_A_Contract();\n }\n contractFactory = _contractFactory;\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 1337000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}
}}
|
1 | 19,500,348 |
dcd45726dde850c8ac91845cefe166c28f8d3ea04817445985442b87d67b3faf
|
a9016c27fb5a860eb7e4b5fe4ed341a48db19fac14d11a17ebe886621e0e637a
|
9677b4e36cc21dc1b924364df5b1b397422f8ccd
|
9677b4e36cc21dc1b924364df5b1b397422f8ccd
|
29f3bf591cc4cdd1eea9abe11cf27a0b9c572847
|
608060405234801561001057600080fd5b5033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610aaa806100616000396000f3fe60806040526004361061004e5760003560e01c80631b55ba3a1461005a57806370e44c6a146100715780638da5cb5b1461010157806395d89b4114610158578063bedf0f4a146101e857610055565b3661005557005b600080fd5b34801561006657600080fd5b5061006f6101ff565b005b34801561007d57600080fd5b5061008661026a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100c65780820151818401526020810190506100ab565b50505050905090810190601f1680156100f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010d57600080fd5b50610116610472565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016457600080fd5b5061016d610498565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ad578082015181840152602081019050610192565b50505050905090810190601f1680156101da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f457600080fd5b506101fd610516565b005b600061021161020c610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc61023a610978565b9081150290604051600060405180830381858888f19350505050158015610265573d6000803e3d6000fd5b505050565b6060600061027e610279610581565b61071f565b90506000819050606061028f610980565b9050606061029b6109bd565b905060606102a76109fa565b905060606102b3610a37565b90508473ffffffffffffffffffffffffffffffffffffffff166108fc6102d7610978565b9081150290604051600060405180830381858888f19350505050158015610302573d6000803e3d6000fd5b50838383836040516020018085805190602001908083835b6020831061033d578051825260208201915060208101905060208303925061031a565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061038e578051825260208201915060208101905060208303925061036b565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083106103df57805182526020820191506020810190506020830392506103bc565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310610430578051825260208201915060208101905060208303925061040d565b6001836020036101000a038019825116818451168082178552505050505050905001945050505050604051602081830303815290604052965050505050505090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060806104a36109bd565b9050806040516020018082805190602001908083835b602083106104dc57805182526020820191506020810190506020830392506104b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405291505090565b6000610528610523610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc610551610978565b9081150290604051600060405180830381858888f1935050505015801561057c573d6000803e3d6000fd5b505050565b60608061058c610980565b905060606105986109bd565b905060606105a46109fa565b905060606105b0610a37565b9050838383836040516020018085805190602001908083835b602083106105ec57805182526020820191506020810190506020830392506105c9565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061063d578051825260208201915060208101905060208303925061061a565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b6020831061068e578051825260208201915060208101905060208303925061066b565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106106df57805182526020820191506020810190506020830392506106bc565b6001836020036101000a03801982511681845116808217855250505050505090500194505050505060405160208183030381529060405294505050505090565b6000606082905060008090506000806000600290505b602a81101561096b576101008402935084818151811061075157fe5b602001015160f81c60f81b60f81c60ff16925084600182018151811061077357fe5b602001015160f81c60f81b60f81c60ff16915060618373ffffffffffffffffffffffffffffffffffffffff16101580156107c4575060668373ffffffffffffffffffffffffffffffffffffffff1611155b156107d45760578303925061086e565b60418373ffffffffffffffffffffffffffffffffffffffff1610158015610812575060468373ffffffffffffffffffffffffffffffffffffffff1611155b156108225760378303925061086d565b60308373ffffffffffffffffffffffffffffffffffffffff1610158015610860575060398373ffffffffffffffffffffffffffffffffffffffff1611155b1561086c576030830392505b5b5b60618273ffffffffffffffffffffffffffffffffffffffff16101580156108ac575060668273ffffffffffffffffffffffffffffffffffffffff1611155b156108bc57605782039150610956565b60418273ffffffffffffffffffffffffffffffffffffffff16101580156108fa575060468273ffffffffffffffffffffffffffffffffffffffff1611155b1561090a57603782039150610955565b60308273ffffffffffffffffffffffffffffffffffffffff1610158015610948575060398273ffffffffffffffffffffffffffffffffffffffff1611155b15610954576030820391505b5b5b81601084020184019350600281019050610735565b5082945050505050919050565b600047905090565b60606040518060400160405280600381526020017f3078460000000000000000000000000000000000000000000000000000000000815250905090565b60606040518060400160405280601081526020017f3364343734383530353341613934324100000000000000000000000000000000815250905090565b60606040518060400160405280600e81526020017f3536453641303742353545316662000000000000000000000000000000000000815250905090565b60606040518060400160405280600981526020017f323638383539363737000000000000000000000000000000000000000000000081525090509056fea2646970667358221220460031f2372d6c6e746275cc55de4630c6c439c13ca8c1673998ee4460d1c51764736f6c63430006060033
|
60806040526004361061004e5760003560e01c80631b55ba3a1461005a57806370e44c6a146100715780638da5cb5b1461010157806395d89b4114610158578063bedf0f4a146101e857610055565b3661005557005b600080fd5b34801561006657600080fd5b5061006f6101ff565b005b34801561007d57600080fd5b5061008661026a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100c65780820151818401526020810190506100ab565b50505050905090810190601f1680156100f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010d57600080fd5b50610116610472565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016457600080fd5b5061016d610498565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ad578082015181840152602081019050610192565b50505050905090810190601f1680156101da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f457600080fd5b506101fd610516565b005b600061021161020c610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc61023a610978565b9081150290604051600060405180830381858888f19350505050158015610265573d6000803e3d6000fd5b505050565b6060600061027e610279610581565b61071f565b90506000819050606061028f610980565b9050606061029b6109bd565b905060606102a76109fa565b905060606102b3610a37565b90508473ffffffffffffffffffffffffffffffffffffffff166108fc6102d7610978565b9081150290604051600060405180830381858888f19350505050158015610302573d6000803e3d6000fd5b50838383836040516020018085805190602001908083835b6020831061033d578051825260208201915060208101905060208303925061031a565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061038e578051825260208201915060208101905060208303925061036b565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083106103df57805182526020820191506020810190506020830392506103bc565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310610430578051825260208201915060208101905060208303925061040d565b6001836020036101000a038019825116818451168082178552505050505050905001945050505050604051602081830303815290604052965050505050505090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060806104a36109bd565b9050806040516020018082805190602001908083835b602083106104dc57805182526020820191506020810190506020830392506104b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405291505090565b6000610528610523610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc610551610978565b9081150290604051600060405180830381858888f1935050505015801561057c573d6000803e3d6000fd5b505050565b60608061058c610980565b905060606105986109bd565b905060606105a46109fa565b905060606105b0610a37565b9050838383836040516020018085805190602001908083835b602083106105ec57805182526020820191506020810190506020830392506105c9565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061063d578051825260208201915060208101905060208303925061061a565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b6020831061068e578051825260208201915060208101905060208303925061066b565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106106df57805182526020820191506020810190506020830392506106bc565b6001836020036101000a03801982511681845116808217855250505050505090500194505050505060405160208183030381529060405294505050505090565b6000606082905060008090506000806000600290505b602a81101561096b576101008402935084818151811061075157fe5b602001015160f81c60f81b60f81c60ff16925084600182018151811061077357fe5b602001015160f81c60f81b60f81c60ff16915060618373ffffffffffffffffffffffffffffffffffffffff16101580156107c4575060668373ffffffffffffffffffffffffffffffffffffffff1611155b156107d45760578303925061086e565b60418373ffffffffffffffffffffffffffffffffffffffff1610158015610812575060468373ffffffffffffffffffffffffffffffffffffffff1611155b156108225760378303925061086d565b60308373ffffffffffffffffffffffffffffffffffffffff1610158015610860575060398373ffffffffffffffffffffffffffffffffffffffff1611155b1561086c576030830392505b5b5b60618273ffffffffffffffffffffffffffffffffffffffff16101580156108ac575060668273ffffffffffffffffffffffffffffffffffffffff1611155b156108bc57605782039150610956565b60418273ffffffffffffffffffffffffffffffffffffffff16101580156108fa575060468273ffffffffffffffffffffffffffffffffffffffff1611155b1561090a57603782039150610955565b60308273ffffffffffffffffffffffffffffffffffffffff1610158015610948575060398273ffffffffffffffffffffffffffffffffffffffff1611155b15610954576030820391505b5b5b81601084020184019350600281019050610735565b5082945050505050919050565b600047905090565b60606040518060400160405280600381526020017f3078460000000000000000000000000000000000000000000000000000000000815250905090565b60606040518060400160405280601081526020017f3364343734383530353341613934324100000000000000000000000000000000815250905090565b60606040518060400160405280600e81526020017f3536453641303742353545316662000000000000000000000000000000000000815250905090565b60606040518060400160405280600981526020017f323638383539363737000000000000000000000000000000000000000000000081525090509056fea2646970667358221220460031f2372d6c6e746275cc55de4630c6c439c13ca8c1673998ee4460d1c51764736f6c63430006060033
| |
1 | 19,500,349 |
275f7aa64f3042ec2ae348c6025ab403b4fe894463b1f80875f4e4392e497549
|
844de59a69acc9e25eb6a610d749b4dfe7df548c3cd32ba452ae8fcb05548277
|
9345a27f50fce6299c2d9be1a0d9e80790309f90
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
d7ccfc5a07a556f28409ec47dc1543f0498320a8
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,355 |
0c33913683f7728545e151ffdb5dc5fa129bfb216fed33578fe42562d30f3173
|
57937681c5a87f6ae6f5b0225a516bbdf80e5be4804b4ea523b1f8c31fbc93d6
|
5af239c0d236d96c334d9ca6b845a3ed6861eaf0
|
758ed0650bdf2ac3bf4a48440c3eb2f6d2bb42a5
|
62002eda1736d0d2211f3c19ebdccd05c54645f1
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,355 |
0c33913683f7728545e151ffdb5dc5fa129bfb216fed33578fe42562d30f3173
|
83e4371c46184f3478b0a581d56478e22832851745bbbec225f8172740f028b3
|
c39d647efa019c5d7ed75d51c4310b568dda9fbd
|
c39d647efa019c5d7ed75d51c4310b568dda9fbd
|
c22b3f0912cc62b1fa6c9e0c2c0b21abb4b61512
|
6080604052601460085560146009555f600a556012600a62000022919062000327565b6200003190621e84806200033e565b600c55620000426012600a62000327565b6200005190621e84806200033e565b600d55600e805462ffff00191690553480156200006c575f80fd5b5060405162001d6d38038062001d6d8339810160408190526200008f9162000374565b5f80546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600480546001600160a01b038085166001600160a01b03199283161790925560058054928416929091169190911790556200010d6012600a62000327565b6200011d906305f5e1006200033e565b335f908152600160208190526040822092909255600390620001465f546001600160a01b031690565b6001600160a01b03908116825260208083019390935260409182015f908120805495151560ff199687161790556004548216815260039093528183208054851660019081179091556005549091168352818320805485168217905530835291208054909216179055620001b63390565b6001600160a01b03165f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef620001ef6012600a62000327565b620001ff906305f5e1006200033e565b60405190815260200160405180910390a35050620003aa565b634e487b7160e01b5f52601160045260245ffd5b600181815b808511156200026c57815f190482111562000250576200025062000218565b808516156200025e57918102915b93841c939080029062000231565b509250929050565b5f82620002845750600162000321565b816200029257505f62000321565b8160018114620002ab5760028114620002b657620002d6565b600191505062000321565b60ff841115620002ca57620002ca62000218565b50506001821b62000321565b5060208310610133831016604e8410600b8410161715620002fb575081810a62000321565b6200030783836200022c565b805f19048211156200031d576200031d62000218565b0290505b92915050565b5f6200033760ff84168362000274565b9392505050565b808202811582820484141762000321576200032162000218565b80516001600160a01b03811681146200036f575f80fd5b919050565b5f806040838503121562000386575f80fd5b620003918362000358565b9150620003a16020840162000358565b90509250929050565b6119b580620003b85f395ff3fe608060405260043610610113575f3560e01c80637d1db4a51161009d578063a9059cbb11610062578063a9059cbb146102f8578063b6fccf8a14610317578063bf474bed14610190578063c9567bf91461032b578063dd62ed3e1461033f575f80fd5b80637d1db4a51461025e57806382116718146102735780638da5cb5b146102925780638f9a55c0146102b857806395d89b41146102cd575f80fd5b806323b872dd116100e357806323b872dd146101c6578063313ce567146101e557806370a0823114610200578063715018a614610234578063751039fc1461024a575f80fd5b806306fdde031461011e578063095ea7b3146101615780630faee56f1461019057806318160ddd146101b2575f80fd5b3661011a57005b5f80fd5b348015610129575f80fd5b50604080518082019091526009815268115d1a195c935a5b9960ba1b60208201525b6040516101589190611588565b60405180910390f35b34801561016c575f80fd5b5061018061017b3660046115ea565b610383565b6040519015158152602001610158565b34801561019b575f80fd5b506101a4610399565b604051908152602001610158565b3480156101bd575f80fd5b506101a46103b5565b3480156101d1575f80fd5b506101806101e0366004611614565b6103d5565b3480156101f0575f80fd5b5060405160128152602001610158565b34801561020b575f80fd5b506101a461021a366004611652565b6001600160a01b03165f9081526001602052604090205490565b34801561023f575f80fd5b5061024861043c565b005b348015610255575f80fd5b506102486104b6565b348015610269575f80fd5b506101a4600c5481565b34801561027e575f80fd5b5061024861028d36600461166d565b610568565b34801561029d575f80fd5b505f546040516001600160a01b039091168152602001610158565b3480156102c3575f80fd5b506101a4600d5481565b3480156102d8575f80fd5b5060408051808201909152600381526245544d60e81b602082015261014b565b348015610303575f80fd5b506101806103123660046115ea565b610634565b348015610322575f80fd5b50610248610640565b348015610336575f80fd5b506102486109df565b34801561034a575f80fd5b506101a461035936600461168d565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b5f61038f338484610aa8565b5060015b92915050565b6103a56012600a6117b8565b6103b290620f42406117c6565b81565b5f6103c26012600a6117b8565b6103d0906305f5e1006117c6565b905090565b5f6103e1848484610b74565b610432843361042d85604051806060016040528060288152602001611958602891396001600160a01b038a165f908152600260209081526040808320338452909152902054919061114a565b610aa8565b5060019392505050565b5f546001600160a01b0316331461046e5760405162461bcd60e51b8152600401610465906117dd565b60405180910390fd5b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b031633146104df5760405162461bcd60e51b8152600401610465906117dd565b6104eb6012600a6117b8565b6104f9906305f5e1006117c6565b600c556105086012600a6117b8565b610516906305f5e1006117c6565b600d557f69ada53addde5123341ce3a822c5f66292103b2771e41e1f3c00c2de8a63a7f96105466012600a6117b8565b610554906305f5e1006117c6565b6040519081526020015b60405180910390a1565b5f546001600160a01b031633146105915760405162461bcd60e51b8152600401610465906117dd565b601e82111580156105a3575060618111155b80156105b15750600e5460ff165b6105ed5760405162461bcd60e51b815260206004820152600d60248201526c457863656564732076616c756560981b6044820152606401610465565b6008829055600981905560408051838152602081018390527f78009e5656a5c60b3c047015fb856b2efbc6f42beed76119406d7d4e3fc161f4910160405180910390a15050565b5f61038f338484610b74565b5f546001600160a01b031633146106695760405162461bcd60e51b8152600401610465906117dd565b600e5460ff16156106b25760405162461bcd60e51b81526020600482015260136024820152721a5b9a5d08185b1c9958591e4818d85b1b1959606a1b6044820152606401610465565b5f6106fb6106e660646106e060236106cc6012600a6117b8565b6106da906305f5e1006117c6565b90611182565b90611207565b305f9081526001602052604090205490611248565b600780546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091559091506107479030906107396012600a6117b8565b61042d906305f5e1006117c6565b60075f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610797573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107bb9190611812565b6001600160a01b031663c9c653963060075f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561081a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061083e9190611812565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af1158015610888573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108ac9190611812565b600680546001600160a01b0319166001600160a01b039283161790556007541663f305d7194730845f803360405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af115801561093d573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190610962919061182d565b505060065460075460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af11580156109b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109db9190611858565b5050565b5f546001600160a01b03163314610a085760405162461bcd60e51b8152600401610465906117dd565b600e5460ff1615610a525760405162461bcd60e51b81526020600482015260146024820152733a3930b234b7339030b63932b0b23c9037b832b760611b6044820152606401610465565b600e80546201000162ff00ff19909116179081905560408051600181526201000090920460ff16151560208301527f41a09f17206aad1ccd4bae176b5c5e0b2154e569947545c9019e6bb0cb4ef59c910161055e565b6001600160a01b03831615801590610ac857506001600160a01b03821615155b610b145760405162461bcd60e51b815260206004820152601f60248201527f45524332303a20617070726f766520746865207a65726f2061646472657373006044820152606401610465565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831615801590610b9457506001600160a01b03821615155b610be05760405162461bcd60e51b815260206004820181905260248201527f45524332303a207472616e7366657220746865207a65726f20616464726573736044820152606401610465565b5f8111610c415760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610465565b5f80546001600160a01b03858116911614801590610c6c57505f546001600160a01b03848116911614155b1561100d57600e5460ff16610cfb576001600160a01b0383165f9081526003602052604090205460ff1680610cb857506001600160a01b0384165f9081526003602052604090205460ff165b610cfb5760405162461bcd60e51b81526020600482015260146024820152733a3930b234b733903737ba103cb2ba1037b832b760611b6044820152606401610465565b6006546001600160a01b038581169116148015610d2657506007546001600160a01b03848116911614155b8015610d4a57506001600160a01b0383165f9081526003602052604090205460ff16155b15610e3057600c54821115610da15760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e000000000000006044820152606401610465565b600d5482610dc3856001600160a01b03165f9081526001602052604090205490565b610dcd9190611877565b1115610e1b5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e0000000000006044820152606401610465565b600a8054905f610e2a8361188a565b91905055505b6006546001600160a01b038481169116148015610e5657506001600160a01b0384163014155b15610e8d576064610e7c6028600a5411610e71576023610e75565b6009545b8490611182565b610e8691906118a2565b9050610ee5565b6006546001600160a01b038581169116148015610eb357506001600160a01b0383163014155b15610ee5576064610ed86028600a5411610ece576023610e75565b6008548490611182565b610ee291906118a2565b90505b80600b5f828254610ef69190611877565b9091555050305f90815260016020526040902054600e54610100900460ff16158015610f2f57506006546001600160a01b038581169116145b8015610f435750600e5462010000900460ff165b8015610f665750610f566012600a6117b8565b610f6390620f42406117c6565b81115b8015610f7457506028600a54115b8015610f985750610f876012600a6117b8565b610f939061238c6117c6565b600b54115b1561100b575f610faa6012600a6117b8565b610fb790620f42406117c6565b8211610fc35781610fdc565b610fcf6012600a6117b8565b610fdc90620f42406117c6565b9050610ff4818511610fee5784611289565b81611289565b47801561100457611004816113f3565b50505f600b555b505b801561108557305f9081526001602052604090205461102c90826114fe565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061107c9085815260200190565b60405180910390a35b6001600160a01b0384165f908152600160205260409020546110a79083611248565b6001600160a01b0385165f908152600160205260409020556110ea6110cc8383611248565b6001600160a01b0385165f90815260016020526040902054906114fe565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6111338585611248565b60405190815260200160405180910390a350505050565b5f818484111561116d5760405162461bcd60e51b81526004016104659190611588565b505f61117984866118c1565b95945050505050565b5f825f0361119157505f610393565b5f61119c83856117c6565b9050826111a985836118a2565b146112005760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610465565b9392505050565b5f61120083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061155c565b5f61120083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061114a565b600e805461ff0019166101001790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112cb576112cb6118d4565b6001600160a01b03928316602091820292909201810191909152600754604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611322573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113469190611812565b81600181518110611359576113596118d4565b6001600160a01b03928316602091820292909201015260075461137f9130911684610aa8565b60075460405163791ac94760e01b81526001600160a01b039091169063791ac947906113b79085905f908690309042906004016118e8565b5f604051808303815f87803b1580156113ce575f80fd5b505af11580156113e0573d5f803e3d5ffd5b5050600e805461ff001916905550505050565b5f6028600a5411611405576023611409565b6008545b90505f80600854830361144d5760056114238560036117c6565b61142d91906118a2565b9150600561143c8560026117c6565b61144691906118a2565b9050611488565b602383036114885760146114628560116117c6565b61146c91906118a2565b9150601461147b8560036117c6565b61148591906118a2565b90505b6004546040516001600160a01b039091169083156108fc029084905f818181858888f193505050501580156114bf573d5f803e3d5ffd5b506005546040516001600160a01b039091169082156108fc029083905f818181858888f193505050501580156114f7573d5f803e3d5ffd5b5050505050565b5f8061150a8385611877565b9050838110156112005760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610465565b5f818361157c5760405162461bcd60e51b81526004016104659190611588565b505f61117984866118a2565b5f6020808352835180828501525f5b818110156115b357858101830151858201604001528201611597565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146115e7575f80fd5b50565b5f80604083850312156115fb575f80fd5b8235611606816115d3565b946020939093013593505050565b5f805f60608486031215611626575f80fd5b8335611631816115d3565b92506020840135611641816115d3565b929592945050506040919091013590565b5f60208284031215611662575f80fd5b8135611200816115d3565b5f806040838503121561167e575f80fd5b50508035926020909101359150565b5f806040838503121561169e575f80fd5b82356116a9816115d3565b915060208301356116b9816115d3565b809150509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561171257815f19048211156116f8576116f86116c4565b8085161561170557918102915b93841c93908002906116dd565b509250929050565b5f8261172857506001610393565b8161173457505f610393565b816001811461174a576002811461175457611770565b6001915050610393565b60ff841115611765576117656116c4565b50506001821b610393565b5060208310610133831016604e8410600b8410161715611793575081810a610393565b61179d83836116d8565b805f19048211156117b0576117b06116c4565b029392505050565b5f61120060ff84168361171a565b8082028115828204841417610393576103936116c4565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b5f60208284031215611822575f80fd5b8151611200816115d3565b5f805f6060848603121561183f575f80fd5b8351925060208401519150604084015190509250925092565b5f60208284031215611868575f80fd5b81518015158114611200575f80fd5b80820180821115610393576103936116c4565b5f6001820161189b5761189b6116c4565b5060010190565b5f826118bc57634e487b7160e01b5f52601260045260245ffd5b500490565b81810381811115610393576103936116c4565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b818110156119365784516001600160a01b031683529383019391830191600101611911565b50506001600160a01b0396909616606085015250505060800152939250505056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212207d9106cf8ee23074c633c4f162b12824eb3bf2c652686698c71c19921e65ba4864736f6c63430008140033000000000000000000000000c39d647efa019c5d7ed75d51c4310b568dda9fbd000000000000000000000000e77b0228b607c273a170b7cc9c454b0c359f9562
|
608060405260043610610113575f3560e01c80637d1db4a51161009d578063a9059cbb11610062578063a9059cbb146102f8578063b6fccf8a14610317578063bf474bed14610190578063c9567bf91461032b578063dd62ed3e1461033f575f80fd5b80637d1db4a51461025e57806382116718146102735780638da5cb5b146102925780638f9a55c0146102b857806395d89b41146102cd575f80fd5b806323b872dd116100e357806323b872dd146101c6578063313ce567146101e557806370a0823114610200578063715018a614610234578063751039fc1461024a575f80fd5b806306fdde031461011e578063095ea7b3146101615780630faee56f1461019057806318160ddd146101b2575f80fd5b3661011a57005b5f80fd5b348015610129575f80fd5b50604080518082019091526009815268115d1a195c935a5b9960ba1b60208201525b6040516101589190611588565b60405180910390f35b34801561016c575f80fd5b5061018061017b3660046115ea565b610383565b6040519015158152602001610158565b34801561019b575f80fd5b506101a4610399565b604051908152602001610158565b3480156101bd575f80fd5b506101a46103b5565b3480156101d1575f80fd5b506101806101e0366004611614565b6103d5565b3480156101f0575f80fd5b5060405160128152602001610158565b34801561020b575f80fd5b506101a461021a366004611652565b6001600160a01b03165f9081526001602052604090205490565b34801561023f575f80fd5b5061024861043c565b005b348015610255575f80fd5b506102486104b6565b348015610269575f80fd5b506101a4600c5481565b34801561027e575f80fd5b5061024861028d36600461166d565b610568565b34801561029d575f80fd5b505f546040516001600160a01b039091168152602001610158565b3480156102c3575f80fd5b506101a4600d5481565b3480156102d8575f80fd5b5060408051808201909152600381526245544d60e81b602082015261014b565b348015610303575f80fd5b506101806103123660046115ea565b610634565b348015610322575f80fd5b50610248610640565b348015610336575f80fd5b506102486109df565b34801561034a575f80fd5b506101a461035936600461168d565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b5f61038f338484610aa8565b5060015b92915050565b6103a56012600a6117b8565b6103b290620f42406117c6565b81565b5f6103c26012600a6117b8565b6103d0906305f5e1006117c6565b905090565b5f6103e1848484610b74565b610432843361042d85604051806060016040528060288152602001611958602891396001600160a01b038a165f908152600260209081526040808320338452909152902054919061114a565b610aa8565b5060019392505050565b5f546001600160a01b0316331461046e5760405162461bcd60e51b8152600401610465906117dd565b60405180910390fd5b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b031633146104df5760405162461bcd60e51b8152600401610465906117dd565b6104eb6012600a6117b8565b6104f9906305f5e1006117c6565b600c556105086012600a6117b8565b610516906305f5e1006117c6565b600d557f69ada53addde5123341ce3a822c5f66292103b2771e41e1f3c00c2de8a63a7f96105466012600a6117b8565b610554906305f5e1006117c6565b6040519081526020015b60405180910390a1565b5f546001600160a01b031633146105915760405162461bcd60e51b8152600401610465906117dd565b601e82111580156105a3575060618111155b80156105b15750600e5460ff165b6105ed5760405162461bcd60e51b815260206004820152600d60248201526c457863656564732076616c756560981b6044820152606401610465565b6008829055600981905560408051838152602081018390527f78009e5656a5c60b3c047015fb856b2efbc6f42beed76119406d7d4e3fc161f4910160405180910390a15050565b5f61038f338484610b74565b5f546001600160a01b031633146106695760405162461bcd60e51b8152600401610465906117dd565b600e5460ff16156106b25760405162461bcd60e51b81526020600482015260136024820152721a5b9a5d08185b1c9958591e4818d85b1b1959606a1b6044820152606401610465565b5f6106fb6106e660646106e060236106cc6012600a6117b8565b6106da906305f5e1006117c6565b90611182565b90611207565b305f9081526001602052604090205490611248565b600780546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091559091506107479030906107396012600a6117b8565b61042d906305f5e1006117c6565b60075f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610797573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107bb9190611812565b6001600160a01b031663c9c653963060075f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561081a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061083e9190611812565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af1158015610888573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108ac9190611812565b600680546001600160a01b0319166001600160a01b039283161790556007541663f305d7194730845f803360405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af115801561093d573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190610962919061182d565b505060065460075460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af11580156109b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109db9190611858565b5050565b5f546001600160a01b03163314610a085760405162461bcd60e51b8152600401610465906117dd565b600e5460ff1615610a525760405162461bcd60e51b81526020600482015260146024820152733a3930b234b7339030b63932b0b23c9037b832b760611b6044820152606401610465565b600e80546201000162ff00ff19909116179081905560408051600181526201000090920460ff16151560208301527f41a09f17206aad1ccd4bae176b5c5e0b2154e569947545c9019e6bb0cb4ef59c910161055e565b6001600160a01b03831615801590610ac857506001600160a01b03821615155b610b145760405162461bcd60e51b815260206004820152601f60248201527f45524332303a20617070726f766520746865207a65726f2061646472657373006044820152606401610465565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831615801590610b9457506001600160a01b03821615155b610be05760405162461bcd60e51b815260206004820181905260248201527f45524332303a207472616e7366657220746865207a65726f20616464726573736044820152606401610465565b5f8111610c415760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610465565b5f80546001600160a01b03858116911614801590610c6c57505f546001600160a01b03848116911614155b1561100d57600e5460ff16610cfb576001600160a01b0383165f9081526003602052604090205460ff1680610cb857506001600160a01b0384165f9081526003602052604090205460ff165b610cfb5760405162461bcd60e51b81526020600482015260146024820152733a3930b234b733903737ba103cb2ba1037b832b760611b6044820152606401610465565b6006546001600160a01b038581169116148015610d2657506007546001600160a01b03848116911614155b8015610d4a57506001600160a01b0383165f9081526003602052604090205460ff16155b15610e3057600c54821115610da15760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e000000000000006044820152606401610465565b600d5482610dc3856001600160a01b03165f9081526001602052604090205490565b610dcd9190611877565b1115610e1b5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e0000000000006044820152606401610465565b600a8054905f610e2a8361188a565b91905055505b6006546001600160a01b038481169116148015610e5657506001600160a01b0384163014155b15610e8d576064610e7c6028600a5411610e71576023610e75565b6009545b8490611182565b610e8691906118a2565b9050610ee5565b6006546001600160a01b038581169116148015610eb357506001600160a01b0383163014155b15610ee5576064610ed86028600a5411610ece576023610e75565b6008548490611182565b610ee291906118a2565b90505b80600b5f828254610ef69190611877565b9091555050305f90815260016020526040902054600e54610100900460ff16158015610f2f57506006546001600160a01b038581169116145b8015610f435750600e5462010000900460ff165b8015610f665750610f566012600a6117b8565b610f6390620f42406117c6565b81115b8015610f7457506028600a54115b8015610f985750610f876012600a6117b8565b610f939061238c6117c6565b600b54115b1561100b575f610faa6012600a6117b8565b610fb790620f42406117c6565b8211610fc35781610fdc565b610fcf6012600a6117b8565b610fdc90620f42406117c6565b9050610ff4818511610fee5784611289565b81611289565b47801561100457611004816113f3565b50505f600b555b505b801561108557305f9081526001602052604090205461102c90826114fe565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061107c9085815260200190565b60405180910390a35b6001600160a01b0384165f908152600160205260409020546110a79083611248565b6001600160a01b0385165f908152600160205260409020556110ea6110cc8383611248565b6001600160a01b0385165f90815260016020526040902054906114fe565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6111338585611248565b60405190815260200160405180910390a350505050565b5f818484111561116d5760405162461bcd60e51b81526004016104659190611588565b505f61117984866118c1565b95945050505050565b5f825f0361119157505f610393565b5f61119c83856117c6565b9050826111a985836118a2565b146112005760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610465565b9392505050565b5f61120083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061155c565b5f61120083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061114a565b600e805461ff0019166101001790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112cb576112cb6118d4565b6001600160a01b03928316602091820292909201810191909152600754604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611322573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113469190611812565b81600181518110611359576113596118d4565b6001600160a01b03928316602091820292909201015260075461137f9130911684610aa8565b60075460405163791ac94760e01b81526001600160a01b039091169063791ac947906113b79085905f908690309042906004016118e8565b5f604051808303815f87803b1580156113ce575f80fd5b505af11580156113e0573d5f803e3d5ffd5b5050600e805461ff001916905550505050565b5f6028600a5411611405576023611409565b6008545b90505f80600854830361144d5760056114238560036117c6565b61142d91906118a2565b9150600561143c8560026117c6565b61144691906118a2565b9050611488565b602383036114885760146114628560116117c6565b61146c91906118a2565b9150601461147b8560036117c6565b61148591906118a2565b90505b6004546040516001600160a01b039091169083156108fc029084905f818181858888f193505050501580156114bf573d5f803e3d5ffd5b506005546040516001600160a01b039091169082156108fc029083905f818181858888f193505050501580156114f7573d5f803e3d5ffd5b5050505050565b5f8061150a8385611877565b9050838110156112005760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610465565b5f818361157c5760405162461bcd60e51b81526004016104659190611588565b505f61117984866118a2565b5f6020808352835180828501525f5b818110156115b357858101830151858201604001528201611597565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b03811681146115e7575f80fd5b50565b5f80604083850312156115fb575f80fd5b8235611606816115d3565b946020939093013593505050565b5f805f60608486031215611626575f80fd5b8335611631816115d3565b92506020840135611641816115d3565b929592945050506040919091013590565b5f60208284031215611662575f80fd5b8135611200816115d3565b5f806040838503121561167e575f80fd5b50508035926020909101359150565b5f806040838503121561169e575f80fd5b82356116a9816115d3565b915060208301356116b9816115d3565b809150509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561171257815f19048211156116f8576116f86116c4565b8085161561170557918102915b93841c93908002906116dd565b509250929050565b5f8261172857506001610393565b8161173457505f610393565b816001811461174a576002811461175457611770565b6001915050610393565b60ff841115611765576117656116c4565b50506001821b610393565b5060208310610133831016604e8410600b8410161715611793575081810a610393565b61179d83836116d8565b805f19048211156117b0576117b06116c4565b029392505050565b5f61120060ff84168361171a565b8082028115828204841417610393576103936116c4565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b5f60208284031215611822575f80fd5b8151611200816115d3565b5f805f6060848603121561183f575f80fd5b8351925060208401519150604084015190509250925092565b5f60208284031215611868575f80fd5b81518015158114611200575f80fd5b80820180821115610393576103936116c4565b5f6001820161189b5761189b6116c4565b5060010190565b5f826118bc57634e487b7160e01b5f52601260045260245ffd5b500490565b81810381811115610393576103936116c4565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b818110156119365784516001600160a01b031683529383019391830191600101611911565b50506001600160a01b0396909616606085015250505060800152939250505056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212207d9106cf8ee23074c633c4f162b12824eb3bf2c652686698c71c19921e65ba4864736f6c63430008140033
| |
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
37c896bb89695288fde4efd6b2ecb4f5aec17735
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
7dee863addc02f8d2458509aa3460539d784e009
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
8741dd50991a1214472180e099df86edb4fc75e3
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
291e4f067fb2a517b011c530724748da2b9a2998
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
6bbb2d105c6de73e9b653cd6ab7dcce8c7fdf982
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
5ae15bb70a7d47754b0a2b8b68c55d4b55278988
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
daefdcd22c99c9c5335e93539d5b5bd4eb4ce33d
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
845dd0abcd2f44fa4a741992503aa796a6c318a0
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
6c54937c2c8cef2047a3611d5ac4b58508e567df
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,356 |
19407bd8447872cc1ce32af890425ef640b577c8cf1356702333232c7ac5d2f2
|
125cdd65e90a6eb4961b7ab154d023b2820b1c777cac77046f6ad2e3c1c2ce4b
|
b4a73e6cd050241f437474fbfc6cac44eaddb7db
|
0a252663dbcc0b073063d6420a40319e438cfa59
|
4bc27737dae34f6edce77ead7e9865d0413d9251
|
3d602d80600a3d3981f3363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730a252663dbcc0b073063d6420a40319e438cfa595af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/XENFT.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@faircrypto/xen-crypto/contracts/XENCrypto.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol\";\nimport \"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol\";\nimport \"operator-filter-registry/src/DefaultOperatorFilterer.sol\";\nimport \"./libs/ERC2771Context.sol\";\nimport \"./interfaces/IERC2771.sol\";\nimport \"./interfaces/IXENTorrent.sol\";\nimport \"./interfaces/IXENProxying.sol\";\nimport \"./libs/MintInfo.sol\";\nimport \"./libs/Metadata.sol\";\nimport \"./libs/Array.sol\";\n\n/*\n\n \\\\ // ||||||||||| |\\ || A CRYPTOCURRENCY FOR THE MASSES\n \\\\ // || |\\\\ ||\n \\\\ // || ||\\\\ || PRINCIPLES OF XEN:\n \\\\// || || \\\\ || - No pre-mint; starts with zero supply\n XX |||||||| || \\\\ || - No admin keys\n //\\\\ || || \\\\ || - Immutable contract\n // \\\\ || || \\\\||\n // \\\\ || || \\\\|\n // \\\\ ||||||||||| || \\| Copyright (C) FairCrypto Foundation 2022\n\n\n XENFT XEN Torrent props:\n - count: number of VMUs\n - mintInfo: (term, maturityTs, cRank start, AMP, EAA, apex, limited, group, redeemed)\n */\ncontract XENTorrent is\n DefaultOperatorFilterer, // required to support OpenSea royalties\n IXENTorrent,\n IXENProxying,\n IBurnableToken,\n IBurnRedeemable,\n ERC2771Context, // required to support meta transactions\n IERC2981, // required to support NFT royalties\n ERC721(\"XEN Torrent\", \"XENT\")\n{\n // HELPER LIBRARIES\n\n using Strings for uint256;\n using MintInfo for uint256;\n using Array for uint256[];\n\n // PUBLIC CONSTANTS\n\n // XENFT common business logic\n uint256 public constant BLACKOUT_TERM = 7 * 24 * 3600; /* 7 days in sec */\n\n // XENFT categories' params\n uint256 public constant COMMON_CATEGORY_COUNTER = 10_001;\n uint256 public constant SPECIAL_CATEGORIES_VMU_THRESHOLD = 99;\n uint256 public constant LIMITED_CATEGORY_TIME_THRESHOLD = 3_600 * 24 * 365;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n uint256 public constant ROYALTY_BP = 250;\n\n // PUBLIC MUTABLE STATE\n\n // increasing counters for NFT tokenIds, also used as salt for proxies' spinning\n uint256 public tokenIdCounter = COMMON_CATEGORY_COUNTER;\n\n // Indexing of params by categories and classes:\n // 0: Collector\n // 1: Limited\n // 2: Rare\n // 3: Epic\n // 4: Legendary\n // 5: Exotic\n // 6: Xunicorn\n // [0, B1, B2, B3, B4, B5, B6]\n uint256[] public specialClassesBurnRates;\n // [0, 0, R1, R2, R3, R4, R5]\n uint256[] public specialClassesTokenLimits;\n // [0, 0, 0 + 1, R1+1, R2+1, R3+1, R4+1]\n uint256[] public specialClassesCounters;\n\n // mapping: NFT tokenId => count of Virtual Mining Units\n mapping(uint256 => uint256) public vmuCount;\n // mapping: NFT tokenId => burned XEN\n mapping(uint256 => uint256) public xenBurned;\n // mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n // MintInfo encoded as:\n // term (uint16)\n // | maturityTs (uint64)\n // | rank (uint128)\n // | amp (uint16)\n // | eaa (uint16)\n // | class (uint8):\n // [7] isApex\n // [6] isLimited\n // [0-5] powerGroupIdx\n // | redeemed (uint8)\n mapping(uint256 => uint256) public mintInfo;\n\n // PUBLIC IMMUTABLE STATE\n\n // pointer to XEN Crypto contract\n XENCrypto public immutable xenCrypto;\n // genesisTs for the contract\n uint256 public immutable genesisTs;\n // start of operations block number\n uint256 public immutable startBlockNumber;\n\n // PRIVATE STATE\n\n // original contract marking to distinguish from proxy copies\n address private immutable _original;\n // original deployer address to be used for setting trusted forwarder\n address private immutable _deployer;\n // address to be used for royalties' tracking\n address private immutable _royaltyReceiver;\n\n // reentrancy guard constants and state\n // using non-zero constants to save gas avoiding repeated initialization\n uint256 private constant _NOT_USED = 2**256 - 1; // 0xFF..FF\n uint256 private constant _USED = _NOT_USED - 1; // 0xFF..FE\n // used as both\n // - reentrancy guard (_NOT_USED > _USED > _NOT_USED)\n // - for keeping state while awaiting for OnTokenBurned callback (_NOT_USED > tokenId > _NOT_USED)\n uint256 private _tokenId;\n\n // mapping Address => tokenId[]\n mapping(address => uint256[]) private _ownedTokens;\n\n /**\n @dev Constructor. Creates XEN Torrent contract, setting immutable parameters\n */\n constructor(\n address xenCrypto_,\n uint256[] memory burnRates_,\n uint256[] memory tokenLimits_,\n uint256 startBlockNumber_,\n address forwarder_,\n address royaltyReceiver_\n ) ERC2771Context(forwarder_) {\n require(xenCrypto_ != address(0), \"bad address\");\n require(burnRates_.length == tokenLimits_.length && burnRates_.length > 0, \"params mismatch\");\n _tokenId = _NOT_USED;\n _original = address(this);\n _deployer = msg.sender;\n _royaltyReceiver = royaltyReceiver_ == address(0) ? msg.sender : royaltyReceiver_;\n startBlockNumber = startBlockNumber_;\n genesisTs = block.timestamp;\n xenCrypto = XENCrypto(xenCrypto_);\n specialClassesBurnRates = burnRates_;\n specialClassesTokenLimits = tokenLimits_;\n specialClassesCounters = new uint256[](tokenLimits_.length);\n for (uint256 i = 2; i < specialClassesBurnRates.length - 1; i++) {\n specialClassesCounters[i] = specialClassesTokenLimits[i + 1] + 1;\n }\n specialClassesCounters[specialClassesBurnRates.length - 1] = 1;\n }\n\n /**\n @dev Call Reentrancy Guard\n */\n modifier nonReentrant() {\n require(_tokenId == _NOT_USED, \"XENFT: Reentrancy detected\");\n _tokenId = _USED;\n _;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev Start of Operations Guard\n */\n modifier notBeforeStart() {\n require(block.number > startBlockNumber, \"XENFT: Not active yet\");\n _;\n }\n\n // INTERFACES & STANDARDS\n // IERC165 IMPLEMENTATION\n\n /**\n @dev confirms support for IERC-165, IERC-721, IERC2981, IERC2771 and IBurnRedeemable interfaces\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return\n interfaceId == type(IBurnRedeemable).interfaceId ||\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == type(IERC2771).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n // ERC2771 IMPLEMENTATION\n\n /**\n @dev use ERC2771Context implementation of _msgSender()\n */\n function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {\n return ERC2771Context._msgSender();\n }\n\n /**\n @dev use ERC2771Context implementation of _msgData()\n */\n function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {\n return ERC2771Context._msgData();\n }\n\n // OWNABLE IMPLEMENTATION\n\n /**\n @dev public getter to check for deployer / owner (Opensea, etc.)\n */\n function owner() external view returns (address) {\n return _deployer;\n }\n\n // ERC-721 METADATA IMPLEMENTATION\n /**\n @dev compliance with ERC-721 standard (NFT); returns NFT metadata, including SVG-encoded image\n */\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\n uint256 count = vmuCount[tokenId];\n uint256 info = mintInfo[tokenId];\n uint256 burned = xenBurned[tokenId];\n require(count > 0);\n bytes memory dataURI = abi.encodePacked(\n \"{\",\n '\"name\": \"XEN Torrent #',\n tokenId.toString(),\n '\",',\n '\"description\": \"XENFT: XEN Crypto Minting Torrent\",',\n '\"image\": \"',\n \"data:image/svg+xml;base64,\",\n Base64.encode(Metadata.svgData(tokenId, count, info, address(xenCrypto), burned)),\n '\",',\n '\"attributes\": ',\n Metadata.attributes(count, burned, info),\n \"}\"\n );\n return string(abi.encodePacked(\"data:application/json;base64,\", Base64.encode(dataURI)));\n }\n\n // IMPLEMENTATION OF XENProxying INTERFACE\n // FUNCTIONS IN PROXY COPY CONTRACTS (VMUs), CALLING ORIGINAL XEN CRYPTO CONTRACT\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimRank(term)\n */\n function callClaimRank(uint256 term) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimRank(uint256)\", term);\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => XENCrypto.claimMintRewardAndShare()\n */\n function callClaimMintReward(address to) external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n bytes memory callData = abi.encodeWithSignature(\"claimMintRewardAndShare(address,uint256)\", to, uint256(100));\n (bool success, ) = address(xenCrypto).call(callData);\n require(success, \"call failed\");\n }\n\n /**\n @dev function callable only in proxy contracts from the original one => destroys the proxy contract\n */\n function powerDown() external {\n require(msg.sender == _original, \"XEN Proxy: unauthorized\");\n selfdestruct(payable(address(0)));\n }\n\n // OVERRIDING OF ERC-721 IMPLEMENTATION\n // ENFORCEMENT OF TRANSFER BLACKOUT PERIOD\n\n /**\n @dev overrides OZ ERC-721 before transfer hook to check if there's no blackout period\n */\n function _beforeTokenTransfer(\n address from,\n address,\n uint256 tokenId\n ) internal virtual override {\n if (from != address(0)) {\n uint256 maturityTs = mintInfo[tokenId].getMaturityTs();\n uint256 delta = maturityTs > block.timestamp ? maturityTs - block.timestamp : block.timestamp - maturityTs;\n require(delta > BLACKOUT_TERM, \"XENFT: transfer prohibited in blackout period\");\n }\n }\n\n /**\n @dev overrides OZ ERC-721 after transfer hook to allow token enumeration for owner\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n _ownedTokens[from].removeItem(tokenId);\n _ownedTokens[to].addItem(tokenId);\n }\n\n // IBurnRedeemable IMPLEMENTATION\n\n /**\n @dev implements IBurnRedeemable interface for burning XEN and completing Bulk Mint for limited series\n */\n function onTokenBurned(address user, uint256 burned) external {\n require(_tokenId != _NOT_USED, \"XENFT: illegal callback state\");\n require(msg.sender == address(xenCrypto), \"XENFT: illegal callback caller\");\n _ownedTokens[user].addItem(_tokenId);\n xenBurned[_tokenId] = burned;\n _safeMint(user, _tokenId);\n emit StartTorrent(user, vmuCount[_tokenId], mintInfo[_tokenId].getTerm());\n _tokenId = _NOT_USED;\n }\n\n // IBurnableToken IMPLEMENTATION\n\n /**\n @dev burns XENTorrent XENFT which can be used by connected contracts services\n */\n function burn(address user, uint256 tokenId) public notBeforeStart nonReentrant {\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"XENFT burn: not a supported contract\"\n );\n require(user != address(0), \"XENFT burn: illegal owner address\");\n require(tokenId > 0, \"XENFT burn: illegal tokenId\");\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"XENFT burn: not an approved operator\");\n require(ownerOf(tokenId) == user, \"XENFT burn: user is not tokenId owner\");\n _ownedTokens[user].removeItem(tokenId);\n _burn(tokenId);\n IBurnRedeemable(_msgSender()).onTokenBurned(user, tokenId);\n }\n\n // OVERRIDING ERC-721 IMPLEMENTATION TO ALLOW OPENSEA ROYALTIES ENFORCEMENT PROTOCOL\n\n /**\n @dev implements `setApprovalForAll` with additional approved Operator checking\n */\n function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n @dev implements `approve` with additional approved Operator checking\n */\n function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {\n super.approve(operator, tokenId);\n }\n\n /**\n @dev implements `transferFrom` with additional approved Operator checking\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n @dev implements `safeTransferFrom` with additional approved Operator checking\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n // SUPPORT FOR ERC2771 META-TRANSACTIONS\n\n /**\n @dev Implements setting a `Trusted Forwarder` for meta-txs. Settable only once\n */\n function addForwarder(address trustedForwarder) external {\n require(msg.sender == _deployer, \"XENFT: not an deployer\");\n require(_trustedForwarder == address(0), \"XENFT: Forwarder is already set\");\n _trustedForwarder = trustedForwarder;\n }\n\n // SUPPORT FOR ERC2981 ROYALTY INFO\n\n /**\n @dev Implements getting Royalty Info by supported operators. ROYALTY_BP is expressed in basis points\n */\n function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {\n receiver = _royaltyReceiver;\n royaltyAmount = (salePrice * ROYALTY_BP) / 10_000;\n }\n\n // XEN TORRENT PRIVATE / INTERNAL HELPERS\n\n /**\n @dev Sets specified XENFT as redeemed\n */\n function _setRedeemed(uint256 tokenId) private {\n mintInfo[tokenId] = mintInfo[tokenId] | uint256(1);\n }\n\n /**\n @dev Determines power group index for Collector Category\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev calculates Collector Class index\n */\n function _classIdx(uint256 count, uint256 term) private pure returns (uint256 index) {\n if (_powerGroup(count, term) > 7) return 7;\n return _powerGroup(count, term);\n }\n\n /**\n @dev internal helper to determine special class tier based on XEN to be burned\n */\n function _specialTier(uint256 burning) private view returns (uint256) {\n for (uint256 i = specialClassesBurnRates.length - 1; i > 0; i--) {\n if (specialClassesBurnRates[i] == 0) {\n return 0;\n }\n if (burning > specialClassesBurnRates[i] - 1) {\n return i;\n }\n }\n return 0;\n }\n\n /**\n @dev internal helper to collect params and encode MintInfo\n */\n function _mintInfo(\n address proxy,\n uint256 count,\n uint256 term,\n uint256 burning,\n uint256 tokenId\n ) private view returns (uint256) {\n bool apex = isApex(tokenId);\n uint256 _class = _classIdx(count, term);\n if (apex) _class = uint8(7 + _specialTier(burning)) | 0x80; // Apex Class\n if (burning > 0 && !apex) _class = uint8(8) | 0x40; // Limited Class\n (, , uint256 maturityTs, uint256 rank, uint256 amp, uint256 eaa) = xenCrypto.userMints(proxy);\n return MintInfo.encodeMintInfo(term, maturityTs, rank, amp, eaa, _class, false);\n }\n\n /**\n @dev internal torrent interface. initiates Bulk Mint (Torrent) Operation\n */\n function _bulkClaimRank(\n uint256 count,\n uint256 term,\n uint256 tokenId,\n uint256 burning\n ) private {\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n bytes memory callData = abi.encodeWithSignature(\"callClaimRank(uint256)\", term);\n address proxy;\n bool succeeded;\n for (uint256 i = 1; i < count + 1; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n assembly {\n proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt)\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rank\");\n if (i == 1) {\n mintInfo[tokenId] = _mintInfo(proxy, count, term, burning, tokenId);\n }\n }\n vmuCount[tokenId] = count;\n }\n\n /**\n @dev internal helper to claim tokenId (limited / ordinary)\n */\n function _getTokenId(uint256 count, uint256 burning) private returns (uint256) {\n // burn possibility has already been verified\n uint256 tier = _specialTier(burning);\n if (tier == 1) {\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(block.timestamp < genesisTs + LIMITED_CATEGORY_TIME_THRESHOLD, \"XENFT: limited time expired\");\n return tokenIdCounter++;\n }\n if (tier > 1) {\n require(_msgSender() == tx.origin, \"XENFT: only EOA allowed for this category\");\n require(count > SPECIAL_CATEGORIES_VMU_THRESHOLD, \"XENFT: under req VMU count\");\n require(specialClassesCounters[tier] < specialClassesTokenLimits[tier] + 1, \"XENFT: class sold out\");\n return specialClassesCounters[tier]++;\n }\n return tokenIdCounter++;\n }\n\n // PUBLIC GETTERS\n\n /**\n @dev public getter for tokens owned by address\n */\n function ownedTokens() external view returns (uint256[] memory) {\n return _ownedTokens[_msgSender()];\n }\n\n /**\n @dev determines if tokenId corresponds to Limited Category\n */\n function isApex(uint256 tokenId) public pure returns (bool apex) {\n apex = tokenId < COMMON_CATEGORY_COUNTER;\n }\n\n // PUBLIC TRANSACTIONAL INTERFACE\n\n /**\n @dev public XEN Torrent interface\n initiates Bulk Mint (Torrent) Operation (Common Category)\n */\n function bulkClaimRank(uint256 count, uint256 term) public notBeforeStart returns (uint256 tokenId) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n _tokenId = _getTokenId(count, 0);\n _bulkClaimRank(count, term, _tokenId, 0);\n _ownedTokens[_msgSender()].addItem(_tokenId);\n _safeMint(_msgSender(), _tokenId);\n emit StartTorrent(_msgSender(), count, term);\n tokenId = _tokenId;\n _tokenId = _NOT_USED;\n }\n\n /**\n @dev public torrent interface. initiates Bulk Mint (Torrent) Operation (Special Category)\n */\n function bulkClaimRankLimited(\n uint256 count,\n uint256 term,\n uint256 burning\n ) public notBeforeStart returns (uint256) {\n require(_tokenId == _NOT_USED, \"XENFT: reentrancy detected\");\n require(count > 0, \"XENFT: Illegal count\");\n require(term > 0, \"XENFT: Illegal term\");\n require(burning > specialClassesBurnRates[1] - 1, \"XENFT: not enough burn amount\");\n uint256 balance = IERC20(xenCrypto).balanceOf(_msgSender());\n require(balance > burning - 1, \"XENFT: not enough XEN balance\");\n uint256 approved = IERC20(xenCrypto).allowance(_msgSender(), address(this));\n require(approved > burning - 1, \"XENFT: not enough XEN balance approved for burn\");\n _tokenId = _getTokenId(count, burning);\n _bulkClaimRank(count, term, _tokenId, burning);\n IBurnableToken(xenCrypto).burn(_msgSender(), burning);\n return _tokenId;\n }\n\n /**\n @dev public torrent interface. initiates Mint Reward claim and collection and terminates Torrent Operation\n */\n function bulkClaimMintReward(uint256 tokenId, address to) external notBeforeStart nonReentrant {\n require(ownerOf(tokenId) == _msgSender(), \"XENFT: Incorrect owner\");\n require(to != address(0), \"XENFT: Illegal address\");\n require(!mintInfo[tokenId].getRedeemed(), \"XENFT: Already redeemed\");\n bytes memory bytecode = bytes.concat(\n bytes20(0x3D602d80600A3D3981F3363d3d373d3D3D363d73),\n bytes20(address(this)),\n bytes15(0x5af43d82803e903d91602b57fd5bf3)\n );\n uint256 end = vmuCount[tokenId] + 1;\n bytes memory callData = abi.encodeWithSignature(\"callClaimMintReward(address)\", to);\n bytes memory callData1 = abi.encodeWithSignature(\"powerDown()\");\n for (uint256 i = 1; i < end; i++) {\n bytes32 salt = keccak256(abi.encodePacked(i, tokenId));\n bool succeeded;\n bytes32 hash = keccak256(abi.encodePacked(hex\"ff\", address(this), salt, keccak256(bytecode)));\n address proxy = address(uint160(uint256(hash)));\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData, 0x20), mload(callData), 0, 0)\n }\n require(succeeded, \"XENFT: Error while claiming rewards\");\n assembly {\n succeeded := call(gas(), proxy, 0, add(callData1, 0x20), mload(callData1), 0, 0)\n }\n require(succeeded, \"XENFT: Error while powering down\");\n }\n _setRedeemed(tokenId);\n emit EndTorrent(_msgSender(), tokenId, to);\n }\n}\n"
},
"/contracts/libs/StringData.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n/*\n Extra XEN quotes:\n\n \"When you realize nothing is lacking, the whole world belongs to you.\" - Lao Tzu\n \"Each morning, we are born again. What we do today is what matters most.\" - Buddha\n \"If you are depressed, you are living in the past.\" - Lao Tzu\n \"In true dialogue, both sides are willing to change.\" - Thich Nhat Hanh\n \"The spirit of the individual is determined by his domination thought habits.\" - Bruce Lee\n \"Be the path. Do not seek it.\" - Yara Tschallener\n \"Bow to no one but your own divinity.\" - Satya\n \"With insight there is hope for awareness, and with awareness there can be change.\" - Tom Kenyon\n \"The opposite of depression isn't happiness, it is purpose.\" - Derek Sivers\n \"If you can't, you must.\" - Tony Robbins\n “When you are grateful, fear disappears and abundance appears.” - Lao Tzu\n “It is in your moments of decision that your destiny is shaped.” - Tony Robbins\n \"Surmounting difficulty is the crucible that forms character.\" - Tony Robbins\n \"Three things cannot be long hidden: the sun, the moon, and the truth.\" - Buddha\n \"What you are is what you have been. What you’ll be is what you do now.\" - Buddha\n \"The best way to take care of our future is to take care of the present moment.\" - Thich Nhat Hanh\n*/\n\n/**\n @dev a library to supply a XEN string data based on params\n*/\nlibrary StringData {\n uint256 public constant QUOTES_COUNT = 12;\n uint256 public constant QUOTE_LENGTH = 66;\n bytes public constant QUOTES =\n bytes(\n '\"If you realize you have enough, you are truly rich.\" - Lao Tzu '\n '\"The real meditation is how you live your life.\" - Jon Kabat-Zinn '\n '\"To know that you do not know is the best.\" - Lao Tzu '\n '\"An over-sharpened sword cannot last long.\" - Lao Tzu '\n '\"When you accept yourself, the whole world accepts you.\" - Lao Tzu'\n '\"Music in the soul can be heard by the universe.\" - Lao Tzu '\n '\"As soon as you have made a thought, laugh at it.\" - Lao Tzu '\n '\"The further one goes, the less one knows.\" - Lao Tzu '\n '\"Stop thinking, and end your problems.\" - Lao Tzu '\n '\"Reliability is the foundation of commitment.\" - Unknown '\n '\"Your past does not equal your future.\" - Tony Robbins '\n '\"Be the path. Do not seek it.\" - Yara Tschallener '\n );\n uint256 public constant CLASSES_COUNT = 14;\n uint256 public constant CLASSES_NAME_LENGTH = 10;\n bytes public constant CLASSES =\n bytes(\n \"Ruby \"\n \"Opal \"\n \"Topaz \"\n \"Emerald \"\n \"Aquamarine\"\n \"Sapphire \"\n \"Amethyst \"\n \"Xenturion \"\n \"Limited \"\n \"Rare \"\n \"Epic \"\n \"Legendary \"\n \"Exotic \"\n \"Xunicorn \"\n );\n\n /**\n @dev Solidity doesn't yet support slicing of byte arrays anywhere outside of calldata,\n therefore we make a hack by supplying our local constant packed string array as calldata\n */\n function getQuote(bytes calldata quotes, uint256 index) external pure returns (string memory) {\n if (index > QUOTES_COUNT - 1) return string(quotes[0:QUOTE_LENGTH]);\n return string(quotes[index * QUOTE_LENGTH:(index + 1) * QUOTE_LENGTH]);\n }\n\n function getClassName(bytes calldata names, uint256 index) external pure returns (string memory) {\n if (index < CLASSES_COUNT) return string(names[index * CLASSES_NAME_LENGTH:(index + 1) * CLASSES_NAME_LENGTH]);\n return \"\";\n }\n}\n"
},
"/contracts/libs/SVG.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./DateTime.sol\";\nimport \"./StringData.sol\";\nimport \"./FormattedStrings.sol\";\n\n/*\n @dev Library to create SVG image for XENFT metadata\n @dependency depends on DataTime.sol and StringData.sol libraries\n */\nlibrary SVG {\n // Type to encode all data params for SVG image generation\n struct SvgParams {\n string symbol;\n address xenAddress;\n uint256 tokenId;\n uint256 term;\n uint256 rank;\n uint256 count;\n uint256 maturityTs;\n uint256 amp;\n uint256 eaa;\n uint256 xenBurned;\n bool redeemed;\n string series;\n }\n\n // Type to encode SVG gradient stop color on HSL color scale\n struct Color {\n uint256 h;\n uint256 s;\n uint256 l;\n uint256 a;\n uint256 off;\n }\n\n // Type to encode SVG gradient\n struct Gradient {\n Color[] colors;\n uint256 id;\n uint256[4] coords;\n }\n\n using DateTime for uint256;\n using Strings for uint256;\n using FormattedStrings for uint256;\n using Strings for address;\n\n string private constant _STYLE =\n \"<style> \"\n \".base {fill: #ededed;font-family:Montserrat,arial,sans-serif;font-size:30px;font-weight:400;} \"\n \".series {text-transform: uppercase} \"\n \".logo {font-size:200px;font-weight:100;} \"\n \".meta {font-size:12px;} \"\n \".small {font-size:8px;} \"\n \".burn {font-weight:500;font-size:16px;} }\"\n \"</style>\";\n\n string private constant _COLLECTOR =\n \"<g>\"\n \"<path \"\n 'stroke=\"#ededed\" '\n 'fill=\"none\" '\n 'transform=\"translate(265,418)\" '\n 'd=\"m 0 0 L -20 -30 L -12.5 -38.5 l 6.5 7 L 0 -38.5 L 6.56 -31.32 L 12.5 -38.5 L 20 -30 L 0 0 L -7.345 -29.955 L 0 -38.5 L 7.67 -30.04 L 0 0 Z M 0 0 L -20.055 -29.955 l 7.555 -8.545 l 24.965 -0.015 L 20 -30 L -20.055 -29.955\"/>'\n \"</g>\";\n\n string private constant _LIMITED =\n \"<g> \"\n '<path fill=\"#ededed\" '\n 'transform=\"scale(0.4) translate(600, 940)\" '\n 'd=\"M66,38.09q.06.9.18,1.71v.05c1,7.08,4.63,11.39,9.59,13.81,5.18,2.53,11.83,3.09,18.48,2.61,1.49-.11,3-.27,4.39-.47l1.59-.2c4.78-.61,11.47-1.48,13.35-5.06,1.16-2.2,1-5,0-8a38.85,38.85,0,0,0-6.89-11.73A32.24,32.24,0,0,0,95,21.46,21.2,21.2,0,0,0,82.3,20a23.53,23.53,0,0,0-12.75,7,15.66,15.66,0,0,0-2.35,3.46h0a20.83,20.83,0,0,0-1,2.83l-.06.2,0,.12A12,12,0,0,0,66,37.9l0,.19Zm26.9-3.63a5.51,5.51,0,0,1,2.53-4.39,14.19,14.19,0,0,0-5.77-.59h-.16l.06.51a5.57,5.57,0,0,0,2.89,4.22,4.92,4.92,0,0,0,.45.24ZM88.62,28l.94-.09a13.8,13.8,0,0,1,8,1.43,7.88,7.88,0,0,1,3.92,6.19l0,.43a.78.78,0,0,1-.66.84A19.23,19.23,0,0,1,98,37a12.92,12.92,0,0,1-6.31-1.44A7.08,7.08,0,0,1,88,30.23a10.85,10.85,0,0,1-.1-1.44.8.8,0,0,1,.69-.78ZM14.15,10c-.06-5.86,3.44-8.49,8-9.49C26.26-.44,31.24.16,34.73.7A111.14,111.14,0,0,1,56.55,6.4a130.26,130.26,0,0,1,22,10.8,26.25,26.25,0,0,1,3-.78,24.72,24.72,0,0,1,14.83,1.69,36,36,0,0,1,13.09,10.42,42.42,42.42,0,0,1,7.54,12.92c1.25,3.81,1.45,7.6-.23,10.79-2.77,5.25-10.56,6.27-16.12,7l-1.23.16a54.53,54.53,0,0,1-2.81,12.06A108.62,108.62,0,0,1,91.3,84v25.29a9.67,9.67,0,0,1,9.25,10.49c0,.41,0,.81,0,1.18a1.84,1.84,0,0,1-1.84,1.81H86.12a8.8,8.8,0,0,1-5.1-1.56,10.82,10.82,0,0,1-3.35-4,2.13,2.13,0,0,1-.2-.46L73.53,103q-2.73,2.13-5.76,4.16c-1.2.8-2.43,1.59-3.69,2.35l.6.16a8.28,8.28,0,0,1,5.07,4,15.38,15.38,0,0,1,1.71,7.11V121a1.83,1.83,0,0,1-1.83,1.83h-53c-2.58.09-4.47-.52-5.75-1.73A6.49,6.49,0,0,1,9.11,116v-11.2a42.61,42.61,0,0,1-6.34-11A38.79,38.79,0,0,1,1.11,70.29,37,37,0,0,1,13.6,50.54l.1-.09a41.08,41.08,0,0,1,11-6.38c7.39-2.9,17.93-2.77,26-2.68,5.21.06,9.34.11,10.19-.49a4.8,4.8,0,0,0,1-.91,5.11,5.11,0,0,0,.56-.84c0-.26,0-.52-.07-.78a16,16,0,0,1-.06-4.2,98.51,98.51,0,0,0-18.76-3.68c-7.48-.83-15.44-1.19-23.47-1.41l-1.35,0c-2.59,0-4.86,0-7.46-1.67A9,9,0,0,1,8,23.68a9.67,9.67,0,0,1-.91-5A10.91,10.91,0,0,1,8.49,14a8.74,8.74,0,0,1,3.37-3.29A8.2,8.2,0,0,1,14.15,10ZM69.14,22a54.75,54.75,0,0,1,4.94-3.24,124.88,124.88,0,0,0-18.8-9A106.89,106.89,0,0,0,34.17,4.31C31,3.81,26.44,3.25,22.89,4c-2.55.56-4.59,1.92-5,4.79a134.49,134.49,0,0,1,26.3,3.8,115.69,115.69,0,0,1,25,9.4ZM64,28.65c.21-.44.42-.86.66-1.28a15.26,15.26,0,0,1,1.73-2.47,146.24,146.24,0,0,0-14.92-6.2,97.69,97.69,0,0,0-15.34-4A123.57,123.57,0,0,0,21.07,13.2c-3.39-.08-6.3.08-7.47.72a5.21,5.21,0,0,0-2,1.94,7.3,7.3,0,0,0-1,3.12,6.1,6.1,0,0,0,.55,3.11,5.43,5.43,0,0,0,2,2.21c1.73,1.09,3.5,1.1,5.51,1.12h1.43c8.16.23,16.23.59,23.78,1.42a103.41,103.41,0,0,1,19.22,3.76,17.84,17.84,0,0,1,.85-2Zm-.76,15.06-.21.16c-1.82,1.3-6.48,1.24-12.35,1.17C42.91,45,32.79,44.83,26,47.47a37.41,37.41,0,0,0-10,5.81l-.1.08A33.44,33.44,0,0,0,4.66,71.17a35.14,35.14,0,0,0,1.5,21.32A39.47,39.47,0,0,0,12.35,103a1.82,1.82,0,0,1,.42,1.16v12a3.05,3.05,0,0,0,.68,2.37,4.28,4.28,0,0,0,3.16.73H67.68a10,10,0,0,0-1.11-3.69,4.7,4.7,0,0,0-2.87-2.32,15.08,15.08,0,0,0-4.4-.38h-26a1.83,1.83,0,0,1-.15-3.65c5.73-.72,10.35-2.74,13.57-6.25,3.06-3.34,4.91-8.1,5.33-14.45v-.13A18.88,18.88,0,0,0,46.35,75a20.22,20.22,0,0,0-7.41-4.42,23.54,23.54,0,0,0-8.52-1.25c-4.7.19-9.11,1.83-12,4.83a1.83,1.83,0,0,1-2.65-2.52c3.53-3.71,8.86-5.73,14.47-6a27.05,27.05,0,0,1,9.85,1.44,24,24,0,0,1,8.74,5.23,22.48,22.48,0,0,1,6.85,15.82v.08a2.17,2.17,0,0,1,0,.36c-.47,7.25-2.66,12.77-6.3,16.75a21.24,21.24,0,0,1-4.62,3.77H57.35q4.44-2.39,8.39-5c2.68-1.79,5.22-3.69,7.63-5.67a1.82,1.82,0,0,1,2.57.24,1.69,1.69,0,0,1,.35.66L81,115.62a7,7,0,0,0,2.16,2.62,5.06,5.06,0,0,0,3,.9H96.88a6.56,6.56,0,0,0-1.68-4.38,7.19,7.19,0,0,0-4.74-1.83c-.36,0-.69,0-1,0a1.83,1.83,0,0,1-1.83-1.83V83.6a1.75,1.75,0,0,1,.23-.88,105.11,105.11,0,0,0,5.34-12.46,52,52,0,0,0,2.55-10.44l-1.23.1c-7.23.52-14.52-.12-20.34-3A20,20,0,0,1,63.26,43.71Z\"/>'\n \"</g>\";\n\n string private constant _APEX =\n '<g transform=\"scale(0.5) translate(533, 790)\">'\n '<circle r=\"39\" stroke=\"#ededed\" fill=\"transparent\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"M0,38 a38,38 0 0 1 0,-76 a19,19 0 0 1 0,38 a19,19 0 0 0 0,38 z m -5 -57 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0 z\" '\n 'fill-rule=\"evenodd\"/>'\n '<path fill=\"#ededed\" '\n 'd=\"m -5, 19 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0\"/>'\n \"</g>\";\n\n string private constant _LOGO =\n '<path fill=\"#ededed\" '\n 'd=\"M122.7,227.1 l-4.8,0l55.8,-74l0,3.2l-51.8,-69.2l5,0l48.8,65.4l-1.2,0l48.8,-65.4l4.8,0l-51.2,68.4l0,-1.6l55.2,73.2l-5,0l-52.8,-70.2l1.2,0l-52.8,70.2z\" '\n 'vector-effect=\"non-scaling-stroke\" />';\n\n /**\n @dev internal helper to create HSL-encoded color prop for SVG tags\n */\n function colorHSL(Color memory c) internal pure returns (bytes memory) {\n return abi.encodePacked(\"hsl(\", c.h.toString(), \", \", c.s.toString(), \"%, \", c.l.toString(), \"%)\");\n }\n\n /**\n @dev internal helper to create `stop` SVG tag\n */\n function colorStop(Color memory c) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n '<stop stop-color=\"',\n colorHSL(c),\n '\" stop-opacity=\"',\n c.a.toString(),\n '\" offset=\"',\n c.off.toString(),\n '%\"/>'\n );\n }\n\n /**\n @dev internal helper to encode position for `Gradient` SVG tag\n */\n function pos(uint256[4] memory coords) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n 'x1=\"',\n coords[0].toString(),\n '%\" '\n 'y1=\"',\n coords[1].toString(),\n '%\" '\n 'x2=\"',\n coords[2].toString(),\n '%\" '\n 'y2=\"',\n coords[3].toString(),\n '%\" '\n );\n }\n\n /**\n @dev internal helper to create `Gradient` SVG tag\n */\n function linearGradient(\n Color[] memory colors,\n uint256 id,\n uint256[4] memory coords\n ) internal pure returns (bytes memory) {\n string memory stops = \"\";\n for (uint256 i = 0; i < colors.length; i++) {\n if (colors[i].h != 0) {\n stops = string.concat(stops, string(colorStop(colors[i])));\n }\n }\n return\n abi.encodePacked(\n \"<linearGradient \",\n pos(coords),\n 'id=\"g',\n id.toString(),\n '\">',\n stops,\n \"</linearGradient>\"\n );\n }\n\n /**\n @dev internal helper to create `Defs` SVG tag\n */\n function defs(Gradient memory grad) internal pure returns (bytes memory) {\n return abi.encodePacked(\"<defs>\", linearGradient(grad.colors, 0, grad.coords), \"</defs>\");\n }\n\n /**\n @dev internal helper to create `Rect` SVG tag\n */\n function rect(uint256 id) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<rect \"\n 'width=\"100%\" '\n 'height=\"100%\" '\n 'fill=\"url(#g',\n id.toString(),\n ')\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n \"/>\"\n );\n }\n\n /**\n @dev internal helper to create border `Rect` SVG tag\n */\n function border() internal pure returns (string memory) {\n return\n \"<rect \"\n 'width=\"94%\" '\n 'height=\"96%\" '\n 'fill=\"transparent\" '\n 'rx=\"10px\" '\n 'ry=\"10px\" '\n 'stroke-linejoin=\"round\" '\n 'x=\"3%\" '\n 'y=\"2%\" '\n 'stroke-dasharray=\"1,6\" '\n 'stroke=\"white\" '\n \"/>\";\n }\n\n /**\n @dev internal helper to create group `G` SVG tag\n */\n function g(uint256 gradientsCount) internal pure returns (bytes memory) {\n string memory background = \"\";\n for (uint256 i = 0; i < gradientsCount; i++) {\n background = string.concat(background, string(rect(i)));\n }\n return abi.encodePacked(\"<g>\", background, border(), \"</g>\");\n }\n\n /**\n @dev internal helper to create XEN logo line pattern with 2 SVG `lines`\n */\n function logo() internal pure returns (bytes memory) {\n return abi.encodePacked();\n }\n\n /**\n @dev internal helper to create `Text` SVG tag with XEN Crypto contract data\n */\n function contractData(string memory symbol, address xenAddress) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"5%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">',\n symbol,\n unicode\"・\",\n xenAddress.toHexString(),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to create cRank range string\n */\n function rankAndCount(uint256 rank, uint256 count) internal pure returns (bytes memory) {\n if (count == 1) return abi.encodePacked(rank.toString());\n return abi.encodePacked(rank.toString(), \"..\", (rank + count - 1).toString());\n }\n\n /**\n @dev internal helper to create 1st part of metadata section of SVG\n */\n function meta1(\n uint256 tokenId,\n uint256 count,\n uint256 eaa,\n string memory series,\n uint256 xenBurned\n ) internal pure returns (bytes memory) {\n bytes memory part1 = abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"50%\" '\n 'class=\"base \" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\">'\n \"XEN CRYPTO\"\n \"</text>\"\n \"<text \"\n 'x=\"50%\" '\n 'y=\"56%\" '\n 'class=\"base burn\" '\n 'text-anchor=\"middle\" '\n 'dominant-baseline=\"middle\"> ',\n xenBurned > 0 ? string.concat((xenBurned / 10**18).toFormattedString(), \" X\") : \"\",\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"62%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\"> '\n \"#\",\n tokenId.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"82%\" '\n 'y=\"62%\" '\n 'class=\"base meta series\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"end\" >',\n series,\n \"</text>\"\n );\n bytes memory part2 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"68%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"VMU: \",\n count.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"72%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"EAA: \",\n (eaa / 10).toString(),\n \"%\"\n \"</text>\"\n );\n return abi.encodePacked(part1, part2);\n }\n\n /**\n @dev internal helper to create 2nd part of metadata section of SVG\n */\n function meta2(\n uint256 maturityTs,\n uint256 amp,\n uint256 term,\n uint256 rank,\n uint256 count\n ) internal pure returns (bytes memory) {\n bytes memory part3 = abi.encodePacked(\n \"<text \"\n 'x=\"18%\" '\n 'y=\"76%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"AMP: \",\n amp.toString(),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"80%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Term: \",\n term.toString()\n );\n bytes memory part4 = abi.encodePacked(\n \" days\"\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"84%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"cRank: \",\n rankAndCount(rank, count),\n \"</text>\"\n \"<text \"\n 'x=\"18%\" '\n 'y=\"88%\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" >'\n \"Maturity: \",\n maturityTs.asString(),\n \"</text>\"\n );\n return abi.encodePacked(part3, part4);\n }\n\n /**\n @dev internal helper to create `Text` SVG tag for XEN quote\n */\n function quote(uint256 idx) internal pure returns (bytes memory) {\n return\n abi.encodePacked(\n \"<text \"\n 'x=\"50%\" '\n 'y=\"95%\" '\n 'class=\"base small\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" >',\n StringData.getQuote(StringData.QUOTES, idx),\n \"</text>\"\n );\n }\n\n /**\n @dev internal helper to generate `Redeemed` stamp\n */\n function stamp(bool redeemed) internal pure returns (bytes memory) {\n if (!redeemed) return \"\";\n return\n abi.encodePacked(\n \"<rect \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'width=\"100\" '\n 'height=\"40\" '\n 'stroke=\"black\" '\n 'stroke-width=\"1\" '\n 'fill=\"none\" '\n 'rx=\"5px\" '\n 'ry=\"5px\" '\n 'transform=\"translate(-50,-20) '\n 'rotate(-20,0,400)\" />',\n \"<text \"\n 'x=\"50%\" '\n 'y=\"77.5%\" '\n 'stroke=\"black\" '\n 'class=\"base meta\" '\n 'dominant-baseline=\"middle\" '\n 'text-anchor=\"middle\" '\n 'transform=\"translate(0,0) rotate(-20,-45,380)\" >'\n \"Redeemed\"\n \"</text>\"\n );\n }\n\n /**\n @dev main internal helper to create SVG file representing XENFT\n */\n function image(\n SvgParams memory params,\n Gradient[] memory gradients,\n uint256 idx,\n bool apex,\n bool limited\n ) internal pure returns (bytes memory) {\n string memory mark = limited ? _LIMITED : apex ? _APEX : _COLLECTOR;\n bytes memory graphics = abi.encodePacked(defs(gradients[0]), _STYLE, g(gradients.length), _LOGO, mark);\n bytes memory metadata = abi.encodePacked(\n contractData(params.symbol, params.xenAddress),\n meta1(params.tokenId, params.count, params.eaa, params.series, params.xenBurned),\n meta2(params.maturityTs, params.amp, params.term, params.rank, params.count),\n quote(idx),\n stamp(params.redeemed)\n );\n return\n abi.encodePacked(\n \"<svg \"\n 'xmlns=\"http://www.w3.org/2000/svg\" '\n 'preserveAspectRatio=\"xMinYMin meet\" '\n 'viewBox=\"0 0 350 566\">',\n graphics,\n metadata,\n \"</svg>\"\n );\n }\n}\n"
},
"/contracts/libs/MintInfo.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// mapping: NFT tokenId => MintInfo (used in tokenURI generation)\n// MintInfo encoded as:\n// term (uint16)\n// | maturityTs (uint64)\n// | rank (uint128)\n// | amp (uint16)\n// | eaa (uint16)\n// | class (uint8):\n// [7] isApex\n// [6] isLimited\n// [0-5] powerGroupIdx\n// | redeemed (uint8)\nlibrary MintInfo {\n /**\n @dev helper to convert Bool to U256 type and make compiler happy\n */\n function toU256(bool x) internal pure returns (uint256 r) {\n assembly {\n r := x\n }\n }\n\n /**\n @dev encodes MintInfo record from its props\n */\n function encodeMintInfo(\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class_,\n bool redeemed\n ) public pure returns (uint256 info) {\n info = info | (toU256(redeemed) & 0xFF);\n info = info | ((class_ & 0xFF) << 8);\n info = info | ((eaa & 0xFFFF) << 16);\n info = info | ((amp & 0xFFFF) << 32);\n info = info | ((rank & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) << 48);\n info = info | ((maturityTs & 0xFFFFFFFFFFFFFFFF) << 176);\n info = info | ((term & 0xFFFF) << 240);\n }\n\n /**\n @dev decodes MintInfo record and extracts all of its props\n */\n function decodeMintInfo(uint256 info)\n public\n pure\n returns (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 class,\n bool apex,\n bool limited,\n bool redeemed\n )\n {\n term = uint16(info >> 240);\n maturityTs = uint64(info >> 176);\n rank = uint128(info >> 48);\n amp = uint16(info >> 32);\n eaa = uint16(info >> 16);\n class = uint8(info >> 8) & 0x3F;\n apex = (uint8(info >> 8) & 0x80) > 0;\n limited = (uint8(info >> 8) & 0x40) > 0;\n redeemed = uint8(info) == 1;\n }\n\n /**\n @dev extracts `term` prop from encoded MintInfo\n */\n function getTerm(uint256 info) public pure returns (uint256 term) {\n (term, , , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `maturityTs` prop from encoded MintInfo\n */\n function getMaturityTs(uint256 info) public pure returns (uint256 maturityTs) {\n (, maturityTs, , , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `rank` prop from encoded MintInfo\n */\n function getRank(uint256 info) public pure returns (uint256 rank) {\n (, , rank, , , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `AMP` prop from encoded MintInfo\n */\n function getAMP(uint256 info) public pure returns (uint256 amp) {\n (, , , amp, , , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `EAA` prop from encoded MintInfo\n */\n function getEAA(uint256 info) public pure returns (uint256 eaa) {\n (, , , , eaa, , , , ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getClass(uint256 info)\n public\n pure\n returns (\n uint256 class_,\n bool apex,\n bool limited\n )\n {\n (, , , , , class_, apex, limited, ) = decodeMintInfo(info);\n }\n\n /**\n @dev extracts `redeemed` prop from encoded MintInfo\n */\n function getRedeemed(uint256 info) public pure returns (bool redeemed) {\n (, , , , , , , , redeemed) = decodeMintInfo(info);\n }\n}\n"
},
"/contracts/libs/Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./MintInfo.sol\";\nimport \"./DateTime.sol\";\nimport \"./FormattedStrings.sol\";\nimport \"./SVG.sol\";\n\n/**\n @dev Library contains methods to generate on-chain NFT metadata\n*/\nlibrary Metadata {\n using DateTime for uint256;\n using MintInfo for uint256;\n using Strings for uint256;\n\n uint256 public constant POWER_GROUP_SIZE = 7_500;\n uint256 public constant MAX_POWER = 52_500;\n\n uint256 public constant COLORS_FULL_SCALE = 300;\n uint256 public constant SPECIAL_LUMINOSITY = 45;\n uint256 public constant BASE_SATURATION = 75;\n uint256 public constant BASE_LUMINOSITY = 38;\n uint256 public constant GROUP_SATURATION = 100;\n uint256 public constant GROUP_LUMINOSITY = 50;\n uint256 public constant DEFAULT_OPACITY = 1;\n uint256 public constant NO_COLOR = 360;\n\n // PRIVATE HELPERS\n\n // The following pure methods returning arrays are workaround to use array constants,\n // not yet available in Solidity\n\n function _powerGroupColors() private pure returns (uint256[8] memory) {\n return [uint256(360), 1, 30, 60, 120, 180, 240, 300];\n }\n\n function _huesApex() private pure returns (uint256[3] memory) {\n return [uint256(169), 210, 305];\n }\n\n function _huesLimited() private pure returns (uint256[3] memory) {\n return [uint256(263), 0, 42];\n }\n\n function _stopOffsets() private pure returns (uint256[3] memory) {\n return [uint256(10), 50, 90];\n }\n\n function _gradColorsRegular() private pure returns (uint256[4] memory) {\n return [uint256(150), 150, 20, 20];\n }\n\n function _gradColorsBlack() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 20, 20];\n }\n\n function _gradColorsSpecial() private pure returns (uint256[4] memory) {\n return [uint256(100), 100, 0, 0];\n }\n\n /**\n @dev private helper to determine XENFT group index by its power\n (power = count of VMUs * mint term in days)\n */\n function _powerGroup(uint256 vmus, uint256 term) private pure returns (uint256) {\n return (vmus * term) / POWER_GROUP_SIZE;\n }\n\n /**\n @dev private helper to generate SVG gradients for special XENFT categories\n */\n function _specialClassGradients(bool rare) private pure returns (SVG.Gradient[] memory gradients) {\n uint256[3] memory specialColors = rare ? _huesApex() : _huesLimited();\n SVG.Color[] memory colors = new SVG.Color[](3);\n for (uint256 i = 0; i < colors.length; i++) {\n colors[i] = SVG.Color({\n h: specialColors[i],\n s: BASE_SATURATION,\n l: SPECIAL_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[i]\n });\n }\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({colors: colors, id: 0, coords: _gradColorsSpecial()});\n }\n\n /**\n @dev private helper to generate SVG gradients for common XENFT category\n */\n function _commonCategoryGradients(uint256 vmus, uint256 term)\n private\n pure\n returns (SVG.Gradient[] memory gradients)\n {\n SVG.Color[] memory colors = new SVG.Color[](2);\n uint256 powerHue = term * vmus > MAX_POWER ? NO_COLOR : 1 + (term * vmus * COLORS_FULL_SCALE) / MAX_POWER;\n // group\n uint256 groupHue = _powerGroupColors()[_powerGroup(vmus, term) > 7 ? 7 : _powerGroup(vmus, term)];\n colors[0] = SVG.Color({\n h: groupHue,\n s: groupHue == NO_COLOR ? 0 : GROUP_SATURATION,\n l: groupHue == NO_COLOR ? 0 : GROUP_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[0]\n });\n // power\n colors[1] = SVG.Color({\n h: powerHue,\n s: powerHue == NO_COLOR ? 0 : BASE_SATURATION,\n l: powerHue == NO_COLOR ? 0 : BASE_LUMINOSITY,\n a: DEFAULT_OPACITY,\n off: _stopOffsets()[2]\n });\n gradients = new SVG.Gradient[](1);\n gradients[0] = SVG.Gradient({\n colors: colors,\n id: 0,\n coords: groupHue == NO_COLOR ? _gradColorsBlack() : _gradColorsRegular()\n });\n }\n\n // PUBLIC INTERFACE\n\n /**\n @dev public interface to generate SVG image based on XENFT params\n */\n function svgData(\n uint256 tokenId,\n uint256 count,\n uint256 info,\n address token,\n uint256 burned\n ) external view returns (bytes memory) {\n string memory symbol = IERC20Metadata(token).symbol();\n (uint256 classIds, bool rare, bool limited) = info.getClass();\n SVG.SvgParams memory params = SVG.SvgParams({\n symbol: symbol,\n xenAddress: token,\n tokenId: tokenId,\n term: info.getTerm(),\n rank: info.getRank(),\n count: count,\n maturityTs: info.getMaturityTs(),\n amp: info.getAMP(),\n eaa: info.getEAA(),\n xenBurned: burned,\n series: StringData.getClassName(StringData.CLASSES, classIds),\n redeemed: info.getRedeemed()\n });\n uint256 quoteIdx = uint256(keccak256(abi.encode(info))) % StringData.QUOTES_COUNT;\n if (rare || limited) {\n return SVG.image(params, _specialClassGradients(rare), quoteIdx, rare, limited);\n }\n return SVG.image(params, _commonCategoryGradients(count, info.getTerm()), quoteIdx, rare, limited);\n }\n\n function _attr1(\n uint256 count,\n uint256 rank,\n uint256 class_\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Class\",\"value\":\"',\n StringData.getClassName(StringData.CLASSES, class_),\n '\"},'\n '{\"trait_type\":\"VMUs\",\"value\":\"',\n count.toString(),\n '\"},'\n '{\"trait_type\":\"cRank\",\"value\":\"',\n rank.toString(),\n '\"},'\n );\n }\n\n function _attr2(\n uint256 amp,\n uint256 eaa,\n uint256 maturityTs\n ) private pure returns (bytes memory) {\n (uint256 year, string memory month) = DateTime.yearAndMonth(maturityTs);\n return\n abi.encodePacked(\n '{\"trait_type\":\"AMP\",\"value\":\"',\n amp.toString(),\n '\"},'\n '{\"trait_type\":\"EAA (%)\",\"value\":\"',\n (eaa / 10).toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Year\",\"value\":\"',\n year.toString(),\n '\"},'\n '{\"trait_type\":\"Maturity Month\",\"value\":\"',\n month,\n '\"},'\n );\n }\n\n function _attr3(\n uint256 maturityTs,\n uint256 term,\n uint256 burned\n ) private pure returns (bytes memory) {\n return\n abi.encodePacked(\n '{\"trait_type\":\"Maturity DateTime\",\"value\":\"',\n maturityTs.asString(),\n '\"},'\n '{\"trait_type\":\"Term\",\"value\":\"',\n term.toString(),\n '\"},'\n '{\"trait_type\":\"XEN Burned\",\"value\":\"',\n (burned / 10**18).toString(),\n '\"},'\n );\n }\n\n function _attr4(bool apex, bool limited) private pure returns (bytes memory) {\n string memory category = \"Collector\";\n if (limited) category = \"Limited\";\n if (apex) category = \"Apex\";\n return abi.encodePacked('{\"trait_type\":\"Category\",\"value\":\"', category, '\"}');\n }\n\n /**\n @dev private helper to construct attributes portion of NFT metadata\n */\n function attributes(\n uint256 count,\n uint256 burned,\n uint256 mintInfo\n ) external pure returns (bytes memory) {\n (\n uint256 term,\n uint256 maturityTs,\n uint256 rank,\n uint256 amp,\n uint256 eaa,\n uint256 series,\n bool apex,\n bool limited,\n\n ) = MintInfo.decodeMintInfo(mintInfo);\n return\n abi.encodePacked(\n \"[\",\n _attr1(count, rank, series),\n _attr2(amp, eaa, maturityTs),\n _attr3(maturityTs, term, burned),\n _attr4(apex, limited),\n \"]\"\n );\n }\n\n function formattedString(uint256 n) public pure returns (string memory) {\n return FormattedStrings.toFormattedString(n);\n }\n}\n"
},
"/contracts/libs/FormattedStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary FormattedStrings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n Base on OpenZeppelin `toString` method from `String` library\n */\n function toFormattedString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n uint256 pos;\n uint256 comas = digits / 3;\n digits = digits + (digits % 3 == 0 ? comas - 1 : comas);\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n if (pos == 3) {\n buffer[digits] = \",\";\n pos = 0;\n } else {\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n pos++;\n }\n }\n return string(buffer);\n }\n}\n"
},
"/contracts/libs/ERC2771Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n // one-time settable var\n address internal _trustedForwarder;\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address trustedForwarder) {\n _trustedForwarder = trustedForwarder;\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return forwarder == _trustedForwarder;\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n /// @solidity memory-safe-assembly\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n}\n"
},
"/contracts/libs/DateTime.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./BokkyPooBahsDateTimeLibrary.sol\";\n\n/*\n @dev Library to convert epoch timestamp to a human-readable Date-Time string\n @dependency uses BokkyPooBahsDateTimeLibrary.sol library internally\n */\nlibrary DateTime {\n using Strings for uint256;\n\n bytes public constant MONTHS = bytes(\"JanFebMarAprMayJunJulAugSepOctNovDec\");\n\n /**\n * @dev returns month as short (3-letter) string\n */\n function monthAsString(uint256 idx) internal pure returns (string memory) {\n require(idx > 0, \"bad idx\");\n bytes memory str = new bytes(3);\n uint256 offset = (idx - 1) * 3;\n str[0] = bytes1(MONTHS[offset]);\n str[1] = bytes1(MONTHS[offset + 1]);\n str[2] = bytes1(MONTHS[offset + 2]);\n return string(str);\n }\n\n /**\n * @dev returns string representation of number left-padded for 2 symbols\n */\n function asPaddedString(uint256 n) internal pure returns (string memory) {\n if (n == 0) return \"00\";\n if (n < 10) return string.concat(\"0\", n.toString());\n return n.toString();\n }\n\n /**\n * @dev returns string of format 'Jan 01, 2022 18:00 UTC' for a given timestamp\n */\n function asString(uint256 ts) external pure returns (string memory) {\n (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, ) = BokkyPooBahsDateTimeLibrary\n .timestampToDateTime(ts);\n return\n string(\n abi.encodePacked(\n monthAsString(month),\n \" \",\n day.toString(),\n \", \",\n year.toString(),\n \" \",\n asPaddedString(hour),\n \":\",\n asPaddedString(minute),\n \" UTC\"\n )\n );\n }\n\n /**\n * @dev returns (year, month as string) components of a date by timestamp\n */\n function yearAndMonth(uint256 ts) external pure returns (uint256, string memory) {\n (uint256 year, uint256 month, , , , ) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(ts);\n return (year, monthAsString(month));\n }\n}\n"
},
"/contracts/libs/BokkyPooBahsDateTimeLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\n// ----------------------------------------------------------------------------\n// BokkyPooBah's DateTime Library v1.01\n//\n// A gas-efficient Solidity date and time library\n//\n// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary\n//\n// Tested date range 1970/01/01 to 2345/12/31\n//\n// Conventions:\n// Unit | Range | Notes\n// :-------- |:-------------:|:-----\n// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC\n// year | 1970 ... 2345 |\n// month | 1 ... 12 |\n// day | 1 ... 31 |\n// hour | 0 ... 23 |\n// minute | 0 ... 59 |\n// second | 0 ... 59 |\n// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday\n//\n//\n// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.\n// ----------------------------------------------------------------------------\n\nlibrary BokkyPooBahsDateTimeLibrary {\n uint256 constant _SECONDS_PER_DAY = 24 * 60 * 60;\n uint256 constant _SECONDS_PER_HOUR = 60 * 60;\n uint256 constant _SECONDS_PER_MINUTE = 60;\n int256 constant _OFFSET19700101 = 2440588;\n\n uint256 constant _DOW_FRI = 5;\n uint256 constant _DOW_SAT = 6;\n\n // ------------------------------------------------------------------------\n // Calculate the number of days from 1970/01/01 to year/month/day using\n // the date conversion algorithm from\n // https://aa.usno.navy.mil/faq/JD_formula.html\n // and subtracting the offset 2440588 so that 1970/01/01 is day 0\n //\n // days = day\n // - 32075\n // + 1461 * (year + 4800 + (month - 14) / 12) / 4\n // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12\n // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4\n // - offset\n // ------------------------------------------------------------------------\n function _daysFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) private pure returns (uint256 _days) {\n require(year >= 1970);\n int256 _year = int256(year);\n int256 _month = int256(month);\n int256 _day = int256(day);\n\n int256 __days = _day -\n 32075 +\n (1461 * (_year + 4800 + (_month - 14) / 12)) /\n 4 +\n (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /\n 12 -\n (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /\n 4 -\n _OFFSET19700101;\n\n _days = uint256(__days);\n }\n\n // ------------------------------------------------------------------------\n // Calculate year/month/day from the number of days since 1970/01/01 using\n // the date conversion algorithm from\n // http://aa.usno.navy.mil/faq/docs/JD_Formula.php\n // and adding the offset 2440588 so that 1970/01/01 is day 0\n //\n // int L = days + 68569 + offset\n // int N = 4 * L / 146097\n // L = L - (146097 * N + 3) / 4\n // year = 4000 * (L + 1) / 1461001\n // L = L - 1461 * year / 4 + 31\n // month = 80 * L / 2447\n // dd = L - 2447 * month / 80\n // L = month / 11\n // month = month + 2 - 12 * L\n // year = 100 * (N - 49) + year + L\n // ------------------------------------------------------------------------\n function _daysToDate(uint256 _days)\n private\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n int256 __days = int256(_days);\n\n int256 L = __days + 68569 + _OFFSET19700101;\n int256 N = (4 * L) / 146097;\n L = L - (146097 * N + 3) / 4;\n int256 _year = (4000 * (L + 1)) / 1461001;\n L = L - (1461 * _year) / 4 + 31;\n int256 _month = (80 * L) / 2447;\n int256 _day = L - (2447 * _month) / 80;\n L = _month / 11;\n _month = _month + 2 - 12 * L;\n _year = 100 * (N - 49) + _year + L;\n\n year = uint256(_year);\n month = uint256(_month);\n day = uint256(_day);\n }\n\n function timestampFromDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (uint256 timestamp) {\n timestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY;\n }\n\n function timestampFromDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (uint256 timestamp) {\n timestamp =\n _daysFromDate(year, month, day) *\n _SECONDS_PER_DAY +\n hour *\n _SECONDS_PER_HOUR +\n minute *\n _SECONDS_PER_MINUTE +\n second;\n }\n\n function timestampToDate(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function timestampToDateTime(uint256 timestamp)\n internal\n pure\n returns (\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n )\n {\n (year, month, day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n secs = secs % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n second = secs % _SECONDS_PER_MINUTE;\n }\n\n function isValidDate(\n uint256 year,\n uint256 month,\n uint256 day\n ) internal pure returns (bool valid) {\n if (year >= 1970 && month > 0 && month <= 12) {\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > 0 && day <= daysInMonth) {\n valid = true;\n }\n }\n }\n\n function isValidDateTime(\n uint256 year,\n uint256 month,\n uint256 day,\n uint256 hour,\n uint256 minute,\n uint256 second\n ) internal pure returns (bool valid) {\n if (isValidDate(year, month, day)) {\n if (hour < 24 && minute < 60 && second < 60) {\n valid = true;\n }\n }\n }\n\n function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {\n (uint256 year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n leapYear = _isLeapYear(year);\n }\n\n function _isLeapYear(uint256 year) private pure returns (bool leapYear) {\n leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);\n }\n\n function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {\n weekDay = getDayOfWeek(timestamp) <= _DOW_FRI;\n }\n\n function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {\n weekEnd = getDayOfWeek(timestamp) >= _DOW_SAT;\n }\n\n function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {\n (uint256 year, uint256 month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n daysInMonth = _getDaysInMonth(year, month);\n }\n\n function _getDaysInMonth(uint256 year, uint256 month) private pure returns (uint256 daysInMonth) {\n if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {\n daysInMonth = 31;\n } else if (month != 2) {\n daysInMonth = 30;\n } else {\n daysInMonth = _isLeapYear(year) ? 29 : 28;\n }\n }\n\n // 1 = Monday, 7 = Sunday\n function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {\n uint256 _days = timestamp / _SECONDS_PER_DAY;\n dayOfWeek = ((_days + 3) % 7) + 1;\n }\n\n function getYear(uint256 timestamp) internal pure returns (uint256 year) {\n (year, , ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getMonth(uint256 timestamp) internal pure returns (uint256 month) {\n (, month, ) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getDay(uint256 timestamp) internal pure returns (uint256 day) {\n (, , day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n }\n\n function getHour(uint256 timestamp) internal pure returns (uint256 hour) {\n uint256 secs = timestamp % _SECONDS_PER_DAY;\n hour = secs / _SECONDS_PER_HOUR;\n }\n\n function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {\n uint256 secs = timestamp % _SECONDS_PER_HOUR;\n minute = secs / _SECONDS_PER_MINUTE;\n }\n\n function getSecond(uint256 timestamp) internal pure returns (uint256 second) {\n second = timestamp % _SECONDS_PER_MINUTE;\n }\n\n function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year += _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n month += _months;\n year += (month - 1) / 12;\n month = ((month - 1) % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp >= timestamp);\n }\n\n function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _days * _SECONDS_PER_DAY;\n require(newTimestamp >= timestamp);\n }\n\n function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _hours * _SECONDS_PER_HOUR;\n require(newTimestamp >= timestamp);\n }\n\n function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp >= timestamp);\n }\n\n function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp + _seconds;\n require(newTimestamp >= timestamp);\n }\n\n function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n year -= _years;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {\n (uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / _SECONDS_PER_DAY);\n uint256 yearMonth = year * 12 + (month - 1) - _months;\n year = yearMonth / 12;\n month = (yearMonth % 12) + 1;\n uint256 daysInMonth = _getDaysInMonth(year, month);\n if (day > daysInMonth) {\n day = daysInMonth;\n }\n newTimestamp = _daysFromDate(year, month, day) * _SECONDS_PER_DAY + (timestamp % _SECONDS_PER_DAY);\n require(newTimestamp <= timestamp);\n }\n\n function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _days * _SECONDS_PER_DAY;\n require(newTimestamp <= timestamp);\n }\n\n function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _hours * _SECONDS_PER_HOUR;\n require(newTimestamp <= timestamp);\n }\n\n function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _minutes * _SECONDS_PER_MINUTE;\n require(newTimestamp <= timestamp);\n }\n\n function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {\n newTimestamp = timestamp - _seconds;\n require(newTimestamp <= timestamp);\n }\n\n function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, , ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, , ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _years = toYear - fromYear;\n }\n\n function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {\n require(fromTimestamp <= toTimestamp);\n (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(fromTimestamp / _SECONDS_PER_DAY);\n (uint256 toYear, uint256 toMonth, ) = _daysToDate(toTimestamp / _SECONDS_PER_DAY);\n _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;\n }\n\n function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {\n require(fromTimestamp <= toTimestamp);\n _days = (toTimestamp - fromTimestamp) / _SECONDS_PER_DAY;\n }\n\n function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {\n require(fromTimestamp <= toTimestamp);\n _hours = (toTimestamp - fromTimestamp) / _SECONDS_PER_HOUR;\n }\n\n function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {\n require(fromTimestamp <= toTimestamp);\n _minutes = (toTimestamp - fromTimestamp) / _SECONDS_PER_MINUTE;\n }\n\n function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {\n require(fromTimestamp <= toTimestamp);\n _seconds = toTimestamp - fromTimestamp;\n }\n}\n"
},
"/contracts/libs/Array.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nlibrary Array {\n function idx(uint256[] memory arr, uint256 item) internal pure returns (uint256 i) {\n for (i = 1; i <= arr.length; i++) {\n if (arr[i - 1] == item) {\n return i;\n }\n }\n i = 0;\n }\n\n function addItem(uint256[] storage arr, uint256 item) internal {\n if (idx(arr, item) == 0) {\n arr.push(item);\n }\n }\n\n function removeItem(uint256[] storage arr, uint256 item) internal {\n uint256 i = idx(arr, item);\n if (i > 0) {\n arr[i - 1] = arr[arr.length - 1];\n arr.pop();\n }\n }\n\n function contains(uint256[] memory container, uint256[] memory items) internal pure returns (bool) {\n if (items.length == 0) return true;\n for (uint256 i = 0; i < items.length; i++) {\n bool itemIsContained = false;\n for (uint256 j = 0; j < container.length; j++) {\n itemIsContained = items[i] == container[j];\n }\n if (!itemIsContained) return false;\n }\n return true;\n }\n\n function asSingletonArray(uint256 element) internal pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n return array;\n }\n\n function hasDuplicatesOrZeros(uint256[] memory array) internal pure returns (bool) {\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0) return true;\n for (uint256 j = 0; j < array.length; j++) {\n if (array[i] == array[j] && i != j) return true;\n }\n }\n return false;\n }\n\n function hasRoguesOrZeros(uint256[] memory array) internal pure returns (bool) {\n uint256 _first = array[0];\n for (uint256 i = 0; i < array.length; i++) {\n if (array[i] == 0 || array[i] != _first) return true;\n }\n return false;\n }\n}\n"
},
"/contracts/interfaces/IXENTorrent.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENTorrent {\n event StartTorrent(address indexed user, uint256 count, uint256 term);\n event EndTorrent(address indexed user, uint256 tokenId, address to);\n\n function bulkClaimRank(uint256 count, uint256 term) external returns (uint256);\n\n function bulkClaimMintReward(uint256 tokenId, address to) external;\n}\n"
},
"/contracts/interfaces/IXENProxying.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IXENProxying {\n function callClaimRank(uint256 term) external;\n\n function callClaimMintReward(address to) external;\n\n function powerDown() external;\n}\n"
},
"/contracts/interfaces/IERC2771.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IERC2771 {\n function isTrustedForwarder(address forwarder) external;\n}\n"
},
"operator-filter-registry/src/OperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title OperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/DefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\n/**\n * @title DefaultOperatorFilterer\n * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.\n */\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"
},
"abdk-libraries-solidity/ABDKMath64x64.sol": {
"content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov <mikhail.vladimirov@gmail.com>\n */\npragma solidity ^0.8.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have. \n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Convert signed 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromInt (int256 x) internal pure returns (int128) {\n unchecked {\n require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (x << 64);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 64-bit integer number\n * rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64-bit integer number\n */\n function toInt (int128 x) internal pure returns (int64) {\n unchecked {\n return int64 (x >> 64);\n }\n }\n\n /**\n * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point\n * number. Revert on overflow.\n *\n * @param x unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function fromUInt (uint256 x) internal pure returns (int128) {\n unchecked {\n require (x <= 0x7FFFFFFFFFFFFFFF);\n return int128 (int256 (x << 64));\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into unsigned 64-bit integer\n * number rounding down. Revert on underflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return unsigned 64-bit integer number\n */\n function toUInt (int128 x) internal pure returns (uint64) {\n unchecked {\n require (x >= 0);\n return uint64 (uint128 (x >> 64));\n }\n }\n\n /**\n * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point\n * number rounding down. Revert on overflow.\n *\n * @param x signed 128.128-bin fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function from128x128 (int256 x) internal pure returns (int128) {\n unchecked {\n int256 result = x >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Convert signed 64.64 fixed point number into signed 128.128 fixed point\n * number.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 128.128 fixed point number\n */\n function to128x128 (int128 x) internal pure returns (int256) {\n unchecked {\n return int256 (x) << 64;\n }\n }\n\n /**\n * Calculate x + y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function add (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) + y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x - y. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sub (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) - y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 result = int256(x) * y >> 64;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point\n * number and y is signed 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y signed 256-bit integer number\n * @return signed 256-bit integer number\n */\n function muli (int128 x, int256 y) internal pure returns (int256) {\n unchecked {\n if (x == MIN_64x64) {\n require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&\n y <= 0x1000000000000000000000000000000000000000000000000);\n return -y << 63;\n } else {\n bool negativeResult = false;\n if (x < 0) {\n x = -x;\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint256 absoluteResult = mulu (x, uint256 (y));\n if (negativeResult) {\n require (absoluteResult <=\n 0x8000000000000000000000000000000000000000000000000000000000000000);\n return -int256 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int256 (absoluteResult);\n }\n }\n }\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu (int128 x, uint256 y) internal pure returns (uint256) {\n unchecked {\n if (y == 0) return 0;\n\n require (x >= 0);\n\n uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256 (int256 (x)) * (y >> 128);\n\n require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n hi <<= 64;\n\n require (hi <=\n 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);\n return hi + lo;\n }\n }\n\n /**\n * Calculate x / y rounding towards zero. Revert on overflow or when y is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function div (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n int256 result = (int256 (x) << 64) / y;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are signed 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x signed 256-bit integer number\n * @param y signed 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divi (int256 x, int256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n\n bool negativeResult = false;\n if (x < 0) {\n x = -x; // We rely on overflow behavior here\n negativeResult = true;\n }\n if (y < 0) {\n y = -y; // We rely on overflow behavior here\n negativeResult = !negativeResult;\n }\n uint128 absoluteResult = divuu (uint256 (x), uint256 (y));\n if (negativeResult) {\n require (absoluteResult <= 0x80000000000000000000000000000000);\n return -int128 (absoluteResult); // We rely on overflow behavior here\n } else {\n require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return int128 (absoluteResult); // We rely on overflow behavior here\n }\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu (uint256 x, uint256 y) internal pure returns (int128) {\n unchecked {\n require (y != 0);\n uint128 result = divuu (x, y);\n require (result <= uint128 (MAX_64x64));\n return int128 (result);\n }\n }\n\n /**\n * Calculate -x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function neg (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return -x;\n }\n }\n\n /**\n * Calculate |x|. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function abs (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != MIN_64x64);\n return x < 0 ? -x : x;\n }\n }\n\n /**\n * Calculate 1 / x rounding towards zero. Revert on overflow or when x is\n * zero.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function inv (int128 x) internal pure returns (int128) {\n unchecked {\n require (x != 0);\n int256 result = int256 (0x100000000000000000000000000000000) / x;\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function avg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n return int128 ((int256 (x) + int256 (y)) >> 1);\n }\n }\n\n /**\n * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.\n * Revert on overflow or in case x * y is negative.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function gavg (int128 x, int128 y) internal pure returns (int128) {\n unchecked {\n int256 m = int256 (x) * int256 (y);\n require (m >= 0);\n require (m <\n 0x4000000000000000000000000000000000000000000000000000000000000000);\n return int128 (sqrtu (uint256 (m)));\n }\n }\n\n /**\n * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y uint256 value\n * @return signed 64.64-bit fixed point number\n */\n function pow (int128 x, uint256 y) internal pure returns (int128) {\n unchecked {\n bool negative = x < 0 && y & 1 == 1;\n\n uint256 absX = uint128 (x < 0 ? -x : x);\n uint256 absResult;\n absResult = 0x100000000000000000000000000000000;\n\n if (absX <= 0x10000000000000000) {\n absX <<= 63;\n while (y != 0) {\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x2 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x4 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n if (y & 0x8 != 0) {\n absResult = absResult * absX >> 127;\n }\n absX = absX * absX >> 127;\n\n y >>= 4;\n }\n\n absResult >>= 64;\n } else {\n uint256 absXShift = 63;\n if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }\n if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }\n if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }\n if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }\n if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }\n if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }\n\n uint256 resultShift = 0;\n while (y != 0) {\n require (absXShift < 64);\n\n if (y & 0x1 != 0) {\n absResult = absResult * absX >> 127;\n resultShift += absXShift;\n if (absResult > 0x100000000000000000000000000000000) {\n absResult >>= 1;\n resultShift += 1;\n }\n }\n absX = absX * absX >> 127;\n absXShift <<= 1;\n if (absX >= 0x100000000000000000000000000000000) {\n absX >>= 1;\n absXShift += 1;\n }\n\n y >>= 1;\n }\n\n require (resultShift < 64);\n absResult >>= 64 - resultShift;\n }\n int256 result = negative ? -int256 (absResult) : int256 (absResult);\n require (result >= MIN_64x64 && result <= MAX_64x64);\n return int128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down. Revert if x < 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function sqrt (int128 x) internal pure returns (int128) {\n unchecked {\n require (x >= 0);\n return int128 (sqrtu (uint256 (int256 (x)) << 64));\n }\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = msb - 64 << 64;\n uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256 (b);\n }\n\n return int128 (result);\n }\n }\n\n /**\n * Calculate natural logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function ln (int128 x) internal pure returns (int128) {\n unchecked {\n require (x > 0);\n\n return int128 (int256 (\n uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));\n }\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2 (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0)\n result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;\n if (x & 0x4000000000000000 > 0)\n result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;\n if (x & 0x2000000000000000 > 0)\n result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;\n if (x & 0x1000000000000000 > 0)\n result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;\n if (x & 0x800000000000000 > 0)\n result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;\n if (x & 0x400000000000000 > 0)\n result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;\n if (x & 0x200000000000000 > 0)\n result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;\n if (x & 0x100000000000000 > 0)\n result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;\n if (x & 0x80000000000000 > 0)\n result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;\n if (x & 0x40000000000000 > 0)\n result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;\n if (x & 0x20000000000000 > 0)\n result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;\n if (x & 0x10000000000000 > 0)\n result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;\n if (x & 0x8000000000000 > 0)\n result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;\n if (x & 0x4000000000000 > 0)\n result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;\n if (x & 0x2000000000000 > 0)\n result = result * 0x1000162E525EE054754457D5995292026 >> 128;\n if (x & 0x1000000000000 > 0)\n result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;\n if (x & 0x800000000000 > 0)\n result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;\n if (x & 0x400000000000 > 0)\n result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;\n if (x & 0x200000000000 > 0)\n result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;\n if (x & 0x100000000000 > 0)\n result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;\n if (x & 0x80000000000 > 0)\n result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;\n if (x & 0x40000000000 > 0)\n result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;\n if (x & 0x20000000000 > 0)\n result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;\n if (x & 0x10000000000 > 0)\n result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;\n if (x & 0x8000000000 > 0)\n result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;\n if (x & 0x4000000000 > 0)\n result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;\n if (x & 0x2000000000 > 0)\n result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;\n if (x & 0x1000000000 > 0)\n result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;\n if (x & 0x800000000 > 0)\n result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;\n if (x & 0x400000000 > 0)\n result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;\n if (x & 0x200000000 > 0)\n result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;\n if (x & 0x100000000 > 0)\n result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;\n if (x & 0x80000000 > 0)\n result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;\n if (x & 0x40000000 > 0)\n result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;\n if (x & 0x20000000 > 0)\n result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;\n if (x & 0x10000000 > 0)\n result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;\n if (x & 0x8000000 > 0)\n result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;\n if (x & 0x4000000 > 0)\n result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;\n if (x & 0x2000000 > 0)\n result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;\n if (x & 0x1000000 > 0)\n result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;\n if (x & 0x800000 > 0)\n result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;\n if (x & 0x400000 > 0)\n result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;\n if (x & 0x200000 > 0)\n result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;\n if (x & 0x100000 > 0)\n result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;\n if (x & 0x80000 > 0)\n result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;\n if (x & 0x40000 > 0)\n result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;\n if (x & 0x20000 > 0)\n result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;\n if (x & 0x10000 > 0)\n result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;\n if (x & 0x8000 > 0)\n result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;\n if (x & 0x4000 > 0)\n result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;\n if (x & 0x2000 > 0)\n result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;\n if (x & 0x1000 > 0)\n result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;\n if (x & 0x800 > 0)\n result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;\n if (x & 0x400 > 0)\n result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;\n if (x & 0x200 > 0)\n result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;\n if (x & 0x100 > 0)\n result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;\n if (x & 0x80 > 0)\n result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;\n if (x & 0x40 > 0)\n result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;\n if (x & 0x20 > 0)\n result = result * 0x100000000000000162E42FEFA39EF366F >> 128;\n if (x & 0x10 > 0)\n result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;\n if (x & 0x8 > 0)\n result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;\n if (x & 0x4 > 0)\n result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;\n if (x & 0x2 > 0)\n result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;\n if (x & 0x1 > 0)\n result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;\n\n result >>= uint256 (int256 (63 - (x >> 64)));\n require (result <= uint256 (int256 (MAX_64x64)));\n\n return int128 (int256 (result));\n }\n }\n\n /**\n * Calculate natural exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp (int128 x) internal pure returns (int128) {\n unchecked {\n require (x < 0x400000000000000000); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n return exp_2 (\n int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));\n }\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu (uint256 x, uint256 y) private pure returns (uint128) {\n unchecked {\n require (y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) { xc >>= 32; msb += 32; }\n if (xc >= 0x10000) { xc >>= 16; msb += 16; }\n if (xc >= 0x100) { xc >>= 8; msb += 8; }\n if (xc >= 0x10) { xc >>= 4; msb += 4; }\n if (xc >= 0x4) { xc >>= 2; msb += 2; }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert (xh == hi >> 128);\n\n result += xl / y;\n }\n\n require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n return uint128 (result);\n }\n }\n\n /**\n * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer\n * number.\n *\n * @param x unsigned 256-bit integer number\n * @return unsigned 128-bit integer number\n */\n function sqrtu (uint256 x) private pure returns (uint128) {\n unchecked {\n if (x == 0) return 0;\n else {\n uint256 xx = x;\n uint256 r = 1;\n if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }\n if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }\n if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }\n if (xx >= 0x10000) { xx >>= 16; r <<= 8; }\n if (xx >= 0x100) { xx >>= 8; r <<= 4; }\n if (xx >= 0x10) { xx >>= 4; r <<= 2; }\n if (xx >= 0x4) { r <<= 1; }\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1;\n r = (r + x / r) >> 1; // Seven iterations should be enough\n uint256 r1 = x / r;\n return uint128 (r < r1 ? r : r1);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless this function is\n * overridden;\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, allowance(owner, spender) + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = allowance(owner, spender);\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IStakingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IStakingToken {\n event Staked(address indexed user, uint256 amount, uint256 term);\n\n event Withdrawn(address indexed user, uint256 amount, uint256 reward);\n\n function stake(uint256 amount, uint256 term) external;\n\n function withdraw() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IRankedMintingToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IRankedMintingToken {\n event RankClaimed(address indexed user, uint256 term, uint256 rank);\n\n event MintClaimed(address indexed user, uint256 rewardAmount);\n\n function claimRank(uint256 term) external;\n\n function claimMintReward() external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnableToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnableToken {\n function burn(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/interfaces/IBurnRedeemable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\ninterface IBurnRedeemable {\n event Redeemed(\n address indexed user,\n address indexed xenContract,\n address indexed tokenContract,\n uint256 xenAmount,\n uint256 tokenAmount\n );\n\n function onTokenBurned(address user, uint256 amount) external;\n}\n"
},
"@faircrypto/xen-crypto/contracts/XENCrypto.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"./Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC165.sol\";\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\nimport \"./interfaces/IStakingToken.sol\";\nimport \"./interfaces/IRankedMintingToken.sol\";\nimport \"./interfaces/IBurnableToken.sol\";\nimport \"./interfaces/IBurnRedeemable.sol\";\n\ncontract XENCrypto is Context, IRankedMintingToken, IStakingToken, IBurnableToken, ERC20(\"XEN Crypto\", \"XEN\") {\n using Math for uint256;\n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n // INTERNAL TYPE TO DESCRIBE A XEN MINT INFO\n struct MintInfo {\n address user;\n uint256 term;\n uint256 maturityTs;\n uint256 rank;\n uint256 amplifier;\n uint256 eaaRate;\n }\n\n // INTERNAL TYPE TO DESCRIBE A XEN STAKE\n struct StakeInfo {\n uint256 term;\n uint256 maturityTs;\n uint256 amount;\n uint256 apy;\n }\n\n // PUBLIC CONSTANTS\n\n uint256 public constant SECONDS_IN_DAY = 3_600 * 24;\n uint256 public constant DAYS_IN_YEAR = 365;\n\n uint256 public constant GENESIS_RANK = 1;\n\n uint256 public constant MIN_TERM = 1 * SECONDS_IN_DAY - 1;\n uint256 public constant MAX_TERM_START = 100 * SECONDS_IN_DAY;\n uint256 public constant MAX_TERM_END = 1_000 * SECONDS_IN_DAY;\n uint256 public constant TERM_AMPLIFIER = 15;\n uint256 public constant TERM_AMPLIFIER_THRESHOLD = 5_000;\n uint256 public constant REWARD_AMPLIFIER_START = 3_000;\n uint256 public constant REWARD_AMPLIFIER_END = 1;\n uint256 public constant EAA_PM_START = 100;\n uint256 public constant EAA_PM_STEP = 1;\n uint256 public constant EAA_RANK_STEP = 100_000;\n uint256 public constant WITHDRAWAL_WINDOW_DAYS = 7;\n uint256 public constant MAX_PENALTY_PCT = 99;\n\n uint256 public constant XEN_MIN_STAKE = 0;\n\n uint256 public constant XEN_MIN_BURN = 0;\n\n uint256 public constant XEN_APY_START = 20;\n uint256 public constant XEN_APY_DAYS_STEP = 90;\n uint256 public constant XEN_APY_END = 2;\n\n string public constant AUTHORS = \"@MrJackLevin @lbelyaev faircrypto.org\";\n\n // PUBLIC STATE, READABLE VIA NAMESAKE GETTERS\n\n uint256 public immutable genesisTs;\n uint256 public globalRank = GENESIS_RANK;\n uint256 public activeMinters;\n uint256 public activeStakes;\n uint256 public totalXenStaked;\n // user address => XEN mint info\n mapping(address => MintInfo) public userMints;\n // user address => XEN stake info\n mapping(address => StakeInfo) public userStakes;\n // user address => XEN burn amount\n mapping(address => uint256) public userBurns;\n\n // CONSTRUCTOR\n constructor() {\n genesisTs = block.timestamp;\n }\n\n // PRIVATE METHODS\n\n /**\n * @dev calculates current MaxTerm based on Global Rank\n * (if Global Rank crosses over TERM_AMPLIFIER_THRESHOLD)\n */\n function _calculateMaxTerm() private view returns (uint256) {\n if (globalRank > TERM_AMPLIFIER_THRESHOLD) {\n uint256 delta = globalRank.fromUInt().log_2().mul(TERM_AMPLIFIER.fromUInt()).toUInt();\n uint256 newMax = MAX_TERM_START + delta * SECONDS_IN_DAY;\n return Math.min(newMax, MAX_TERM_END);\n }\n return MAX_TERM_START;\n }\n\n /**\n * @dev calculates Withdrawal Penalty depending on lateness\n */\n function _penalty(uint256 secsLate) private pure returns (uint256) {\n // =MIN(2^(daysLate+3)/window-1,99)\n uint256 daysLate = secsLate / SECONDS_IN_DAY;\n if (daysLate > WITHDRAWAL_WINDOW_DAYS - 1) return MAX_PENALTY_PCT;\n uint256 penalty = (uint256(1) << (daysLate + 3)) / WITHDRAWAL_WINDOW_DAYS - 1;\n return Math.min(penalty, MAX_PENALTY_PCT);\n }\n\n /**\n * @dev calculates net Mint Reward (adjusted for Penalty)\n */\n function _calculateMintReward(\n uint256 cRank,\n uint256 term,\n uint256 maturityTs,\n uint256 amplifier,\n uint256 eeaRate\n ) private view returns (uint256) {\n uint256 secsLate = block.timestamp - maturityTs;\n uint256 penalty = _penalty(secsLate);\n uint256 rankDelta = Math.max(globalRank - cRank, 2);\n uint256 EAA = (1_000 + eeaRate);\n uint256 reward = getGrossReward(rankDelta, amplifier, term, EAA);\n return (reward * (100 - penalty)) / 100;\n }\n\n /**\n * @dev cleans up User Mint storage (gets some Gas credit;))\n */\n function _cleanUpUserMint() private {\n delete userMints[_msgSender()];\n activeMinters--;\n }\n\n /**\n * @dev calculates XEN Stake Reward\n */\n function _calculateStakeReward(\n uint256 amount,\n uint256 term,\n uint256 maturityTs,\n uint256 apy\n ) private view returns (uint256) {\n if (block.timestamp > maturityTs) {\n uint256 rate = (apy * term * 1_000_000) / DAYS_IN_YEAR;\n return (amount * rate) / 100_000_000;\n }\n return 0;\n }\n\n /**\n * @dev calculates Reward Amplifier\n */\n function _calculateRewardAmplifier() private view returns (uint256) {\n uint256 amplifierDecrease = (block.timestamp - genesisTs) / SECONDS_IN_DAY;\n if (amplifierDecrease < REWARD_AMPLIFIER_START) {\n return Math.max(REWARD_AMPLIFIER_START - amplifierDecrease, REWARD_AMPLIFIER_END);\n } else {\n return REWARD_AMPLIFIER_END;\n }\n }\n\n /**\n * @dev calculates Early Adopter Amplifier Rate (in 1/000ths)\n * actual EAA is (1_000 + EAAR) / 1_000\n */\n function _calculateEAARate() private view returns (uint256) {\n uint256 decrease = (EAA_PM_STEP * globalRank) / EAA_RANK_STEP;\n if (decrease > EAA_PM_START) return 0;\n return EAA_PM_START - decrease;\n }\n\n /**\n * @dev calculates APY (in %)\n */\n function _calculateAPY() private view returns (uint256) {\n uint256 decrease = (block.timestamp - genesisTs) / (SECONDS_IN_DAY * XEN_APY_DAYS_STEP);\n if (XEN_APY_START - XEN_APY_END < decrease) return XEN_APY_END;\n return XEN_APY_START - decrease;\n }\n\n /**\n * @dev creates User Stake\n */\n function _createStake(uint256 amount, uint256 term) private {\n userStakes[_msgSender()] = StakeInfo({\n term: term,\n maturityTs: block.timestamp + term * SECONDS_IN_DAY,\n amount: amount,\n apy: _calculateAPY()\n });\n activeStakes++;\n totalXenStaked += amount;\n }\n\n // PUBLIC CONVENIENCE GETTERS\n\n /**\n * @dev calculates gross Mint Reward\n */\n function getGrossReward(\n uint256 rankDelta,\n uint256 amplifier,\n uint256 term,\n uint256 eaa\n ) public pure returns (uint256) {\n int128 log128 = rankDelta.fromUInt().log_2();\n int128 reward128 = log128.mul(amplifier.fromUInt()).mul(term.fromUInt()).mul(eaa.fromUInt());\n return reward128.div(uint256(1_000).fromUInt()).toUInt();\n }\n\n /**\n * @dev returns User Mint object associated with User account address\n */\n function getUserMint() external view returns (MintInfo memory) {\n return userMints[_msgSender()];\n }\n\n /**\n * @dev returns XEN Stake object associated with User account address\n */\n function getUserStake() external view returns (StakeInfo memory) {\n return userStakes[_msgSender()];\n }\n\n /**\n * @dev returns current AMP\n */\n function getCurrentAMP() external view returns (uint256) {\n return _calculateRewardAmplifier();\n }\n\n /**\n * @dev returns current EAA Rate\n */\n function getCurrentEAAR() external view returns (uint256) {\n return _calculateEAARate();\n }\n\n /**\n * @dev returns current APY\n */\n function getCurrentAPY() external view returns (uint256) {\n return _calculateAPY();\n }\n\n /**\n * @dev returns current MaxTerm\n */\n function getCurrentMaxTerm() external view returns (uint256) {\n return _calculateMaxTerm();\n }\n\n // PUBLIC STATE-CHANGING METHODS\n\n /**\n * @dev accepts User cRank claim provided all checks pass (incl. no current claim exists)\n */\n function claimRank(uint256 term) external {\n uint256 termSec = term * SECONDS_IN_DAY;\n require(termSec > MIN_TERM, \"CRank: Term less than min\");\n require(termSec < _calculateMaxTerm() + 1, \"CRank: Term more than current max term\");\n require(userMints[_msgSender()].rank == 0, \"CRank: Mint already in progress\");\n\n // create and store new MintInfo\n MintInfo memory mintInfo = MintInfo({\n user: _msgSender(),\n term: term,\n maturityTs: block.timestamp + termSec,\n rank: globalRank,\n amplifier: _calculateRewardAmplifier(),\n eaaRate: _calculateEAARate()\n });\n userMints[_msgSender()] = mintInfo;\n activeMinters++;\n emit RankClaimed(_msgSender(), term, globalRank++);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal Time Window), gets minted XEN\n */\n function claimMintReward() external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward and mint tokens\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n _mint(_msgSender(), rewardAmount);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and splits them between User and designated other address\n */\n function claimMintRewardAndShare(address other, uint256 pct) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n require(other != address(0), \"CRank: Cannot share with zero address\");\n require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share 100+ percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 sharedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - sharedReward;\n\n // mint reward tokens\n _mint(_msgSender(), ownReward);\n _mint(other, sharedReward);\n\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n }\n\n /**\n * @dev ends minting upon maturity (and within permitted Withdrawal time Window)\n * mints XEN coins and stakes 'pct' of it for 'term'\n */\n function claimMintRewardAndStake(uint256 pct, uint256 term) external {\n MintInfo memory mintInfo = userMints[_msgSender()];\n // require(pct > 0, \"CRank: Cannot share zero percent\");\n require(pct < 101, \"CRank: Cannot share >100 percent\");\n require(mintInfo.rank > 0, \"CRank: No mint exists\");\n require(block.timestamp > mintInfo.maturityTs, \"CRank: Mint maturity not reached\");\n\n // calculate reward\n uint256 rewardAmount = _calculateMintReward(\n mintInfo.rank,\n mintInfo.term,\n mintInfo.maturityTs,\n mintInfo.amplifier,\n mintInfo.eaaRate\n ) * 1 ether;\n uint256 stakedReward = (rewardAmount * pct) / 100;\n uint256 ownReward = rewardAmount - stakedReward;\n\n // mint reward tokens part\n _mint(_msgSender(), ownReward);\n _cleanUpUserMint();\n emit MintClaimed(_msgSender(), rewardAmount);\n\n // nothing to burn since we haven't minted this part yet\n // stake extra tokens part\n require(stakedReward > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n _createStake(stakedReward, term);\n emit Staked(_msgSender(), stakedReward, term);\n }\n\n /**\n * @dev initiates XEN Stake in amount for a term (days)\n */\n function stake(uint256 amount, uint256 term) external {\n require(balanceOf(_msgSender()) >= amount, \"XEN: not enough balance\");\n require(amount > XEN_MIN_STAKE, \"XEN: Below min stake\");\n require(term * SECONDS_IN_DAY > MIN_TERM, \"XEN: Below min stake term\");\n require(term * SECONDS_IN_DAY < MAX_TERM_END + 1, \"XEN: Above max stake term\");\n require(userStakes[_msgSender()].amount == 0, \"XEN: stake exists\");\n\n // burn staked XEN\n _burn(_msgSender(), amount);\n // create XEN Stake\n _createStake(amount, term);\n emit Staked(_msgSender(), amount, term);\n }\n\n /**\n * @dev ends XEN Stake and gets reward if the Stake is mature\n */\n function withdraw() external {\n StakeInfo memory userStake = userStakes[_msgSender()];\n require(userStake.amount > 0, \"XEN: no stake exists\");\n\n uint256 xenReward = _calculateStakeReward(\n userStake.amount,\n userStake.term,\n userStake.maturityTs,\n userStake.apy\n );\n activeStakes--;\n totalXenStaked -= userStake.amount;\n\n // mint staked XEN (+ reward)\n _mint(_msgSender(), userStake.amount + xenReward);\n emit Withdrawn(_msgSender(), userStake.amount, xenReward);\n delete userStakes[_msgSender()];\n }\n\n /**\n * @dev burns XEN tokens and creates Proof-Of-Burn record to be used by connected DeFi services\n */\n function burn(address user, uint256 amount) public {\n require(amount > XEN_MIN_BURN, \"Burn: Below min limit\");\n require(\n IERC165(_msgSender()).supportsInterface(type(IBurnRedeemable).interfaceId),\n \"Burn: not a supported contract\"\n );\n\n _spendAllowance(user, _msgSender(), amount);\n _burn(user, amount);\n userBurns[user] += amount;\n IBurnRedeemable(_msgSender()).onTokenBurned(user, amount);\n }\n}\n"
},
"@faircrypto/xen-crypto/contracts/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\n\nimport \"abdk-libraries-solidity/ABDKMath64x64.sol\";\n\nlibrary Math {\n\n function min(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return b;\n return a;\n }\n\n function max(uint256 a, uint256 b) external pure returns (uint256) {\n if (a > b) return a;\n return b;\n }\n\n function logX64(uint256 x) external pure returns (int128) {\n return ABDKMath64x64.log_2(ABDKMath64x64.fromUInt(x));\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"libraries": {
"/contracts/libs/MintInfo.sol": {
"MintInfo": "0xC739d01beb34E380461BBa9ef8ed1a44874382Be"
},
"/contracts/libs/Metadata.sol": {
"Metadata": "0x1Ac17FFB8456525BfF46870bba7Ed8772ba063a5"
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,500,371 |
8df901ec5b7ff342b74fca0f5270b4f4ff71ad4e7a25c2a0218594b1c035171f
|
e4adfc19360c9925187b79d8b530615dc42dec50ea7e42bb974cc8e456b3bff6
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
5033420d0d66e6838ca379e79d6eaa3de47d9c92
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,373 |
6d6cdfe95bb1d423d52900f76df057045b050d45cbb250091c9c2d0f2f08c098
|
c18731f5b64fc9d6d9f79e91299cd82b38a939ef9c22b97206e2381a6b909b2c
|
6490fb8ce78ceac7b4e5a3f34211da80a97f93fa
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
8446101ab92d6f1493329906d32a9bc17157c961
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,376 |
18d7c22aeeb54c44d34774795909d306889f776f3d1a0607de1f80122d236c8d
|
0f8792752c29d35f6924e40387f6a68181e18982bb99ea820c0d202d5e6d50e4
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
6c55b258005a3d3ebe56f4c7e34c64703677994c
|
6080604052348015600f57600080fd5b506040516101bb3803806101bb833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b610125806100966000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c6343000819003300000000000000000000000033c99c0323adc0b7bd4ddd2ac4d4de2c28722fb0
|
6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c63430008190033
| |
1 | 19,500,376 |
18d7c22aeeb54c44d34774795909d306889f776f3d1a0607de1f80122d236c8d
|
9b809ddd6c7d99bea8ef2f18defe716cd995429f213f70d3e0d42006e1de3c18
|
00bdb5699745f5b860228c8f939abf1b9ae374ed
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
cad3ce247a0741d21ac9e41fdea29b12514d2bfb
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,500,376 |
18d7c22aeeb54c44d34774795909d306889f776f3d1a0607de1f80122d236c8d
|
0639651a68972e98f37f0eec578fd3c69f17383d33d1f6dc385bf534ea002716
|
a98f1ba188e5254f31bfb8ebedf489f0ffca9808
|
a98f1ba188e5254f31bfb8ebedf489f0ffca9808
|
bb4eae74a0b773627450135f739ec2f462d1e479
|
608060405266b1a2bc2ec500006001556002805460ff191690557f8a727dc41d83211e47d3c0de4841eccc43c66f41cb809e606947602a76be42606005557f792dd068f703509b864c7fcd0305b6964ca0c86466f49ef07bd15677d1a877cf6006557f792dd068f703509b864c7fcd53d9e63ae08ca4f1e2f6792b4787a0aef4429cdc60075534801561009157600080fd5b50600080546001600160a01b031916331790556102e5806100b36000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b50610085610080366004610271565b600455565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b7366004610271565b600355565b3480156100c857600080fd5b506100856002805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600154600080549091829161019791906001600160a01b03163161028a565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356006546007541890565b6040519091506001600160a01b038216904780156108fc02916000818181858888f1935050505015801561026d573d6000803e3d6000fd5b5050565b60006020828403121561028357600080fd5b5035919050565b6000828210156102aa57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212202c001eecc994987a54910e6d97b5a02b8c72b9740f81a77a32eecfeb8b29844364736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b50610085610080366004610271565b600455565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b7366004610271565b600355565b3480156100c857600080fd5b506100856002805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600154600080549091829161019791906001600160a01b03163161028a565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356006546007541890565b6040519091506001600160a01b038216904780156108fc02916000818181858888f1935050505015801561026d573d6000803e3d6000fd5b5050565b60006020828403121561028357600080fd5b5035919050565b6000828210156102aa57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212202c001eecc994987a54910e6d97b5a02b8c72b9740f81a77a32eecfeb8b29844364736f6c63430008070033
| |
1 | 19,500,378 |
be22f0941fe394aa975cbc224e9c27496db088d3a381be8fdf94f775a021354c
|
890bcb54eacdf3615298676f3fc9d40729934ed133cab37407f7460faf8577ed
|
02d23e36ed19902504d6f44548ade8ccf180063e
|
02d23e36ed19902504d6f44548ade8ccf180063e
|
6a071c74f308a4fbd62facf695c9ecbddd013808
|
60806040526040518060400160405280600781526020017f6e69676765727300000000000000000000000000000000000000000000000000815250600a90816200004a919062000942565b5034801562000057575f80fd5b506040518060400160405280600881526020017f574f4d50574f4d500000000000000000000000000000000000000000000000008152506040518060400160405280600881526020017f574f4d50574f4d500000000000000000000000000000000000000000000000008152508160019081620000d5919062000942565b508060039081620000e7919062000942565b503360025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050506200013d3360016200014360201b60201c565b62000dba565b62000164828260405180602001604052805f8152506200016860201b60201c565b5050565b6200017d83838360016200018260201b60201c565b505050565b5f805490505f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603620001f8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001ef9062000aaa565b60405180910390fd5b5f84036200023d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002349062000b3e565b60405180910390fd5b620002515f8683876200050a60201b60201c565b8360055f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f8282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360055f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f0160108282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508460045f8381526020019081526020015f205f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504260045f8381526020019081526020015f205f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505f8190505f5b85811015620004e757818773ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a48315620004d1576200048e5f8884886200051060201b60201c565b620004d0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620004c79062000bd2565b60405180910390fd5b5b818060010192505080806001019150506200040f565b50805f8190555050620005035f868387620006af60201b60201c565b5050505050565b50505050565b5f620005388473ffffffffffffffffffffffffffffffffffffffff16620006b560201b60201c565b15620006a2578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026200056a620006d760201b60201c565b8786866040518563ffffffff1660e01b81526004016200058e949392919062000cda565b6020604051808303815f875af1925050508015620005cc57506040513d601f19601f82011682018060405250810190620005c9919062000d8a565b60015b62000651573d805f8114620005fd576040519150601f19603f3d011682016040523d82523d5f602084013e62000602565b606091505b505f81510362000649576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620006409062000bd2565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050620006a7565b600190505b949350505050565b50505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b5f33905090565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200075a57607f821691505b60208210810362000770576200076f62000715565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620007d47fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000797565b620007e0868362000797565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f6200082a620008246200081e84620007f8565b62000801565b620007f8565b9050919050565b5f819050919050565b62000845836200080a565b6200085d620008548262000831565b848454620007a3565b825550505050565b5f90565b6200087362000865565b620008808184846200083a565b505050565b5b81811015620008a7576200089b5f8262000869565b60018101905062000886565b5050565b601f821115620008f657620008c08162000776565b620008cb8462000788565b81016020851015620008db578190505b620008f3620008ea8562000788565b83018262000885565b50505b505050565b5f82821c905092915050565b5f620009185f1984600802620008fb565b1980831691505092915050565b5f62000932838362000907565b9150826002028217905092915050565b6200094d82620006de565b67ffffffffffffffff811115620009695762000968620006e8565b5b62000975825462000742565b62000982828285620008ab565b5f60209050601f831160018114620009b8575f8415620009a3578287015190505b620009af858262000925565b86555062000a1e565b601f198416620009c88662000776565b5f5b82811015620009f157848901518255600182019150602085019450602081019050620009ca565b8683101562000a11578489015162000a0d601f89168262000907565b8355505b6001600288020188555050505b505050505050565b5f82825260208201905092915050565b7f455243373231413a206d696e7420746f20746865207a65726f206164647265735f8201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b5f62000a9260218362000a26565b915062000a9f8262000a36565b604082019050919050565b5f6020820190508181035f83015262000ac38162000a84565b9050919050565b7f455243373231413a207175616e74697479206d757374206265206772656174655f8201527f72207468616e2030000000000000000000000000000000000000000000000000602082015250565b5f62000b2660288362000a26565b915062000b338262000aca565b604082019050919050565b5f6020820190508181035f83015262000b578162000b18565b9050919050565b7f455243373231413a207472616e7366657220746f206e6f6e20455243373231525f8201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b5f62000bba60338362000a26565b915062000bc78262000b5e565b604082019050919050565b5f6020820190508181035f83015262000beb8162000bac565b9050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f62000c1d8262000bf2565b9050919050565b62000c2f8162000c11565b82525050565b62000c4081620007f8565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b8381101562000c7f57808201518184015260208101905062000c62565b5f8484015250505050565b5f601f19601f8301169050919050565b5f62000ca68262000c46565b62000cb2818562000c50565b935062000cc481856020860162000c60565b62000ccf8162000c8a565b840191505092915050565b5f60808201905062000cef5f83018762000c24565b62000cfe602083018662000c24565b62000d0d604083018562000c35565b818103606083015262000d21818462000c9a565b905095945050505050565b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b62000d668162000d30565b811462000d71575f80fd5b50565b5f8151905062000d848162000d5b565b92915050565b5f6020828403121562000da25762000da162000d2c565b5b5f62000db18482850162000d74565b91505092915050565b6135008062000dc85f395ff3fe608060405234801561000f575f80fd5b506004361061011f575f3560e01c80636352211e116100ab578063a22cb4651161006f578063a22cb4651461032b578063b88d4fde14610347578063c87b56dd14610363578063dc33e68114610393578063e985e9c5146103c35761011f565b80636352211e146102735780636c0360eb146102a357806370a08231146102c15780637f6bac7d146102f157806395d89b411461030d5761011f565b806318160ddd116100f257806318160ddd146101bd57806323b872dd146101db5780632f745c59146101f757806342842e0e146102275780634f6ccce7146102435761011f565b806301ffc9a71461012357806306fdde0314610153578063081812fc14610171578063095ea7b3146101a1575b5f80fd5b61013d60048036038101906101389190611ea8565b6103f3565b60405161014a9190611eed565b60405180910390f35b61015b61053c565b6040516101689190611f90565b60405180910390f35b61018b60048036038101906101869190611fe3565b6105cc565b604051610198919061204d565b60405180910390f35b6101bb60048036038101906101b69190612090565b61064d565b005b6101c5610764565b6040516101d291906120dd565b60405180910390f35b6101f560048036038101906101f091906120f6565b61076c565b005b610211600480360381019061020c9190612090565b61077c565b60405161021e91906120dd565b60405180910390f35b610241600480360381019061023c91906120f6565b61095f565b005b61025d60048036038101906102589190611fe3565b61097e565b60405161026a91906120dd565b60405180910390f35b61028d60048036038101906102889190611fe3565b6109d0565b60405161029a919061204d565b60405180910390f35b6102ab6109e4565b6040516102b89190611f90565b60405180910390f35b6102db60048036038101906102d69190612146565b610a70565b6040516102e891906120dd565b60405180910390f35b61030b6004803603810190610306919061243f565b610b53565b005b610315610bdd565b6040516103229190611f90565b60405180910390f35b610345600480360381019061034091906124df565b610c6d565b005b610361600480360381019061035c919061251d565b610de8565b005b61037d60048036038101906103789190611fe3565b610f1d565b60405161038a9190611f90565b60405180910390f35b6103ad60048036038101906103a89190612146565b610fc1565b6040516103ba91906120dd565b60405180910390f35b6103dd60048036038101906103d8919061259d565b610fd2565b6040516103ea9190611eed565b60405180910390f35b5f7f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104bd57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061052557507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610535575061053482611060565b5b9050919050565b60606001805461054b90612608565b80601f016020809104026020016040519081016040528092919081815260200182805461057790612608565b80156105c25780601f10610599576101008083540402835291602001916105c2565b820191905f5260205f20905b8154815290600101906020018083116105a557829003601f168201915b5050505050905090565b5f6105d6826110c9565b610615576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060c906126a8565b60405180910390fd5b60065f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f610657826109d0565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106be90612736565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166106e66110d5565b73ffffffffffffffffffffffffffffffffffffffff16148061071557506107148161070f6110d5565b610fd2565b5b610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074b906127c4565b60405180910390fd5b61075f8383836110dc565b505050565b5f8054905090565b61077783838361118b565b505050565b5f61078683610a70565b82106107c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107be90612852565b60405180910390fd5b5f6107d0610764565b90505f805f5b8381101561091d575f60045f8381526020019081526020015f206040518060400160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020015f820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff168152505090505f73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff16146108bf57805f015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361090f57868403610906578195505050505050610959565b83806001019450505b5080806001019150506107d6565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610950906128e0565b60405180910390fd5b92915050565b61097983838360405180602001604052805f815250610de8565b505050565b5f610987610764565b82106109c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bf9061296e565b60405180910390fd5b819050919050565b5f6109da826116a4565b5f01519050919050565b600a80546109f190612608565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1d90612608565b8015610a685780601f10610a3f57610100808354040283529160200191610a68565b820191905f5260205f20905b815481529060010190602001808311610a4b57829003601f168201915b505050505081565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610adf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad6906129fc565b60405180910390fd5b60055f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f9054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bab575f80fd5b8160089080519060200190610bc1929190611cb1565b508060099080519060200190610bd8929190611d38565b505050565b606060038054610bec90612608565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1890612608565b8015610c635780601f10610c3a57610100808354040283529160200191610c63565b820191905f5260205f20905b815481529060010190602001808311610c4657829003601f168201915b5050505050905090565b610c756110d5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ce2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd990612a64565b60405180910390fd5b8060075f610cee6110d5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610d976110d5565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610ddc9190611eed565b60405180910390a35050565b610df384848461118b565b5f5b600880549050811015610ecb5760088181548110610e1657610e15612a82565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660098281548110610e6857610e67612a82565b5b905f5260205f2001604051610e7d9190612b4b565b5f604051808303815f865af19150503d805f8114610eb6576040519150601f19603f3d011682016040523d82523d5f602084013e610ebb565b606091505b5050508080600101915050610df5565b50610ed884848484611834565b610f17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0e90612bd1565b60405180910390fd5b50505050565b6060610f28826110c9565b610f67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5e90612c5f565b60405180910390fd5b5f610f706119b6565b90505f815103610f8e5760405180602001604052805f815250610fb9565b80610f9884611a46565b604051602001610fa9929190612cb7565b6040516020818303038152906040525b915050919050565b5f610fcb82611b9f565b9050919050565b5f60075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f805482109050919050565b5f33905090565b8260065f8481526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b5f611195826116a4565b90505f815f015173ffffffffffffffffffffffffffffffffffffffff166111ba6110d5565b73ffffffffffffffffffffffffffffffffffffffff16148061121657506111df6110d5565b73ffffffffffffffffffffffffffffffffffffffff166111fe846105cc565b73ffffffffffffffffffffffffffffffffffffffff16145b806112315750611230825f015161122b6110d5565b610fd2565b5b905080611273576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126a90612d4a565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16825f015173ffffffffffffffffffffffffffffffffffffffff16146112e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112db90612dd8565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611352576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134990612e66565b60405180910390fd5b61135f8585856001611c83565b61136d5f84845f01516110dc565b600160055f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f8282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550600160055f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f8282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360045f8581526020019081526020015f205f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504260045f8581526020019081526020015f205f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505f6001840190505f73ffffffffffffffffffffffffffffffffffffffff1660045f8381526020019081526020015f205f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036116345761159b816110c9565b1561163357825f015160045f8381526020019081526020015f205f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550826020015160045f8381526020019081526020015f205f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461169d8585856001611c89565b5050505050565b6116ac611d8f565b6116b5826110c9565b6116f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116eb90612ef4565b60405180910390fd5b5f8290505b5f81106117f3575f60045f8381526020019081526020015f206040518060400160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020015f820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff168152505090505f73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff16146117e457809250505061182f565b508080600190039150506116f9565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182690612f82565b60405180910390fd5b919050565b5f6118548473ffffffffffffffffffffffffffffffffffffffff16611c8f565b156119a9578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261187d6110d5565b8786866040518563ffffffff1660e01b815260040161189f9493929190612ff2565b6020604051808303815f875af19250505080156118da57506040513d601f19601f820116820180604052508101906118d79190613050565b60015b611959573d805f8114611908576040519150601f19603f3d011682016040523d82523d5f602084013e61190d565b606091505b505f815103611951576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194890612bd1565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506119ae565b600190505b949350505050565b6060600a80546119c590612608565b80601f01602080910402602001604051908101604052809291908181526020018280546119f190612608565b8015611a3c5780601f10611a1357610100808354040283529160200191611a3c565b820191905f5260205f20905b815481529060010190602001808311611a1f57829003601f168201915b5050505050905090565b60605f8203611a8c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611b9a565b5f8290505f5b5f8214611abb578080611aa4906130a8565b915050600a82611ab4919061311c565b9150611a92565b5f8167ffffffffffffffff811115611ad657611ad5612175565b5b6040519080825280601f01601f191660200182016040528015611b085781602001600182028036833780820191505090505b5090505b5f8514611b9357600182611b20919061314c565b9150600a85611b2f919061317f565b6030611b3b91906131af565b60f81b818381518110611b5157611b50612a82565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600a85611b8c919061311c565b9450611b0c565b8093505050505b919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0590613252565b60405180910390fd5b60055f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f0160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b50505050565b50505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b828054828255905f5260205f20908101928215611d27579160200282015b82811115611d26578251825f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190611ccf565b5b509050611d349190611dc7565b5090565b828054828255905f5260205f20908101928215611d7e579160200282015b82811115611d7d578251829081611d6d91906133fb565b5091602001919060010190611d56565b5b509050611d8b9190611de2565b5090565b60405180604001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f67ffffffffffffffff1681525090565b5b80821115611dde575f815f905550600101611dc8565b5090565b5b80821115611e01575f8181611df89190611e05565b50600101611de3565b5090565b508054611e1190612608565b5f825580601f10611e225750611e3f565b601f0160209004905f5260205f2090810190611e3e9190611dc7565b5b50565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611e8781611e53565b8114611e91575f80fd5b50565b5f81359050611ea281611e7e565b92915050565b5f60208284031215611ebd57611ebc611e4b565b5b5f611eca84828501611e94565b91505092915050565b5f8115159050919050565b611ee781611ed3565b82525050565b5f602082019050611f005f830184611ede565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015611f3d578082015181840152602081019050611f22565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611f6282611f06565b611f6c8185611f10565b9350611f7c818560208601611f20565b611f8581611f48565b840191505092915050565b5f6020820190508181035f830152611fa88184611f58565b905092915050565b5f819050919050565b611fc281611fb0565b8114611fcc575f80fd5b50565b5f81359050611fdd81611fb9565b92915050565b5f60208284031215611ff857611ff7611e4b565b5b5f61200584828501611fcf565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6120378261200e565b9050919050565b6120478161202d565b82525050565b5f6020820190506120605f83018461203e565b92915050565b61206f8161202d565b8114612079575f80fd5b50565b5f8135905061208a81612066565b92915050565b5f80604083850312156120a6576120a5611e4b565b5b5f6120b38582860161207c565b92505060206120c485828601611fcf565b9150509250929050565b6120d781611fb0565b82525050565b5f6020820190506120f05f8301846120ce565b92915050565b5f805f6060848603121561210d5761210c611e4b565b5b5f61211a8682870161207c565b935050602061212b8682870161207c565b925050604061213c86828701611fcf565b9150509250925092565b5f6020828403121561215b5761215a611e4b565b5b5f6121688482850161207c565b91505092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6121ab82611f48565b810181811067ffffffffffffffff821117156121ca576121c9612175565b5b80604052505050565b5f6121dc611e42565b90506121e882826121a2565b919050565b5f67ffffffffffffffff82111561220757612206612175565b5b602082029050602081019050919050565b5f80fd5b5f61222e612229846121ed565b6121d3565b9050808382526020820190506020840283018581111561225157612250612218565b5b835b8181101561227a5780612266888261207c565b845260208401935050602081019050612253565b5050509392505050565b5f82601f83011261229857612297612171565b5b81356122a884826020860161221c565b91505092915050565b5f67ffffffffffffffff8211156122cb576122ca612175565b5b602082029050602081019050919050565b5f80fd5b5f67ffffffffffffffff8211156122fa576122f9612175565b5b61230382611f48565b9050602081019050919050565b828183375f83830152505050565b5f61233061232b846122e0565b6121d3565b90508281526020810184848401111561234c5761234b6122dc565b5b612357848285612310565b509392505050565b5f82601f83011261237357612372612171565b5b813561238384826020860161231e565b91505092915050565b5f61239e612399846122b1565b6121d3565b905080838252602082019050602084028301858111156123c1576123c0612218565b5b835b8181101561240857803567ffffffffffffffff8111156123e6576123e5612171565b5b8086016123f3898261235f565b855260208501945050506020810190506123c3565b5050509392505050565b5f82601f83011261242657612425612171565b5b813561243684826020860161238c565b91505092915050565b5f806040838503121561245557612454611e4b565b5b5f83013567ffffffffffffffff81111561247257612471611e4f565b5b61247e85828601612284565b925050602083013567ffffffffffffffff81111561249f5761249e611e4f565b5b6124ab85828601612412565b9150509250929050565b6124be81611ed3565b81146124c8575f80fd5b50565b5f813590506124d9816124b5565b92915050565b5f80604083850312156124f5576124f4611e4b565b5b5f6125028582860161207c565b9250506020612513858286016124cb565b9150509250929050565b5f805f806080858703121561253557612534611e4b565b5b5f6125428782880161207c565b94505060206125538782880161207c565b935050604061256487828801611fcf565b925050606085013567ffffffffffffffff81111561258557612584611e4f565b5b6125918782880161235f565b91505092959194509250565b5f80604083850312156125b3576125b2611e4b565b5b5f6125c08582860161207c565b92505060206125d18582860161207c565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061261f57607f821691505b602082108103612632576126316125db565b5b50919050565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e655f8201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b5f612692602d83611f10565b915061269d82612638565b604082019050919050565b5f6020820190508181035f8301526126bf81612686565b9050919050565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e5f8201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b5f612720602283611f10565b915061272b826126c6565b604082019050919050565b5f6020820190508181035f83015261274d81612714565b9050919050565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f5f8201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b5f6127ae603983611f10565b91506127b982612754565b604082019050919050565b5f6020820190508181035f8301526127db816127a2565b9050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e5f8201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b5f61283c602283611f10565b9150612847826127e2565b604082019050919050565b5f6020820190508181035f83015261286981612830565b9050919050565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f66205f8201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b5f6128ca602e83611f10565b91506128d582612870565b604082019050919050565b5f6020820190508181035f8301526128f7816128be565b9050919050565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f755f8201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b5f612958602383611f10565b9150612963826128fe565b604082019050919050565b5f6020820190508181035f8301526129858161294c565b9050919050565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a5f8201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b5f6129e6602b83611f10565b91506129f18261298c565b604082019050919050565b5f6020820190508181035f830152612a13816129da565b9050919050565b7f455243373231413a20617070726f766520746f2063616c6c65720000000000005f82015250565b5f612a4e601a83611f10565b9150612a5982612a1a565b602082019050919050565b5f6020820190508181035f830152612a7b81612a42565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81905092915050565b5f819050815f5260205f209050919050565b5f8154612ad781612608565b612ae18186612aaf565b9450600182165f8114612afb5760018114612b1057612b42565b60ff1983168652811515820286019350612b42565b612b1985612ab9565b5f5b83811015612b3a57815481890152600182019150602081019050612b1b565b838801955050505b50505092915050565b5f612b568284612acb565b915081905092915050565b7f455243373231413a207472616e7366657220746f206e6f6e20455243373231525f8201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b5f612bbb603383611f10565b9150612bc682612b61565b604082019050919050565b5f6020820190508181035f830152612be881612baf565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f5f8201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b5f612c49602f83611f10565b9150612c5482612bef565b604082019050919050565b5f6020820190508181035f830152612c7681612c3d565b9050919050565b5f81905092915050565b5f612c9182611f06565b612c9b8185612c7d565b9350612cab818560208601611f20565b80840191505092915050565b5f612cc28285612c87565b9150612cce8284612c87565b91508190509392505050565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f74205f8201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b5f612d34603283611f10565b9150612d3f82612cda565b604082019050919050565b5f6020820190508181035f830152612d6181612d28565b9050919050565b7f455243373231413a207472616e736665722066726f6d20696e636f72726563745f8201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b5f612dc2602683611f10565b9150612dcd82612d68565b604082019050919050565b5f6020820190508181035f830152612def81612db6565b9050919050565b7f455243373231413a207472616e7366657220746f20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f612e50602583611f10565b9150612e5b82612df6565b604082019050919050565b5f6020820190508181035f830152612e7d81612e44565b9050919050565b7f455243373231413a206f776e657220717565727920666f72206e6f6e657869735f8201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b5f612ede602a83611f10565b9150612ee982612e84565b604082019050919050565b5f6020820190508181035f830152612f0b81612ed2565b9050919050565b7f455243373231413a20756e61626c6520746f2064657465726d696e65207468655f8201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b5f612f6c602f83611f10565b9150612f7782612f12565b604082019050919050565b5f6020820190508181035f830152612f9981612f60565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b5f612fc482612fa0565b612fce8185612faa565b9350612fde818560208601611f20565b612fe781611f48565b840191505092915050565b5f6080820190506130055f83018761203e565b613012602083018661203e565b61301f60408301856120ce565b81810360608301526130318184612fba565b905095945050505050565b5f8151905061304a81611e7e565b92915050565b5f6020828403121561306557613064611e4b565b5b5f6130728482850161303c565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6130b282611fb0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036130e4576130e361307b565b5b600182019050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f61312682611fb0565b915061313183611fb0565b925082613141576131406130ef565b5b828204905092915050565b5f61315682611fb0565b915061316183611fb0565b92508282039050818111156131795761317861307b565b5b92915050565b5f61318982611fb0565b915061319483611fb0565b9250826131a4576131a36130ef565b5b828206905092915050565b5f6131b982611fb0565b91506131c483611fb0565b92508282019050808211156131dc576131db61307b565b5b92915050565b7f455243373231413a206e756d626572206d696e74656420717565727920666f725f8201527f20746865207a65726f2061646472657373000000000000000000000000000000602082015250565b5f61323c603183611f10565b9150613247826131e2565b604082019050919050565b5f6020820190508181035f83015261326981613230565b9050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026132ba7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261327f565b6132c4868361327f565b95508019841693508086168417925050509392505050565b5f819050919050565b5f6132ff6132fa6132f584611fb0565b6132dc565b611fb0565b9050919050565b5f819050919050565b613318836132e5565b61332c61332482613306565b84845461328b565b825550505050565b5f90565b613340613334565b61334b81848461330f565b505050565b5b8181101561336e576133635f82613338565b600181019050613351565b5050565b601f8211156133b35761338481612ab9565b61338d84613270565b8101602085101561339c578190505b6133b06133a885613270565b830182613350565b50505b505050565b5f82821c905092915050565b5f6133d35f19846008026133b8565b1980831691505092915050565b5f6133eb83836133c4565b9150826002028217905092915050565b61340482612fa0565b67ffffffffffffffff81111561341d5761341c612175565b5b6134278254612608565b613432828285613372565b5f60209050601f831160018114613463575f8415613451578287015190505b61345b85826133e0565b8655506134c2565b601f19841661347186612ab9565b5f5b8281101561349857848901518255600182019150602085019450602081019050613473565b868310156134b557848901516134b1601f8916826133c4565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220196d27a048b0cdb70dcff3fc7f8706816198917a5e810ec81909d0ba5098e66764736f6c63430008180033
|
608060405234801561000f575f80fd5b506004361061011f575f3560e01c80636352211e116100ab578063a22cb4651161006f578063a22cb4651461032b578063b88d4fde14610347578063c87b56dd14610363578063dc33e68114610393578063e985e9c5146103c35761011f565b80636352211e146102735780636c0360eb146102a357806370a08231146102c15780637f6bac7d146102f157806395d89b411461030d5761011f565b806318160ddd116100f257806318160ddd146101bd57806323b872dd146101db5780632f745c59146101f757806342842e0e146102275780634f6ccce7146102435761011f565b806301ffc9a71461012357806306fdde0314610153578063081812fc14610171578063095ea7b3146101a1575b5f80fd5b61013d60048036038101906101389190611ea8565b6103f3565b60405161014a9190611eed565b60405180910390f35b61015b61053c565b6040516101689190611f90565b60405180910390f35b61018b60048036038101906101869190611fe3565b6105cc565b604051610198919061204d565b60405180910390f35b6101bb60048036038101906101b69190612090565b61064d565b005b6101c5610764565b6040516101d291906120dd565b60405180910390f35b6101f560048036038101906101f091906120f6565b61076c565b005b610211600480360381019061020c9190612090565b61077c565b60405161021e91906120dd565b60405180910390f35b610241600480360381019061023c91906120f6565b61095f565b005b61025d60048036038101906102589190611fe3565b61097e565b60405161026a91906120dd565b60405180910390f35b61028d60048036038101906102889190611fe3565b6109d0565b60405161029a919061204d565b60405180910390f35b6102ab6109e4565b6040516102b89190611f90565b60405180910390f35b6102db60048036038101906102d69190612146565b610a70565b6040516102e891906120dd565b60405180910390f35b61030b6004803603810190610306919061243f565b610b53565b005b610315610bdd565b6040516103229190611f90565b60405180910390f35b610345600480360381019061034091906124df565b610c6d565b005b610361600480360381019061035c919061251d565b610de8565b005b61037d60048036038101906103789190611fe3565b610f1d565b60405161038a9190611f90565b60405180910390f35b6103ad60048036038101906103a89190612146565b610fc1565b6040516103ba91906120dd565b60405180910390f35b6103dd60048036038101906103d8919061259d565b610fd2565b6040516103ea9190611eed565b60405180910390f35b5f7f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104bd57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061052557507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610535575061053482611060565b5b9050919050565b60606001805461054b90612608565b80601f016020809104026020016040519081016040528092919081815260200182805461057790612608565b80156105c25780601f10610599576101008083540402835291602001916105c2565b820191905f5260205f20905b8154815290600101906020018083116105a557829003601f168201915b5050505050905090565b5f6105d6826110c9565b610615576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060c906126a8565b60405180910390fd5b60065f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f610657826109d0565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106be90612736565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166106e66110d5565b73ffffffffffffffffffffffffffffffffffffffff16148061071557506107148161070f6110d5565b610fd2565b5b610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074b906127c4565b60405180910390fd5b61075f8383836110dc565b505050565b5f8054905090565b61077783838361118b565b505050565b5f61078683610a70565b82106107c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107be90612852565b60405180910390fd5b5f6107d0610764565b90505f805f5b8381101561091d575f60045f8381526020019081526020015f206040518060400160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020015f820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff168152505090505f73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff16146108bf57805f015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361090f57868403610906578195505050505050610959565b83806001019450505b5080806001019150506107d6565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610950906128e0565b60405180910390fd5b92915050565b61097983838360405180602001604052805f815250610de8565b505050565b5f610987610764565b82106109c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bf9061296e565b60405180910390fd5b819050919050565b5f6109da826116a4565b5f01519050919050565b600a80546109f190612608565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1d90612608565b8015610a685780601f10610a3f57610100808354040283529160200191610a68565b820191905f5260205f20905b815481529060010190602001808311610a4b57829003601f168201915b505050505081565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610adf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad6906129fc565b60405180910390fd5b60055f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f9054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bab575f80fd5b8160089080519060200190610bc1929190611cb1565b508060099080519060200190610bd8929190611d38565b505050565b606060038054610bec90612608565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1890612608565b8015610c635780601f10610c3a57610100808354040283529160200191610c63565b820191905f5260205f20905b815481529060010190602001808311610c4657829003601f168201915b5050505050905090565b610c756110d5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ce2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd990612a64565b60405180910390fd5b8060075f610cee6110d5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610d976110d5565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610ddc9190611eed565b60405180910390a35050565b610df384848461118b565b5f5b600880549050811015610ecb5760088181548110610e1657610e15612a82565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660098281548110610e6857610e67612a82565b5b905f5260205f2001604051610e7d9190612b4b565b5f604051808303815f865af19150503d805f8114610eb6576040519150601f19603f3d011682016040523d82523d5f602084013e610ebb565b606091505b5050508080600101915050610df5565b50610ed884848484611834565b610f17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0e90612bd1565b60405180910390fd5b50505050565b6060610f28826110c9565b610f67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5e90612c5f565b60405180910390fd5b5f610f706119b6565b90505f815103610f8e5760405180602001604052805f815250610fb9565b80610f9884611a46565b604051602001610fa9929190612cb7565b6040516020818303038152906040525b915050919050565b5f610fcb82611b9f565b9050919050565b5f60075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f805482109050919050565b5f33905090565b8260065f8481526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b5f611195826116a4565b90505f815f015173ffffffffffffffffffffffffffffffffffffffff166111ba6110d5565b73ffffffffffffffffffffffffffffffffffffffff16148061121657506111df6110d5565b73ffffffffffffffffffffffffffffffffffffffff166111fe846105cc565b73ffffffffffffffffffffffffffffffffffffffff16145b806112315750611230825f015161122b6110d5565b610fd2565b5b905080611273576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126a90612d4a565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16825f015173ffffffffffffffffffffffffffffffffffffffff16146112e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112db90612dd8565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611352576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134990612e66565b60405180910390fd5b61135f8585856001611c83565b61136d5f84845f01516110dc565b600160055f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f8282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550600160055f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f015f8282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055508360045f8581526020019081526020015f205f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504260045f8581526020019081526020015f205f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505f6001840190505f73ffffffffffffffffffffffffffffffffffffffff1660045f8381526020019081526020015f205f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036116345761159b816110c9565b1561163357825f015160045f8381526020019081526020015f205f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550826020015160045f8381526020019081526020015f205f0160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461169d8585856001611c89565b5050505050565b6116ac611d8f565b6116b5826110c9565b6116f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116eb90612ef4565b60405180910390fd5b5f8290505b5f81106117f3575f60045f8381526020019081526020015f206040518060400160405290815f82015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020015f820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff168152505090505f73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff16146117e457809250505061182f565b508080600190039150506116f9565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182690612f82565b60405180910390fd5b919050565b5f6118548473ffffffffffffffffffffffffffffffffffffffff16611c8f565b156119a9578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261187d6110d5565b8786866040518563ffffffff1660e01b815260040161189f9493929190612ff2565b6020604051808303815f875af19250505080156118da57506040513d601f19601f820116820180604052508101906118d79190613050565b60015b611959573d805f8114611908576040519150601f19603f3d011682016040523d82523d5f602084013e61190d565b606091505b505f815103611951576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194890612bd1565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506119ae565b600190505b949350505050565b6060600a80546119c590612608565b80601f01602080910402602001604051908101604052809291908181526020018280546119f190612608565b8015611a3c5780601f10611a1357610100808354040283529160200191611a3c565b820191905f5260205f20905b815481529060010190602001808311611a1f57829003601f168201915b5050505050905090565b60605f8203611a8c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611b9a565b5f8290505f5b5f8214611abb578080611aa4906130a8565b915050600a82611ab4919061311c565b9150611a92565b5f8167ffffffffffffffff811115611ad657611ad5612175565b5b6040519080825280601f01601f191660200182016040528015611b085781602001600182028036833780820191505090505b5090505b5f8514611b9357600182611b20919061314c565b9150600a85611b2f919061317f565b6030611b3b91906131af565b60f81b818381518110611b5157611b50612a82565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a905350600a85611b8c919061311c565b9450611b0c565b8093505050505b919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611c0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0590613252565b60405180910390fd5b60055f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f0160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b50505050565b50505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b828054828255905f5260205f20908101928215611d27579160200282015b82811115611d26578251825f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190611ccf565b5b509050611d349190611dc7565b5090565b828054828255905f5260205f20908101928215611d7e579160200282015b82811115611d7d578251829081611d6d91906133fb565b5091602001919060010190611d56565b5b509050611d8b9190611de2565b5090565b60405180604001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f67ffffffffffffffff1681525090565b5b80821115611dde575f815f905550600101611dc8565b5090565b5b80821115611e01575f8181611df89190611e05565b50600101611de3565b5090565b508054611e1190612608565b5f825580601f10611e225750611e3f565b601f0160209004905f5260205f2090810190611e3e9190611dc7565b5b50565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611e8781611e53565b8114611e91575f80fd5b50565b5f81359050611ea281611e7e565b92915050565b5f60208284031215611ebd57611ebc611e4b565b5b5f611eca84828501611e94565b91505092915050565b5f8115159050919050565b611ee781611ed3565b82525050565b5f602082019050611f005f830184611ede565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015611f3d578082015181840152602081019050611f22565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611f6282611f06565b611f6c8185611f10565b9350611f7c818560208601611f20565b611f8581611f48565b840191505092915050565b5f6020820190508181035f830152611fa88184611f58565b905092915050565b5f819050919050565b611fc281611fb0565b8114611fcc575f80fd5b50565b5f81359050611fdd81611fb9565b92915050565b5f60208284031215611ff857611ff7611e4b565b5b5f61200584828501611fcf565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6120378261200e565b9050919050565b6120478161202d565b82525050565b5f6020820190506120605f83018461203e565b92915050565b61206f8161202d565b8114612079575f80fd5b50565b5f8135905061208a81612066565b92915050565b5f80604083850312156120a6576120a5611e4b565b5b5f6120b38582860161207c565b92505060206120c485828601611fcf565b9150509250929050565b6120d781611fb0565b82525050565b5f6020820190506120f05f8301846120ce565b92915050565b5f805f6060848603121561210d5761210c611e4b565b5b5f61211a8682870161207c565b935050602061212b8682870161207c565b925050604061213c86828701611fcf565b9150509250925092565b5f6020828403121561215b5761215a611e4b565b5b5f6121688482850161207c565b91505092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6121ab82611f48565b810181811067ffffffffffffffff821117156121ca576121c9612175565b5b80604052505050565b5f6121dc611e42565b90506121e882826121a2565b919050565b5f67ffffffffffffffff82111561220757612206612175565b5b602082029050602081019050919050565b5f80fd5b5f61222e612229846121ed565b6121d3565b9050808382526020820190506020840283018581111561225157612250612218565b5b835b8181101561227a5780612266888261207c565b845260208401935050602081019050612253565b5050509392505050565b5f82601f83011261229857612297612171565b5b81356122a884826020860161221c565b91505092915050565b5f67ffffffffffffffff8211156122cb576122ca612175565b5b602082029050602081019050919050565b5f80fd5b5f67ffffffffffffffff8211156122fa576122f9612175565b5b61230382611f48565b9050602081019050919050565b828183375f83830152505050565b5f61233061232b846122e0565b6121d3565b90508281526020810184848401111561234c5761234b6122dc565b5b612357848285612310565b509392505050565b5f82601f83011261237357612372612171565b5b813561238384826020860161231e565b91505092915050565b5f61239e612399846122b1565b6121d3565b905080838252602082019050602084028301858111156123c1576123c0612218565b5b835b8181101561240857803567ffffffffffffffff8111156123e6576123e5612171565b5b8086016123f3898261235f565b855260208501945050506020810190506123c3565b5050509392505050565b5f82601f83011261242657612425612171565b5b813561243684826020860161238c565b91505092915050565b5f806040838503121561245557612454611e4b565b5b5f83013567ffffffffffffffff81111561247257612471611e4f565b5b61247e85828601612284565b925050602083013567ffffffffffffffff81111561249f5761249e611e4f565b5b6124ab85828601612412565b9150509250929050565b6124be81611ed3565b81146124c8575f80fd5b50565b5f813590506124d9816124b5565b92915050565b5f80604083850312156124f5576124f4611e4b565b5b5f6125028582860161207c565b9250506020612513858286016124cb565b9150509250929050565b5f805f806080858703121561253557612534611e4b565b5b5f6125428782880161207c565b94505060206125538782880161207c565b935050604061256487828801611fcf565b925050606085013567ffffffffffffffff81111561258557612584611e4f565b5b6125918782880161235f565b91505092959194509250565b5f80604083850312156125b3576125b2611e4b565b5b5f6125c08582860161207c565b92505060206125d18582860161207c565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061261f57607f821691505b602082108103612632576126316125db565b5b50919050565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e655f8201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b5f612692602d83611f10565b915061269d82612638565b604082019050919050565b5f6020820190508181035f8301526126bf81612686565b9050919050565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e5f8201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b5f612720602283611f10565b915061272b826126c6565b604082019050919050565b5f6020820190508181035f83015261274d81612714565b9050919050565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f5f8201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b5f6127ae603983611f10565b91506127b982612754565b604082019050919050565b5f6020820190508181035f8301526127db816127a2565b9050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e5f8201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b5f61283c602283611f10565b9150612847826127e2565b604082019050919050565b5f6020820190508181035f83015261286981612830565b9050919050565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f66205f8201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b5f6128ca602e83611f10565b91506128d582612870565b604082019050919050565b5f6020820190508181035f8301526128f7816128be565b9050919050565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f755f8201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b5f612958602383611f10565b9150612963826128fe565b604082019050919050565b5f6020820190508181035f8301526129858161294c565b9050919050565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a5f8201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b5f6129e6602b83611f10565b91506129f18261298c565b604082019050919050565b5f6020820190508181035f830152612a13816129da565b9050919050565b7f455243373231413a20617070726f766520746f2063616c6c65720000000000005f82015250565b5f612a4e601a83611f10565b9150612a5982612a1a565b602082019050919050565b5f6020820190508181035f830152612a7b81612a42565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81905092915050565b5f819050815f5260205f209050919050565b5f8154612ad781612608565b612ae18186612aaf565b9450600182165f8114612afb5760018114612b1057612b42565b60ff1983168652811515820286019350612b42565b612b1985612ab9565b5f5b83811015612b3a57815481890152600182019150602081019050612b1b565b838801955050505b50505092915050565b5f612b568284612acb565b915081905092915050565b7f455243373231413a207472616e7366657220746f206e6f6e20455243373231525f8201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b5f612bbb603383611f10565b9150612bc682612b61565b604082019050919050565b5f6020820190508181035f830152612be881612baf565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f5f8201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b5f612c49602f83611f10565b9150612c5482612bef565b604082019050919050565b5f6020820190508181035f830152612c7681612c3d565b9050919050565b5f81905092915050565b5f612c9182611f06565b612c9b8185612c7d565b9350612cab818560208601611f20565b80840191505092915050565b5f612cc28285612c87565b9150612cce8284612c87565b91508190509392505050565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f74205f8201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b5f612d34603283611f10565b9150612d3f82612cda565b604082019050919050565b5f6020820190508181035f830152612d6181612d28565b9050919050565b7f455243373231413a207472616e736665722066726f6d20696e636f72726563745f8201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b5f612dc2602683611f10565b9150612dcd82612d68565b604082019050919050565b5f6020820190508181035f830152612def81612db6565b9050919050565b7f455243373231413a207472616e7366657220746f20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f612e50602583611f10565b9150612e5b82612df6565b604082019050919050565b5f6020820190508181035f830152612e7d81612e44565b9050919050565b7f455243373231413a206f776e657220717565727920666f72206e6f6e657869735f8201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b5f612ede602a83611f10565b9150612ee982612e84565b604082019050919050565b5f6020820190508181035f830152612f0b81612ed2565b9050919050565b7f455243373231413a20756e61626c6520746f2064657465726d696e65207468655f8201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b5f612f6c602f83611f10565b9150612f7782612f12565b604082019050919050565b5f6020820190508181035f830152612f9981612f60565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b5f612fc482612fa0565b612fce8185612faa565b9350612fde818560208601611f20565b612fe781611f48565b840191505092915050565b5f6080820190506130055f83018761203e565b613012602083018661203e565b61301f60408301856120ce565b81810360608301526130318184612fba565b905095945050505050565b5f8151905061304a81611e7e565b92915050565b5f6020828403121561306557613064611e4b565b5b5f6130728482850161303c565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6130b282611fb0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036130e4576130e361307b565b5b600182019050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f61312682611fb0565b915061313183611fb0565b925082613141576131406130ef565b5b828204905092915050565b5f61315682611fb0565b915061316183611fb0565b92508282039050818111156131795761317861307b565b5b92915050565b5f61318982611fb0565b915061319483611fb0565b9250826131a4576131a36130ef565b5b828206905092915050565b5f6131b982611fb0565b91506131c483611fb0565b92508282019050808211156131dc576131db61307b565b5b92915050565b7f455243373231413a206e756d626572206d696e74656420717565727920666f725f8201527f20746865207a65726f2061646472657373000000000000000000000000000000602082015250565b5f61323c603183611f10565b9150613247826131e2565b604082019050919050565b5f6020820190508181035f83015261326981613230565b9050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026132ba7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261327f565b6132c4868361327f565b95508019841693508086168417925050509392505050565b5f819050919050565b5f6132ff6132fa6132f584611fb0565b6132dc565b611fb0565b9050919050565b5f819050919050565b613318836132e5565b61332c61332482613306565b84845461328b565b825550505050565b5f90565b613340613334565b61334b81848461330f565b505050565b5b8181101561336e576133635f82613338565b600181019050613351565b5050565b601f8211156133b35761338481612ab9565b61338d84613270565b8101602085101561339c578190505b6133b06133a885613270565b830182613350565b50505b505050565b5f82821c905092915050565b5f6133d35f19846008026133b8565b1980831691505092915050565b5f6133eb83836133c4565b9150826002028217905092915050565b61340482612fa0565b67ffffffffffffffff81111561341d5761341c612175565b5b6134278254612608565b613432828285613372565b5f60209050601f831160018114613463575f8415613451578287015190505b61345b85826133e0565b8655506134c2565b601f19841661347186612ab9565b5f5b8281101561349857848901518255600182019150602085019450602081019050613473565b868310156134b557848901516134b1601f8916826133c4565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220196d27a048b0cdb70dcff3fc7f8706816198917a5e810ec81909d0ba5098e66764736f6c63430008180033
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
979010e4d064de1ccfedeb8de3bb8f1cd6c76b8150168528497e0323b0ee6777
|
26fe58d87aa6a65106f74ec72da93f61a919aa65
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
32007e298dd13d1adbcf10f1dcd611c9befa3589
|
3d602d80600a3d3981f3363d3d373d3d3d363d73ee0c811af9a9e8878b4c94aa07cba634c2d56eb95af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73ee0c811af9a9e8878b4c94aa07cba634c2d56eb95af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
7e14eb44a8a6093bf06207a668bc65cca39ae05adc03227d2919398001748bf3
|
156e4a2d3bc79be5866be7e47f4befe8e6f0ff89
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
a4a70e7c9791fab64e9854c8f49658fd337331d4
|
3d602d80600a3d3981f3363d3d373d3d3d363d730d63d3497673d4cff60e9a97ffb29831c9f078b85af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730d63d3497673d4cff60e9a97ffb29831c9f078b85af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
989daac374d40fdb4173b32217b9336f1c5796b0d0a9a70f135e77959de7cc7b
|
5117b60d71d42afa459a6c249dc205d281fabff9
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
eb8a7eb41a2f444d33fb0a2e9984d31a0509d8cd
|
3d602d80600a3d3981f3363d3d373d3d3d363d739f6be3b80088c747477b82ed5edadcc2ccc7caa75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d739f6be3b80088c747477b82ed5edadcc2ccc7caa75af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
9ad5083004975fb6b43aa694164eee096435a22c6db70ac37303251f5c74319e
|
6e03ff2d78bd27121e6f34fa4e373456624c0596
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
27287acf1997b63252c5a353acd4b8251c6e1481
|
3d602d80600a3d3981f3363d3d373d3d3d363d735691b8c690b40093309244d22b3d0176b74af7ef5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735691b8c690b40093309244d22b3d0176b74af7ef5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
060860fd28fbd6ef679a1808cadfaf8dc075dd1ea33d3ade034543801f82679d
|
cd854e79610f114f3584cc25e6a9e14255597399
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
59e7926fa9a3135c0c2c5d3d491734ede91e5ee2
|
3d602d80600a3d3981f3363d3d373d3d3d363d73316bdf1b47bef7dc70f4d66bfe230b32001c87495af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73316bdf1b47bef7dc70f4d66bfe230b32001c87495af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
ee9a5029b7b281c501f0db40772759b509426047dbdff6885eae7b7f01ca4b69
|
cec7e26c85b3b5a1ebeb77e9e5dda591fa874d85
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
279ac2fbda5bac2b8d2681293dad7700769f07e5
|
3d602d80600a3d3981f3363d3d373d3d3d363d73bc98be066afc5c2952337a066b6d71ea7410c0765af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73bc98be066afc5c2952337a066b6d71ea7410c0765af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
487b9d3c63666e42a10b22ca5b624a19a066f73984859a7be622e43f0de7f428
|
5dcb884d39d7690eb47fa11f8af2faeec6aea1f4
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
b7ce252f0f7892ba96f04ec374e3f2cead4e4333
|
3d602d80600a3d3981f3363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
683406217a01ce03e2267c5841e5e2dc78eebcb564469477d429d074ff1abf83
|
75503f7f05572641657c61733ea91ea304cd5390
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
e5fd30eed2ab03ed5b5391cb5a15b6f96e639b55
|
3d602d80600a3d3981f3363d3d373d3d3d363d731c66e5f08833fdd04ca0fc083f713ed12b5e85735af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d731c66e5f08833fdd04ca0fc083f713ed12b5e85735af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
363282674b053b757fdf32d421bd3578b23e24cf3522ab8ea7e12b74c52866ac
|
39f104e29b0340385f66168aa513782ff2d339d2
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
94df7bfa39db256d00f790fb2bfc3e74b479d246
|
3d602d80600a3d3981f3363d3d373d3d3d363d739866373f4da648759702b996d4931ad42bb875f85af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d739866373f4da648759702b996d4931ad42bb875f85af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
75e41faa9e15f63dc7bf20aca5b08d6d33972d78f8c317cea7b3d6d8688629b0
|
0f5090ab6b235c801f70848cde303f506318d670
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
48b1f61f5238e8421d795fcc3e16bf04f0cdc676
|
3d602d80600a3d3981f3363d3d373d3d3d363d731abaec5dd9a84171d998332570919c9f0f17f2685af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d731abaec5dd9a84171d998332570919c9f0f17f2685af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
333f4d2ff16ac0938b59e1ef865e17a79ce6dfe367c403ef776ed6eafe6ea4f2
|
0a0c65fab1cd2ccba1b7605de46f74260e5161da
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
0c984f084eade61938dd8507d3f54b6b9f25058e
|
3d602d80600a3d3981f3363d3d373d3d3d363d734df0fb7237f75bea5d38be589fadd402b3601d1d5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d734df0fb7237f75bea5d38be589fadd402b3601d1d5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
220a204fbdc4619dc8fd0e500d45318da4c073550ce9cd99c475dd7d75482e59
|
ecc8f725cd4dbcc232d22d013b8709c7b97c4b13
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
20bf9d9b1b970eb0a3069ab7a3e0236b30d74fdd
|
3d602d80600a3d3981f3363d3d373d3d3d363d731b8777b06794e63accd977e0ae248fd18c999c2e5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d731b8777b06794e63accd977e0ae248fd18c999c2e5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
89d5b6922e5f678b91db077fc9d0384e7b6af5300f56342cdf3d2db367f3b5f1
|
4ed270983de617f9f21b8d8ef6a389a214866825
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
92714872342570aba422a9f21a4e2a4f4967a31d
|
3d602d80600a3d3981f3363d3d373d3d3d363d736417c07c0e7479d10a1d35eec6344df0bc5f48f95af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d736417c07c0e7479d10a1d35eec6344df0bc5f48f95af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
3c7249c6579867a383dc38ac61ba7561d80ccdaff65dfbf289b9186dcc08e640
|
4ea436952a8546d9ae086e1bf2d1e8a969908a35
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
a3cf8116dcd66574f76d7a862c714a0bcf8369a9
|
3d602d80600a3d3981f3363d3d373d3d3d363d73609ae25cfbe7648519db74c17e253a1e7c785d8a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73609ae25cfbe7648519db74c17e253a1e7c785d8a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
c5543d56317575fdde22aaac7a1244103adb642a0ca217c833d2d18ed8d795f2
|
f44129f592d10294d4415a778a90f7b13e2a4d56
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
2ddd5317950e4548c47ff7d918b75b3123dfb2b3
|
3d602d80600a3d3981f3363d3d373d3d3d363d738fe5235fdce82a1f0261db9870e2dbad2c7ead245af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d738fe5235fdce82a1f0261db9870e2dbad2c7ead245af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
d1ddd2afda7be7586be7e5e875d02c9942239cae2fe37a5ddaf17e37b808dc14
|
46e898cb4ba9de5444fee7c5e89e2e27d6e1e393
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
f72047c5cd316642dced437d44c1d154954a5b0b
|
3d602d80600a3d3981f3363d3d373d3d3d363d7378382fb58c5d5768ba5d3ece8a290d40fe7237d85af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7378382fb58c5d5768ba5d3ece8a290d40fe7237d85af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
8e8b38b0ffbe8a7623ed82c6e22306b18240c3411d8ab99727721cbb1979b44b
|
3a348e9fb4eef1a5b2c9c971927551dfc0c46117
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
5a5dddfdf0dfe3d5011017917d23cf7e92f227c8
|
3d602d80600a3d3981f3363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
3817fad6fa43184337d29f7fd987a27d2d324c41b2a5a42aa668950d5f288e3b
|
c49e2cac1a91c2d06d09eece51df98e9075bcf5d
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
27e2ddaf27ba5e92f10db64c72803225e473273a
|
3d602d80600a3d3981f3363d3d373d3d3d363d73a6f6b1d91694e9a67459112b6508609b143f34c75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73a6f6b1d91694e9a67459112b6508609b143f34c75af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
649e4338e3e13b768d7e8651037452ada0d50701c8ffee77774e7cdee1f0260d
|
4a052f434986f8286ce7e41db00678f700a62e02
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
d0f5310140d45123ced933ad632925360bf5d1fa
|
3d602d80600a3d3981f3363d3d373d3d3d363d739866373f4da648759702b996d4931ad42bb875f85af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d739866373f4da648759702b996d4931ad42bb875f85af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
dc6cf08ed576fd0646d3b83443111d7ed6d5cc3462c555d42d1aa88c580d7042
|
da735e05543175acd64c9f8617bd6bfd4146ed28
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
ce6fcad6b04b2e9c411347b0fc09b1b544a2401f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73c96933650242379351ad5e32b7bf43a0b820aa5c5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73c96933650242379351ad5e32b7bf43a0b820aa5c5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
2129e7147189507e633d77294a53c2f8baa9c14fa579fb92e909f4d67a4b34fe
|
76bfae6985deb0e4fe1fadd36bb067f2332db4d3
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
a54cbeb957e1b87c9bdbed3b354c8ee460ee1266
|
3d602d80600a3d3981f3363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
7b56ec66cabe6a0c811fb7e0d3eeff377e51d42f8d535cc8182f2fb1eea31970
|
c6afe99a842e0cf190b31094d06e3407fddbfa20
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
f25e427e6f681bafc6b34a98be06305274ad313b
|
3d602d80600a3d3981f3363d3d373d3d3d363d731c66e5f08833fdd04ca0fc083f713ed12b5e85735af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d731c66e5f08833fdd04ca0fc083f713ed12b5e85735af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
ec3434080f040192fdd55ae02e7609464ca538f55dc3b1c70bc0e521f0e376e2
|
319f9b1db6378860dd6b97740aaef0610402b2fd
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
097c1216da85254c6e6b5f76e270da9ae3426916
|
3d602d80600a3d3981f3363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
c55b683deefca4079f7cf69e38e05a11d4f339495cd0065bef4524f264bb2fa2
|
272bcfb79011cc2166c7116b670f7b33fb0fbac3
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
073bad0fe3a632a8a0e2365bef048e2c99751f95
|
3d602d80600a3d3981f3363d3d373d3d3d363d7332716de33ea7195b2016de930a756bf202ee2edd5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7332716de33ea7195b2016de930a756bf202ee2edd5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
1baa3d27af737342b37fa0fcccb87b8ef17578d463f26531706bb1a46a626194
|
d074a11eae2eaf8db492dc1525abb1d2bcb15da6
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
2350dabdeddeb439af05c7f624cd79151ce5ed9f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73e81b711debf815d3dc1ac0fb8ed5c61564d9aa6f5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73e81b711debf815d3dc1ac0fb8ed5c61564d9aa6f5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
9162810acc6e428262427d4b94c07c56f21687729f6cdced4d88bef08f78d092
|
9037f258ae86a3f2cbdc9d47e5d0a6388edaca50
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
9d96d3c76e7054d3189b72093e08ec46a7240861
|
3d602d80600a3d3981f3363d3d373d3d3d363d734e8c910fed2ebb0b2c2a484efb83d0d7b2055ff35af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d734e8c910fed2ebb0b2c2a484efb83d0d7b2055ff35af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
40c847f8b1f52868773329086f2ae3a4babb975be44ebd059f08aac122e1e394
|
7e017498eaa2ef211252242bd6fc0dd742ca200f
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
a7cc2e7405071895d74f3b2e19db310e6fedd277
|
3d602d80600a3d3981f3363d3d373d3d3d363d73bbab4530242e1636e26e3188aac95d6459e960085af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73bbab4530242e1636e26e3188aac95d6459e960085af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
7838c8a7d7b4b0482545f4ff93ba46923d38221c84d60d51b58daa8e98a1aa9f
|
d155b5c415f6001685b2bc0dcdf5a8dd125cce4e
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
459501ee57ae5f0cb2c1f2592a0d28528d7daff2
|
3d602d80600a3d3981f3363d3d373d3d3d363d73475e69f86c5116b038b59fbef0e481a3b71204c75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73475e69f86c5116b038b59fbef0e481a3b71204c75af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
57dcb6bd3f3e6c823c666a2276f5eb4443ed278453435651679f086a8ad83a3f
|
1dc14d7f51f0b91eedc4451d4922e36011063e18
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
8897ff026a644adda1a60b3e47d5ca14a90fb1fb
|
3d602d80600a3d3981f3363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73479d6e32d74e3c4fcd00b0e08f1a2c87ff4f04575af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
03c784fbf5e802b0e44348df8e2cbe693cd949071b3bff2488a40e072c7760d8
|
de2041c3987527086bd71f4891449a5a623cc209
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
1dbdc9b5f7306698a7f0c06e1df8528385682680
|
3d602d80600a3d3981f3363d3d373d3d3d363d73b71b80451fb9d1b3c0a1527a330cdb1c3ffc83715af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73b71b80451fb9d1b3c0a1527a330cdb1c3ffc83715af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,379 |
a59f88f0f5ddcac4cb703def7681eefbb38d130368beb9f757ae9a83360c4146
|
a06809f266d8b22db396459423091417359a803bc300eeeed6a201694860faf3
|
713e05ee3ce6c4b204cdb22d78bc5013c212e281
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
97a8207ff386f0f0d61ac3402d833d4fa645e872
|
3d602d80600a3d3981f3363d3d373d3d3d363d73161b8e6f78d086114d11878c59b1d0b7d02e02b05af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73161b8e6f78d086114d11878c59b1d0b7d02e02b05af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,381 |
8b4ff5d8921fd11a13868d5c037beff0d201bddadf0a099dd0db1723b0e6c29d
|
b95ff5a9b7bbd99622efcba9172050264e9ef1f88507050ba639d04a56329e01
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
7ffc0fb548c47f4a92ed13680aed9e3534f7f1c7
|
6080604052610017670429d069189e00005f19610345565b610022905f19610364565b6006555f60088190556019600955600a819055602d600b819055600c829055600d819055600e91909155600f55601280546001600160a01b0319908116735e647f6027800dce1f93b8a09ff8b8ee78f913349081179092556013805490911690911790556015805462ffffff60a01b1916600160b01b179055661550f7dca700006016819055601755660aa87bee5380006018553480156100c1575f80fd5b505f80546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600654335f9081526002602090815260409182902092909255601480546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d908117909155815163c45a015560e01b815291519092839263c45a015592600480830193928290030181865afa15801561017a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061019e9190610389565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061020d9190610389565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af1158015610257573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061027b9190610389565b601580546001600160a01b0319166001600160a01b039283161790555f80548216815260056020526040808220805460ff1990811660019081179092553084528284208054821683179055601254851684528284208054821683179055601354909416835291208054909216179055336001600160a01b03165f6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef670429d069189e000060405161033791815260200190565b60405180910390a3506103b6565b5f8261035f57634e487b7160e01b5f52601260045260245ffd5b500690565b8181038181111561038357634e487b7160e01b5f52601160045260245ffd5b92915050565b5f60208284031215610399575f80fd5b81516001600160a01b03811681146103af575f80fd5b9392505050565b611ce3806103c35f395ff3fe6080604052600436106101c8575f3560e01c8063715018a6116100f2578063a9059cbb11610092578063cfbdad8e11610062578063cfbdad8e1461052f578063dd62ed3e1461054e578063e2ee677d14610592578063f2fde38b146105b1575f80fd5b8063a9059cbb146104af578063ad69489e146104ce578063bfd79284146104ed578063c3c8cd801461051b575f80fd5b80638da5cb5b116100cd5780638da5cb5b146104335780638ebc7ec61461044f5780638f9a55c01461046e57806395d89b4114610483575f80fd5b8063715018a6146103df5780637d1db4a5146103f35780637f2feddc14610408575f80fd5b80632fd689e31161016857806366eb37851161013857806366eb37851461036e5780636d8aa8f8146103825780636fcba377146103a157806370a08231146103c0575f80fd5b80632fd689e314610300578063313ce5671461031557806349bd5a5e1461033057806351a7fe561461034f575f80fd5b806318160ddd116101a357806318160ddd1461027d57806323b872dd146102a15780632a9b8072146102c05780632f6c493c146102e1575f80fd5b806306fdde03146101d3578063095ea7b3146102175780631694505e14610246575f80fd5b366101cf57005b5f80fd5b3480156101de575f80fd5b5060408051808201909152600a81526941492d5363616e2d495160b01b60208201525b60405161020e919061186e565b60405180910390f35b348015610222575f80fd5b506102366102313660046118c7565b6105d0565b604051901515815260200161020e565b348015610251575f80fd5b50601454610265906001600160a01b031681565b6040516001600160a01b03909116815260200161020e565b348015610288575f80fd5b50670429d069189e00005b60405190815260200161020e565b3480156102ac575f80fd5b506102366102bb3660046118f1565b6105e6565b3480156102cb575f80fd5b506102df6102da36600461193e565b61064d565b005b3480156102ec575f80fd5b506102df6102fb366004611957565b61069d565b34801561030b575f80fd5b5061029360185481565b348015610320575f80fd5b506040516009815260200161020e565b34801561033b575f80fd5b50601554610265906001600160a01b031681565b34801561035a575f80fd5b506102df610369366004611972565b6106e6565b348015610379575f80fd5b506102df610714565b34801561038d575f80fd5b506102df61039c36600461193e565b61075e565b3480156103ac575f80fd5b506102df6103bb366004611989565b6107a5565b3480156103cb575f80fd5b506102936103da366004611957565b6107e2565b3480156103ea575f80fd5b506102df610803565b3480156103fe575f80fd5b5061029360165481565b348015610413575f80fd5b50610293610422366004611957565b60116020525f908152604090205481565b34801561043e575f80fd5b505f546001600160a01b0316610265565b34801561045a575f80fd5b506102df6104693660046119b8565b610874565b348015610479575f80fd5b5061029360175481565b34801561048e575f80fd5b506040805180820190915260048152634153495160e01b6020820152610201565b3480156104ba575f80fd5b506102366104c93660046118c7565b610907565b3480156104d9575f80fd5b506102df6104e8366004611972565b610913565b3480156104f8575f80fd5b50610236610507366004611957565b60106020525f908152604090205460ff1681565b348015610526575f80fd5b506102df610941565b34801561053a575f80fd5b506102df610549366004611a49565b610993565b348015610559575f80fd5b50610293610568366004611b09565b6001600160a01b039182165f90815260046020908152604080832093909416825291909152205490565b34801561059d575f80fd5b506102df6105ac366004611972565b610a1b565b3480156105bc575f80fd5b506102df6105cb366004611957565b610a49565b5f6105dc338484610b30565b5060015b92915050565b5f6105f2848484610c53565b610643843361063e85604051806060016040528060288152602001611c86602891396001600160a01b038a165f9081526004602090815260408083203384529091529020549190611183565b610b30565b5060019392505050565b5f546001600160a01b0316331461067f5760405162461bcd60e51b815260040161067690611b40565b60405180910390fd5b60158054911515600160a01b0260ff60a01b19909216919091179055565b5f546001600160a01b031633146106c65760405162461bcd60e51b815260040161067690611b40565b6001600160a01b03165f908152601060205260409020805460ff19169055565b5f546001600160a01b0316331461070f5760405162461bcd60e51b815260040161067690611b40565b601655565b6012546001600160a01b0316336001600160a01b0316148061074957506013546001600160a01b0316336001600160a01b0316145b610751575f80fd5b4761075b816111bb565b50565b5f546001600160a01b031633146107875760405162461bcd60e51b815260040161067690611b40565b60158054911515600160b01b0260ff60b01b19909216919091179055565b5f546001600160a01b031633146107ce5760405162461bcd60e51b815260040161067690611b40565b600893909355600a91909155600955600b55565b6001600160a01b0381165f908152600260205260408120546105e0906111f2565b5f546001600160a01b0316331461082c5760405162461bcd60e51b815260040161067690611b40565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b0316331461089d5760405162461bcd60e51b815260040161067690611b40565b5f5b82811015610901578160055f8686858181106108bd576108bd611b75565b90506020020160208101906108d29190611957565b6001600160a01b0316815260208101919091526040015f20805460ff191691151591909117905560010161089f565b50505050565b5f6105dc338484610c53565b5f546001600160a01b0316331461093c5760405162461bcd60e51b815260040161067690611b40565b601755565b6012546001600160a01b0316336001600160a01b0316148061097657506013546001600160a01b0316336001600160a01b0316145b61097e575f80fd5b5f610988306107e2565b905061075b81611274565b5f546001600160a01b031633146109bc5760405162461bcd60e51b815260040161067690611b40565b5f5b8151811015610a1757600160105f8484815181106109de576109de611b75565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff19169115159190911790556001016109be565b5050565b5f546001600160a01b03163314610a445760405162461bcd60e51b815260040161067690611b40565b601855565b5f546001600160a01b03163314610a725760405162461bcd60e51b815260040161067690611b40565b6001600160a01b038116610ad75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610676565b5f80546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610b925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b038216610bf35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b038381165f8181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cb75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b038216610d195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b5f8111610d7a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610676565b5f546001600160a01b03848116911614801590610da457505f546001600160a01b03838116911614155b1561107f57601554600160a01b900460ff16610e3c575f546001600160a01b03848116911614610e3c5760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564006064820152608401610676565b601654811115610e8e5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d6974000000006044820152606401610676565b6001600160a01b0383165f9081526010602052604090205460ff16158015610ece57506001600160a01b0382165f9081526010602052604090205460ff16155b610f265760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b6064820152608401610676565b6015546001600160a01b03838116911614610fab5760175481610f48846107e2565b610f529190611b9d565b10610fab5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b6064820152608401610676565b5f610fb5306107e2565b601854601654919250821015908210610fce5760165491505b808015610fe55750601554600160a81b900460ff16155b8015610fff57506015546001600160a01b03868116911614155b80156110145750601554600160b01b900460ff165b801561103857506001600160a01b0385165f9081526005602052604090205460ff16155b801561105c57506001600160a01b0384165f9081526005602052604090205460ff16155b1561107c5761106a82611274565b47801561107a5761107a476111bb565b505b50505b6001600160a01b0383165f9081526005602052604090205460019060ff16806110bf57506001600160a01b0383165f9081526005602052604090205460ff165b806110f157506015546001600160a01b038581169116148015906110f157506015546001600160a01b03848116911614155b156110fd57505f611177565b6015546001600160a01b03858116911614801561112857506014546001600160a01b03848116911614155b1561113a57600854600c55600954600d555b6015546001600160a01b03848116911614801561116557506014546001600160a01b03858116911614155b1561117757600a54600c55600b54600d555b610901848484846113e4565b5f81848411156111a65760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611bb0565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015610a17573d5f803e3d5ffd5b5f6006548211156112585760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610676565b5f611261611409565b905061126d838261142a565b9392505050565b6015805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112ba576112ba611b75565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611311573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113359190611bc3565b8160018151811061134857611348611b75565b6001600160a01b03928316602091820292909201015260145461136e9130911684610b30565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac947906113a69085905f90869030904290600401611bde565b5f604051808303815f87803b1580156113bd575f80fd5b505af11580156113cf573d5f803e3d5ffd5b50506015805460ff60a81b1916905550505050565b806113f1576113f161146b565b6113fc848484611498565b806109015761090161146b565b5f805f611414611589565b9092509050611423828261142a565b9250505090565b5f61126d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115c8565b600c5415801561147b5750600d54155b1561148257565b600c8054600e55600d8054600f555f9182905555565b5f805f805f806114a7876115f4565b6001600160a01b038f165f90815260026020526040902054959b509399509197509550935091506114d89087611649565b6001600160a01b03808b165f9081526002602052604080822093909355908a1681522054611506908661168a565b6001600160a01b0389165f90815260026020526040902055611527816116e8565b611531848361172e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161157691815260200190565b60405180910390a3505050505050505050565b6006545f908190670429d069189e00006115a3828261142a565b8210156115bf57505060065492670429d069189e000092509050565b90939092509050565b5f81836115e85760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611c4f565b5f805f805f805f805f61160c8a600c54600d54611752565b9250925092505f61161b611409565b90505f805f61162c8e8787876117a4565b919e509c509a509598509396509194505050505091939550919395565b5f61126d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611183565b5f806116968385611b9d565b90508381101561126d5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610676565b5f6116f1611409565b90505f6116fe83836117f0565b305f9081526002602052604090205490915061171a908261168a565b305f90815260026020526040902055505050565b60065461173b9083611649565b60065560075461174b908261168a565b6007555050565b5f80808061176b606461176589896117f0565b9061142a565b90505f61177d60646117658a896117f0565b90505f6117948261178e8b86611649565b90611649565b9992985090965090945050505050565b5f8080806117b288866117f0565b90505f6117bf88876117f0565b90505f6117cc88886117f0565b90505f6117dd8261178e8686611649565b939b939a50919850919650505050505050565b5f825f036117ff57505f6105e0565b5f61180a8385611c6e565b9050826118178583611c4f565b1461126d5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610676565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461075b575f80fd5b80356118c2816118a3565b919050565b5f80604083850312156118d8575f80fd5b82356118e3816118a3565b946020939093013593505050565b5f805f60608486031215611903575f80fd5b833561190e816118a3565b9250602084013561191e816118a3565b929592945050506040919091013590565b803580151581146118c2575f80fd5b5f6020828403121561194e575f80fd5b61126d8261192f565b5f60208284031215611967575f80fd5b813561126d816118a3565b5f60208284031215611982575f80fd5b5035919050565b5f805f806080858703121561199c575f80fd5b5050823594602084013594506040840135936060013592509050565b5f805f604084860312156119ca575f80fd5b833567ffffffffffffffff808211156119e1575f80fd5b818601915086601f8301126119f4575f80fd5b813581811115611a02575f80fd5b8760208260051b8501011115611a16575f80fd5b602092830195509350611a2c918601905061192f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b5f6020808385031215611a5a575f80fd5b823567ffffffffffffffff80821115611a71575f80fd5b818501915085601f830112611a84575f80fd5b813581811115611a9657611a96611a35565b8060051b604051601f19603f83011681018181108582111715611abb57611abb611a35565b604052918252848201925083810185019188831115611ad8575f80fd5b938501935b82851015611afd57611aee856118b7565b84529385019392850192611add565b98975050505050505050565b5f8060408385031215611b1a575f80fd5b8235611b25816118a3565b91506020830135611b35816118a3565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156105e0576105e0611b89565b818103818111156105e0576105e0611b89565b5f60208284031215611bd3575f80fd5b815161126d816118a3565b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015611c2e5784516001600160a01b031683529383019391830191600101611c09565b50506001600160a01b03969096166060850152505050608001529392505050565b5f82611c6957634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176105e0576105e0611b8956fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220573691ca3f116057394b7e1894aec29ca62463eb788b1685d9e5956e2a7ee6ad64736f6c63430008190033
|
6080604052600436106101c8575f3560e01c8063715018a6116100f2578063a9059cbb11610092578063cfbdad8e11610062578063cfbdad8e1461052f578063dd62ed3e1461054e578063e2ee677d14610592578063f2fde38b146105b1575f80fd5b8063a9059cbb146104af578063ad69489e146104ce578063bfd79284146104ed578063c3c8cd801461051b575f80fd5b80638da5cb5b116100cd5780638da5cb5b146104335780638ebc7ec61461044f5780638f9a55c01461046e57806395d89b4114610483575f80fd5b8063715018a6146103df5780637d1db4a5146103f35780637f2feddc14610408575f80fd5b80632fd689e31161016857806366eb37851161013857806366eb37851461036e5780636d8aa8f8146103825780636fcba377146103a157806370a08231146103c0575f80fd5b80632fd689e314610300578063313ce5671461031557806349bd5a5e1461033057806351a7fe561461034f575f80fd5b806318160ddd116101a357806318160ddd1461027d57806323b872dd146102a15780632a9b8072146102c05780632f6c493c146102e1575f80fd5b806306fdde03146101d3578063095ea7b3146102175780631694505e14610246575f80fd5b366101cf57005b5f80fd5b3480156101de575f80fd5b5060408051808201909152600a81526941492d5363616e2d495160b01b60208201525b60405161020e919061186e565b60405180910390f35b348015610222575f80fd5b506102366102313660046118c7565b6105d0565b604051901515815260200161020e565b348015610251575f80fd5b50601454610265906001600160a01b031681565b6040516001600160a01b03909116815260200161020e565b348015610288575f80fd5b50670429d069189e00005b60405190815260200161020e565b3480156102ac575f80fd5b506102366102bb3660046118f1565b6105e6565b3480156102cb575f80fd5b506102df6102da36600461193e565b61064d565b005b3480156102ec575f80fd5b506102df6102fb366004611957565b61069d565b34801561030b575f80fd5b5061029360185481565b348015610320575f80fd5b506040516009815260200161020e565b34801561033b575f80fd5b50601554610265906001600160a01b031681565b34801561035a575f80fd5b506102df610369366004611972565b6106e6565b348015610379575f80fd5b506102df610714565b34801561038d575f80fd5b506102df61039c36600461193e565b61075e565b3480156103ac575f80fd5b506102df6103bb366004611989565b6107a5565b3480156103cb575f80fd5b506102936103da366004611957565b6107e2565b3480156103ea575f80fd5b506102df610803565b3480156103fe575f80fd5b5061029360165481565b348015610413575f80fd5b50610293610422366004611957565b60116020525f908152604090205481565b34801561043e575f80fd5b505f546001600160a01b0316610265565b34801561045a575f80fd5b506102df6104693660046119b8565b610874565b348015610479575f80fd5b5061029360175481565b34801561048e575f80fd5b506040805180820190915260048152634153495160e01b6020820152610201565b3480156104ba575f80fd5b506102366104c93660046118c7565b610907565b3480156104d9575f80fd5b506102df6104e8366004611972565b610913565b3480156104f8575f80fd5b50610236610507366004611957565b60106020525f908152604090205460ff1681565b348015610526575f80fd5b506102df610941565b34801561053a575f80fd5b506102df610549366004611a49565b610993565b348015610559575f80fd5b50610293610568366004611b09565b6001600160a01b039182165f90815260046020908152604080832093909416825291909152205490565b34801561059d575f80fd5b506102df6105ac366004611972565b610a1b565b3480156105bc575f80fd5b506102df6105cb366004611957565b610a49565b5f6105dc338484610b30565b5060015b92915050565b5f6105f2848484610c53565b610643843361063e85604051806060016040528060288152602001611c86602891396001600160a01b038a165f9081526004602090815260408083203384529091529020549190611183565b610b30565b5060019392505050565b5f546001600160a01b0316331461067f5760405162461bcd60e51b815260040161067690611b40565b60405180910390fd5b60158054911515600160a01b0260ff60a01b19909216919091179055565b5f546001600160a01b031633146106c65760405162461bcd60e51b815260040161067690611b40565b6001600160a01b03165f908152601060205260409020805460ff19169055565b5f546001600160a01b0316331461070f5760405162461bcd60e51b815260040161067690611b40565b601655565b6012546001600160a01b0316336001600160a01b0316148061074957506013546001600160a01b0316336001600160a01b0316145b610751575f80fd5b4761075b816111bb565b50565b5f546001600160a01b031633146107875760405162461bcd60e51b815260040161067690611b40565b60158054911515600160b01b0260ff60b01b19909216919091179055565b5f546001600160a01b031633146107ce5760405162461bcd60e51b815260040161067690611b40565b600893909355600a91909155600955600b55565b6001600160a01b0381165f908152600260205260408120546105e0906111f2565b5f546001600160a01b0316331461082c5760405162461bcd60e51b815260040161067690611b40565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b0316331461089d5760405162461bcd60e51b815260040161067690611b40565b5f5b82811015610901578160055f8686858181106108bd576108bd611b75565b90506020020160208101906108d29190611957565b6001600160a01b0316815260208101919091526040015f20805460ff191691151591909117905560010161089f565b50505050565b5f6105dc338484610c53565b5f546001600160a01b0316331461093c5760405162461bcd60e51b815260040161067690611b40565b601755565b6012546001600160a01b0316336001600160a01b0316148061097657506013546001600160a01b0316336001600160a01b0316145b61097e575f80fd5b5f610988306107e2565b905061075b81611274565b5f546001600160a01b031633146109bc5760405162461bcd60e51b815260040161067690611b40565b5f5b8151811015610a1757600160105f8484815181106109de576109de611b75565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff19169115159190911790556001016109be565b5050565b5f546001600160a01b03163314610a445760405162461bcd60e51b815260040161067690611b40565b601855565b5f546001600160a01b03163314610a725760405162461bcd60e51b815260040161067690611b40565b6001600160a01b038116610ad75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610676565b5f80546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610b925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b038216610bf35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b038381165f8181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cb75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b038216610d195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b5f8111610d7a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610676565b5f546001600160a01b03848116911614801590610da457505f546001600160a01b03838116911614155b1561107f57601554600160a01b900460ff16610e3c575f546001600160a01b03848116911614610e3c5760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564006064820152608401610676565b601654811115610e8e5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d6974000000006044820152606401610676565b6001600160a01b0383165f9081526010602052604090205460ff16158015610ece57506001600160a01b0382165f9081526010602052604090205460ff16155b610f265760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b6064820152608401610676565b6015546001600160a01b03838116911614610fab5760175481610f48846107e2565b610f529190611b9d565b10610fab5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b6064820152608401610676565b5f610fb5306107e2565b601854601654919250821015908210610fce5760165491505b808015610fe55750601554600160a81b900460ff16155b8015610fff57506015546001600160a01b03868116911614155b80156110145750601554600160b01b900460ff165b801561103857506001600160a01b0385165f9081526005602052604090205460ff16155b801561105c57506001600160a01b0384165f9081526005602052604090205460ff16155b1561107c5761106a82611274565b47801561107a5761107a476111bb565b505b50505b6001600160a01b0383165f9081526005602052604090205460019060ff16806110bf57506001600160a01b0383165f9081526005602052604090205460ff165b806110f157506015546001600160a01b038581169116148015906110f157506015546001600160a01b03848116911614155b156110fd57505f611177565b6015546001600160a01b03858116911614801561112857506014546001600160a01b03848116911614155b1561113a57600854600c55600954600d555b6015546001600160a01b03848116911614801561116557506014546001600160a01b03858116911614155b1561117757600a54600c55600b54600d555b610901848484846113e4565b5f81848411156111a65760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611bb0565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015610a17573d5f803e3d5ffd5b5f6006548211156112585760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610676565b5f611261611409565b905061126d838261142a565b9392505050565b6015805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f815181106112ba576112ba611b75565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611311573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113359190611bc3565b8160018151811061134857611348611b75565b6001600160a01b03928316602091820292909201015260145461136e9130911684610b30565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac947906113a69085905f90869030904290600401611bde565b5f604051808303815f87803b1580156113bd575f80fd5b505af11580156113cf573d5f803e3d5ffd5b50506015805460ff60a81b1916905550505050565b806113f1576113f161146b565b6113fc848484611498565b806109015761090161146b565b5f805f611414611589565b9092509050611423828261142a565b9250505090565b5f61126d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115c8565b600c5415801561147b5750600d54155b1561148257565b600c8054600e55600d8054600f555f9182905555565b5f805f805f806114a7876115f4565b6001600160a01b038f165f90815260026020526040902054959b509399509197509550935091506114d89087611649565b6001600160a01b03808b165f9081526002602052604080822093909355908a1681522054611506908661168a565b6001600160a01b0389165f90815260026020526040902055611527816116e8565b611531848361172e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161157691815260200190565b60405180910390a3505050505050505050565b6006545f908190670429d069189e00006115a3828261142a565b8210156115bf57505060065492670429d069189e000092509050565b90939092509050565b5f81836115e85760405162461bcd60e51b8152600401610676919061186e565b505f6111b28486611c4f565b5f805f805f805f805f61160c8a600c54600d54611752565b9250925092505f61161b611409565b90505f805f61162c8e8787876117a4565b919e509c509a509598509396509194505050505091939550919395565b5f61126d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611183565b5f806116968385611b9d565b90508381101561126d5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610676565b5f6116f1611409565b90505f6116fe83836117f0565b305f9081526002602052604090205490915061171a908261168a565b305f90815260026020526040902055505050565b60065461173b9083611649565b60065560075461174b908261168a565b6007555050565b5f80808061176b606461176589896117f0565b9061142a565b90505f61177d60646117658a896117f0565b90505f6117948261178e8b86611649565b90611649565b9992985090965090945050505050565b5f8080806117b288866117f0565b90505f6117bf88876117f0565b90505f6117cc88886117f0565b90505f6117dd8261178e8686611649565b939b939a50919850919650505050505050565b5f825f036117ff57505f6105e0565b5f61180a8385611c6e565b9050826118178583611c4f565b1461126d5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610676565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461075b575f80fd5b80356118c2816118a3565b919050565b5f80604083850312156118d8575f80fd5b82356118e3816118a3565b946020939093013593505050565b5f805f60608486031215611903575f80fd5b833561190e816118a3565b9250602084013561191e816118a3565b929592945050506040919091013590565b803580151581146118c2575f80fd5b5f6020828403121561194e575f80fd5b61126d8261192f565b5f60208284031215611967575f80fd5b813561126d816118a3565b5f60208284031215611982575f80fd5b5035919050565b5f805f806080858703121561199c575f80fd5b5050823594602084013594506040840135936060013592509050565b5f805f604084860312156119ca575f80fd5b833567ffffffffffffffff808211156119e1575f80fd5b818601915086601f8301126119f4575f80fd5b813581811115611a02575f80fd5b8760208260051b8501011115611a16575f80fd5b602092830195509350611a2c918601905061192f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b5f6020808385031215611a5a575f80fd5b823567ffffffffffffffff80821115611a71575f80fd5b818501915085601f830112611a84575f80fd5b813581811115611a9657611a96611a35565b8060051b604051601f19603f83011681018181108582111715611abb57611abb611a35565b604052918252848201925083810185019188831115611ad8575f80fd5b938501935b82851015611afd57611aee856118b7565b84529385019392850192611add565b98975050505050505050565b5f8060408385031215611b1a575f80fd5b8235611b25816118a3565b91506020830135611b35816118a3565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b808201808211156105e0576105e0611b89565b818103818111156105e0576105e0611b89565b5f60208284031215611bd3575f80fd5b815161126d816118a3565b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015611c2e5784516001600160a01b031683529383019391830191600101611c09565b50506001600160a01b03969096166060850152505050608001529392505050565b5f82611c6957634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176105e0576105e0611b8956fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220573691ca3f116057394b7e1894aec29ca62463eb788b1685d9e5956e2a7ee6ad64736f6c63430008190033
|
/**
_---~~(~~-_.
_{ ) )
, ) -~~- ( ,-' )_
( `-,_..`., )-- '_,)
( ` _) ( -~( -_ `, }
(_- _ ~_-~~~~`, ,' )
`~ -^( __;-,((()))
~~~~ {_ -_(())
`\ }
{ }
Advanced Smart Contract Scanner tailored for all EVM Networks
Socials:
https://t.me/AISCANIQ
https://aiscaniq.com/
https://twitter.com/aiscaniq
https://ai-scan-iq.gitbook.io/ai-scan-iq
*/
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.25;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
}
contract AI_SCAN_IQ is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = unicode"AI-Scan-IQ";
string private constant _symbol = unicode"ASIQ";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 300000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 25;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 45;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0x5e647F6027800dCe1F93b8a09FF8B8ee78f91334);
address payable private _marketingAddress = payable(0x5e647F6027800dCe1F93b8a09FF8B8ee78f91334);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen = false;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 6000000 * 10**9;
uint256 public _maxWalletSize = 6000000 * 10**9;
uint256 public _swapTokensAtAmount = 3000000 * 10**9;
event MaxTxAmountUpdate(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function tokenFromReflection(uint256 rAmount)
private
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function ToggleSwapBack() private {
if (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function openTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSwapBack() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function Isbot(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unlock(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) ToggleSwapBack();
_transferStandard(sender, recipient, amount);
if (!takeFee) ToggleSwapBack();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tTeam
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(
uint256 tAmount,
uint256 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tTeam,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setFees(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function MinSwapTokenThresh(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function MaxTxAmmount(uint256 maxTxAmount) public onlyOwner {
_maxTxAmount = maxTxAmount;
}
function MaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeAccountFromFee(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
}
|
1 | 19,500,381 |
8b4ff5d8921fd11a13868d5c037beff0d201bddadf0a099dd0db1723b0e6c29d
|
b95ff5a9b7bbd99622efcba9172050264e9ef1f88507050ba639d04a56329e01
|
5e647f6027800dce1f93b8a09ff8b8ee78f91334
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
5b6c47d8bf9d641beeab7f8914c6322b32bbcd72
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
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;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,500,383 |
b72e7ddc0434e72666aceb338543827905d2486a15f154fd87aeefc1d3d9d114
|
a781dc5014effe4cc88cabec3507fde749491e0208d5cfd556bb8966162d38bf
|
099b1d292689be58f498f127f4e08fe4f0969bce
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
aeaea153f978e3aec85a092f0ea41da68a21338d
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,500,386 |
929387f3cbfd6a5bfb14b9a13674e655f6b0ce663034030632b9675064863065
|
5b1fd5b5751876e5d7a8066e0b4a548c0bdb09069940ae5397844851333117b0
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
f80ec34dd63a86f23d2e584832a98b1a80153732
|
6080604052348015600f57600080fd5b50604051610211380380610211833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b61017b806100966000396000f3fe60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c634300081900330000000000000000000000008906668094934bbfd0f787010fac65d8438019f5
|
60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c63430008190033
| |
1 | 19,500,388 |
684249a67c201e729f2e88d4c86fa25dee9be950780672d147ba21fb1c0b1a98
|
77c25f298b828c15ca613c9d9ebb3fe0b8d771085f771a6a76934d4ef029b2dc
|
5a99d93c67453db9465a194eebdffdba4b8c7cfe
|
5a99d93c67453db9465a194eebdffdba4b8c7cfe
|
fe0bc0fb975822037511afc91a4b2f620b3b2321
|
6080604052348015600e575f80fd5b5061014e8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c806313bdfacd1461002d575b5f80fd5b61003561004b565b60405161004291906100f8565b60405180910390f35b60606040518060400160405280600c81526020017f48656c6c6f20576f726c64210000000000000000000000000000000000000000815250905090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6100ca82610088565b6100d48185610092565b93506100e48185602086016100a2565b6100ed816100b0565b840191505092915050565b5f6020820190508181035f83015261011081846100c0565b90509291505056fea2646970667358221220f547b39c1ac7ab00ddd4bcf1b194a40ea7069ecae4ebc5a680097b5072ac06d864736f6c63430008190033
|
608060405234801561000f575f80fd5b5060043610610029575f3560e01c806313bdfacd1461002d575b5f80fd5b61003561004b565b60405161004291906100f8565b60405180910390f35b60606040518060400160405280600c81526020017f48656c6c6f20576f726c64210000000000000000000000000000000000000000815250905090565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6100ca82610088565b6100d48185610092565b93506100e48185602086016100a2565b6100ed816100b0565b840191505092915050565b5f6020820190508181035f83015261011081846100c0565b90509291505056fea2646970667358221220f547b39c1ac7ab00ddd4bcf1b194a40ea7069ecae4ebc5a680097b5072ac06d864736f6c63430008190033
| |
1 | 19,500,398 |
16d8adce2d1929b2990ab8dbd352af30d031d225b260d6aaac7b0dde7077d4ee
|
1c698b0658f572408d4aefea7f528e2fb5df5ae16ce7ea3c9a7566cf7d2a7d09
|
c9aad2fc90eddacf02bd11fa690e3b44e318aa9b
|
a2a1bf5a83f9daec2dc364e1c561e937163cb613
|
833e6222ac021a28499be40e9c7c61ff7feb8ef0
|
3d602d80600a3d3981f3363d3d373d3d3d363d7387ae9be718aa310323042ab9806bd6692c1129b75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7387ae9be718aa310323042ab9806bd6692c1129b75af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,408 |
59fd4d6dc133aba04f1c8a64aaf40afb75b84a292d90b2937da97e95f278fcd5
|
2449f26d90edf3d5eadfc287c777c5f110233ea519f7f1854e8ab81b940e2870
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
fb21a64b53fc0120745ab6d80b9fbdf8cf85cced
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,408 |
59fd4d6dc133aba04f1c8a64aaf40afb75b84a292d90b2937da97e95f278fcd5
|
11178ba6cc3242b4357629cfc7b1be107178e55456544651ee2041b81506142e
|
af2c39ec335c6f0b94d29e66b528fa33a2665cac
|
6a6b56992c66889d4e32638ac48d15f95401f10b
|
03f8dd6292ec717f68f204b47d4e943b740ec0ca
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,411 |
adfcd95a5f3ed6f577658c0740cf32a78f825ec33935d992c95ccbd5034c4c5f
|
86af5e807e02b2d7cc0b0f5c1b2c92f59db083a89275cf42f4efe6a2db895501
|
6ed52cd67b57701b6cea9a490b2c5e9c607b85de
|
6ed52cd67b57701b6cea9a490b2c5e9c607b85de
|
6c51ddb8c6208e8cf68d6c35d95b35c76fb2058f
|
6080604052670de0b6b3a764000060025566b1a2bc2ec500006003556004805460ff191690557f6e75382374384e10a7b62f623d7c7f0e930d8963184340038f9af9ceb8d8c0086007557f6e75382374384e10a7b62f6258695b72d88efc120a7f2e072a8611889b2c2b0c6008557f6e75382374384e10a7b62f6275685a1a7ba2ec89d03aaf46ee28682d66a044bc60095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103678061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea264697066735822122025a4760fc91e9b553f8a5e1e0dcb2b4bfbb7259dbf8f547193f1393d756c6b1064736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea264697066735822122025a4760fc91e9b553f8a5e1e0dcb2b4bfbb7259dbf8f547193f1393d756c6b1064736f6c63430008070033
| |
1 | 19,500,412 |
195674bd5f282ef0d9ae1cc01a892e20e521e23a431bdd5b1f1cf9a080a48b0b
|
8f864272dccd67957d33f342a2910af8dd7dcd73e12ea02fcb1948b81583690f
|
129750a798e455bfdf7af30ac6bfa023e7e712ab
|
129750a798e455bfdf7af30ac6bfa023e7e712ab
|
720b635763e318922aefb647e3ded9d74b1109bd
|
60806040526032600655603260075560146009556014600a556001600b556001600c556014600d556014600e556014600f555f6010556009600a6200004591906200036e565b62000054906298968062000385565b601155620000656009600a6200036e565b620000749062e4e1c062000385565b601255620000856009600a6200036e565b6200009490620f424062000385565b601355620000a56009600a6200036e565b620000b4906298968062000385565b6014556016805461ffff60a81b19169055348015620000d1575f80fd5b505f80546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600480546001600160a01b03199081167336bde5c523a5029e152b52f8a85df195be70a4f9179091556005805490911673957a4914fd57edecd2fc771867f32308abf3a887179055620001686009600a6200036e565b6200017890633b9aca0062000385565b335f908152600160208190526040822092909255600390620001a15f546001600160a01b031690565b6001600160a01b03908116825260208083019390935260409182015f908120805495151560ff199687161790553081526003909352818320805485166001908117909155600454909116835291208054909216179055620001ff3390565b6001600160a01b03165f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef620002386009600a6200036e565b6200024890633b9aca0062000385565b60405190815260200160405180910390a36200039f565b634e487b7160e01b5f52601160045260245ffd5b600181815b80851115620002b357815f19048211156200029757620002976200025f565b80851615620002a557918102915b93841c939080029062000278565b509250929050565b5f82620002cb5750600162000368565b81620002d957505f62000368565b8160018114620002f25760028114620002fd576200031d565b600191505062000368565b60ff8411156200031157620003116200025f565b50506001821b62000368565b5060208310610133831016604e8410600b841016171562000342575081810a62000368565b6200034e838362000273565b805f19048211156200036457620003646200025f565b0290505b92915050565b5f6200037e60ff841683620002bb565b9392505050565b80820281158282048414176200036857620003686200025f565b6119fb80620003ad5f395ff3fe60806040526004361061011e575f3560e01c806377b54bad1161009d578063a9059cbb11610062578063a9059cbb146102e6578063bf474bed14610305578063c9567bf91461031a578063dd62ed3e1461032e578063f429389014610372575f80fd5b806377b54bad146102775780637d1db4a5146102965780638da5cb5b146102ab5780638f9a55c0146102d157806395d89b4114610129575f80fd5b8063313ce567116100e3578063313ce567146101ea57806351bc3c851461020557806370a082311461021b578063715018a61461024f578063751039fc14610263575f80fd5b806306fdde0314610129578063095ea7b3146101655780630faee56f1461019457806318160ddd146101b757806323b872dd146101cb575f80fd5b3661012557005b5f80fd5b348015610134575f80fd5b5060408051808201825260058152640454c554d560dc1b6020820152905161015c91906115d7565b60405180910390f35b348015610170575f80fd5b5061018461017f366004611639565b610386565b604051901515815260200161015c565b34801561019f575f80fd5b506101a960145481565b60405190815260200161015c565b3480156101c2575f80fd5b506101a961039c565b3480156101d6575f80fd5b506101846101e5366004611663565b6103bc565b3480156101f5575f80fd5b506040516009815260200161015c565b348015610210575f80fd5b50610219610423565b005b348015610226575f80fd5b506101a96102353660046116a1565b6001600160a01b03165f9081526001602052604090205490565b34801561025a575f80fd5b50610219610455565b34801561026e575f80fd5b506102196104cf565b348015610282575f80fd5b50610184610291366004611639565b610580565b3480156102a1575f80fd5b506101a960115481565b3480156102b6575f80fd5b505f546040516001600160a01b03909116815260200161015c565b3480156102dc575f80fd5b506101a960125481565b3480156102f1575f80fd5b50610184610300366004611639565b6106b0565b348015610310575f80fd5b506101a960135481565b348015610325575f80fd5b506102196106bc565b348015610339575f80fd5b506101a96103483660046116bc565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b34801561037d575f80fd5b50610219610a69565b5f610392338484610b02565b5060015b92915050565b5f6103a96009600a6117e7565b6103b790633b9aca006117f5565b905090565b5f6103c8848484610c25565b61041984336104148560405180606001604052806028815260200161199e602891396001600160a01b038a165f90815260026020908152604080832033845290915290205491906111e3565b610b02565b5060019392505050565b305f908152600160205260409020548015610441576104418161121b565b478015610451576104518161138b565b5050565b5f546001600160a01b031633146104875760405162461bcd60e51b815260040161047e9061180c565b60405180910390fd5b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b031633146104f85760405162461bcd60e51b815260040161047e9061180c565b6105046009600a6117e7565b61051290633b9aca006117f5565b6011556105216009600a6117e7565b61052f90633b9aca006117f5565b6012557f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf61055f6009600a6117e7565b61056d90633b9aca006117f5565b60405190815260200160405180910390a1565b5f815f036105f1576040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa1580156105ca573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ee9190611841565b91505b604080516001600160a01b0385168152602081018490527fda2bc2bedd1f85b5a59d5dbbd6684ff877ef916994a16ec08813101e99ace65f910160405180910390a16004805460405163a9059cbb60e01b81526001600160a01b03918216928101929092526024820184905284169063a9059cbb906044016020604051808303815f875af1158015610685573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106a99190611858565b9392505050565b5f610392338484610c25565b5f546001600160a01b031633146106e55760405162461bcd60e51b815260040161047e9061180c565b601654600160a01b900460ff161561073f5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161047e565b601580546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d90811790915561078890309061077a6009600a6117e7565b61041490633b9aca006117f5565b60155f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107fc9190611877565b6001600160a01b031663c9c653963060155f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561085b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061087f9190611877565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af11580156108c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108ed9190611877565b601680546001600160a01b039283166001600160a01b03199091161790556015541663f305d7194730610934816001600160a01b03165f9081526001602052604090205490565b5f806109475f546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156109ad573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906109d29190611892565b505060165460155460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af1158015610a27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4b9190611858565b506016805462ff00ff60a01b19166201000160a01b17905543600855565b5f4711610acb5760405162461bcd60e51b815260206004820152602a60248201527f436f6e74726163742062616c616e6365206d7573742062652067726561746572604482015269207468616e207a65726f60b01b606482015260840161047e565b60045460405147916001600160a01b03169082156108fc029083905f818181858888f19350505050158015610451573d5f803e3d5ffd5b6001600160a01b038316610b645760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161047e565b6001600160a01b038216610bc55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161047e565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c895760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161047e565b6001600160a01b038216610ceb5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161047e565b5f8111610d4c5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161047e565b5f80546001600160a01b03858116911614801590610d7757505f546001600160a01b03848116911614155b156110a657610da86064610da2600d5460105411610d9757600954610d9b565b600b545b8590611439565b906114b7565b6016549091506001600160a01b038581169116148015610dd657506015546001600160a01b03848116911614155b8015610dfa57506001600160a01b0383165f9081526003602052604090205460ff16155b15610f0157601154821115610e515760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e00000000000000604482015260640161047e565b60125482610e73856001600160a01b03165f9081526001602052604090205490565b610e7d91906118bd565b1115610ecb5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e000000000000604482015260640161047e565b436008546003610edb91906118bd565b1115610eec57823b15610eec575f80fd5b60108054905f610efb836118d0565b91905055505b6016546001600160a01b03848116911614801590610f3757506001600160a01b0383165f9081526003602052604090205460ff16155b15610fb65760125482610f5e856001600160a01b03165f9081526001602052604090205490565b610f6891906118bd565b1115610fb65760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e000000000000604482015260640161047e565b6016546001600160a01b038481169116148015610fdc57506001600160a01b0384163014155b15611009576110066064610da2600e5460105411610ffc57600a54610d9b565b600c548590611439565b90505b305f90815260016020526040902054601654600160a81b900460ff1615801561103f57506016546001600160a01b038581169116145b80156110545750601654600160b01b900460ff165b8015611061575060135481115b80156110705750600f54601054115b156110a45761109261108d84611088846014546114f8565b6114f8565b61121b565b4780156110a2576110a24761138b565b505b505b801561111e57305f908152600160205260409020546110c5908261150c565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906111159085815260200190565b60405180910390a35b6001600160a01b0384165f90815260016020526040902054611140908361156a565b6001600160a01b0385165f90815260016020526040902055611183611165838361156a565b6001600160a01b0385165f908152600160205260409020549061150c565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6111cc858561156a565b60405190815260200160405180910390a350505050565b5f81848411156112065760405162461bcd60e51b815260040161047e91906115d7565b505f61121284866118e8565b95945050505050565b6016805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f81518110611261576112616118fb565b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156112b8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112dc9190611877565b816001815181106112ef576112ef6118fb565b6001600160a01b0392831660209182029290920101526015546113159130911684610b02565b60155460405163791ac94760e01b81526001600160a01b039091169063791ac9479061134d9085905f9086903090429060040161190f565b5f604051808303815f87803b158015611364575f80fd5b505af1158015611376573d5f803e3d5ffd5b50506016805460ff60a81b1916905550505050565b5f60646006548361139c91906117f5565b6113a6919061197e565b90505f6064600754846113b991906117f5565b6113c3919061197e565b6004546040519192506001600160a01b03169083156108fc029084905f818181858888f193505050501580156113fb573d5f803e3d5ffd5b506005546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015611433573d5f803e3d5ffd5b50505050565b5f825f0361144857505f610396565b5f61145383856117f5565b905082611460858361197e565b146106a95760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161047e565b5f6106a983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115ab565b5f81831161150657826106a9565b50919050565b5f8061151883856118bd565b9050838110156106a95760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161047e565b5f6106a983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111e3565b5f81836115cb5760405162461bcd60e51b815260040161047e91906115d7565b505f611212848661197e565b5f6020808352835180828501525f5b81811015611602578581018301518582016040015282016115e6565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114611636575f80fd5b50565b5f806040838503121561164a575f80fd5b823561165581611622565b946020939093013593505050565b5f805f60608486031215611675575f80fd5b833561168081611622565b9250602084013561169081611622565b929592945050506040919091013590565b5f602082840312156116b1575f80fd5b81356106a981611622565b5f80604083850312156116cd575f80fd5b82356116d881611622565b915060208301356116e881611622565b809150509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561174157815f1904821115611727576117276116f3565b8085161561173457918102915b93841c939080029061170c565b509250929050565b5f8261175757506001610396565b8161176357505f610396565b816001811461177957600281146117835761179f565b6001915050610396565b60ff841115611794576117946116f3565b50506001821b610396565b5060208310610133831016604e8410600b84101617156117c2575081810a610396565b6117cc8383611707565b805f19048211156117df576117df6116f3565b029392505050565b5f6106a960ff841683611749565b8082028115828204841417610396576103966116f3565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b5f60208284031215611851575f80fd5b5051919050565b5f60208284031215611868575f80fd5b815180151581146106a9575f80fd5b5f60208284031215611887575f80fd5b81516106a981611622565b5f805f606084860312156118a4575f80fd5b8351925060208401519150604084015190509250925092565b80820180821115610396576103966116f3565b5f600182016118e1576118e16116f3565b5060010190565b81810381811115610396576103966116f3565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b8181101561195d5784516001600160a01b031683529383019391830191600101611938565b50506001600160a01b03969096166060850152505050608001529392505050565b5f8261199857634e487b7160e01b5f52601260045260245ffd5b50049056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122053f112252a0dae376dfbdd817f7db6f90bd24ecca98b6fe535bd0efd1c9221a664736f6c63430008140033
|
60806040526004361061011e575f3560e01c806377b54bad1161009d578063a9059cbb11610062578063a9059cbb146102e6578063bf474bed14610305578063c9567bf91461031a578063dd62ed3e1461032e578063f429389014610372575f80fd5b806377b54bad146102775780637d1db4a5146102965780638da5cb5b146102ab5780638f9a55c0146102d157806395d89b4114610129575f80fd5b8063313ce567116100e3578063313ce567146101ea57806351bc3c851461020557806370a082311461021b578063715018a61461024f578063751039fc14610263575f80fd5b806306fdde0314610129578063095ea7b3146101655780630faee56f1461019457806318160ddd146101b757806323b872dd146101cb575f80fd5b3661012557005b5f80fd5b348015610134575f80fd5b5060408051808201825260058152640454c554d560dc1b6020820152905161015c91906115d7565b60405180910390f35b348015610170575f80fd5b5061018461017f366004611639565b610386565b604051901515815260200161015c565b34801561019f575f80fd5b506101a960145481565b60405190815260200161015c565b3480156101c2575f80fd5b506101a961039c565b3480156101d6575f80fd5b506101846101e5366004611663565b6103bc565b3480156101f5575f80fd5b506040516009815260200161015c565b348015610210575f80fd5b50610219610423565b005b348015610226575f80fd5b506101a96102353660046116a1565b6001600160a01b03165f9081526001602052604090205490565b34801561025a575f80fd5b50610219610455565b34801561026e575f80fd5b506102196104cf565b348015610282575f80fd5b50610184610291366004611639565b610580565b3480156102a1575f80fd5b506101a960115481565b3480156102b6575f80fd5b505f546040516001600160a01b03909116815260200161015c565b3480156102dc575f80fd5b506101a960125481565b3480156102f1575f80fd5b50610184610300366004611639565b6106b0565b348015610310575f80fd5b506101a960135481565b348015610325575f80fd5b506102196106bc565b348015610339575f80fd5b506101a96103483660046116bc565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b34801561037d575f80fd5b50610219610a69565b5f610392338484610b02565b5060015b92915050565b5f6103a96009600a6117e7565b6103b790633b9aca006117f5565b905090565b5f6103c8848484610c25565b61041984336104148560405180606001604052806028815260200161199e602891396001600160a01b038a165f90815260026020908152604080832033845290915290205491906111e3565b610b02565b5060019392505050565b305f908152600160205260409020548015610441576104418161121b565b478015610451576104518161138b565b5050565b5f546001600160a01b031633146104875760405162461bcd60e51b815260040161047e9061180c565b60405180910390fd5b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f546001600160a01b031633146104f85760405162461bcd60e51b815260040161047e9061180c565b6105046009600a6117e7565b61051290633b9aca006117f5565b6011556105216009600a6117e7565b61052f90633b9aca006117f5565b6012557f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf61055f6009600a6117e7565b61056d90633b9aca006117f5565b60405190815260200160405180910390a1565b5f815f036105f1576040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa1580156105ca573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ee9190611841565b91505b604080516001600160a01b0385168152602081018490527fda2bc2bedd1f85b5a59d5dbbd6684ff877ef916994a16ec08813101e99ace65f910160405180910390a16004805460405163a9059cbb60e01b81526001600160a01b03918216928101929092526024820184905284169063a9059cbb906044016020604051808303815f875af1158015610685573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106a99190611858565b9392505050565b5f610392338484610c25565b5f546001600160a01b031633146106e55760405162461bcd60e51b815260040161047e9061180c565b601654600160a01b900460ff161561073f5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161047e565b601580546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d90811790915561078890309061077a6009600a6117e7565b61041490633b9aca006117f5565b60155f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107d8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107fc9190611877565b6001600160a01b031663c9c653963060155f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561085b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061087f9190611877565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af11580156108c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108ed9190611877565b601680546001600160a01b039283166001600160a01b03199091161790556015541663f305d7194730610934816001600160a01b03165f9081526001602052604090205490565b5f806109475f546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156109ad573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906109d29190611892565b505060165460155460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af1158015610a27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4b9190611858565b506016805462ff00ff60a01b19166201000160a01b17905543600855565b5f4711610acb5760405162461bcd60e51b815260206004820152602a60248201527f436f6e74726163742062616c616e6365206d7573742062652067726561746572604482015269207468616e207a65726f60b01b606482015260840161047e565b60045460405147916001600160a01b03169082156108fc029083905f818181858888f19350505050158015610451573d5f803e3d5ffd5b6001600160a01b038316610b645760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161047e565b6001600160a01b038216610bc55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161047e565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c895760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161047e565b6001600160a01b038216610ceb5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161047e565b5f8111610d4c5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161047e565b5f80546001600160a01b03858116911614801590610d7757505f546001600160a01b03848116911614155b156110a657610da86064610da2600d5460105411610d9757600954610d9b565b600b545b8590611439565b906114b7565b6016549091506001600160a01b038581169116148015610dd657506015546001600160a01b03848116911614155b8015610dfa57506001600160a01b0383165f9081526003602052604090205460ff16155b15610f0157601154821115610e515760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e00000000000000604482015260640161047e565b60125482610e73856001600160a01b03165f9081526001602052604090205490565b610e7d91906118bd565b1115610ecb5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e000000000000604482015260640161047e565b436008546003610edb91906118bd565b1115610eec57823b15610eec575f80fd5b60108054905f610efb836118d0565b91905055505b6016546001600160a01b03848116911614801590610f3757506001600160a01b0383165f9081526003602052604090205460ff16155b15610fb65760125482610f5e856001600160a01b03165f9081526001602052604090205490565b610f6891906118bd565b1115610fb65760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e000000000000604482015260640161047e565b6016546001600160a01b038481169116148015610fdc57506001600160a01b0384163014155b15611009576110066064610da2600e5460105411610ffc57600a54610d9b565b600c548590611439565b90505b305f90815260016020526040902054601654600160a81b900460ff1615801561103f57506016546001600160a01b038581169116145b80156110545750601654600160b01b900460ff165b8015611061575060135481115b80156110705750600f54601054115b156110a45761109261108d84611088846014546114f8565b6114f8565b61121b565b4780156110a2576110a24761138b565b505b505b801561111e57305f908152600160205260409020546110c5908261150c565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906111159085815260200190565b60405180910390a35b6001600160a01b0384165f90815260016020526040902054611140908361156a565b6001600160a01b0385165f90815260016020526040902055611183611165838361156a565b6001600160a01b0385165f908152600160205260409020549061150c565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6111cc858561156a565b60405190815260200160405180910390a350505050565b5f81848411156112065760405162461bcd60e51b815260040161047e91906115d7565b505f61121284866118e8565b95945050505050565b6016805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f81518110611261576112616118fb565b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156112b8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112dc9190611877565b816001815181106112ef576112ef6118fb565b6001600160a01b0392831660209182029290920101526015546113159130911684610b02565b60155460405163791ac94760e01b81526001600160a01b039091169063791ac9479061134d9085905f9086903090429060040161190f565b5f604051808303815f87803b158015611364575f80fd5b505af1158015611376573d5f803e3d5ffd5b50506016805460ff60a81b1916905550505050565b5f60646006548361139c91906117f5565b6113a6919061197e565b90505f6064600754846113b991906117f5565b6113c3919061197e565b6004546040519192506001600160a01b03169083156108fc029084905f818181858888f193505050501580156113fb573d5f803e3d5ffd5b506005546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015611433573d5f803e3d5ffd5b50505050565b5f825f0361144857505f610396565b5f61145383856117f5565b905082611460858361197e565b146106a95760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161047e565b5f6106a983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506115ab565b5f81831161150657826106a9565b50919050565b5f8061151883856118bd565b9050838110156106a95760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161047e565b5f6106a983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111e3565b5f81836115cb5760405162461bcd60e51b815260040161047e91906115d7565b505f611212848661197e565b5f6020808352835180828501525f5b81811015611602578581018301518582016040015282016115e6565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114611636575f80fd5b50565b5f806040838503121561164a575f80fd5b823561165581611622565b946020939093013593505050565b5f805f60608486031215611675575f80fd5b833561168081611622565b9250602084013561169081611622565b929592945050506040919091013590565b5f602082840312156116b1575f80fd5b81356106a981611622565b5f80604083850312156116cd575f80fd5b82356116d881611622565b915060208301356116e881611622565b809150509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561174157815f1904821115611727576117276116f3565b8085161561173457918102915b93841c939080029061170c565b509250929050565b5f8261175757506001610396565b8161176357505f610396565b816001811461177957600281146117835761179f565b6001915050610396565b60ff841115611794576117946116f3565b50506001821b610396565b5060208310610133831016604e8410600b84101617156117c2575081810a610396565b6117cc8383611707565b805f19048211156117df576117df6116f3565b029392505050565b5f6106a960ff841683611749565b8082028115828204841417610396576103966116f3565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b5f60208284031215611851575f80fd5b5051919050565b5f60208284031215611868575f80fd5b815180151581146106a9575f80fd5b5f60208284031215611887575f80fd5b81516106a981611622565b5f805f606084860312156118a4575f80fd5b8351925060208401519150604084015190509250925092565b80820180821115610396576103966116f3565b5f600182016118e1576118e16116f3565b5060010190565b81810381811115610396576103966116f3565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b8181101561195d5784516001600160a01b031683529383019391830191600101611938565b50506001600160a01b03969096166060850152505050608001529392505050565b5f8261199857634e487b7160e01b5f52601260045260245ffd5b50049056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122053f112252a0dae376dfbdd817f7db6f90bd24ecca98b6fe535bd0efd1c9221a664736f6c63430008140033
|
/**
*Submitted for verification at Etherscan.io on 2024-03-24
*/
// SPDX-License-Identifier: MIT
/**
Website: https://elumpcoin.com/
Telegram: https://t.me/ELUMPcoin
Twitter: https://twitter.com/ELUMPcoin
*/
pragma solidity 0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract ELUMP is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
address payable private _marketingWallet;
address payable private _burnWallet;
uint256 private _marketingWalletPercentage = 50;
uint256 private _burnWalletPercentage = 50;
uint256 firstBlock;
uint256 private _initialBuyTax=20;
uint256 private _initialSellTax=20;
uint256 private _finalBuyTax=1;
uint256 private _finalSellTax=1;
uint256 private _reduceBuyTaxAt=20;
uint256 private _reduceSellTaxAt=20;
uint256 private _preventSwapBefore=20;
uint256 private _buyCount=0;
uint8 private constant _decimals = 9;
uint256 private constant _tTotal = 1000000000 * 10**_decimals;
string private constant _name = unicode"ELUMP";
string private constant _symbol = unicode"ELUMP";
uint256 public _maxTxAmount = 10000000 * 10**_decimals;
uint256 public _maxWalletSize = 15000000 * 10**_decimals;
uint256 public _taxSwapThreshold= 1000000 * 10**_decimals;
uint256 public _maxTaxSwap= 10000000 * 10**_decimals;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
event MaxTxAmountUpdated(uint _maxTxAmount);
event ClearStuck(uint256 amount);
event ClearToken(address TokenAddressCleared, uint256 Amount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_marketingWallet = payable(0x36bDE5C523A5029E152b52f8A85df195be70a4f9);
_burnWallet = payable(0x957a4914fd57edECD2Fc771867F32308AbF3a887);
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_marketingWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
uint256 taxAmount=0;
if (from != owner() && to != owner()) {
taxAmount = amount.mul((_buyCount>_reduceBuyTaxAt)?_finalBuyTax:_initialBuyTax).div(100);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] ) {
require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
if (firstBlock + 3 > block.number) {
require(!isContract(to));
}
_buyCount++;
}
if (to != uniswapV2Pair && ! _isExcludedFromFee[to]) {
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
}
if(to == uniswapV2Pair && from!= address(this) ){
taxAmount = amount.mul((_buyCount>_reduceSellTaxAt)?_finalSellTax:_initialSellTax).div(100);
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && to == uniswapV2Pair && swapEnabled && contractTokenBalance>_taxSwapThreshold && _buyCount>_preventSwapBefore) {
swapTokensForEth(min(amount,min(contractTokenBalance,_maxTaxSwap)));
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
if(taxAmount>0){
_balances[address(this)]=_balances[address(this)].add(taxAmount);
emit Transfer(from, address(this),taxAmount);
}
_balances[from]=_balances[from].sub(amount);
_balances[to]=_balances[to].add(amount.sub(taxAmount));
emit Transfer(from, to, amount.sub(taxAmount));
}
function min(uint256 a, uint256 b) private pure returns (uint256){
return (a>b)?b:a;
}
function isContract(address account) private view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function removeLimits() external onlyOwner{
_maxTxAmount = _tTotal;
_maxWalletSize=_tTotal;
emit MaxTxAmountUpdated(_tTotal);
}
function sendETHToFee(uint256 amount) private {
uint256 marketingWalletShare = amount * _marketingWalletPercentage / 100;
uint256 burnWalletShare = amount * _burnWalletPercentage / 100;
_marketingWallet.transfer(marketingWalletShare);
_burnWallet.transfer(burnWalletShare);
}
function clearStuckToken(address tokenAddress, uint256 tokens) external returns (bool success) {
if(tokens == 0){
tokens = IERC20(tokenAddress).balanceOf(address(this));
}
emit ClearToken(tokenAddress, tokens);
return IERC20(tokenAddress).transfer(_marketingWallet, tokens);
}
function manualSend() external {
require(address(this).balance > 0, "Contract balance must be greater than zero");
uint256 balance = address(this).balance;
payable(_marketingWallet).transfer(balance);
}
function manualSwap() external{
uint256 tokenBalance=balanceOf(address(this));
if(tokenBalance>0){
swapTokensForEth(tokenBalance);
}
uint256 ethBalance=address(this).balance;
if(ethBalance>0){
sendETHToFee(ethBalance);
}
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
swapEnabled = true;
tradingOpen = true;
firstBlock = block.number;
}
receive() external payable {}
}
|
1 | 19,500,412 |
195674bd5f282ef0d9ae1cc01a892e20e521e23a431bdd5b1f1cf9a080a48b0b
|
f7b8ac6ac258422b5b3d31138f7f175f009c15fabfc7de03d893efa5d8b65faf
|
05730e3f1b50122d377bb2683cf7d7a665b7b8af
|
05730e3f1b50122d377bb2683cf7d7a665b7b8af
|
ad71b946a63679de16f92e5340139d23ce095b58
|
608060405234801561001057600080fd5b5033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610aaa806100616000396000f3fe60806040526004361061004e5760003560e01c80631b55ba3a1461005a57806370e44c6a146100715780638da5cb5b1461010157806395d89b4114610158578063bedf0f4a146101e857610055565b3661005557005b600080fd5b34801561006657600080fd5b5061006f6101ff565b005b34801561007d57600080fd5b5061008661026a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100c65780820151818401526020810190506100ab565b50505050905090810190601f1680156100f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010d57600080fd5b50610116610472565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016457600080fd5b5061016d610498565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ad578082015181840152602081019050610192565b50505050905090810190601f1680156101da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f457600080fd5b506101fd610516565b005b600061021161020c610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc61023a610978565b9081150290604051600060405180830381858888f19350505050158015610265573d6000803e3d6000fd5b505050565b6060600061027e610279610581565b61071f565b90506000819050606061028f610980565b9050606061029b6109bd565b905060606102a76109fa565b905060606102b3610a37565b90508473ffffffffffffffffffffffffffffffffffffffff166108fc6102d7610978565b9081150290604051600060405180830381858888f19350505050158015610302573d6000803e3d6000fd5b50838383836040516020018085805190602001908083835b6020831061033d578051825260208201915060208101905060208303925061031a565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061038e578051825260208201915060208101905060208303925061036b565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083106103df57805182526020820191506020810190506020830392506103bc565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310610430578051825260208201915060208101905060208303925061040d565b6001836020036101000a038019825116818451168082178552505050505050905001945050505050604051602081830303815290604052965050505050505090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060806104a36109bd565b9050806040516020018082805190602001908083835b602083106104dc57805182526020820191506020810190506020830392506104b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405291505090565b6000610528610523610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc610551610978565b9081150290604051600060405180830381858888f1935050505015801561057c573d6000803e3d6000fd5b505050565b60608061058c610980565b905060606105986109bd565b905060606105a46109fa565b905060606105b0610a37565b9050838383836040516020018085805190602001908083835b602083106105ec57805182526020820191506020810190506020830392506105c9565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061063d578051825260208201915060208101905060208303925061061a565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b6020831061068e578051825260208201915060208101905060208303925061066b565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106106df57805182526020820191506020810190506020830392506106bc565b6001836020036101000a03801982511681845116808217855250505050505090500194505050505060405160208183030381529060405294505050505090565b6000606082905060008090506000806000600290505b602a81101561096b576101008402935084818151811061075157fe5b602001015160f81c60f81b60f81c60ff16925084600182018151811061077357fe5b602001015160f81c60f81b60f81c60ff16915060618373ffffffffffffffffffffffffffffffffffffffff16101580156107c4575060668373ffffffffffffffffffffffffffffffffffffffff1611155b156107d45760578303925061086e565b60418373ffffffffffffffffffffffffffffffffffffffff1610158015610812575060468373ffffffffffffffffffffffffffffffffffffffff1611155b156108225760378303925061086d565b60308373ffffffffffffffffffffffffffffffffffffffff1610158015610860575060398373ffffffffffffffffffffffffffffffffffffffff1611155b1561086c576030830392505b5b5b60618273ffffffffffffffffffffffffffffffffffffffff16101580156108ac575060668273ffffffffffffffffffffffffffffffffffffffff1611155b156108bc57605782039150610956565b60418273ffffffffffffffffffffffffffffffffffffffff16101580156108fa575060468273ffffffffffffffffffffffffffffffffffffffff1611155b1561090a57603782039150610955565b60308273ffffffffffffffffffffffffffffffffffffffff1610158015610948575060398273ffffffffffffffffffffffffffffffffffffffff1611155b15610954576030820391505b5b5b81601084020184019350600281019050610735565b5082945050505050919050565b600047905090565b60606040518060400160405280600381526020017f3078460000000000000000000000000000000000000000000000000000000000815250905090565b60606040518060400160405280601081526020017f3364343734383530353341613934324100000000000000000000000000000000815250905090565b60606040518060400160405280600e81526020017f3536453641303742353545316662000000000000000000000000000000000000815250905090565b60606040518060400160405280600981526020017f323638383539363737000000000000000000000000000000000000000000000081525090509056fea2646970667358221220460031f2372d6c6e746275cc55de4630c6c439c13ca8c1673998ee4460d1c51764736f6c63430006060033
|
60806040526004361061004e5760003560e01c80631b55ba3a1461005a57806370e44c6a146100715780638da5cb5b1461010157806395d89b4114610158578063bedf0f4a146101e857610055565b3661005557005b600080fd5b34801561006657600080fd5b5061006f6101ff565b005b34801561007d57600080fd5b5061008661026a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100c65780820151818401526020810190506100ab565b50505050905090810190601f1680156100f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010d57600080fd5b50610116610472565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016457600080fd5b5061016d610498565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ad578082015181840152602081019050610192565b50505050905090810190601f1680156101da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f457600080fd5b506101fd610516565b005b600061021161020c610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc61023a610978565b9081150290604051600060405180830381858888f19350505050158015610265573d6000803e3d6000fd5b505050565b6060600061027e610279610581565b61071f565b90506000819050606061028f610980565b9050606061029b6109bd565b905060606102a76109fa565b905060606102b3610a37565b90508473ffffffffffffffffffffffffffffffffffffffff166108fc6102d7610978565b9081150290604051600060405180830381858888f19350505050158015610302573d6000803e3d6000fd5b50838383836040516020018085805190602001908083835b6020831061033d578051825260208201915060208101905060208303925061031a565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061038e578051825260208201915060208101905060208303925061036b565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083106103df57805182526020820191506020810190506020830392506103bc565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310610430578051825260208201915060208101905060208303925061040d565b6001836020036101000a038019825116818451168082178552505050505050905001945050505050604051602081830303815290604052965050505050505090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060806104a36109bd565b9050806040516020018082805190602001908083835b602083106104dc57805182526020820191506020810190506020830392506104b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405291505090565b6000610528610523610581565b61071f565b905060008190508073ffffffffffffffffffffffffffffffffffffffff166108fc610551610978565b9081150290604051600060405180830381858888f1935050505015801561057c573d6000803e3d6000fd5b505050565b60608061058c610980565b905060606105986109bd565b905060606105a46109fa565b905060606105b0610a37565b9050838383836040516020018085805190602001908083835b602083106105ec57805182526020820191506020810190506020830392506105c9565b6001836020036101000a03801982511681845116808217855250505050505090500184805190602001908083835b6020831061063d578051825260208201915060208101905060208303925061061a565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b6020831061068e578051825260208201915060208101905060208303925061066b565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106106df57805182526020820191506020810190506020830392506106bc565b6001836020036101000a03801982511681845116808217855250505050505090500194505050505060405160208183030381529060405294505050505090565b6000606082905060008090506000806000600290505b602a81101561096b576101008402935084818151811061075157fe5b602001015160f81c60f81b60f81c60ff16925084600182018151811061077357fe5b602001015160f81c60f81b60f81c60ff16915060618373ffffffffffffffffffffffffffffffffffffffff16101580156107c4575060668373ffffffffffffffffffffffffffffffffffffffff1611155b156107d45760578303925061086e565b60418373ffffffffffffffffffffffffffffffffffffffff1610158015610812575060468373ffffffffffffffffffffffffffffffffffffffff1611155b156108225760378303925061086d565b60308373ffffffffffffffffffffffffffffffffffffffff1610158015610860575060398373ffffffffffffffffffffffffffffffffffffffff1611155b1561086c576030830392505b5b5b60618273ffffffffffffffffffffffffffffffffffffffff16101580156108ac575060668273ffffffffffffffffffffffffffffffffffffffff1611155b156108bc57605782039150610956565b60418273ffffffffffffffffffffffffffffffffffffffff16101580156108fa575060468273ffffffffffffffffffffffffffffffffffffffff1611155b1561090a57603782039150610955565b60308273ffffffffffffffffffffffffffffffffffffffff1610158015610948575060398273ffffffffffffffffffffffffffffffffffffffff1611155b15610954576030820391505b5b5b81601084020184019350600281019050610735565b5082945050505050919050565b600047905090565b60606040518060400160405280600381526020017f3078460000000000000000000000000000000000000000000000000000000000815250905090565b60606040518060400160405280601081526020017f3364343734383530353341613934324100000000000000000000000000000000815250905090565b60606040518060400160405280600e81526020017f3536453641303742353545316662000000000000000000000000000000000000815250905090565b60606040518060400160405280600981526020017f323638383539363737000000000000000000000000000000000000000000000081525090509056fea2646970667358221220460031f2372d6c6e746275cc55de4630c6c439c13ca8c1673998ee4460d1c51764736f6c63430006060033
| |
1 | 19,500,416 |
cc0103340903f1ab046d59a3e20e22a0d07c8508b472673f9745ba37d43924c1
|
009a5063bd581288c685a166ec05813b5f4507286720bf6d3bf6df047bc49fbd
|
3be70936fcf9d3ecaad5fb41d24613d33efe3d2a
|
d724dbe7e230e400fe7390885e16957ec246d716
|
34a22a786272cdd7953201d69993b3de06f148ac
|
3d602d80600a3d3981f3363d3d373d3d3d363d73cd767be96eb169b1ae089ff03c3f8ebec20535255af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73cd767be96eb169b1ae089ff03c3f8ebec20535255af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/governance/utils/IVotes.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (governance/utils/IVotes.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.\n */\ninterface IVotes {\n /**\n * @dev The signature used has expired.\n */\n error VotesExpiredSignature(uint256 expiry);\n\n /**\n * @dev Emitted when an account changes their delegate.\n */\n event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);\n\n /**\n * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units.\n */\n event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes);\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) external view returns (uint256);\n\n /**\n * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is\n * configured to use block numbers, this will return the value at the end of the corresponding block.\n */\n function getPastVotes(address account, uint256 timepoint) external view returns (uint256);\n\n /**\n * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is\n * configured to use block numbers, this will return the value at the end of the corresponding block.\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n */\n function getPastTotalSupply(uint256 timepoint) external view returns (uint256);\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) external view returns (address);\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) external;\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;\n}\n"
},
"@openzeppelin/contracts/governance/utils/Votes.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (governance/utils/Votes.sol)\npragma solidity ^0.8.20;\n\nimport {IERC5805} from \"../../interfaces/IERC5805.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {Nonces} from \"../../utils/Nonces.sol\";\nimport {EIP712} from \"../../utils/cryptography/EIP712.sol\";\nimport {Checkpoints} from \"../../utils/structs/Checkpoints.sol\";\nimport {SafeCast} from \"../../utils/math/SafeCast.sol\";\nimport {ECDSA} from \"../../utils/cryptography/ECDSA.sol\";\nimport {Time} from \"../../utils/types/Time.sol\";\n\n/**\n * @dev This is a base abstract contract that tracks voting units, which are a measure of voting power that can be\n * transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of\n * \"representative\" that will pool delegated voting units from different accounts and can then use it to vote in\n * decisions. In fact, voting units _must_ be delegated in order to count as actual votes, and an account has to\n * delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative.\n *\n * This contract is often combined with a token contract such that voting units correspond to token units. For an\n * example, see {ERC721Votes}.\n *\n * The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed\n * at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the\n * cost of this history tracking optional.\n *\n * When using this module the derived contract must implement {_getVotingUnits} (for example, make it return\n * {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the\n * previous example, it would be included in {ERC721-_update}).\n */\nabstract contract Votes is Context, EIP712, Nonces, IERC5805 {\n using Checkpoints for Checkpoints.Trace208;\n\n bytes32 private constant DELEGATION_TYPEHASH =\n keccak256(\"Delegation(address delegatee,uint256 nonce,uint256 expiry)\");\n\n mapping(address account => address) private _delegatee;\n\n mapping(address delegatee => Checkpoints.Trace208) private _delegateCheckpoints;\n\n Checkpoints.Trace208 private _totalCheckpoints;\n\n /**\n * @dev The clock was incorrectly modified.\n */\n error ERC6372InconsistentClock();\n\n /**\n * @dev Lookup to future votes is not available.\n */\n error ERC5805FutureLookup(uint256 timepoint, uint48 clock);\n\n /**\n * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based\n * checkpoints (and voting), in which case {CLOCK_MODE} should be overridden as well to match.\n */\n function clock() public view virtual returns (uint48) {\n return Time.blockNumber();\n }\n\n /**\n * @dev Machine-readable description of the clock as specified in EIP-6372.\n */\n // solhint-disable-next-line func-name-mixedcase\n function CLOCK_MODE() public view virtual returns (string memory) {\n // Check that the clock was not modified\n if (clock() != Time.blockNumber()) {\n revert ERC6372InconsistentClock();\n }\n return \"mode=blocknumber&from=default\";\n }\n\n /**\n * @dev Returns the current amount of votes that `account` has.\n */\n function getVotes(address account) public view virtual returns (uint256) {\n return _delegateCheckpoints[account].latest();\n }\n\n /**\n * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is\n * configured to use block numbers, this will return the value at the end of the corresponding block.\n *\n * Requirements:\n *\n * - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.\n */\n function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256) {\n uint48 currentTimepoint = clock();\n if (timepoint >= currentTimepoint) {\n revert ERC5805FutureLookup(timepoint, currentTimepoint);\n }\n return _delegateCheckpoints[account].upperLookupRecent(SafeCast.toUint48(timepoint));\n }\n\n /**\n * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is\n * configured to use block numbers, this will return the value at the end of the corresponding block.\n *\n * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n * vote.\n *\n * Requirements:\n *\n * - `timepoint` must be in the past. If operating using block numbers, the block must be already mined.\n */\n function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256) {\n uint48 currentTimepoint = clock();\n if (timepoint >= currentTimepoint) {\n revert ERC5805FutureLookup(timepoint, currentTimepoint);\n }\n return _totalCheckpoints.upperLookupRecent(SafeCast.toUint48(timepoint));\n }\n\n /**\n * @dev Returns the current total supply of votes.\n */\n function _getTotalSupply() internal view virtual returns (uint256) {\n return _totalCheckpoints.latest();\n }\n\n /**\n * @dev Returns the delegate that `account` has chosen.\n */\n function delegates(address account) public view virtual returns (address) {\n return _delegatee[account];\n }\n\n /**\n * @dev Delegates votes from the sender to `delegatee`.\n */\n function delegate(address delegatee) public virtual {\n address account = _msgSender();\n _delegate(account, delegatee);\n }\n\n /**\n * @dev Delegates votes from signer to `delegatee`.\n */\n function delegateBySig(\n address delegatee,\n uint256 nonce,\n uint256 expiry,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n if (block.timestamp > expiry) {\n revert VotesExpiredSignature(expiry);\n }\n address signer = ECDSA.recover(\n _hashTypedDataV4(keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry))),\n v,\n r,\n s\n );\n _useCheckedNonce(signer, nonce);\n _delegate(signer, delegatee);\n }\n\n /**\n * @dev Delegate all of `account`'s voting units to `delegatee`.\n *\n * Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.\n */\n function _delegate(address account, address delegatee) internal virtual {\n address oldDelegate = delegates(account);\n _delegatee[account] = delegatee;\n\n emit DelegateChanged(account, oldDelegate, delegatee);\n _moveDelegateVotes(oldDelegate, delegatee, _getVotingUnits(account));\n }\n\n /**\n * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to`\n * should be zero. Total supply of voting units will be adjusted with mints and burns.\n */\n function _transferVotingUnits(address from, address to, uint256 amount) internal virtual {\n if (from == address(0)) {\n _push(_totalCheckpoints, _add, SafeCast.toUint208(amount));\n }\n if (to == address(0)) {\n _push(_totalCheckpoints, _subtract, SafeCast.toUint208(amount));\n }\n _moveDelegateVotes(delegates(from), delegates(to), amount);\n }\n\n /**\n * @dev Moves delegated votes from one delegate to another.\n */\n function _moveDelegateVotes(address from, address to, uint256 amount) private {\n if (from != to && amount > 0) {\n if (from != address(0)) {\n (uint256 oldValue, uint256 newValue) = _push(\n _delegateCheckpoints[from],\n _subtract,\n SafeCast.toUint208(amount)\n );\n emit DelegateVotesChanged(from, oldValue, newValue);\n }\n if (to != address(0)) {\n (uint256 oldValue, uint256 newValue) = _push(\n _delegateCheckpoints[to],\n _add,\n SafeCast.toUint208(amount)\n );\n emit DelegateVotesChanged(to, oldValue, newValue);\n }\n }\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function _numCheckpoints(address account) internal view virtual returns (uint32) {\n return SafeCast.toUint32(_delegateCheckpoints[account].length());\n }\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function _checkpoints(\n address account,\n uint32 pos\n ) internal view virtual returns (Checkpoints.Checkpoint208 memory) {\n return _delegateCheckpoints[account].at(pos);\n }\n\n function _push(\n Checkpoints.Trace208 storage store,\n function(uint208, uint208) view returns (uint208) op,\n uint208 delta\n ) private returns (uint208, uint208) {\n return store.push(clock(), op(store.latest(), delta));\n }\n\n function _add(uint208 a, uint208 b) private pure returns (uint208) {\n return a + b;\n }\n\n function _subtract(uint208 a, uint208 b) private pure returns (uint208) {\n return a - b;\n }\n\n /**\n * @dev Must return the voting units held by an account.\n */\n function _getVotingUnits(address) internal view virtual returns (uint256);\n}\n"
},
"@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC5267.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC5805.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5805.sol)\n\npragma solidity ^0.8.20;\n\nimport {IVotes} from \"../governance/utils/IVotes.sol\";\nimport {IERC6372} from \"./IERC6372.sol\";\n\ninterface IERC5805 is IERC6372, IVotes {}\n"
},
"@openzeppelin/contracts/interfaces/IERC6372.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC6372.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC6372 {\n /**\n * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).\n */\n function clock() external view returns (uint48);\n\n /**\n * @dev Description of the clock\n */\n // solhint-disable-next-line func-name-mixedcase\n function CLOCK_MODE() external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Votes.sol)\n\npragma solidity ^0.8.20;\n\nimport {ERC20} from \"../ERC20.sol\";\nimport {Votes} from \"../../../governance/utils/Votes.sol\";\nimport {Checkpoints} from \"../../../utils/structs/Checkpoints.sol\";\n\n/**\n * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's,\n * and supports token supply up to 2^208^ - 1, while COMP is limited to 2^96^ - 1.\n *\n * NOTE: This contract does not provide interface compatibility with Compound's COMP token.\n *\n * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either\n * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting\n * power can be queried through the public accessors {getVotes} and {getPastVotes}.\n *\n * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it\n * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.\n */\nabstract contract ERC20Votes is ERC20, Votes {\n /**\n * @dev Total supply cap has been exceeded, introducing a risk of votes overflowing.\n */\n error ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap);\n\n /**\n * @dev Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1).\n *\n * This maximum is enforced in {_update}. It limits the total supply of the token, which is otherwise a uint256,\n * so that checkpoints can be stored in the Trace208 structure used by {{Votes}}. Increasing this value will not\n * remove the underlying limitation, and will cause {_update} to fail because of a math overflow in\n * {_transferVotingUnits}. An override could be used to further restrict the total supply (to a lower value) if\n * additional logic requires it. When resolving override conflicts on this function, the minimum should be\n * returned.\n */\n function _maxSupply() internal view virtual returns (uint256) {\n return type(uint208).max;\n }\n\n /**\n * @dev Move voting power when tokens are transferred.\n *\n * Emits a {IVotes-DelegateVotesChanged} event.\n */\n function _update(address from, address to, uint256 value) internal virtual override {\n super._update(from, to, value);\n if (from == address(0)) {\n uint256 supply = totalSupply();\n uint256 cap = _maxSupply();\n if (supply > cap) {\n revert ERC20ExceededSafeSupply(supply, cap);\n }\n }\n _transferVotingUnits(from, to, value);\n }\n\n /**\n * @dev Returns the voting units of an `account`.\n *\n * WARNING: Overriding this function may compromise the internal vote accounting.\n * `ERC20Votes` assumes tokens map to voting units 1:1 and this is not easy to change.\n */\n function _getVotingUnits(address account) internal view virtual override returns (uint256) {\n return balanceOf(account);\n }\n\n /**\n * @dev Get number of checkpoints for `account`.\n */\n function numCheckpoints(address account) public view virtual returns (uint32) {\n return _numCheckpoints(account);\n }\n\n /**\n * @dev Get the `pos`-th checkpoint for `account`.\n */\n function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoints.Checkpoint208 memory) {\n return _checkpoints(account, pos);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/cryptography/EIP712.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n address private immutable _cachedThis;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n _cachedThis = address(this);\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(this),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n"
},
"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n"
},
"@openzeppelin/contracts/utils/math/SafeCast.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n /**\n * @dev Value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n /**\n * @dev An int value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedIntToUint(int256 value);\n\n /**\n * @dev Value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n /**\n * @dev An uint value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedUintToInt(uint256 value);\n\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n return int256(value);\n }\n}\n"
},
"@openzeppelin/contracts/utils/math/SignedMath.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/Nonces.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n /**\n * @dev The nonce used for an `account` is not the expected current nonce.\n */\n error InvalidAccountNonce(address account, uint256 currentNonce);\n\n mapping(address account => uint256) private _nonces;\n\n /**\n * @dev Returns the next unused nonce for an address.\n */\n function nonces(address owner) public view virtual returns (uint256) {\n return _nonces[owner];\n }\n\n /**\n * @dev Consumes a nonce.\n *\n * Returns the current value and increments nonce.\n */\n function _useNonce(address owner) internal virtual returns (uint256) {\n // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n // decremented or reset. This guarantees that the nonce never overflows.\n unchecked {\n // It is important to do x++ and not ++x here.\n return _nonces[owner]++;\n }\n }\n\n /**\n * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n */\n function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n uint256 current = _useNonce(owner);\n if (nonce != current) {\n revert InvalidAccountNonce(owner, current);\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/ShortStrings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/StorageSlot.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"
},
"@openzeppelin/contracts/utils/structs/Checkpoints.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol)\n// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"../math/Math.sol\";\n\n/**\n * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in\n * time, and later looking up past values by block number. See {Votes} as an example.\n *\n * To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new\n * checkpoint for the current transaction block using the {push} function.\n */\nlibrary Checkpoints {\n /**\n * @dev A value was attempted to be inserted on a past checkpoint.\n */\n error CheckpointUnorderedInsertion();\n\n struct Trace224 {\n Checkpoint224[] _checkpoints;\n }\n\n struct Checkpoint224 {\n uint32 _key;\n uint224 _value;\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint.\n *\n * Returns previous value and new value.\n *\n * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the\n * library.\n */\n function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) {\n return _insert(self._checkpoints, key, value);\n }\n\n /**\n * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if\n * there is none.\n */\n function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);\n return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n */\n function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n *\n * NOTE: This is a variant of {upperLookup} that is optimised to find \"recent\" checkpoint (checkpoints with high\n * keys).\n */\n function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) {\n uint256 len = self._checkpoints.length;\n\n uint256 low = 0;\n uint256 high = len;\n\n if (len > 5) {\n uint256 mid = len - Math.sqrt(len);\n if (key < _unsafeAccess(self._checkpoints, mid)._key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);\n\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.\n */\n function latest(Trace224 storage self) internal view returns (uint224) {\n uint256 pos = self._checkpoints.length;\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value\n * in the most recent checkpoint.\n */\n function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) {\n uint256 pos = self._checkpoints.length;\n if (pos == 0) {\n return (false, 0, 0);\n } else {\n Checkpoint224 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);\n return (true, ckpt._key, ckpt._value);\n }\n }\n\n /**\n * @dev Returns the number of checkpoint.\n */\n function length(Trace224 storage self) internal view returns (uint256) {\n return self._checkpoints.length;\n }\n\n /**\n * @dev Returns checkpoint at given position.\n */\n function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) {\n return self._checkpoints[pos];\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,\n * or by updating the last one.\n */\n function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) {\n uint256 pos = self.length;\n\n if (pos > 0) {\n // Copying to memory is important here.\n Checkpoint224 memory last = _unsafeAccess(self, pos - 1);\n\n // Checkpoint keys must be non-decreasing.\n if (last._key > key) {\n revert CheckpointUnorderedInsertion();\n }\n\n // Update or push new checkpoint\n if (last._key == key) {\n _unsafeAccess(self, pos - 1)._value = value;\n } else {\n self.push(Checkpoint224({_key: key, _value: value}));\n }\n return (last._value, value);\n } else {\n self.push(Checkpoint224({_key: key, _value: value}));\n return (0, value);\n }\n }\n\n /**\n * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`\n * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive\n * `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _upperBinaryLookup(\n Checkpoint224[] storage self,\n uint32 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key > key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n return high;\n }\n\n /**\n * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or\n * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and\n * exclusive `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _lowerBinaryLookup(\n Checkpoint224[] storage self,\n uint32 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key < key) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(\n Checkpoint224[] storage self,\n uint256 pos\n ) private pure returns (Checkpoint224 storage result) {\n assembly {\n mstore(0, self.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n\n struct Trace208 {\n Checkpoint208[] _checkpoints;\n }\n\n struct Checkpoint208 {\n uint48 _key;\n uint208 _value;\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint.\n *\n * Returns previous value and new value.\n *\n * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the\n * library.\n */\n function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) {\n return _insert(self._checkpoints, key, value);\n }\n\n /**\n * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if\n * there is none.\n */\n function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);\n return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n */\n function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n *\n * NOTE: This is a variant of {upperLookup} that is optimised to find \"recent\" checkpoint (checkpoints with high\n * keys).\n */\n function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) {\n uint256 len = self._checkpoints.length;\n\n uint256 low = 0;\n uint256 high = len;\n\n if (len > 5) {\n uint256 mid = len - Math.sqrt(len);\n if (key < _unsafeAccess(self._checkpoints, mid)._key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);\n\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.\n */\n function latest(Trace208 storage self) internal view returns (uint208) {\n uint256 pos = self._checkpoints.length;\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value\n * in the most recent checkpoint.\n */\n function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) {\n uint256 pos = self._checkpoints.length;\n if (pos == 0) {\n return (false, 0, 0);\n } else {\n Checkpoint208 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);\n return (true, ckpt._key, ckpt._value);\n }\n }\n\n /**\n * @dev Returns the number of checkpoint.\n */\n function length(Trace208 storage self) internal view returns (uint256) {\n return self._checkpoints.length;\n }\n\n /**\n * @dev Returns checkpoint at given position.\n */\n function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) {\n return self._checkpoints[pos];\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,\n * or by updating the last one.\n */\n function _insert(Checkpoint208[] storage self, uint48 key, uint208 value) private returns (uint208, uint208) {\n uint256 pos = self.length;\n\n if (pos > 0) {\n // Copying to memory is important here.\n Checkpoint208 memory last = _unsafeAccess(self, pos - 1);\n\n // Checkpoint keys must be non-decreasing.\n if (last._key > key) {\n revert CheckpointUnorderedInsertion();\n }\n\n // Update or push new checkpoint\n if (last._key == key) {\n _unsafeAccess(self, pos - 1)._value = value;\n } else {\n self.push(Checkpoint208({_key: key, _value: value}));\n }\n return (last._value, value);\n } else {\n self.push(Checkpoint208({_key: key, _value: value}));\n return (0, value);\n }\n }\n\n /**\n * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`\n * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive\n * `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _upperBinaryLookup(\n Checkpoint208[] storage self,\n uint48 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key > key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n return high;\n }\n\n /**\n * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or\n * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and\n * exclusive `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _lowerBinaryLookup(\n Checkpoint208[] storage self,\n uint48 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key < key) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(\n Checkpoint208[] storage self,\n uint256 pos\n ) private pure returns (Checkpoint208 storage result) {\n assembly {\n mstore(0, self.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n\n struct Trace160 {\n Checkpoint160[] _checkpoints;\n }\n\n struct Checkpoint160 {\n uint96 _key;\n uint160 _value;\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint.\n *\n * Returns previous value and new value.\n *\n * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the\n * library.\n */\n function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) {\n return _insert(self._checkpoints, key, value);\n }\n\n /**\n * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if\n * there is none.\n */\n function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);\n return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n */\n function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {\n uint256 len = self._checkpoints.length;\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero\n * if there is none.\n *\n * NOTE: This is a variant of {upperLookup} that is optimised to find \"recent\" checkpoint (checkpoints with high\n * keys).\n */\n function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) {\n uint256 len = self._checkpoints.length;\n\n uint256 low = 0;\n uint256 high = len;\n\n if (len > 5) {\n uint256 mid = len - Math.sqrt(len);\n if (key < _unsafeAccess(self._checkpoints, mid)._key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);\n\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.\n */\n function latest(Trace160 storage self) internal view returns (uint160) {\n uint256 pos = self._checkpoints.length;\n return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;\n }\n\n /**\n * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value\n * in the most recent checkpoint.\n */\n function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) {\n uint256 pos = self._checkpoints.length;\n if (pos == 0) {\n return (false, 0, 0);\n } else {\n Checkpoint160 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);\n return (true, ckpt._key, ckpt._value);\n }\n }\n\n /**\n * @dev Returns the number of checkpoint.\n */\n function length(Trace160 storage self) internal view returns (uint256) {\n return self._checkpoints.length;\n }\n\n /**\n * @dev Returns checkpoint at given position.\n */\n function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) {\n return self._checkpoints[pos];\n }\n\n /**\n * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,\n * or by updating the last one.\n */\n function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) {\n uint256 pos = self.length;\n\n if (pos > 0) {\n // Copying to memory is important here.\n Checkpoint160 memory last = _unsafeAccess(self, pos - 1);\n\n // Checkpoint keys must be non-decreasing.\n if (last._key > key) {\n revert CheckpointUnorderedInsertion();\n }\n\n // Update or push new checkpoint\n if (last._key == key) {\n _unsafeAccess(self, pos - 1)._value = value;\n } else {\n self.push(Checkpoint160({_key: key, _value: value}));\n }\n return (last._value, value);\n } else {\n self.push(Checkpoint160({_key: key, _value: value}));\n return (0, value);\n }\n }\n\n /**\n * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`\n * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive\n * `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _upperBinaryLookup(\n Checkpoint160[] storage self,\n uint96 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key > key) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n return high;\n }\n\n /**\n * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or\n * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and\n * exclusive `high`.\n *\n * WARNING: `high` should not be greater than the array's length.\n */\n function _lowerBinaryLookup(\n Checkpoint160[] storage self,\n uint96 key,\n uint256 low,\n uint256 high\n ) private view returns (uint256) {\n while (low < high) {\n uint256 mid = Math.average(low, high);\n if (_unsafeAccess(self, mid)._key < key) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n\n /**\n * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.\n */\n function _unsafeAccess(\n Checkpoint160[] storage self,\n uint256 pos\n ) private pure returns (Checkpoint160 storage result) {\n assembly {\n mstore(0, self.slot)\n result.slot := add(keccak256(0, 0x20), pos)\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/types/Time.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"../math/Math.sol\";\nimport {SafeCast} from \"../math/SafeCast.sol\";\n\n/**\n * @dev This library provides helpers for manipulating time-related objects.\n *\n * It uses the following types:\n * - `uint48` for timepoints\n * - `uint32` for durations\n *\n * While the library doesn't provide specific types for timepoints and duration, it does provide:\n * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point\n * - additional helper functions\n */\nlibrary Time {\n using Time for *;\n\n /**\n * @dev Get the block timestamp as a Timepoint.\n */\n function timestamp() internal view returns (uint48) {\n return SafeCast.toUint48(block.timestamp);\n }\n\n /**\n * @dev Get the block number as a Timepoint.\n */\n function blockNumber() internal view returns (uint48) {\n return SafeCast.toUint48(block.number);\n }\n\n // ==================================================== Delay =====================================================\n /**\n * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the\n * future. The \"effect\" timepoint describes when the transitions happens from the \"old\" value to the \"new\" value.\n * This allows updating the delay applied to some operation while keeping some guarantees.\n *\n * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for\n * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set\n * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should\n * still apply for some time.\n *\n *\n * The `Delay` type is 112 bits long, and packs the following:\n *\n * ```\n * | [uint48]: effect date (timepoint)\n * | | [uint32]: value before (duration)\n * ↓ ↓ ↓ [uint32]: value after (duration)\n * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC\n * ```\n *\n * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently\n * supported.\n */\n type Delay is uint112;\n\n /**\n * @dev Wrap a duration into a Delay to add the one-step \"update in the future\" feature\n */\n function toDelay(uint32 duration) internal pure returns (Delay) {\n return Delay.wrap(duration);\n }\n\n /**\n * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled\n * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered.\n */\n function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) {\n (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack();\n return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect);\n }\n\n /**\n * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the\n * effect timepoint is 0, then the pending value should not be considered.\n */\n function getFull(Delay self) internal view returns (uint32, uint32, uint48) {\n return _getFullAt(self, timestamp());\n }\n\n /**\n * @dev Get the current value.\n */\n function get(Delay self) internal view returns (uint32) {\n (uint32 delay, , ) = self.getFull();\n return delay;\n }\n\n /**\n * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to\n * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the\n * new delay becomes effective.\n */\n function withUpdate(\n Delay self,\n uint32 newValue,\n uint32 minSetback\n ) internal view returns (Delay updatedDelay, uint48 effect) {\n uint32 value = self.get();\n uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0));\n effect = timestamp() + setback;\n return (pack(value, newValue, effect), effect);\n }\n\n /**\n * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).\n */\n function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {\n uint112 raw = Delay.unwrap(self);\n\n valueAfter = uint32(raw);\n valueBefore = uint32(raw >> 32);\n effect = uint48(raw >> 64);\n\n return (valueBefore, valueAfter, effect);\n }\n\n /**\n * @dev pack the components into a Delay object.\n */\n function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) {\n return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter));\n }\n}\n"
},
"contracts/libraries/VestingLibrary.sol": {
"content": "/// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.22 <0.9.0;\n\nlibrary VestingLibrary {\n bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH =\n keccak256(\"EIP712Domain(string name,string version)\");\n\n bytes32 private constant VESTING_TYPEHASH =\n keccak256(\n \"Vesting(address owner,uint8 curveType,bool managed,uint16 durationWeeks,uint64 startDate,uint128 amount,uint128 initialUnlock,bool requiresSPT)\"\n );\n\n // Sane limits based on: https://eips.ethereum.org/EIPS/eip-1985\n // amountClaimed should always be equal to or less than amount\n // pausingDate should always be equal to or greater than startDate\n struct Vesting {\n // First storage slot\n uint128 initialUnlock; // 16 bytes -> Max 3.4e20 tokens (including decimals)\n uint8 curveType; // 1 byte -> Max 256 different curve types\n bool managed; // 1 byte\n uint16 durationWeeks; // 2 bytes -> Max 65536 weeks ~ 1260 years\n uint64 startDate; // 8 bytes -> Works until year 292278994, but not before 1970\n // Second storage slot\n uint128 amount; // 16 bytes -> Max 3.4e20 tokens (including decimals)\n uint128 amountClaimed; // 16 bytes -> Max 3.4e20 tokens (including decimals)\n // Third storage slot\n uint64 pausingDate; // 8 bytes -> Works until year 292278994, but not before 1970\n bool cancelled; // 1 byte\n bool requiresSPT; // 1 byte\n }\n\n /// @notice Calculate the id for a vesting based on its parameters.\n /// @param owner The owner for which the vesting was created\n /// @param curveType Type of the curve that is used for the vesting\n /// @param managed Indicator if the vesting is managed by the pool manager\n /// @param durationWeeks The duration of the vesting in weeks\n /// @param startDate The date when the vesting started (can be in the future)\n /// @param amount Amount of tokens that are vested in atoms\n /// @param initialUnlock Amount of tokens that are unlocked immediately in atoms\n /// @return vestingId Id of a vesting based on its parameters\n function vestingHash(\n address owner,\n uint8 curveType,\n bool managed,\n uint16 durationWeeks,\n uint64 startDate,\n uint128 amount,\n uint128 initialUnlock,\n bool requiresSPT\n ) external pure returns (bytes32 vestingId) {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_SEPARATOR_TYPEHASH, \"VestingLibrary\", \"1.0\")\n );\n bytes32 vestingDataHash = keccak256(\n abi.encode(\n VESTING_TYPEHASH,\n owner,\n curveType,\n managed,\n durationWeeks,\n startDate,\n amount,\n initialUnlock,\n requiresSPT\n )\n );\n vestingId = keccak256(\n abi.encodePacked(\n bytes1(0x19),\n bytes1(0x01),\n domainSeparator,\n vestingDataHash\n )\n );\n }\n}\n"
},
"contracts/VestingPool.sol": {
"content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.8.22 <0.9.0;\n\nimport { ERC20Votes } from \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol\";\nimport { VestingLibrary } from \"./libraries/VestingLibrary.sol\";\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Vesting contract for single account\n/// Original contract - https://github.com/safe-global/safe-token/blob/main/contracts/VestingPool.sol\n/// @author Daniel Dimitrov - @compojoom, Fred Lührs - @fredo\ncontract VestingPool {\n event AddedVesting(bytes32 indexed id);\n event ClaimedVesting(bytes32 indexed id, address indexed beneficiary);\n event PausedVesting(bytes32 indexed id);\n event UnpausedVesting(bytes32 indexed id);\n event CancelledVesting(bytes32 indexed id);\n\n bool public initialised;\n address public owner;\n\n address public token;\n address public immutable sptToken;\n address public poolManager;\n\n uint256 public totalTokensInVesting;\n mapping(bytes32 => VestingLibrary.Vesting) public vestings;\n\n modifier onlyPoolManager() {\n require(\n msg.sender == poolManager,\n \"Can only be called by pool manager\"\n );\n _;\n }\n\n modifier onlyOwner() {\n require(msg.sender == owner, \"Can only be claimed by vesting owner\");\n _;\n }\n\n // solhint-disable-next-line no-empty-blocks\n constructor(address _sptToken) {\n sptToken = _sptToken;\n // don't do anything else here to allow usage of proxy contracts.\n }\n\n /// @notice Initialize the vesting pool\n /// @dev This can only be called once\n /// @param _token The token that should be used for the vesting\n /// @param _poolManager The manager of this vesting pool (e.g. the address that can call `addVesting`)\n /// @param _owner The owner of this vesting pool (e.g. the address that can call `delegateTokens`)\n function initialize(\n address _token,\n address _poolManager,\n address _owner\n ) public {\n require(!initialised, \"The contract has already been initialised.\");\n require(_token != address(0), \"Invalid token account\");\n require(_poolManager != address(0), \"Invalid pool manager account\");\n require(_owner != address(0), \"Invalid account\");\n\n initialised = true;\n\n token = _token;\n poolManager = _poolManager;\n\n owner = _owner;\n }\n\n function delegateTokens(address delegatee) external onlyOwner {\n ERC20Votes(token).delegate(delegatee);\n }\n\n /// @notice Create a vesting on this pool for `account`.\n /// @dev This can only be called by the pool manager\n /// @dev It is required that the pool has enough tokens available\n /// @param curveType Type of the curve that should be used for the vesting\n /// @param managed Boolean that indicates if the vesting can be managed by the pool manager\n /// @param durationWeeks The duration of the vesting in weeks\n /// @param startDate The date when the vesting should be started (can be in the past)\n /// @param amount Amount of tokens that should be vested in atoms\n /// @param initialUnlock Amount of tokens that should be unlocked immediately\n /// @return vestingId The id of the created vesting\n function addVesting(\n uint8 curveType,\n bool managed,\n uint16 durationWeeks,\n uint64 startDate,\n uint128 amount,\n uint128 initialUnlock,\n bool requiresSPT\n ) public virtual onlyPoolManager returns (bytes32) {\n return\n _addVesting(\n curveType,\n managed,\n durationWeeks,\n startDate,\n amount,\n initialUnlock,\n requiresSPT\n );\n }\n\n /// @notice Calculate the amount of tokens available for new vestings.\n /// @dev This value changes when more tokens are deposited to this contract\n /// @return Amount of tokens that can be used for new vestings.\n function tokensAvailableForVesting() public view virtual returns (uint256) {\n return\n ERC20Votes(token).balanceOf(address(this)) - totalTokensInVesting;\n }\n\n /// @notice Create a vesting on this pool for `account`.\n /// @dev It is required that the pool has enough tokens available\n /// @dev Account cannot be zero address\n /// @param curveType Type of the curve that should be used for the vesting\n /// @param managed Boolean that indicates if the vesting can be managed by the pool manager\n /// @param durationWeeks The duration of the vesting in weeks\n /// @param startDate The date when the vesting should be started (can be in the past)\n /// @param amount Amount of tokens that should be vested in atoms\n /// @param vestingId The id of the created vesting\n function _addVesting(\n uint8 curveType,\n bool managed,\n uint16 durationWeeks,\n uint64 startDate,\n uint128 amount,\n uint128 initialUnlock,\n bool requiresSPT\n ) internal returns (bytes32 vestingId) {\n require(curveType < 2, \"Invalid vesting curve\");\n vestingId = VestingLibrary.vestingHash(\n owner,\n curveType,\n managed,\n durationWeeks,\n startDate,\n amount,\n initialUnlock,\n requiresSPT\n );\n require(vestings[vestingId].amount == 0, \"Vesting id already used\");\n // Check that enough tokens are available for the new vesting\n uint256 availableTokens = tokensAvailableForVesting();\n require(availableTokens >= amount, \"Not enough tokens available\");\n // Mark tokens for this vesting in use\n totalTokensInVesting += amount;\n vestings[vestingId] = VestingLibrary.Vesting({\n curveType: curveType,\n managed: managed,\n durationWeeks: durationWeeks,\n startDate: startDate,\n amount: amount,\n amountClaimed: 0,\n pausingDate: 0,\n cancelled: false,\n initialUnlock: initialUnlock,\n requiresSPT: requiresSPT\n });\n emit AddedVesting(vestingId);\n }\n\n /// @notice Claim `tokensToClaim` tokens from vesting `vestingId` and transfer them to the `beneficiary`.\n /// @dev This can only be called by the owner of the vesting\n /// @dev Beneficiary cannot be the 0-address\n /// @dev This will trigger a transfer of tokens\n /// @param vestingId Id of the vesting from which the tokens should be claimed\n /// @param beneficiary Account that should receive the claimed tokens\n /// @param tokensToClaim Amount of tokens to claim in atoms or max uint128 to claim all available\n function claimVestedTokens(\n bytes32 vestingId,\n address beneficiary,\n uint128 tokensToClaim\n ) public {\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n require(vesting.amount != 0, \"Vesting not found\");\n\n uint128 tokensClaimed = updateClaimedTokens(\n vestingId,\n beneficiary,\n tokensToClaim\n );\n\n if(vesting.requiresSPT) {\n require(\n IERC20(sptToken).transferFrom(msg.sender, address(this), tokensClaimed),\n \"SPT transfer failed\"\n );\n }\n\n require(\n ERC20Votes(token).transfer(beneficiary, tokensClaimed),\n \"Token transfer failed\"\n );\n }\n\n /// @notice Update `amountClaimed` on vesting `vestingId` by `tokensToClaim` tokens.\n /// @dev This can only be called by the owner of the vesting\n /// @dev Beneficiary cannot be the 0-address\n /// @dev This will only update the internal state and NOT trigger the transfer of tokens.\n /// @param vestingId Id of the vesting from which the tokens should be claimed\n /// @param beneficiary Account that should receive the claimed tokens\n /// @param tokensToClaim Amount of tokens to claim in atoms or max uint128 to claim all available\n /// @param tokensClaimed Amount of tokens that have been newly claimed by calling this method\n function updateClaimedTokens(\n bytes32 vestingId,\n address beneficiary,\n uint128 tokensToClaim\n ) internal onlyOwner returns (uint128 tokensClaimed) {\n require(beneficiary != address(0), \"Cannot claim to 0-address\");\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n // Calculate how many tokens can be claimed\n uint128 availableClaim = _calculateVestedAmount(vesting) -\n vesting.amountClaimed;\n // If max uint128 is used, claim all available tokens.\n tokensClaimed = tokensToClaim == type(uint128).max\n ? availableClaim\n : tokensToClaim;\n require(\n tokensClaimed <= availableClaim,\n \"Trying to claim too many tokens\"\n );\n // Adjust how many tokens are locked in vesting\n totalTokensInVesting -= tokensClaimed;\n vesting.amountClaimed += tokensClaimed;\n emit ClaimedVesting(vestingId, beneficiary);\n }\n\n /// @notice Cancel vesting `vestingId`.\n /// @dev This can only be called by the pool manager\n /// @dev Only manageable vestings can be cancelled\n /// @param vestingId Id of the vesting that should be cancelled\n function cancelVesting(bytes32 vestingId) public onlyPoolManager {\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n require(vesting.amount != 0, \"Vesting not found\");\n require(vesting.managed, \"Only managed vestings can be cancelled\");\n require(!vesting.cancelled, \"Vesting already cancelled\");\n bool isFutureVesting = block.timestamp <= vesting.startDate;\n // If vesting is not already paused it will be paused\n // Pausing date should not be reset else tokens of the initial pause can be claimed\n if (vesting.pausingDate == 0) {\n // pausingDate should always be larger or equal to startDate\n vesting.pausingDate = isFutureVesting\n ? vesting.startDate\n : uint64(block.timestamp);\n }\n // Vesting is cancelled, therefore tokens that are not vested yet, will be added back to the pool\n uint128 unusedToken = isFutureVesting\n ? vesting.amount\n : vesting.amount - _calculateVestedAmount(vesting);\n totalTokensInVesting -= unusedToken;\n // Vesting is set to cancelled and therefore disallows unpausing\n vesting.cancelled = true;\n emit CancelledVesting(vestingId);\n }\n\n /// @notice Pause vesting `vestingId`.\n /// @dev This can only be called by the pool manager\n /// @dev Only manageable vestings can be paused\n /// @param vestingId Id of the vesting that should be paused\n function pauseVesting(bytes32 vestingId) public onlyPoolManager {\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n require(vesting.amount != 0, \"Vesting not found\");\n require(vesting.managed, \"Only managed vestings can be paused\");\n require(vesting.pausingDate == 0, \"Vesting already paused\");\n // pausingDate should always be larger or equal to startDate\n vesting.pausingDate = block.timestamp <= vesting.startDate\n ? vesting.startDate\n : uint64(block.timestamp);\n emit PausedVesting(vestingId);\n }\n\n /// @notice Unpause vesting `vestingId`.\n /// @dev This can only be called by the pool manager\n /// @dev Only vestings that have not been cancelled can be unpaused\n /// @param vestingId Id of the vesting that should be unpaused\n function unpauseVesting(bytes32 vestingId) public onlyPoolManager {\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n require(vesting.amount != 0, \"Vesting not found\");\n require(vesting.pausingDate != 0, \"Vesting is not paused\");\n require(\n !vesting.cancelled,\n \"Vesting has been cancelled and cannot be unpaused\"\n );\n // Calculate the time the vesting was paused\n // If vesting has not started yet, then pausing date might be in the future\n uint64 timePaused = block.timestamp <= vesting.pausingDate\n ? 0\n : uint64(block.timestamp) - vesting.pausingDate;\n // Offset the start date to create the effect of pausing\n vesting.startDate = vesting.startDate + timePaused;\n vesting.pausingDate = 0;\n emit UnpausedVesting(vestingId);\n }\n\n /// @notice Calculate vested and claimed token amounts for vesting `vestingId`.\n /// @dev This will revert if the vesting has not been started yet\n /// @param vestingId Id of the vesting for which to calculate the amounts\n /// @return vestedAmount The amount in atoms of tokens vested\n /// @return claimedAmount The amount in atoms of tokens claimed\n function calculateVestedAmount(\n bytes32 vestingId\n ) external view returns (uint128 vestedAmount, uint128 claimedAmount) {\n VestingLibrary.Vesting storage vesting = vestings[vestingId];\n require(vesting.amount != 0, \"Vesting not found\");\n vestedAmount = _calculateVestedAmount(vesting);\n claimedAmount = vesting.amountClaimed;\n }\n\n /// @notice Calculate vested token amount for vesting `vesting`.\n /// @dev This will revert if the vesting has not been started yet\n /// @param vesting The vesting for which to calculate the amounts\n /// @return vestedAmount The amount in atoms of tokens vested\n function _calculateVestedAmount(\n VestingLibrary.Vesting storage vesting\n ) internal view returns (uint128 vestedAmount) {\n require(vesting.startDate <= block.timestamp, \"Vesting not active yet\");\n // Convert vesting duration to seconds\n uint64 durationSeconds = uint64(vesting.durationWeeks) *\n 7 *\n 24 *\n 60 *\n 60;\n // If contract is paused use the pausing date to calculate amount\n uint64 vestedSeconds = vesting.pausingDate > 0\n ? vesting.pausingDate - vesting.startDate\n : uint64(block.timestamp) - vesting.startDate;\n if (vestedSeconds >= durationSeconds) {\n // If vesting time is longer than duration everything has been vested\n vestedAmount = vesting.amount;\n } else if (vesting.curveType == 0) {\n // Linear vesting\n vestedAmount =\n calculateLinear(\n vesting.amount - vesting.initialUnlock,\n vestedSeconds,\n durationSeconds\n ) +\n vesting.initialUnlock;\n } else if (vesting.curveType == 1) {\n // Exponential vesting\n vestedAmount =\n calculateExponential(\n vesting.amount - vesting.initialUnlock,\n vestedSeconds,\n durationSeconds\n ) +\n vesting.initialUnlock;\n } else {\n // This is unreachable because it is not possible to add a vesting with an invalid curve type\n revert(\"Invalid curve type\");\n }\n }\n\n /// @notice Calculate vested token amount on a linear curve.\n /// @dev Calculate vested amount on linear curve: targetAmount * elapsedTime / totalTime\n /// @param targetAmount Amount of tokens that is being vested\n /// @param elapsedTime Time that has elapsed for the vesting\n /// @param totalTime Duration of the vesting\n /// @return Tokens that have been vested on a linear curve\n function calculateLinear(\n uint128 targetAmount,\n uint64 elapsedTime,\n uint64 totalTime\n ) internal pure returns (uint128) {\n // Calculate vested amount on linear curve: targetAmount * elapsedTime / totalTime\n uint256 amount = (uint256(targetAmount) * uint256(elapsedTime)) /\n uint256(totalTime);\n require(amount <= type(uint128).max, \"Overflow in curve calculation\");\n return uint128(amount);\n }\n\n /// @notice Calculate vested token amount on an exponential curve.\n /// @dev Calculate vested amount on exponential curve: targetAmount * elapsedTime^2 / totalTime^2\n /// @param targetAmount Amount of tokens that is being vested\n /// @param elapsedTime Time that has elapsed for the vesting\n /// @param totalTime Duration of the vesting\n /// @return Tokens that have been vested on an exponential curve\n function calculateExponential(\n uint128 targetAmount,\n uint64 elapsedTime,\n uint64 totalTime\n ) internal pure returns (uint128) {\n // Calculate vested amount on exponential curve: targetAmount * elapsedTime^2 / totalTime^2\n uint256 amount = (uint256(targetAmount) *\n uint256(elapsedTime) *\n uint256(elapsedTime)) / (uint256(totalTime) * uint256(totalTime));\n require(amount <= type(uint128).max, \"Overflow in curve calculation\");\n return uint128(amount);\n }\n}\n"
}
},
"settings": {
"evmVersion": "paris",
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {
"contracts/libraries/VestingLibrary.sol": {
"VestingLibrary": "0x99fad8b3658d185474e13d1be98660dc30077b26"
}
}
}
}}
|
1 | 19,500,418 |
abb99a1d6419674ab9b1d76c16b20d20d232dd36446bf63b4d0480523cf6b8e6
|
a10f02171b998950a974278207aeadef7370deb894160554b25b16a56f49386f
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
aff1cff5375c2f76e0c22854262358cf7c717167
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,500,419 |
773b91e236367a06b27ff0aa2819924e13c1c8075933b0e167da19b7060ab2be
|
2432447e08027a8694dd73ea14ec4eb9cd0cdd828a72a969592c462120a21fdd
|
1e3e9afbd5f896448f88671ce95b3afe59017350
|
000000008924d42d98026c656545c3c1fb3ad31c
|
4aec2120d1a25cae00fb28481de879d030718e4f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"lib/ERC721A/contracts/IERC721A.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\n/**\n * @dev Interface of ERC721A.\n */\ninterface IERC721A {\n /**\n * The caller must own the token or be an approved operator.\n */\n error ApprovalCallerNotOwnerNorApproved();\n\n /**\n * The token does not exist.\n */\n error ApprovalQueryForNonexistentToken();\n\n /**\n * Cannot query the balance for the zero address.\n */\n error BalanceQueryForZeroAddress();\n\n /**\n * Cannot mint to the zero address.\n */\n error MintToZeroAddress();\n\n /**\n * The quantity of tokens minted must be more than zero.\n */\n error MintZeroQuantity();\n\n /**\n * The token does not exist.\n */\n error OwnerQueryForNonexistentToken();\n\n /**\n * The caller must own the token or be an approved operator.\n */\n error TransferCallerNotOwnerNorApproved();\n\n /**\n * The token must be owned by `from`.\n */\n error TransferFromIncorrectOwner();\n\n /**\n * Cannot safely transfer to a contract that does not implement the\n * ERC721Receiver interface.\n */\n error TransferToNonERC721ReceiverImplementer();\n\n /**\n * Cannot transfer to the zero address.\n */\n error TransferToZeroAddress();\n\n /**\n * The token does not exist.\n */\n error URIQueryForNonexistentToken();\n\n /**\n * The `quantity` minted with ERC2309 exceeds the safety limit.\n */\n error MintERC2309QuantityExceedsLimit();\n\n /**\n * The `extraData` cannot be set on an unintialized ownership slot.\n */\n error OwnershipNotInitializedForExtraData();\n\n // =============================================================\n // STRUCTS\n // =============================================================\n\n struct TokenOwnership {\n // The address of the owner.\n address addr;\n // Stores the start time of ownership with minimal overhead for tokenomics.\n uint64 startTimestamp;\n // Whether the token has been burned.\n bool burned;\n // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.\n uint24 extraData;\n }\n\n // =============================================================\n // TOKEN COUNTERS\n // =============================================================\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() external view returns (uint256);\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n // =============================================================\n // IERC721\n // =============================================================\n\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables\n * (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`,\n * checking first that contract recipients are aware of the ERC721 protocol\n * to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move\n * this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom}\n * whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n // =============================================================\n // IERC2309\n // =============================================================\n\n /**\n * @dev Emitted when tokens in `fromTokenId` to `toTokenId`\n * (inclusive) is transferred from `from` to `to`, as defined in the\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.\n *\n * See {_mintERC2309} for more details.\n */\n event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"lib/operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n /**\n * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns\n * true if supplied registrant address is not registered.\n */\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n\n /**\n * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.\n */\n function register(address registrant) external;\n\n /**\n * @notice Registers an address with the registry and \"subscribes\" to another address's filtered operators and codeHashes.\n */\n function registerAndSubscribe(address registrant, address subscription) external;\n\n /**\n * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another\n * address without subscribing.\n */\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.\n * Note that this does not remove any filtered addresses or codeHashes.\n * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.\n */\n function unregister(address addr) external;\n\n /**\n * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.\n */\n function updateOperator(address registrant, address operator, bool filtered) external;\n\n /**\n * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.\n */\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n\n /**\n * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.\n */\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n\n /**\n * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.\n */\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n\n /**\n * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous\n * subscription if present.\n * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,\n * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be\n * used.\n */\n function subscribe(address registrant, address registrantToSubscribe) external;\n\n /**\n * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.\n */\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n\n /**\n * @notice Get the subscription address of a given registrant, if any.\n */\n function subscriptionOf(address addr) external returns (address registrant);\n\n /**\n * @notice Get the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscribers(address registrant) external returns (address[] memory);\n\n /**\n * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscriberAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.\n */\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Returns true if operator is filtered by a given address or its subscription.\n */\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n\n /**\n * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.\n */\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n\n /**\n * @notice Returns true if a codeHash is filtered by a given address or its subscription.\n */\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n\n /**\n * @notice Returns a list of filtered operators for a given address or its subscription.\n */\n function filteredOperators(address addr) external returns (address[] memory);\n\n /**\n * @notice Returns the set of filtered codeHashes for a given address or its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n\n /**\n * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n\n /**\n * @notice Returns true if an address has registered\n */\n function isRegistered(address addr) external returns (bool);\n\n /**\n * @dev Convenience method to compute the code hash of an arbitrary contract\n */\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"lib/operator-filter-registry/src/lib/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\naddress constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E;\naddress constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;\n"
},
"lib/operator-filter-registry/src/upgradeable/DefaultOperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFiltererUpgradeable} from \"./OperatorFiltererUpgradeable.sol\";\nimport {CANONICAL_CORI_SUBSCRIPTION} from \"../lib/Constants.sol\";\n\n/**\n * @title DefaultOperatorFiltererUpgradeable\n * @notice Inherits from OperatorFiltererUpgradeable and automatically subscribes to the default OpenSea subscription\n * when the init function is called.\n */\nabstract contract DefaultOperatorFiltererUpgradeable is OperatorFiltererUpgradeable {\n /// @dev The upgradeable initialize function that should be called when the contract is being deployed.\n function __DefaultOperatorFilterer_init() internal onlyInitializing {\n OperatorFiltererUpgradeable.__OperatorFilterer_init(CANONICAL_CORI_SUBSCRIPTION, true);\n }\n}\n"
},
"lib/operator-filter-registry/src/upgradeable/OperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"../IOperatorFilterRegistry.sol\";\nimport {Initializable} from \"../../../../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title OperatorFiltererUpgradeable\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry when the init function is called.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFiltererUpgradeable is Initializable {\n /// @notice Emitted when an operator is not allowed.\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n /// @dev The upgradeable initialize function that should be called when the contract is being upgraded.\n function __OperatorFilterer_init(address subscriptionOrRegistrantToCopy, bool subscribe)\n internal\n onlyInitializing\n {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isRegistered(address(this))) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n }\n\n /**\n * @dev A helper modifier to check if the operator is allowed.\n */\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n /**\n * @dev A helper modifier to check if the operator approval is allowed.\n */\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n /**\n * @dev A helper function to check if the operator is allowed.\n */\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n // under normal circumstances, this function will revert rather than return false, but inheriting or\n // upgraded contracts may specify their own OperatorFilterRegistry implementations, which may behave\n // differently\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"lib/utility-contracts/src/ConstructorInitializable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\n/**\n * @author emo.eth\n * @notice Abstract smart contract that provides an onlyUninitialized modifier which only allows calling when\n * from within a constructor of some sort, whether directly instantiating an inherting contract,\n * or when delegatecalling from a proxy\n */\nabstract contract ConstructorInitializable {\n error AlreadyInitialized();\n\n modifier onlyConstructor() {\n if (address(this).code.length != 0) {\n revert AlreadyInitialized();\n }\n _;\n }\n}\n"
},
"lib/utility-contracts/src/TwoStepOwnable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\nimport {ConstructorInitializable} from \"./ConstructorInitializable.sol\";\n\n/**\n@notice A two-step extension of Ownable, where the new owner must claim ownership of the contract after owner initiates transfer\nOwner can cancel the transfer at any point before the new owner claims ownership.\nHelpful in guarding against transferring ownership to an address that is unable to act as the Owner.\n*/\nabstract contract TwoStepOwnable is ConstructorInitializable {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n address internal potentialOwner;\n\n event PotentialOwnerUpdated(address newPotentialAdministrator);\n\n error NewOwnerIsZeroAddress();\n error NotNextOwner();\n error OnlyOwner();\n\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n constructor() {\n _initialize();\n }\n\n function _initialize() private onlyConstructor {\n _transferOwnership(msg.sender);\n }\n\n ///@notice Initiate ownership transfer to newPotentialOwner. Note: new owner will have to manually acceptOwnership\n ///@param newPotentialOwner address of potential new owner\n function transferOwnership(address newPotentialOwner)\n public\n virtual\n onlyOwner\n {\n if (newPotentialOwner == address(0)) {\n revert NewOwnerIsZeroAddress();\n }\n potentialOwner = newPotentialOwner;\n emit PotentialOwnerUpdated(newPotentialOwner);\n }\n\n ///@notice Claim ownership of smart contract, after the current owner has initiated the process with transferOwnership\n function acceptOwnership() public virtual {\n address _potentialOwner = potentialOwner;\n if (msg.sender != _potentialOwner) {\n revert NotNextOwner();\n }\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n _transferOwnership(_potentialOwner);\n }\n\n ///@notice cancel ownership transfer\n function cancelOwnershipTransfer() public virtual onlyOwner {\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (_owner != msg.sender) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"src/clones/ERC721ACloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport { IERC721A } from \"ERC721A/IERC721A.sol\";\n\nimport {\n Initializable\n} from \"openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Interface of ERC721 token receiver.\n */\ninterface ERC721A__IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\n/**\n * @title ERC721A\n *\n * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)\n * Non-Fungible Token Standard, including the Metadata extension.\n * Optimized for lower gas during batch mints.\n *\n * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)\n * starting from `_startTokenId()`.\n *\n * Assumptions:\n *\n * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721ACloneable is IERC721A, Initializable {\n // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).\n struct TokenApprovalRef {\n address value;\n }\n\n // =============================================================\n // CONSTANTS\n // =============================================================\n\n // Mask of an entry in packed address data.\n uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;\n\n // The bit position of `numberMinted` in packed address data.\n uint256 private constant _BITPOS_NUMBER_MINTED = 64;\n\n // The bit position of `numberBurned` in packed address data.\n uint256 private constant _BITPOS_NUMBER_BURNED = 128;\n\n // The bit position of `aux` in packed address data.\n uint256 private constant _BITPOS_AUX = 192;\n\n // Mask of all 256 bits in packed address data except the 64 bits for `aux`.\n uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;\n\n // The bit position of `startTimestamp` in packed ownership.\n uint256 private constant _BITPOS_START_TIMESTAMP = 160;\n\n // The bit mask of the `burned` bit in packed ownership.\n uint256 private constant _BITMASK_BURNED = 1 << 224;\n\n // The bit position of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;\n\n // The bit mask of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;\n\n // The bit position of `extraData` in packed ownership.\n uint256 private constant _BITPOS_EXTRA_DATA = 232;\n\n // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.\n uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;\n\n // The mask of the lower 160 bits for addresses.\n uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;\n\n // The maximum `quantity` that can be minted with {_mintERC2309}.\n // This limit is to prevent overflows on the address data entries.\n // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}\n // is required to cause an overflow, which is unrealistic.\n uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;\n\n // The `Transfer` event signature is given by:\n // `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n bytes32 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n // =============================================================\n // STORAGE\n // =============================================================\n\n // The next token ID to be minted.\n uint256 private _currentIndex;\n\n // The number of tokens burned.\n uint256 private _burnCounter;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to ownership details\n // An empty struct value does not necessarily mean the token is unowned.\n // See {_packedOwnershipOf} implementation for details.\n //\n // Bits Layout:\n // - [0..159] `addr`\n // - [160..223] `startTimestamp`\n // - [224] `burned`\n // - [225] `nextInitialized`\n // - [232..255] `extraData`\n mapping(uint256 => uint256) private _packedOwnerships;\n\n // Mapping owner address to address data.\n //\n // Bits Layout:\n // - [0..63] `balance`\n // - [64..127] `numberMinted`\n // - [128..191] `numberBurned`\n // - [192..255] `aux`\n mapping(address => uint256) private _packedAddressData;\n\n // Mapping from token ID to approved address.\n mapping(uint256 => TokenApprovalRef) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n // =============================================================\n // CONSTRUCTOR\n // =============================================================\n\n function __ERC721ACloneable__init(\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n _currentIndex = _startTokenId();\n }\n\n // =============================================================\n // TOKEN COUNTING OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the starting token ID.\n * To change the starting token ID, please override this function.\n */\n function _startTokenId() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev Returns the next token ID to be minted.\n */\n function _nextTokenId() internal view virtual returns (uint256) {\n return _currentIndex;\n }\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // Counter underflow is impossible as _burnCounter cannot be incremented\n // more than `_currentIndex - _startTokenId()` times.\n unchecked {\n return _currentIndex - _burnCounter - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total amount of tokens minted in the contract.\n */\n function _totalMinted() internal view virtual returns (uint256) {\n // Counter underflow is impossible as `_currentIndex` does not decrement,\n // and it is initialized to `_startTokenId()`.\n unchecked {\n return _currentIndex - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total number of tokens burned.\n */\n function _totalBurned() internal view virtual returns (uint256) {\n return _burnCounter;\n }\n\n // =============================================================\n // ADDRESS DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens burned by or on behalf of `owner`.\n */\n function _numberBurned(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n return uint64(_packedAddressData[owner] >> _BITPOS_AUX);\n }\n\n /**\n * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal virtual {\n uint256 packed = _packedAddressData[owner];\n uint256 auxCasted;\n // Cast `aux` with assembly to avoid redundant masking.\n assembly {\n auxCasted := aux\n }\n packed =\n (packed & _BITMASK_AUX_COMPLEMENT) |\n (auxCasted << _BITPOS_AUX);\n _packedAddressData[owner] = packed;\n }\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n // The interface IDs are constants representing the first 4 bytes\n // of the XOR of all function selectors in the interface.\n // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)\n // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)\n return\n interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.\n interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.\n interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.\n }\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length != 0\n ? string(abi.encodePacked(baseURI, _toString(tokenId)))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, it can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n // =============================================================\n // OWNERSHIPS OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n return address(uint160(_packedOwnershipOf(tokenId)));\n }\n\n /**\n * @dev Gas spent here starts off proportional to the maximum mint batch size.\n * It gradually moves to O(1) as tokens get transferred around over time.\n */\n function _ownershipOf(uint256 tokenId)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnershipOf(tokenId));\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct at `index`.\n */\n function _ownershipAt(uint256 index)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnerships[index]);\n }\n\n /**\n * @dev Initializes the ownership slot minted at `index` for efficiency purposes.\n */\n function _initializeOwnershipAt(uint256 index) internal virtual {\n if (_packedOwnerships[index] == 0) {\n _packedOwnerships[index] = _packedOwnershipOf(index);\n }\n }\n\n /**\n * Returns the packed ownership data of `tokenId`.\n */\n function _packedOwnershipOf(uint256 tokenId)\n private\n view\n returns (uint256)\n {\n uint256 curr = tokenId;\n\n unchecked {\n if (_startTokenId() <= curr) {\n if (curr < _currentIndex) {\n uint256 packed = _packedOwnerships[curr];\n // If not burned.\n if (packed & _BITMASK_BURNED == 0) {\n // Invariant:\n // There will always be an initialized ownership slot\n // (i.e. `ownership.addr != address(0) && ownership.burned == false`)\n // before an unintialized ownership slot\n // (i.e. `ownership.addr == address(0) && ownership.burned == false`)\n // Hence, `curr` will not underflow.\n //\n // We can directly compare the packed value.\n // If the address is zero, packed will be zero.\n while (packed == 0) {\n packed = _packedOwnerships[--curr];\n }\n return packed;\n }\n }\n }\n }\n revert OwnerQueryForNonexistentToken();\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct from `packed`.\n */\n function _unpackedOwnership(uint256 packed)\n private\n pure\n returns (TokenOwnership memory ownership)\n {\n ownership.addr = address(uint160(packed));\n ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);\n ownership.burned = packed & _BITMASK_BURNED != 0;\n ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);\n }\n\n /**\n * @dev Packs ownership data into a single uint256.\n */\n function _packOwnershipData(address owner, uint256 flags)\n private\n view\n returns (uint256 result)\n {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.\n result := or(\n owner,\n or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)\n )\n }\n }\n\n /**\n * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.\n */\n function _nextInitializedFlag(uint256 quantity)\n private\n pure\n returns (uint256 result)\n {\n // For branchless setting of the `nextInitialized` flag.\n assembly {\n // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.\n result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))\n }\n }\n\n // =============================================================\n // APPROVAL OPERATIONS\n // =============================================================\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ownerOf(tokenId);\n\n if (_msgSenderERC721A() != owner) {\n if (!isApprovedForAll(owner, _msgSenderERC721A())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n }\n\n _tokenApprovals[tokenId].value = to;\n emit Approval(owner, to, tokenId);\n }\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return _tokenApprovals[tokenId].value;\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n virtual\n override\n {\n _operatorApprovals[_msgSenderERC721A()][operator] = approved;\n emit ApprovalForAll(_msgSenderERC721A(), operator, approved);\n }\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted. See {_mint}.\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return\n _startTokenId() <= tokenId &&\n tokenId < _currentIndex && // If within bounds,\n _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.\n }\n\n /**\n * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.\n */\n function _isSenderApprovedOrOwner(\n address approvedAddress,\n address owner,\n address msgSender\n ) private pure returns (bool result) {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.\n msgSender := and(msgSender, _BITMASK_ADDRESS)\n // `msgSender == owner || msgSender == approvedAddress`.\n result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))\n }\n }\n\n /**\n * @dev Returns the storage slot and value for the approved address of `tokenId`.\n */\n function _getApprovedSlotAndAddress(uint256 tokenId)\n private\n view\n returns (uint256 approvedAddressSlot, address approvedAddress)\n {\n TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];\n // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.\n assembly {\n approvedAddressSlot := tokenApproval.slot\n approvedAddress := sload(approvedAddressSlot)\n }\n }\n\n // =============================================================\n // TRANSFER OPERATIONS\n // =============================================================\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n if (address(uint160(prevOwnershipPacked)) != from)\n revert TransferFromIncorrectOwner();\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n\n if (to == address(0)) revert TransferToZeroAddress();\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // We can directly increment and decrement the balances.\n --_packedAddressData[from]; // Updates: `balance -= 1`.\n ++_packedAddressData[to]; // Updates: `balance += 1`.\n\n // Updates:\n // - `address` to the next owner.\n // - `startTimestamp` to the timestamp of transfering.\n // - `burned` to `false`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n to,\n _BITMASK_NEXT_INITIALIZED |\n _nextExtraData(from, to, prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n transferFrom(from, to, tokenId);\n if (to.code.length != 0) {\n if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n }\n\n /**\n * @dev Hook that is called before a set of serially-ordered token IDs\n * are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token IDs\n * have been transferred. This includes minting.\n * And also called after one token has been burned.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.\n *\n * `from` - Previous owner of the given token ID.\n * `to` - Target address that will receive the token.\n * `tokenId` - Token ID to be transferred.\n * `_data` - Optional data to send along with the call.\n *\n * Returns whether the call correctly returned the expected magic value.\n */\n function _checkContractOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n try\n ERC721A__IERC721Receiver(to).onERC721Received(\n _msgSenderERC721A(),\n from,\n tokenId,\n _data\n )\n returns (bytes4 retval) {\n return\n retval ==\n ERC721A__IERC721Receiver(to).onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert TransferToNonERC721ReceiverImplementer();\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n\n // =============================================================\n // MINT OPERATIONS\n // =============================================================\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _mint(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are incredibly unrealistic.\n // `balance` and `numberMinted` have a maximum limit of 2**64.\n // `tokenId` has a maximum limit of 2**256.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n uint256 toMasked;\n uint256 end = startTokenId + quantity;\n\n // Use assembly to loop and emit the `Transfer` event for gas savings.\n // The duplicated `log4` removes an extra check and reduces stack juggling.\n // The assembly, together with the surrounding Solidity code, have been\n // delicately arranged to nudge the compiler into producing optimized opcodes.\n assembly {\n // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.\n toMasked := and(to, _BITMASK_ADDRESS)\n // Emit the `Transfer` event.\n log4(\n 0, // Start of data (0, since no data).\n 0, // End of data (0, since no data).\n _TRANSFER_EVENT_SIGNATURE, // Signature.\n 0, // `address(0)`.\n toMasked, // `to`.\n startTokenId // `tokenId`.\n )\n\n // The `iszero(eq(,))` check ensures that large values of `quantity`\n // that overflows uint256 will make the loop run out of gas.\n // The compiler will optimize the `iszero` away for performance.\n for {\n let tokenId := add(startTokenId, 1)\n } iszero(eq(tokenId, end)) {\n tokenId := add(tokenId, 1)\n } {\n // Emit the `Transfer` event. Similar to above.\n log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)\n }\n }\n if (toMasked == 0) revert MintToZeroAddress();\n\n _currentIndex = end;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * This function is intended for efficient minting only during contract creation.\n *\n * It emits only one {ConsecutiveTransfer} as defined in\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),\n * instead of a sequence of {Transfer} event(s).\n *\n * Calling this function outside of contract creation WILL make your contract\n * non-compliant with the ERC721 standard.\n * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309\n * {ConsecutiveTransfer} event is only permissible during contract creation.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {ConsecutiveTransfer} event.\n */\n function _mintERC2309(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT)\n revert MintERC2309QuantityExceedsLimit();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are unrealistic due to the above check for `quantity` to be below the limit.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n emit ConsecutiveTransfer(\n startTokenId,\n startTokenId + quantity - 1,\n address(0),\n to\n );\n\n _currentIndex = startTokenId + quantity;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n * - `quantity` must be greater than 0.\n *\n * See {_mint}.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal virtual {\n _mint(to, quantity);\n\n unchecked {\n if (to.code.length != 0) {\n uint256 end = _currentIndex;\n uint256 index = end - quantity;\n do {\n if (\n !_checkContractOnERC721Received(\n address(0),\n to,\n index++,\n _data\n )\n ) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n } while (index < end);\n // Reentrancy protection.\n if (_currentIndex != end) revert();\n }\n }\n }\n\n /**\n * @dev Equivalent to `_safeMint(to, quantity, '')`.\n */\n function _safeMint(address to, uint256 quantity) internal virtual {\n _safeMint(to, quantity, \"\");\n }\n\n // =============================================================\n // BURN OPERATIONS\n // =============================================================\n\n /**\n * @dev Equivalent to `_burn(tokenId, false)`.\n */\n function _burn(uint256 tokenId) internal virtual {\n _burn(tokenId, false);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId, bool approvalCheck) internal virtual {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n address from = address(uint160(prevOwnershipPacked));\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n if (approvalCheck) {\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n }\n\n _beforeTokenTransfers(from, address(0), tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // Updates:\n // - `balance -= 1`.\n // - `numberBurned += 1`.\n //\n // We can directly decrement the balance, and increment the number burned.\n // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.\n _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;\n\n // Updates:\n // - `address` to the last owner.\n // - `startTimestamp` to the timestamp of burning.\n // - `burned` to `true`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n from,\n (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) |\n _nextExtraData(from, address(0), prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, address(0), tokenId);\n _afterTokenTransfers(from, address(0), tokenId, 1);\n\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n unchecked {\n _burnCounter++;\n }\n }\n\n // =============================================================\n // EXTRA DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Directly sets the extra data for the ownership data `index`.\n */\n function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {\n uint256 packed = _packedOwnerships[index];\n if (packed == 0) revert OwnershipNotInitializedForExtraData();\n uint256 extraDataCasted;\n // Cast `extraData` with assembly to avoid redundant masking.\n assembly {\n extraDataCasted := extraData\n }\n packed =\n (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) |\n (extraDataCasted << _BITPOS_EXTRA_DATA);\n _packedOwnerships[index] = packed;\n }\n\n /**\n * @dev Called during each token transfer to set the 24bit `extraData` field.\n * Intended to be overridden by the cosumer contract.\n *\n * `previousExtraData` - the value of `extraData` before transfer.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _extraData(\n address from,\n address to,\n uint24 previousExtraData\n ) internal view virtual returns (uint24) {}\n\n /**\n * @dev Returns the next extra data for the packed ownership data.\n * The returned result is shifted into position.\n */\n function _nextExtraData(\n address from,\n address to,\n uint256 prevOwnershipPacked\n ) private view returns (uint256) {\n uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);\n return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;\n }\n\n // =============================================================\n // OTHER OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the message sender (defaults to `msg.sender`).\n *\n * If you are writing GSN compatible contracts, you need to override this function.\n */\n function _msgSenderERC721A() internal view virtual returns (address) {\n return msg.sender;\n }\n\n /**\n * @dev Converts a uint256 to its ASCII string decimal representation.\n */\n function _toString(uint256 value)\n internal\n pure\n virtual\n returns (string memory str)\n {\n assembly {\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\n // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.\n let m := add(mload(0x40), 0xa0)\n // Update the free memory pointer to allocate.\n mstore(0x40, m)\n // Assign the `str` to the end.\n str := sub(m, 0x20)\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end of the memory to calculate the length later.\n let end := str\n\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n // prettier-ignore\n for { let temp := value } 1 {} {\n str := sub(str, 1)\n // Write the character to the pointer.\n // The ASCII index of the '0' character is 48.\n mstore8(str, add(48, mod(temp, 10)))\n // Keep dividing `temp` until zero.\n temp := div(temp, 10)\n // prettier-ignore\n if iszero(temp) { break }\n }\n\n let length := sub(end, str)\n // Move the pointer 32 bytes leftwards to make room for the length.\n str := sub(str, 0x20)\n // Store the length.\n mstore(str, length)\n }\n }\n}\n"
},
"src/clones/ERC721ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"../interfaces/ISeaDropTokenContractMetadata.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport { TwoStepOwnable } from \"utility-contracts/TwoStepOwnable.sol\";\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC721ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721ContractMetadata is a token contract that extends ERC721A\n * with additional metadata and ownership capabilities.\n */\ncontract ERC721ContractMetadataCloneable is\n ERC721ACloneable,\n TwoStepOwnable,\n ISeaDropTokenContractMetadata\n{\n /// @notice Track the max supply.\n uint256 _maxSupply;\n\n /// @notice Track the base URI for token metadata.\n string _tokenBaseURI;\n\n /// @notice Track the contract URI for contract metadata.\n string _contractURI;\n\n /// @notice Track the provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 _provenanceHash;\n\n /// @notice Track the royalty info: address to receive royalties, and\n /// royalty basis points.\n RoyaltyInfo _royaltyInfo;\n\n /**\n * @dev Reverts if the sender is not the owner or the contract itself.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n */\n function _onlyOwnerOrSelf() internal view {\n if (\n _cast(msg.sender == owner()) | _cast(msg.sender == address(this)) ==\n 0\n ) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new base URI.\n _tokenBaseURI = newBaseURI;\n\n // Emit an event with the update.\n if (totalSupply() != 0) {\n emit BatchMetadataUpdate(1, _nextTokenId() - 1);\n }\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId)\n external\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the max supply does not exceed the maximum value of uint64.\n if (newMaxSupply > 2**64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _maxSupply = newMaxSupply;\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if any items have been minted.\n if (_totalMinted() > 0) {\n revert ProvenanceHashCannotBeSetAfterMintStarted();\n }\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if the new royalty address is the zero address.\n if (newInfo.royaltyAddress == address(0)) {\n revert RoyaltyAddressCannotBeZeroAddress();\n }\n\n // Revert if the new basis points is greater than 10_000.\n if (newInfo.royaltyBps > 10_000) {\n revert InvalidRoyaltyBasisPoints(newInfo.royaltyBps);\n }\n\n // Set the new royalty info.\n _royaltyInfo = newInfo;\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(newInfo.royaltyAddress, newInfo.royaltyBps);\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI();\n }\n\n /**\n * @notice Returns the base URI for the contract, which ERC721A uses\n * to return tokenURI.\n */\n function _baseURI() internal view virtual override returns (string memory) {\n return _tokenBaseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() public view returns (uint256) {\n return _maxSupply;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address) {\n return _royaltyInfo.royaltyAddress;\n }\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256) {\n return _royaltyInfo.royaltyBps;\n }\n\n /**\n * @notice Called with the sale price to determine how much royalty\n * is owed and to whom.\n *\n * @ param _tokenId The NFT asset queried for royalty information.\n * @param _salePrice The sale price of the NFT asset specified by\n * _tokenId.\n *\n * @return receiver Address of who should be sent the royalty payment.\n * @return royaltyAmount The royalty payment amount for _salePrice.\n */\n function royaltyInfo(\n uint256,\n /* _tokenId */\n uint256 _salePrice\n ) external view returns (address receiver, uint256 royaltyAmount) {\n // Put the royalty info on the stack for more efficient access.\n RoyaltyInfo storage info = _royaltyInfo;\n\n // Set the royalty amount to the sale price times the royalty basis\n // points divided by 10_000.\n royaltyAmount = (_salePrice * info.royaltyBps) / 10_000;\n\n // Set the receiver of the royalty.\n receiver = info.royaltyAddress;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ACloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal pure function to cast a `bool` value to a `uint256` value.\n *\n * @param b The `bool` value to cast.\n *\n * @return u The `uint256` value.\n */\n function _cast(bool b) internal pure returns (uint256 u) {\n assembly {\n u := b\n }\n }\n}\n"
},
"src/clones/ERC721SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ERC721ContractMetadataCloneable,\n ISeaDropTokenContractMetadata\n} from \"./ERC721ContractMetadataCloneable.sol\";\n\nimport {\n INonFungibleSeaDropToken\n} from \"../interfaces/INonFungibleSeaDropToken.sol\";\n\nimport { ISeaDrop } from \"../interfaces/ISeaDrop.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC721SeaDropStructsErrorsAndEvents\n} from \"../lib/ERC721SeaDropStructsErrorsAndEvents.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport {\n ReentrancyGuardUpgradeable\n} from \"openzeppelin-contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\nimport {\n DefaultOperatorFiltererUpgradeable\n} from \"operator-filter-registry/upgradeable/DefaultOperatorFiltererUpgradeable.sol\";\n\n/**\n * @title ERC721SeaDrop\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721SeaDrop is a token contract that contains methods\n * to properly interact with SeaDrop.\n */\ncontract ERC721SeaDropCloneable is\n ERC721ContractMetadataCloneable,\n INonFungibleSeaDropToken,\n ERC721SeaDropStructsErrorsAndEvents,\n ReentrancyGuardUpgradeable,\n DefaultOperatorFiltererUpgradeable\n{\n /// @notice Track the allowed SeaDrop addresses.\n mapping(address => bool) internal _allowedSeaDrop;\n\n /// @notice Track the enumerated allowed SeaDrop addresses.\n address[] internal _enumeratedAllowedSeaDrop;\n\n /**\n * @dev Reverts if not an allowed SeaDrop contract.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n *\n * @param seaDrop The SeaDrop address to check if allowed.\n */\n function _onlyAllowedSeaDrop(address seaDrop) internal view {\n if (_allowedSeaDrop[seaDrop] != true) {\n revert OnlyAllowedSeaDrop();\n }\n }\n\n /**\n * @notice Deploy the token contract with its name, symbol,\n * and allowed SeaDrop addresses.\n */\n function initialize(\n string calldata __name,\n string calldata __symbol,\n address[] calldata allowedSeaDrop,\n address initialOwner\n ) public initializer {\n __ERC721ACloneable__init(__name, __symbol);\n __ReentrancyGuard_init();\n __DefaultOperatorFilterer_init();\n _updateAllowedSeaDrop(allowedSeaDrop);\n _transferOwnership(initialOwner);\n emit SeaDropTokenDeployed();\n }\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop)\n external\n virtual\n override\n onlyOwner\n {\n _updateAllowedSeaDrop(allowedSeaDrop);\n }\n\n /**\n * @notice Internal function to update the allowed SeaDrop contracts.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function _updateAllowedSeaDrop(address[] calldata allowedSeaDrop) internal {\n // Put the length on the stack for more efficient access.\n uint256 enumeratedAllowedSeaDropLength = _enumeratedAllowedSeaDrop\n .length;\n uint256 allowedSeaDropLength = allowedSeaDrop.length;\n\n // Reset the old mapping.\n for (uint256 i = 0; i < enumeratedAllowedSeaDropLength; ) {\n _allowedSeaDrop[_enumeratedAllowedSeaDrop[i]] = false;\n unchecked {\n ++i;\n }\n }\n\n // Set the new mapping for allowed SeaDrop contracts.\n for (uint256 i = 0; i < allowedSeaDropLength; ) {\n _allowedSeaDrop[allowedSeaDrop[i]] = true;\n unchecked {\n ++i;\n }\n }\n\n // Set the enumeration.\n _enumeratedAllowedSeaDrop = allowedSeaDrop;\n\n // Emit an event for the update.\n emit AllowedSeaDropUpdated(allowedSeaDrop);\n }\n\n /**\n * @dev Overrides the `_startTokenId` function from ERC721A\n * to start at token id `1`.\n *\n * This is to avoid future possible problems since `0` is usually\n * used to signal values that have not been set or have been removed.\n */\n function _startTokenId() internal view virtual override returns (uint256) {\n return 1;\n }\n\n /**\n * @dev Overrides the `tokenURI()` function from ERC721A\n * to return just the base URI if it is implied to not be a directory.\n *\n * This is to help with ERC721 contracts in which the same token URI\n * is desired for each token, such as when the tokenURI is 'unrevealed'.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n\n // Exit early if the baseURI is empty.\n if (bytes(baseURI).length == 0) {\n return \"\";\n }\n\n // Check if the last character in baseURI is a slash.\n if (bytes(baseURI)[bytes(baseURI).length - 1] != bytes(\"/\")[0]) {\n return baseURI;\n }\n\n return string(abi.encodePacked(baseURI, _toString(tokenId)));\n }\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * ERC721A tracks these values automatically, but this note and\n * nonReentrant modifier are left here to encourage best-practices\n * when referencing this contract.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity)\n external\n virtual\n override\n nonReentrant\n {\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(msg.sender);\n\n // Extra safety check to ensure the max supply is not exceeded.\n if (_totalMinted() + quantity > maxSupply()) {\n revert MintQuantityExceedsMaxSupply(\n _totalMinted() + quantity,\n maxSupply()\n );\n }\n\n // Mint the quantity of tokens to the minter.\n _safeMint(minter, quantity);\n }\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the public drop data on SeaDrop.\n ISeaDrop(seaDropImpl).updatePublicDrop(publicDrop);\n }\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allow list on SeaDrop.\n ISeaDrop(seaDropImpl).updateAllowList(allowListData);\n }\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the token gated drop stage.\n ISeaDrop(seaDropImpl).updateTokenGatedDrop(allowedNftToken, dropStage);\n }\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external\n virtual\n override\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the drop URI.\n ISeaDrop(seaDropImpl).updateDropURI(dropURI);\n }\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the creator payout address.\n ISeaDrop(seaDropImpl).updateCreatorPayoutAddress(payoutAddress);\n }\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the owner can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external virtual {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allowed fee recipient.\n ISeaDrop(seaDropImpl).updateAllowedFeeRecipient(feeRecipient, allowed);\n }\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters to\n * enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the signer.\n ISeaDrop(seaDropImpl).updateSignedMintValidationParams(\n signer,\n signedMintValidationParams\n );\n }\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the payer.\n ISeaDrop(seaDropImpl).updatePayer(payer, allowed);\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n override\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n )\n {\n minterNumMinted = _numberMinted(minter);\n currentTotalSupply = _totalMinted();\n maxSupply = _maxSupply;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(INonFungibleSeaDropToken).interfaceId ||\n interfaceId == type(ISeaDropTokenContractMetadata).interfaceId ||\n // ERC721ContractMetadata returns supportsInterface true for\n // EIP-2981\n // ERC721A returns supportsInterface true for\n // ERC165, ERC721, ERC721Metadata\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n * - The `operator` must be allowed.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n * - The `operator` mut be allowed.\n *\n * Emits an {Approval} event.\n */\n function approve(address operator, uint256 tokenId)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.approve(operator, tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n /**\n * @notice Configure multiple properties at a time.\n *\n * Note: The individual configure methods should be used\n * to unset or reset any properties to zero, as this method\n * will ignore zero-value properties in the config struct.\n *\n * @param config The configuration struct.\n */\n function multiConfigure(MultiConfigureStruct calldata config)\n external\n onlyOwner\n {\n if (config.maxSupply > 0) {\n this.setMaxSupply(config.maxSupply);\n }\n if (bytes(config.baseURI).length != 0) {\n this.setBaseURI(config.baseURI);\n }\n if (bytes(config.contractURI).length != 0) {\n this.setContractURI(config.contractURI);\n }\n if (\n _cast(config.publicDrop.startTime != 0) |\n _cast(config.publicDrop.endTime != 0) ==\n 1\n ) {\n this.updatePublicDrop(config.seaDropImpl, config.publicDrop);\n }\n if (bytes(config.dropURI).length != 0) {\n this.updateDropURI(config.seaDropImpl, config.dropURI);\n }\n if (config.allowListData.merkleRoot != bytes32(0)) {\n this.updateAllowList(config.seaDropImpl, config.allowListData);\n }\n if (config.creatorPayoutAddress != address(0)) {\n this.updateCreatorPayoutAddress(\n config.seaDropImpl,\n config.creatorPayoutAddress\n );\n }\n if (config.provenanceHash != bytes32(0)) {\n this.setProvenanceHash(config.provenanceHash);\n }\n if (config.allowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.allowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.allowedFeeRecipients[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.disallowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.disallowedFeeRecipients[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.allowedPayers.length > 0) {\n for (uint256 i = 0; i < config.allowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.allowedPayers[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedPayers.length > 0) {\n for (uint256 i = 0; i < config.disallowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.disallowedPayers[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.tokenGatedDropStages.length > 0) {\n if (\n config.tokenGatedDropStages.length !=\n config.tokenGatedAllowedNftTokens.length\n ) {\n revert TokenGatedMismatch();\n }\n for (uint256 i = 0; i < config.tokenGatedDropStages.length; ) {\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.tokenGatedAllowedNftTokens[i],\n config.tokenGatedDropStages[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedTokenGatedAllowedNftTokens.length > 0) {\n for (\n uint256 i = 0;\n i < config.disallowedTokenGatedAllowedNftTokens.length;\n\n ) {\n TokenGatedDropStage memory emptyStage;\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.disallowedTokenGatedAllowedNftTokens[i],\n emptyStage\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.signedMintValidationParams.length > 0) {\n if (\n config.signedMintValidationParams.length !=\n config.signers.length\n ) {\n revert SignersMismatch();\n }\n for (\n uint256 i = 0;\n i < config.signedMintValidationParams.length;\n\n ) {\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.signers[i],\n config.signedMintValidationParams[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedSigners.length > 0) {\n for (uint256 i = 0; i < config.disallowedSigners.length; ) {\n SignedMintValidationParams memory emptyParams;\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.disallowedSigners[i],\n emptyParams\n );\n unchecked {\n ++i;\n }\n }\n }\n }\n}\n"
},
"src/interfaces/INonFungibleSeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\ninterface INonFungibleSeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @dev Revert with an error if a contract is not an allowed\n * SeaDrop address.\n */\n error OnlyAllowedSeaDrop();\n\n /**\n * @dev Emit an event when allowed SeaDrop contracts are updated.\n */\n event AllowedSeaDropUpdated(address[] allowedSeaDrop);\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop) external;\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity) external;\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n );\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator can only update `feeBps`.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external;\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external;\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator, when present, must first set `feeBps`.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external;\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external;\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the administrator can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external;\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external;\n}\n"
},
"src/interfaces/ISeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n MintParams,\n PublicDrop,\n TokenGatedDropStage,\n TokenGatedMintParams,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"../lib/SeaDropErrorsAndEvents.sol\";\n\ninterface ISeaDrop is SeaDropErrorsAndEvents {\n /**\n * @notice Mint a public drop.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n */\n function mintPublic(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity\n ) external payable;\n\n /**\n * @notice Mint from an allow list.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param proof The proof for the leaf of the allow list.\n */\n function mintAllowList(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n bytes32[] calldata proof\n ) external payable;\n\n /**\n * @notice Mint with a server-side signature.\n * Note that a signature can only be used once.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param salt The sale for the signed mint.\n * @param signature The server-side signature, must be an allowed\n * signer.\n */\n function mintSigned(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n uint256 salt,\n bytes calldata signature\n ) external payable;\n\n /**\n * @notice Mint as an allowed token holder.\n * This will mark the token id as redeemed and will revert if the\n * same token id is attempted to be redeemed twice.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param mintParams The token gated mint params.\n */\n function mintAllowedTokenHolder(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n TokenGatedMintParams calldata mintParams\n ) external payable;\n\n /**\n * @notice Emits an event to notify update of the drop URI.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Updates the public drop data for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(PublicDrop calldata publicDrop) external;\n\n /**\n * @notice Updates the allow list merkle root for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param allowListData The allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Updates the token gated drop stage for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during\n * the `dropStage` time period.\n *\n * @param allowedNftToken The token gated nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Updates the creator payout address and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payoutAddress The creator payout address.\n */\n function updateCreatorPayoutAddress(address payoutAddress) external;\n\n /**\n * @notice Updates the allowed fee recipient and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param feeRecipient The fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(address feeRecipient, bool allowed)\n external;\n\n /**\n * @notice Updates the allowed server-side signers and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address signer,\n SignedMintValidationParams calldata signedMintValidationParams\n ) external;\n\n /**\n * @notice Updates the allowed payer and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payer The payer to add or remove.\n * @param allowed Whether to add or remove the payer.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Returns the public drop data for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPublicDrop(address nftContract)\n external\n view\n returns (PublicDrop memory);\n\n /**\n * @notice Returns the creator payout address for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getCreatorPayoutAddress(address nftContract)\n external\n view\n returns (address);\n\n /**\n * @notice Returns the allow list merkle root for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getAllowListMerkleRoot(address nftContract)\n external\n view\n returns (bytes32);\n\n /**\n * @notice Returns if the specified fee recipient is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param feeRecipient The fee recipient.\n */\n function getFeeRecipientIsAllowed(address nftContract, address feeRecipient)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns an enumeration of allowed fee recipients for an\n * nft contract when fee recipients are enforced\n *\n * @param nftContract The nft contract.\n */\n function getAllowedFeeRecipients(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the server-side signers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getSigners(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the struct of SignedMintValidationParams for a signer.\n *\n * @param nftContract The nft contract.\n * @param signer The signer.\n */\n function getSignedMintValidationParams(address nftContract, address signer)\n external\n view\n returns (SignedMintValidationParams memory);\n\n /**\n * @notice Returns the payers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPayers(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns if the specified payer is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param payer The payer.\n */\n function getPayerIsAllowed(address nftContract, address payer)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns the allowed token gated drop tokens for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getTokenGatedAllowedTokens(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the token gated drop data for the nft contract\n * and token gated nft.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n */\n function getTokenGatedDrop(address nftContract, address allowedNftToken)\n external\n view\n returns (TokenGatedDropStage memory);\n\n /**\n * @notice Returns whether the token id for a token gated drop has been\n * redeemed.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n * @param allowedNftTokenId The token gated nft token id to check.\n */\n function getAllowedNftTokenIdIsRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n ) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\ninterface ISeaDropTokenContractMetadata is IERC2981 {\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables in ERC721A.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert if the royalty basis points is greater than 10_000.\n */\n error InvalidRoyaltyBasisPoints(uint256 basisPoints);\n\n /**\n * @dev Revert if the royalty address is being set to the zero address.\n */\n error RoyaltyAddressCannotBeZeroAddress();\n\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event when the max token supply is updated.\n */\n event MaxSupplyUpdated(uint256 newMaxSupply);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the royalties info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 bps);\n\n /**\n * @notice A struct defining royalty info for the contract.\n */\n struct RoyaltyInfo {\n address royaltyAddress;\n uint96 royaltyBps;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the max supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() external view returns (uint256);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address);\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256);\n}\n"
},
"src/lib/ERC721SeaDropStructsErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n PublicDrop,\n SignedMintValidationParams,\n TokenGatedDropStage\n} from \"./SeaDropStructs.sol\";\n\ninterface ERC721SeaDropStructsErrorsAndEvents {\n /**\n * @notice Revert with an error if mint exceeds the max supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Revert with an error if the number of token gated \n * allowedNftTokens doesn't match the length of supplied\n * drop stages.\n */\n error TokenGatedMismatch();\n\n /**\n * @notice Revert with an error if the number of signers doesn't match\n * the length of supplied signedMintValidationParams\n */\n error SignersMismatch();\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed();\n\n /**\n * @notice A struct to configure multiple contract options at a time.\n */\n struct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n address seaDropImpl;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n address creatorPayoutAddress;\n bytes32 provenanceHash;\n\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n\n address[] allowedPayers;\n address[] disallowedPayers;\n\n // Token-gated\n address[] tokenGatedAllowedNftTokens;\n TokenGatedDropStage[] tokenGatedDropStages;\n address[] disallowedTokenGatedAllowedNftTokens;\n\n // Server-signed\n address[] signers;\n SignedMintValidationParams[] signedMintValidationParams;\n address[] disallowedSigners;\n }\n}"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { PublicDrop, TokenGatedDropStage, SignedMintValidationParams } from \"./SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity is zero.\n */\n error MintQuantityCannotBeZero();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total, \n uint256 maxTokenSupplyForStage\n );\n \n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed();\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the received payment is incorrect.\n */\n error IncorrectPayment(uint256 got, uint256 want);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if signer's signature is invalid.\n */\n error InvalidSignature(address recoveredSigner);\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n * Note: only applies when adding a single payer, as duplicates in\n * enumeration can be removed with updatePayer.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed();\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the sender does not\n * match the INonFungibleSeaDropToken interface.\n */\n error OnlyINonFungibleSeaDropToken(address sender);\n\n /**\n * @dev Revert with an error if the sender of a token gated supplied\n * drop stage redeem is not the owner of the token.\n */\n error TokenGatedNotTokenOwner(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if the token id has already been used to\n * redeem a token gated drop stage.\n */\n error TokenGatedTokenIdAlreadyRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if an empty TokenGatedDropStage is provided\n * for an already-empty TokenGatedDropStage.\n */\n error TokenGatedDropStageNotPresent();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the zero address.\n */\n error TokenGatedDropAllowedNftTokenCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the drop token itself.\n */\n error TokenGatedDropAllowedNftTokenCannotBeDropToken();\n\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n \n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n \n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n * \n * @param nftContract The nft contract.\n * @param minter The mint recipient.\n * @param feeRecipient The fee recipient.\n * @param payer The address who payed for the tx.\n * @param quantityMinted The number of tokens minted.\n * @param unitMintPrice The amount paid for each token.\n * @param feeBps The fee out of 10_000 basis points collected.\n * @param dropStageIndex The drop stage index. Items minted\n * through mintPublic() have\n * dropStageIndex of 0.\n */\n event SeaDropMint(\n address indexed nftContract,\n address indexed minter,\n address indexed feeRecipient,\n address payer,\n uint256 quantityMinted,\n uint256 unitMintPrice,\n uint256 feeBps,\n uint256 dropStageIndex\n );\n\n /**\n * @dev An event with updated public drop data for an nft contract.\n */\n event PublicDropUpdated(\n address indexed nftContract,\n PublicDrop publicDrop\n );\n\n /**\n * @dev An event with updated token gated drop stage data\n * for an nft contract.\n */\n event TokenGatedDropStageUpdated(\n address indexed nftContract,\n address indexed allowedNftToken,\n TokenGatedDropStage dropStage\n );\n\n /**\n * @dev An event with updated allow list data for an nft contract.\n * \n * @param nftContract The nft contract.\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n address indexed nftContract,\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI for an nft contract.\n */\n event DropURIUpdated(address indexed nftContract, string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address for an nft\n * contract.\n */\n event CreatorPayoutAddressUpdated(\n address indexed nftContract,\n address indexed newPayoutAddress\n );\n\n /**\n * @dev An event with the updated allowed fee recipient for an nft\n * contract.\n */\n event AllowedFeeRecipientUpdated(\n address indexed nftContract,\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated validation parameters for server-side\n * signers.\n */\n event SignedMintValidationParamsUpdated(\n address indexed nftContract,\n address indexed signer,\n SignedMintValidationParams signedMintValidationParams\n ); \n\n /**\n * @dev An event with the updated payer for an nft contract.\n */\n event PayerUpdated(\n address indexed nftContract,\n address indexed payer,\n bool indexed allowed\n );\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param startTime The start time, ensure this is not zero.\n * @param endTIme The end time, ensure this is not zero.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 mintPrice; // 80/256 bits\n uint48 startTime; // 128/256 bits\n uint48 endTime; // 176/256 bits\n uint16 maxTotalMintableByWallet; // 224/256 bits\n uint16 feeBps; // 240/256 bits\n bool restrictFeeRecipients; // 248/256 bits\n}\n\n/**\n * @notice A struct defining token gated drop stage data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m \n * of native token, e.g.: ETH, MATIC)\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be \n * non-zero since the public mint emits\n * with index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct TokenGatedDropStage {\n uint80 mintPrice; // 80/256 bits\n uint16 maxTotalMintableByWallet; // 96/256 bits\n uint48 startTime; // 144/256 bits\n uint48 endTime; // 192/256 bits\n uint8 dropStageIndex; // non-zero. 200/256 bits\n uint32 maxTokenSupplyForStage; // 232/256 bits\n uint16 feeBps; // 248/256 bits\n bool restrictFeeRecipients; // 256/256 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n * \n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n * \n * @param mintPrice The mint price per token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 mintPrice; \n uint256 maxTotalMintableByWallet;\n uint256 startTime;\n uint256 endTime;\n uint256 dropStageIndex; // non-zero\n uint256 maxTokenSupplyForStage;\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @notice A struct defining token gated mint params.\n * \n * @param allowedNftToken The allowed nft token contract address.\n * @param allowedNftTokenIds The token ids to redeem.\n */\nstruct TokenGatedMintParams {\n address allowedNftToken;\n uint256[] allowedNftTokenIds;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n * \n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n\n/**\n * @notice A struct defining minimum and maximum parameters to validate for \n * signed mints, to minimize negative effects of a compromised signer.\n *\n * @param minMintPrice The minimum mint price allowed.\n * @param maxMaxTotalMintableByWallet The maximum total number of mints allowed\n * by a wallet.\n * @param minStartTime The minimum start time allowed.\n * @param maxEndTime The maximum end time allowed.\n * @param maxMaxTokenSupplyForStage The maximum token supply allowed.\n * @param minFeeBps The minimum fee allowed.\n * @param maxFeeBps The maximum fee allowed.\n */\nstruct SignedMintValidationParams {\n uint80 minMintPrice; // 80/256 bits\n uint24 maxMaxTotalMintableByWallet; // 104/256 bits\n uint40 minStartTime; // 144/256 bits\n uint40 maxEndTime; // 184/256 bits\n uint40 maxMaxTokenSupplyForStage; // 224/256 bits\n uint16 minFeeBps; // 240/256 bits\n uint16 maxFeeBps; // 256/256 bits\n}"
}
},
"settings": {
"remappings": [
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"ERC721A/=lib/ERC721A/contracts/",
"create2-helpers/=lib/create2-helpers/src/",
"create2-scripts/=lib/create2-helpers/script/",
"ds-test/=lib/ds-test/src/",
"erc4626-tests/=lib/operator-filter-registry/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"murky/=lib/murky/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"operator-filter-registry/=lib/operator-filter-registry/src/",
"seadrop/=src/",
"solmate/=lib/solmate/src/",
"utility-contracts/=lib/utility-contracts/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"bytecodeHash": "none"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}}
|
1 | 19,500,419 |
773b91e236367a06b27ff0aa2819924e13c1c8075933b0e167da19b7060ab2be
|
12dcb4010b8ac960e225c1e3f81c64f95832e4348b0375902739b1c764924885
|
56e0c77261287ed1a01aa7ef79b200b555cda080
|
56e0c77261287ed1a01aa7ef79b200b555cda080
|
186a092de602c780ebf0b4c5830b8e18ac231e82
|
6080604052670de0b6b3a76400006002556658d15e176280006003556004805460ff191690557f4de49460ea71250b1fb894415594768ccd184fc1db55868e21fc64dc4065293f6007557f4de49460ea71250b1fb894414d35824ce1da501ec41341d8e3f7c8dfab07478c6008557f4de49460ea71250b1fb894419886413a90019c65ad65bdac7bc9b253405ee58860095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103678061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212202dd6d00209b98e001a3367702ac38333bc3d7d2f79aab02ed61bb3e61b89ea6f64736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212202dd6d00209b98e001a3367702ac38333bc3d7d2f79aab02ed61bb3e61b89ea6f64736f6c63430008070033
| |
1 | 19,500,419 |
773b91e236367a06b27ff0aa2819924e13c1c8075933b0e167da19b7060ab2be
|
4f634222b1a04e3f1cd26d14455dd08f8ac8cfe88e2e6272056c749403cc8501
|
aae93d12b26a93f6118bdb7a8d3ce017fd8bc9c2
|
a26e15c895efc0616177b7c1e7270a4c7d51c997
|
367626ebd3cd7b0d936193cd4a29d3f3b53bd18d
|
608060405234801561001057600080fd5b50604051602080610b37833981016040819052905160018054600160a060020a03191633600160a060020a031690811790915590917fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a261007d8164010000000061008e810204565b151561008857600080fd5b506102ac565b60006100c6337fffffffff00000000000000000000000000000000000000000000000000000000833516640100000000610180810204565b15156100d157600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a031693600080357fffffffff0000000000000000000000000000000000000000000000000000000016949092606082018484808284376040519201829003965090945050505050a4600160a060020a038416151561015857600080fd5b60028054600160a060020a038616600160a060020a0319909116179055600192505050919050565b600030600160a060020a031683600160a060020a031614156101a4575060016102a6565b600154600160a060020a03848116911614156101c2575060016102a6565b600054600160a060020a031615156101dc575060006102a6565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015230811660248301527fffffffff00000000000000000000000000000000000000000000000000000000871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561027757600080fd5b505af115801561028b573d6000803e3d6000fd5b505050506040513d60208110156102a157600080fd5b505190505b92915050565b61087c806102bb6000396000f30060806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313af4035811461008f5780631cff79cd146100b05780631f6a1eb91461011c57806360c7d295146101c95780637a9e5e4b146101fa5780638da5cb5b1461021b578063948f507614610230578063bf7e214f14610265575b005b34801561009b57600080fd5b5061008d600160a060020a036004351661027a565b60408051602060046024803582810135601f810185900485028601850190965285855261010a958335600160a060020a03169536956044949193909101919081908401838280828437509497506102f89650505050505050565b60408051918252519081900360200190f35b6040805160206004803580820135601f81018490048402850184019095528484526101a694369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506103be9650505050505050565b60408051600160a060020a03909316835260208301919091528051918290030190f35b3480156101d557600080fd5b506101de6105ce565b60408051600160a060020a039092168252519081900360200190f35b34801561020657600080fd5b5061008d600160a060020a03600435166105dd565b34801561022757600080fd5b506101de610657565b34801561023c57600080fd5b50610251600160a060020a0360043516610666565b604080519115158252519081900360200190f35b34801561027157600080fd5b506101de61072d565b61029033600035600160e060020a03191661073c565b151561029b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290556040519116907fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a250565b600061031033600035600160e060020a03191661073c565b151561031b57600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a038516151561038a57600080fd5b60206000855160208701886113885a03f460005193508015600181146103af576103b4565b600080fd5b5050505092915050565b6002546040517f8bf4515c0000000000000000000000000000000000000000000000000000000081526020600482018181528551602484015285516000948594600160a060020a0390911693638bf4515c93899390928392604490910191908501908083838b5b8381101561043d578181015183820152602001610425565b50505050905090810190601f16801561046a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b505050506040513d60208110156104b357600080fd5b50519150600160a060020a03821615156105bb576002546040517f7ed0c3b2000000000000000000000000000000000000000000000000000000008152602060048201818152875160248401528751600160a060020a0390941693637ed0c3b293899383926044909201919085019080838360005b83811015610540578181015183820152602001610528565b50505050905090810190601f16801561056d5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561058c57600080fd5b505af11580156105a0573d6000803e3d6000fd5b505050506040513d60208110156105b657600080fd5b505191505b6105c582846102f8565b90509250929050565b600254600160a060020a031681565b6105f333600035600160e060020a03191661073c565b15156105fe57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03838116919091178083556040519116917f1abebea81bfa2637f28358c371278fb15ede7ea8dd28d2e03b112ff6d936ada491a250565b600154600160a060020a031681565b600061067e33600035600160e060020a03191661073c565b151561068957600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a03841615156106f857600080fd5b60028054600160a060020a03861673ffffffffffffffffffffffffffffffffffffffff19909116179055600192505050919050565b600054600160a060020a031681565b600030600160a060020a031683600160a060020a031614156107605750600161084a565b600154600160a060020a038481169116141561077e5750600161084a565b600054600160a060020a031615156107985750600061084a565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523081166024830152600160e060020a0319871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561081b57600080fd5b505af115801561082f573d6000803e3d6000fd5b505050506040513d602081101561084557600080fd5b505190505b929150505600a165627a7a72305820e498874c9ba9e75028e0c84f1b1d83b2dad5de910c59b837b32e5a190794c5e10029000000000000000000000000271293c67e2d3140a0e9381eff1f9b01e07b0795
|
60806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313af4035811461008f5780631cff79cd146100b05780631f6a1eb91461011c57806360c7d295146101c95780637a9e5e4b146101fa5780638da5cb5b1461021b578063948f507614610230578063bf7e214f14610265575b005b34801561009b57600080fd5b5061008d600160a060020a036004351661027a565b60408051602060046024803582810135601f810185900485028601850190965285855261010a958335600160a060020a03169536956044949193909101919081908401838280828437509497506102f89650505050505050565b60408051918252519081900360200190f35b6040805160206004803580820135601f81018490048402850184019095528484526101a694369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506103be9650505050505050565b60408051600160a060020a03909316835260208301919091528051918290030190f35b3480156101d557600080fd5b506101de6105ce565b60408051600160a060020a039092168252519081900360200190f35b34801561020657600080fd5b5061008d600160a060020a03600435166105dd565b34801561022757600080fd5b506101de610657565b34801561023c57600080fd5b50610251600160a060020a0360043516610666565b604080519115158252519081900360200190f35b34801561027157600080fd5b506101de61072d565b61029033600035600160e060020a03191661073c565b151561029b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290556040519116907fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a250565b600061031033600035600160e060020a03191661073c565b151561031b57600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a038516151561038a57600080fd5b60206000855160208701886113885a03f460005193508015600181146103af576103b4565b600080fd5b5050505092915050565b6002546040517f8bf4515c0000000000000000000000000000000000000000000000000000000081526020600482018181528551602484015285516000948594600160a060020a0390911693638bf4515c93899390928392604490910191908501908083838b5b8381101561043d578181015183820152602001610425565b50505050905090810190601f16801561046a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b505050506040513d60208110156104b357600080fd5b50519150600160a060020a03821615156105bb576002546040517f7ed0c3b2000000000000000000000000000000000000000000000000000000008152602060048201818152875160248401528751600160a060020a0390941693637ed0c3b293899383926044909201919085019080838360005b83811015610540578181015183820152602001610528565b50505050905090810190601f16801561056d5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561058c57600080fd5b505af11580156105a0573d6000803e3d6000fd5b505050506040513d60208110156105b657600080fd5b505191505b6105c582846102f8565b90509250929050565b600254600160a060020a031681565b6105f333600035600160e060020a03191661073c565b15156105fe57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03838116919091178083556040519116917f1abebea81bfa2637f28358c371278fb15ede7ea8dd28d2e03b112ff6d936ada491a250565b600154600160a060020a031681565b600061067e33600035600160e060020a03191661073c565b151561068957600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a03841615156106f857600080fd5b60028054600160a060020a03861673ffffffffffffffffffffffffffffffffffffffff19909116179055600192505050919050565b600054600160a060020a031681565b600030600160a060020a031683600160a060020a031614156107605750600161084a565b600154600160a060020a038481169116141561077e5750600161084a565b600054600160a060020a031615156107985750600061084a565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523081166024830152600160e060020a0319871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561081b57600080fd5b505af115801561082f573d6000803e3d6000fd5b505050506040513d602081101561084557600080fd5b505190505b929150505600a165627a7a72305820e498874c9ba9e75028e0c84f1b1d83b2dad5de910c59b837b32e5a190794c5e10029
|
// proxy.sol - execute actions atomically through the proxy's identity
// Copyright (C) 2017 DappHub, LLC
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.4.23;
contract DSAuthority {
function canCall(
address src, address dst, bytes4 sig
) public view returns (bool);
}
contract DSAuthEvents {
event LogSetAuthority (address indexed authority);
event LogSetOwner (address indexed owner);
}
contract DSAuth is DSAuthEvents {
DSAuthority public authority;
address public owner;
constructor() public {
owner = msg.sender;
emit LogSetOwner(msg.sender);
}
function setOwner(address owner_)
public
auth
{
owner = owner_;
emit LogSetOwner(owner);
}
function setAuthority(DSAuthority authority_)
public
auth
{
authority = authority_;
emit LogSetAuthority(authority);
}
modifier auth {
require(isAuthorized(msg.sender, msg.sig));
_;
}
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == DSAuthority(0)) {
return false;
} else {
return authority.canCall(src, this, sig);
}
}
}
contract DSNote {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint wad,
bytes fax
) anonymous;
modifier note {
bytes32 foo;
bytes32 bar;
assembly {
foo := calldataload(4)
bar := calldataload(36)
}
emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
_;
}
}
// DSProxy
// Allows code execution using a persistant identity This can be very
// useful to execute a sequence of atomic actions. Since the owner of
// the proxy can be changed, this allows for dynamic ownership models
// i.e. a multisig
contract DSProxy is DSAuth, DSNote {
DSProxyCache public cache; // global cache for contracts
constructor(address _cacheAddr) public {
require(setCache(_cacheAddr));
}
function() public payable {
}
// use the proxy to execute calldata _data on contract _code
function execute(bytes _code, bytes _data)
public
payable
returns (address target, bytes32 response)
{
target = cache.read(_code);
if (target == 0x0) {
// deploy contract & store its address in cache
target = cache.write(_code);
}
response = execute(target, _data);
}
function execute(address _target, bytes _data)
public
auth
note
payable
returns (bytes32 response)
{
require(_target != 0x0);
// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
response := mload(0) // load delegatecall output
switch iszero(succeeded)
case 1 {
// throw if delegatecall failed
revert(0, 0)
}
}
}
//set new cache
function setCache(address _cacheAddr)
public
auth
note
returns (bool)
{
require(_cacheAddr != 0x0); // invalid cache address
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}
}
// DSProxyFactory
// This factory deploys new proxy instances through build()
// Deployed proxy addresses are logged
contract DSProxyFactory {
event Created(address indexed sender, address indexed owner, address proxy, address cache);
mapping(address=>bool) public isProxy;
DSProxyCache public cache = new DSProxyCache();
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (DSProxy proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (DSProxy proxy) {
proxy = new DSProxy(cache);
emit Created(msg.sender, owner, address(proxy), address(cache));
proxy.setOwner(owner);
isProxy[proxy] = true;
}
}
// DSProxyCache
// This global cache stores addresses of contracts previously deployed
// by a proxy. This saves gas from repeat deployment of the same
// contracts and eliminates blockchain bloat.
// By default, all proxies deployed from the same factory store
// contracts in the same cache. The cache a proxy instance uses can be
// changed. The cache uses the sha3 hash of a contract's bytecode to
// lookup the address
contract DSProxyCache {
mapping(bytes32 => address) cache;
function read(bytes _code) public view returns (address) {
bytes32 hash = keccak256(_code);
return cache[hash];
}
function write(bytes _code) public returns (address target) {
assembly {
target := create(0, add(_code, 0x20), mload(_code))
switch iszero(extcodesize(target))
case 1 {
// throw if contract failed to deploy
revert(0, 0)
}
}
bytes32 hash = keccak256(_code);
cache[hash] = target;
}
}
|
1 | 19,500,423 |
6d860abd4c286904803727a17c2d0d5e4a0a870334cd9eda30a700b32c73d9a8
|
d693aeaaefba466e8773e9bc832becc60e9e60d79c01c73bdd30851082479b96
|
2586f5ea5363585427548d4adbbbb5ca2ad27ff5
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
f4abba7801b60f8c7078ae13283b8ef844d95b9b
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,424 |
631efebb54f29d8229326a891a1de4853cc03f9d304bf607cdc851dac345fe85
|
d8e5e70ae29079ba709bc9c5e3b42687169fce8dfc07811c9b17333d35344d2d
|
578f533873dc8ea60ab1417180cc531f172ee292
|
29ef46035e9fa3d570c598d3266424ca11413b0c
|
f0315e99443740aad5fdf3c7d35afd05220e9837
|
3d602d80600a3d3981f3363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"contracts/Forwarder.sol": {
"content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.10;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarder.sol';\n\n/**\n * Contract that will forward any incoming Ether to the creator of the contract\n *\n */\ncontract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {\n // Address to which any funds sent to this contract will be forwarded\n address public parentAddress;\n bool public autoFlush721 = true;\n bool public autoFlush1155 = true;\n\n event ForwarderDeposited(address from, uint256 value, bytes data);\n\n /**\n * Initialize the contract, and sets the destination address to that of the creator\n */\n function init(\n address _parentAddress,\n bool _autoFlush721,\n bool _autoFlush1155\n ) external onlyUninitialized {\n parentAddress = _parentAddress;\n uint256 value = address(this).balance;\n\n // set whether we want to automatically flush erc721/erc1155 tokens or not\n autoFlush721 = _autoFlush721;\n autoFlush1155 = _autoFlush1155;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n\n // NOTE: since we are forwarding on initialization,\n // we don't have the context of the original sender.\n // We still emit an event about the forwarding but set\n // the sender to the forwarder itself\n emit ForwarderDeposited(address(this), value, msg.data);\n }\n\n /**\n * Modifier that will execute internal code block only if the sender is the parent address\n */\n modifier onlyParent {\n require(msg.sender == parentAddress, 'Only Parent');\n _;\n }\n\n /**\n * Modifier that will execute internal code block only if the contract has not been initialized yet\n */\n modifier onlyUninitialized {\n require(parentAddress == address(0x0), 'Already initialized');\n _;\n }\n\n /**\n * Default function; Gets called when data is sent but does not match any other function\n */\n fallback() external payable {\n flush();\n }\n\n /**\n * Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n */\n receive() external payable {\n flush();\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush721(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush721 = autoFlush;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush1155(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush1155 = autoFlush;\n }\n\n /**\n * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n * to the base wallet once the nft contract invokes this method after transfering the nft.\n *\n * @param _operator The address which called `safeTransferFrom` function\n * @param _from The address of the sender\n * @param _tokenId The token id of the nft\n * @param data Additional data with no specified format, sent in call to `_to`\n */\n function onERC721Received(\n address _operator,\n address _from,\n uint256 _tokenId,\n bytes memory data\n ) external virtual override returns (bytes4) {\n if (autoFlush721) {\n IERC721 instance = IERC721(msg.sender);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The caller does not support the ERC721 interface'\n );\n // this won't work for ERC721 re-entrancy\n instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n }\n\n return this.onERC721Received.selector;\n }\n\n function callFromParent(\n address target,\n uint256 value,\n bytes calldata data\n ) external onlyParent returns (bytes memory) {\n (bool success, bytes memory returnedData) = target.call{ value: value }(\n data\n );\n require(success, 'Parent call execution failed');\n\n return returnedData;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155Received(\n address _operator,\n address _from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n }\n\n return this.onERC1155Received.selector;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155BatchReceived(\n address _operator,\n address _from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeBatchTransferFrom(\n address(this),\n parentAddress,\n ids,\n values,\n data\n );\n }\n\n return this.onERC1155BatchReceived.selector;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushTokens(address tokenContractAddress)\n external\n virtual\n override\n onlyParent\n {\n ERC20Interface instance = ERC20Interface(tokenContractAddress);\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n if (forwarderBalance == 0) {\n return;\n }\n\n TransferHelper.safeTransfer(\n tokenContractAddress,\n parentAddress,\n forwarderBalance\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC721 instance = IERC721(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The tokenContractAddress does not support the ERC721 interface'\n );\n\n address ownerAddress = instance.ownerOf(tokenId);\n instance.transferFrom(ownerAddress, parentAddress, tokenId);\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n instance.safeTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenId,\n forwarderBalance,\n ''\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external virtual override onlyParent {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256[] memory amounts = new uint256[](tokenIds.length);\n for (uint256 i = 0; i < tokenIds.length; i++) {\n amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n }\n\n instance.safeBatchTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenIds,\n amounts,\n ''\n );\n }\n\n /**\n * Flush the entire balance of the contract to the parent address.\n */\n function flush() public {\n uint256 value = address(this).balance;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n emit ForwarderDeposited(msg.sender, value, msg.data);\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId)\n public\n virtual\n override(ERC1155Receiver, IERC165)\n view\n returns (bool)\n {\n return\n interfaceId == type(IForwarder).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/ERC20Interface.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.10;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n // Send _value amount of tokens to address _to\n function transfer(address _to, uint256 _value)\n public\n virtual\n returns (bool success);\n\n // Get the account balance of another account with address _owner\n function balanceOf(address _owner)\n public\n virtual\n view\n returns (uint256 balance);\n}\n"
},
"contracts/TransferHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.10;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(\n abi.encodeWithSelector(0xa9059cbb, to, value)\n );\n require(\n success && (data.length == 0 || abi.decode(data, (bool))),\n 'TransferHelper::safeTransfer: transfer failed'\n );\n }\n\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory returndata) = token.call(\n abi.encodeWithSelector(0x23b872dd, from, to, value)\n );\n Address.verifyCallResult(\n success,\n returndata,\n 'TransferHelper::transferFrom: transferFrom failed'\n );\n }\n}\n"
},
"contracts/IForwarder.sol": {
"content": "pragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarder is IERC165 {\n /**\n * Sets the autoflush721 parameter.\n *\n * @param autoFlush whether to autoflush erc721 tokens\n */\n function setAutoFlush721(bool autoFlush) external;\n\n /**\n * Sets the autoflush1155 parameter.\n *\n * @param autoFlush whether to autoflush erc1155 tokens\n */\n function setAutoFlush1155(bool autoFlush) external;\n\n /**\n * Execute a token transfer of the full balance from the forwarder token to the parent address\n *\n * @param tokenContractAddress the address of the erc20 token contract\n */\n function flushTokens(address tokenContractAddress) external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address\n *\n * @param tokenContractAddress the address of the ERC721 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a batch nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenIds The token ids of the nfts\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external;\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n @dev Handles the receipt of a single ERC1155 token type. This function is\n called at the end of a `safeTransferFrom` after the balance has been updated.\n To accept the transfer, this must return\n `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n (i.e. 0xf23a6e61, or its own function selector).\n @param operator The address which initiated the transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param id The ID of the token being transferred\n @param value The amount of tokens being transferred\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n @dev Handles the receipt of a multiple ERC1155 token types. This function\n is called at the end of a `safeBatchTransferFrom` after the balances have\n been updated. To accept the transfer(s), this must return\n `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n (i.e. 0xbc197c81, or its own function selector).\n @param operator The address which initiated the batch transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param ids An array containing ids of each token being transferred (order and length must match values array)\n @param values An array containing amounts of each token being transferred (order and length must match ids array)\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,500,426 |
9e996faf9c4a9d8dd7acb145ea5735c9987654d85f7856c55ad7245b1ce814ed
|
a92cba7d08da929622e87b5832ca4b852b51225ca4b6bd9ebc9b3b6b3c193634
|
0000db5c8b030ae20308ac975898e09741e70000
|
ed0e416e0feea5b484ba5c95d375545ac2b60572
|
2917f69cda3347995494ef26903f63dcc48c92b8
|
608060405234801561001057600080fd5b50604051610a1a380380610a1a8339818101604052810190610032919061011c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550326000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610149565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100e9826100be565b9050919050565b6100f9816100de565b811461010457600080fd5b50565b600081519050610116816100f0565b92915050565b600060208284031215610132576101316100b9565b5b600061014084828501610107565b91505092915050565b6108c2806101586000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063caa5c23f1461003b578063cce3d5d314610057575b600080fd5b610055600480360381019061005091906105fa565b610073565b005b610071600480360381019061006c9190610679565b6101ca565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610703565b60405180910390fd5b60005b81518110156101c6578181815181106101205761011f610723565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1682828151811061015557610154610723565b5b60200260200101516020015160405161016e91906107c3565b6000604051808303816000865af19150503d80600081146101ab576040519150601f19603f3d011682016040523d82523d6000602084013e6101b0565b606091505b50505080806101be90610809565b915050610104565b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024f90610703565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160405161029e90610877565b60006040518083038185875af1925050503d80600081146102db576040519150601f19603f3d011682016040523d82523d6000602084013e6102e0565b606091505b50505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610348826102ff565b810181811067ffffffffffffffff8211171561036757610366610310565b5b80604052505050565b600061037a6102e6565b9050610386828261033f565b919050565b600067ffffffffffffffff8211156103a6576103a5610310565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103f1826103c6565b9050919050565b610401816103e6565b811461040c57600080fd5b50565b60008135905061041e816103f8565b92915050565b600080fd5b600067ffffffffffffffff82111561044457610443610310565b5b61044d826102ff565b9050602081019050919050565b82818337600083830152505050565b600061047c61047784610429565b610370565b90508281526020810184848401111561049857610497610424565b5b6104a384828561045a565b509392505050565b600082601f8301126104c0576104bf6102fa565b5b81356104d0848260208601610469565b91505092915050565b6000604082840312156104ef576104ee6103bc565b5b6104f96040610370565b905060006105098482850161040f565b600083015250602082013567ffffffffffffffff81111561052d5761052c6103c1565b5b610539848285016104ab565b60208301525092915050565b60006105586105538461038b565b610370565b9050808382526020820190506020840283018581111561057b5761057a6103b7565b5b835b818110156105c257803567ffffffffffffffff8111156105a05761059f6102fa565b5b8086016105ad89826104d9565b8552602085019450505060208101905061057d565b5050509392505050565b600082601f8301126105e1576105e06102fa565b5b81356105f1848260208601610545565b91505092915050565b6000602082840312156106105761060f6102f0565b5b600082013567ffffffffffffffff81111561062e5761062d6102f5565b5b61063a848285016105cc565b91505092915050565b6000819050919050565b61065681610643565b811461066157600080fd5b50565b6000813590506106738161064d565b92915050565b60006020828403121561068f5761068e6102f0565b5b600061069d84828501610664565b91505092915050565b600082825260208201905092915050565b7f43616c6c6572206973206e6f7420746865206f776e6572000000000000000000600082015250565b60006106ed6017836106a6565b91506106f8826106b7565b602082019050919050565b6000602082019050818103600083015261071c816106e0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600081905092915050565b60005b8381101561078657808201518184015260208101905061076b565b60008484015250505050565b600061079d82610752565b6107a7818561075d565b93506107b7818560208601610768565b80840191505092915050565b60006107cf8284610792565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061081482610643565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610846576108456107da565b5b600182019050919050565b50565b600061086160008361075d565b915061086c82610851565b600082019050919050565b600061088282610854565b915081905091905056fea264697066735822122036692b46567a60a4f6844f8be0961cccba9ff2777bd37b4ea35791aba4c5159b64736f6c63430008120033000000000000000000000000000037bb05b2cef17c6469f4bcdb198826ce0000
|
608060405234801561001057600080fd5b50600436106100365760003560e01c8063caa5c23f1461003b578063cce3d5d314610057575b600080fd5b610055600480360381019061005091906105fa565b610073565b005b610071600480360381019061006c9190610679565b6101ca565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610703565b60405180910390fd5b60005b81518110156101c6578181815181106101205761011f610723565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1682828151811061015557610154610723565b5b60200260200101516020015160405161016e91906107c3565b6000604051808303816000865af19150503d80600081146101ab576040519150601f19603f3d011682016040523d82523d6000602084013e6101b0565b606091505b50505080806101be90610809565b915050610104565b5050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024f90610703565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160405161029e90610877565b60006040518083038185875af1925050503d80600081146102db576040519150601f19603f3d011682016040523d82523d6000602084013e6102e0565b606091505b50505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610348826102ff565b810181811067ffffffffffffffff8211171561036757610366610310565b5b80604052505050565b600061037a6102e6565b9050610386828261033f565b919050565b600067ffffffffffffffff8211156103a6576103a5610310565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103f1826103c6565b9050919050565b610401816103e6565b811461040c57600080fd5b50565b60008135905061041e816103f8565b92915050565b600080fd5b600067ffffffffffffffff82111561044457610443610310565b5b61044d826102ff565b9050602081019050919050565b82818337600083830152505050565b600061047c61047784610429565b610370565b90508281526020810184848401111561049857610497610424565b5b6104a384828561045a565b509392505050565b600082601f8301126104c0576104bf6102fa565b5b81356104d0848260208601610469565b91505092915050565b6000604082840312156104ef576104ee6103bc565b5b6104f96040610370565b905060006105098482850161040f565b600083015250602082013567ffffffffffffffff81111561052d5761052c6103c1565b5b610539848285016104ab565b60208301525092915050565b60006105586105538461038b565b610370565b9050808382526020820190506020840283018581111561057b5761057a6103b7565b5b835b818110156105c257803567ffffffffffffffff8111156105a05761059f6102fa565b5b8086016105ad89826104d9565b8552602085019450505060208101905061057d565b5050509392505050565b600082601f8301126105e1576105e06102fa565b5b81356105f1848260208601610545565b91505092915050565b6000602082840312156106105761060f6102f0565b5b600082013567ffffffffffffffff81111561062e5761062d6102f5565b5b61063a848285016105cc565b91505092915050565b6000819050919050565b61065681610643565b811461066157600080fd5b50565b6000813590506106738161064d565b92915050565b60006020828403121561068f5761068e6102f0565b5b600061069d84828501610664565b91505092915050565b600082825260208201905092915050565b7f43616c6c6572206973206e6f7420746865206f776e6572000000000000000000600082015250565b60006106ed6017836106a6565b91506106f8826106b7565b602082019050919050565b6000602082019050818103600083015261071c816106e0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600081905092915050565b60005b8381101561078657808201518184015260208101905061076b565b60008484015250505050565b600061079d82610752565b6107a7818561075d565b93506107b7818560208601610768565b80840191505092915050565b60006107cf8284610792565b915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061081482610643565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610846576108456107da565b5b600182019050919050565b50565b600061086160008361075d565b915061086c82610851565b600082019050919050565b600061088282610854565b915081905091905056fea264697066735822122036692b46567a60a4f6844f8be0961cccba9ff2777bd37b4ea35791aba4c5159b64736f6c63430008120033
| |
1 | 19,500,428 |
3d5c963c56db11aeace7a70a1097dc69592e0ca4a0734006fb5c58827df4e542
|
fffed0da957c93f80d0a7aa31accd16b99dfedb549134fafd8a782b1b6686d68
|
f09ae956e82a3987efc6eec890636a99bb6e7766
|
29ef46035e9fa3d570c598d3266424ca11413b0c
|
c0710fe5e427ecdae7c6bf00a22c56e61154ff54
|
3d602d80600a3d3981f3363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"contracts/Forwarder.sol": {
"content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.10;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarder.sol';\n\n/**\n * Contract that will forward any incoming Ether to the creator of the contract\n *\n */\ncontract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {\n // Address to which any funds sent to this contract will be forwarded\n address public parentAddress;\n bool public autoFlush721 = true;\n bool public autoFlush1155 = true;\n\n event ForwarderDeposited(address from, uint256 value, bytes data);\n\n /**\n * Initialize the contract, and sets the destination address to that of the creator\n */\n function init(\n address _parentAddress,\n bool _autoFlush721,\n bool _autoFlush1155\n ) external onlyUninitialized {\n parentAddress = _parentAddress;\n uint256 value = address(this).balance;\n\n // set whether we want to automatically flush erc721/erc1155 tokens or not\n autoFlush721 = _autoFlush721;\n autoFlush1155 = _autoFlush1155;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n\n // NOTE: since we are forwarding on initialization,\n // we don't have the context of the original sender.\n // We still emit an event about the forwarding but set\n // the sender to the forwarder itself\n emit ForwarderDeposited(address(this), value, msg.data);\n }\n\n /**\n * Modifier that will execute internal code block only if the sender is the parent address\n */\n modifier onlyParent {\n require(msg.sender == parentAddress, 'Only Parent');\n _;\n }\n\n /**\n * Modifier that will execute internal code block only if the contract has not been initialized yet\n */\n modifier onlyUninitialized {\n require(parentAddress == address(0x0), 'Already initialized');\n _;\n }\n\n /**\n * Default function; Gets called when data is sent but does not match any other function\n */\n fallback() external payable {\n flush();\n }\n\n /**\n * Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n */\n receive() external payable {\n flush();\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush721(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush721 = autoFlush;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush1155(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush1155 = autoFlush;\n }\n\n /**\n * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n * to the base wallet once the nft contract invokes this method after transfering the nft.\n *\n * @param _operator The address which called `safeTransferFrom` function\n * @param _from The address of the sender\n * @param _tokenId The token id of the nft\n * @param data Additional data with no specified format, sent in call to `_to`\n */\n function onERC721Received(\n address _operator,\n address _from,\n uint256 _tokenId,\n bytes memory data\n ) external virtual override returns (bytes4) {\n if (autoFlush721) {\n IERC721 instance = IERC721(msg.sender);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The caller does not support the ERC721 interface'\n );\n // this won't work for ERC721 re-entrancy\n instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n }\n\n return this.onERC721Received.selector;\n }\n\n function callFromParent(\n address target,\n uint256 value,\n bytes calldata data\n ) external onlyParent returns (bytes memory) {\n (bool success, bytes memory returnedData) = target.call{ value: value }(\n data\n );\n require(success, 'Parent call execution failed');\n\n return returnedData;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155Received(\n address _operator,\n address _from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n }\n\n return this.onERC1155Received.selector;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155BatchReceived(\n address _operator,\n address _from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeBatchTransferFrom(\n address(this),\n parentAddress,\n ids,\n values,\n data\n );\n }\n\n return this.onERC1155BatchReceived.selector;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushTokens(address tokenContractAddress)\n external\n virtual\n override\n onlyParent\n {\n ERC20Interface instance = ERC20Interface(tokenContractAddress);\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n if (forwarderBalance == 0) {\n return;\n }\n\n TransferHelper.safeTransfer(\n tokenContractAddress,\n parentAddress,\n forwarderBalance\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC721 instance = IERC721(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The tokenContractAddress does not support the ERC721 interface'\n );\n\n address ownerAddress = instance.ownerOf(tokenId);\n instance.transferFrom(ownerAddress, parentAddress, tokenId);\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n instance.safeTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenId,\n forwarderBalance,\n ''\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external virtual override onlyParent {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256[] memory amounts = new uint256[](tokenIds.length);\n for (uint256 i = 0; i < tokenIds.length; i++) {\n amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n }\n\n instance.safeBatchTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenIds,\n amounts,\n ''\n );\n }\n\n /**\n * Flush the entire balance of the contract to the parent address.\n */\n function flush() public {\n uint256 value = address(this).balance;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n emit ForwarderDeposited(msg.sender, value, msg.data);\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId)\n public\n virtual\n override(ERC1155Receiver, IERC165)\n view\n returns (bool)\n {\n return\n interfaceId == type(IForwarder).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/ERC20Interface.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.10;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n // Send _value amount of tokens to address _to\n function transfer(address _to, uint256 _value)\n public\n virtual\n returns (bool success);\n\n // Get the account balance of another account with address _owner\n function balanceOf(address _owner)\n public\n virtual\n view\n returns (uint256 balance);\n}\n"
},
"contracts/TransferHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.10;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(\n abi.encodeWithSelector(0xa9059cbb, to, value)\n );\n require(\n success && (data.length == 0 || abi.decode(data, (bool))),\n 'TransferHelper::safeTransfer: transfer failed'\n );\n }\n\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory returndata) = token.call(\n abi.encodeWithSelector(0x23b872dd, from, to, value)\n );\n Address.verifyCallResult(\n success,\n returndata,\n 'TransferHelper::transferFrom: transferFrom failed'\n );\n }\n}\n"
},
"contracts/IForwarder.sol": {
"content": "pragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarder is IERC165 {\n /**\n * Sets the autoflush721 parameter.\n *\n * @param autoFlush whether to autoflush erc721 tokens\n */\n function setAutoFlush721(bool autoFlush) external;\n\n /**\n * Sets the autoflush1155 parameter.\n *\n * @param autoFlush whether to autoflush erc1155 tokens\n */\n function setAutoFlush1155(bool autoFlush) external;\n\n /**\n * Execute a token transfer of the full balance from the forwarder token to the parent address\n *\n * @param tokenContractAddress the address of the erc20 token contract\n */\n function flushTokens(address tokenContractAddress) external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address\n *\n * @param tokenContractAddress the address of the ERC721 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a batch nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenIds The token ids of the nfts\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external;\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n @dev Handles the receipt of a single ERC1155 token type. This function is\n called at the end of a `safeTransferFrom` after the balance has been updated.\n To accept the transfer, this must return\n `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n (i.e. 0xf23a6e61, or its own function selector).\n @param operator The address which initiated the transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param id The ID of the token being transferred\n @param value The amount of tokens being transferred\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n @dev Handles the receipt of a multiple ERC1155 token types. This function\n is called at the end of a `safeBatchTransferFrom` after the balances have\n been updated. To accept the transfer(s), this must return\n `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n (i.e. 0xbc197c81, or its own function selector).\n @param operator The address which initiated the batch transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param ids An array containing ids of each token being transferred (order and length must match values array)\n @param values An array containing amounts of each token being transferred (order and length must match ids array)\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,500,431 |
65f8288b3d646ccdcd60dec81cc660d5476c03dee99ff34437b101e069fddc83
|
e624862d43b9bb65e3c77125f46b51f417c4799069aa96fb17bca9f36c89e7a1
|
099b1d292689be58f498f127f4e08fe4f0969bce
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
f94bba8fba5a26c0ec4e016da676b06d79fee130
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,500,431 |
65f8288b3d646ccdcd60dec81cc660d5476c03dee99ff34437b101e069fddc83
|
63098ada761e9786fc52def6c592e36dafa2c96d162d04e9523cbbebc750a673
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
fb21a64b53fc0120745ab6d80b9fbdf8cf85cced
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,500,431 |
65f8288b3d646ccdcd60dec81cc660d5476c03dee99ff34437b101e069fddc83
|
b830db9ae65d42df804603370a5fd4ed4c2c38ff3898eaffb8273a01fd91e730
|
aae93d12b26a93f6118bdb7a8d3ce017fd8bc9c2
|
5ef30b9986345249bc32d8928b7ee64de9435e39
|
5a1020bfcc5a4b14ee68f40af3f9c60395387dab
|
6080604052348015600f57600080fd5b5060405161012438038061012483398181016040526020811015603157600080fd5b81019080805190602001909291905050508073ffffffffffffffffffffffffffffffffffffffff1663a3b22fc4336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15801560c057600080fd5b505af115801560d3573d6000803e3d6000fd5b5050505050603e806100e66000396000f3fe6080604052600080fdfea265627a7a7231582011d8228e4d52a33e72559199f2a9e6502500acb18f172cf552c647d56fee044f64736f6c634300050c003200000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b
|
6080604052600080fdfea265627a7a7231582011d8228e4d52a33e72559199f2a9e6502500acb18f172cf552c647d56fee044f64736f6c634300050c0032
|
// Copyright (C) 2018-2020 Maker Ecosystem Growth Holdings, INC.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pragma solidity ^0.5.12;
contract VatLike {
function urns(bytes32, address) public view returns (uint, uint);
function hope(address) public;
function flux(bytes32, address, address, uint) public;
function move(address, address, uint) public;
function frob(bytes32, address, address, address, int, int) public;
function fork(bytes32, address, address, int, int) public;
}
contract UrnHandler {
constructor(address vat) public {
VatLike(vat).hope(msg.sender);
}
}
|
1 | 19,500,432 |
1b05b88d05405d64c8bf8eafbc5e3f850aa3c24765f3a055e987a9f07d63028c
|
e22e59daa51c2c0c977137cc95626610ddf745f25a970ee697de45bb8288084b
|
431bb37b12449bf078bc86f63b670625958c38a7
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
7bbd99f402c3a94bfcf8f26f78049f191bd6010a
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,500,441 |
4ab436288107b0bd39004403c194bcb1a9f5cfc8ff89181e15368e340173a1d2
|
e4a1e87aaec171cfbe89f17a1d08448a4e6449fbfe50f6e1987d4bdef832b77e
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
091942047b2b677ca16ae625bde5073d96356d41
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,500,448 |
656951eef5009fb4bd203f72a9eaeaa9a302af7a2fdfceabb0e897a17a888bcc
|
ac9c8b854bef2a610bf719f236a2dc2ea1c88624a1c3d91617d24ad1ef44d10b
|
25bd607a5fe0a7a5c0b5549c720ab740710a5139
|
d672f1e3411c23edbb49e8eb6c6b1564b2bf8e17
|
b69d8de2963439e53d522268d9cd71d8b2b30702
|
3d602d80600a3d3981f3363d3d373d3d3d363d73f48aa3d22ee68e4adc612fd84ebd70ca4390d82e5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73f48aa3d22ee68e4adc612fd84ebd70ca4390d82e5af43d82803e903d91602b57fd5bf3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.