Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xC88F47067dB2E25851317A2FDaE73a22c0777c37
Balance 0.000000000 ETH
Nonce 1
Code Size 19251 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

19251 bytes
0x6080604052600436106103f95760003560e01c80637dbe5f1011610213578063c99d3a0611610123578063e9144e73116100ab578063f196d0181161007a578063f196d01814610e24578063f1ae3c7f14610e57578063f2fde38b14610e8a578063f6cad25514610ebd578063fdec254f14610ef0576103f9565b8063e9144e7314610d7f578063e941fa7814610db2578063eb7afed014610dc7578063efdf0bb014610df1576103f9565b8063d494d586116100f2578063d494d58614610c9f578063da2b9bfa14610cd2578063dd62ed3e14610ce7578063e2b11a6414610d22578063e56df6c614610d55576103f9565b8063c99d3a0614610c18578063ca7f171a14610c4b578063ce72d8fd14610c75578063d2d97b0614610c8a576103f9565b806395d89b41116101a6578063a457c2d711610175578063a457c2d714610b00578063a9059cbb14610b39578063b37c551514610b72578063c072ea4314610bb5578063c522e74f14610bee576103f9565b806395d89b4114610aac57806399b16efd14610ac15780639bf7451914610ad65780639f81aed714610aeb576103f9565b80638da5cb5b116101e25780638da5cb5b14610a415780638fe605ad14610a5657806393fab9ee14610a6b57806394bf804d14610a80576103f9565b80637dbe5f10146109ba5780638028faa2146109cf57806384233707146109f957806389a604eb14610a2c576103f9565b806325bbfee21161030e57806354588637116102a157806375e8ef5c1161027057806375e8ef5c146108d657806377be2f14146109005780637bc6729b146109335780637c365e1b146109485780637c4368c114610981576103f9565b806354588637146108465780636ca2fc1b1461085b57806370a082311461088e578063715018a6146108c1576103f9565b806339509351116102dd57806339509351146107ce578063491547f5146108075780634d7efed71461081c5780634f0e0ef314610831576103f9565b806325bbfee21461072857806329e85c1f1461075b5780632e3d48071461078e578063313ce567146107a3576103f9565b806313966db5116103915780631cf3cf31116103605780631cf3cf311461063657806323b872dd1461068857806323e6f5e2146106cb57806324552f33146106fe5780632524081014610713576103f9565b806313966db5146105bc5780631432e810146105d157806317d338451461060c57806318160ddd14610621576103f9565b80630c7d5cd8116103cd5780630c7d5cd81461053a5780630ed2dff0146105615780631190016c1461059257806312d43a51146105a7576103f9565b8062f714ce146103fe57806306fdde0314610439578063095ea7b3146104c35780630acac95e14610510575b600080fd5b34801561040a57600080fd5b506104376004803603604081101561042157600080fd5b50803590602001356001600160a01b0316610f05565b005b34801561044557600080fd5b5061044e61139c565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610488578181015183820152602001610470565b50505050905090810190601f1680156104b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104cf57600080fd5b506104fc600480360360408110156104e657600080fd5b506001600160a01b038135169060200135611433565b604080519115158252519081900360200190f35b34801561051c57600080fd5b506104fc6004803603602081101561053357600080fd5b50356116f4565b34801561054657600080fd5b5061054f6119e6565b60408051918252519081900360200190f35b34801561056d57600080fd5b506105766119ec565b604080516001600160a01b039092168252519081900360200190f35b34801561059e57600080fd5b5061054f6119fb565b3480156105b357600080fd5b50610576611a04565b3480156105c857600080fd5b5061054f611a13565b3480156105dd57600080fd5b50610437600480360360408110156105f457600080fd5b506001600160a01b0381358116916020013516611a19565b34801561061857600080fd5b5061054f611af6565b34801561062d57600080fd5b5061054f611afc565b34801561064257600080fd5b5061066f6004803603604081101561065957600080fd5b50803590602001356001600160a01b0316611b02565b6040805192835260208301919091528051918290030190f35b34801561069457600080fd5b506104fc600480360360608110156106ab57600080fd5b506001600160a01b03813581169160208101359091169060400135611c43565b3480156106d757600080fd5b506104fc600480360360208110156106ee57600080fd5b50356001600160a01b0316611f84565b34801561070a57600080fd5b5061054f61200c565b34801561071f57600080fd5b50610576612012565b34801561073457600080fd5b506104376004803603602081101561074b57600080fd5b50356001600160a01b0316612021565b34801561076757600080fd5b506104fc6004803603602081101561077e57600080fd5b50356001600160a01b031661257f565b34801561079a57600080fd5b5061054f6125f4565b3480156107af57600080fd5b506107b8612853565b6040805160ff9092168252519081900360200190f35b3480156107da57600080fd5b506104fc600480360360408110156107f157600080fd5b506001600160a01b03813516906020013561285c565b34801561081357600080fd5b5061054f6128f0565b34801561082857600080fd5b506105766128f6565b34801561083d57600080fd5b50610576612905565b34801561085257600080fd5b50610576612914565b34801561086757600080fd5b5061054f6004803603602081101561087e57600080fd5b50356001600160a01b0316612923565b34801561089a57600080fd5b5061054f600480360360208110156108b157600080fd5b50356001600160a01b031661293e565b3480156108cd57600080fd5b50610437612959565b3480156108e257600080fd5b50610437600480360360208110156108f957600080fd5b5035612a18565b34801561090c57600080fd5b506104fc6004803603602081101561092357600080fd5b50356001600160a01b0316612a6a565b34801561093f57600080fd5b50610437612adf565b34801561095457600080fd5b506104376004803603604081101561096b57600080fd5b506001600160a01b038135169060200135612b97565b34801561098d57600080fd5b50610437600480360360408110156109a457600080fd5b506001600160a01b038135169060200135612c3f565b3480156109c657600080fd5b506104fc612d90565b3480156109db57600080fd5b50610437600480360360208110156109f257600080fd5b5035612da0565b348015610a0557600080fd5b506104fc60048036036020811015610a1c57600080fd5b50356001600160a01b0316612df2565b348015610a3857600080fd5b5061054f612e6f565b348015610a4d57600080fd5b50610576612e75565b348015610a6257600080fd5b5061054f612e89565b348015610a7757600080fd5b5061054f612f3e565b61043760048036036040811015610a9657600080fd5b50803590602001356001600160a01b0316612f44565b348015610ab857600080fd5b5061044e61335f565b348015610acd57600080fd5b506105766133c0565b348015610ae257600080fd5b506104376133cf565b348015610af757600080fd5b5061054f613487565b348015610b0c57600080fd5b506104fc60048036036040811015610b2357600080fd5b506001600160a01b03813516906020013561348d565b348015610b4557600080fd5b506104fc60048036036040811015610b5c57600080fd5b506001600160a01b038135169060200135613576565b348015610b7e57600080fd5b5061043760048036036060811015610b9557600080fd5b506001600160a01b03813581169160208101359160409091013516613862565b348015610bc157600080fd5b5061066f60048036036040811015610bd857600080fd5b50803590602001356001600160a01b031661397f565b348015610bfa57600080fd5b5061057660048036036020811015610c1157600080fd5b5035613b24565b348015610c2457600080fd5b5061043760048036036020811015610c3b57600080fd5b50356001600160a01b0316613b4b565b348015610c5757600080fd5b5061043760048036036020811015610c6e57600080fd5b5035613bb9565b348015610c8157600080fd5b50610576613c53565b348015610c9657600080fd5b5061054f613c62565b348015610cab57600080fd5b5061054f60048036036020811015610cc257600080fd5b50356001600160a01b0316613dd7565b348015610cde57600080fd5b50610576613f7c565b348015610cf357600080fd5b5061054f60048036036040811015610d0a57600080fd5b506001600160a01b0381358116916020013516613f8b565b348015610d2e57600080fd5b506104fc60048036036020811015610d4557600080fd5b50356001600160a01b0316613fb6565b348015610d6157600080fd5b5061043760048036036020811015610d7857600080fd5b5035613fcb565b348015610d8b57600080fd5b5061057660048036036020811015610da257600080fd5b50356001600160a01b0316614066565b348015610dbe57600080fd5b5061054f614081565b348015610dd357600080fd5b5061043760048036036020811015610dea57600080fd5b5035614087565b348015610dfd57600080fd5b5061043760048036036020811015610e1457600080fd5b50356001600160a01b03166140d9565b348015610e3057600080fd5b5061043760048036036020811015610e4757600080fd5b50356001600160a01b031661419b565b348015610e6357600080fd5b5061054f60048036036020811015610e7a57600080fd5b50356001600160a01b031661424b565b348015610e9657600080fd5b5061043760048036036020811015610ead57600080fd5b50356001600160a01b031661425d565b348015610ec957600080fd5b506104fc60048036036020811015610ee057600080fd5b50356001600160a01b0316614378565b348015610efc57600080fd5b5061054f61438d565b60026006541415610f5d576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600d546001600160a01b03161561119457600e54600160a01b900460ff16610fed57600e60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610fd457600080fd5b505af1158015610fe8573d6000803e3d6000fd5b505050505b600d60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561103d57600080fd5b505af1158015611051573d6000803e3d6000fd5b5050505060005b601c5481101561113057601b6000601c838154811061107357fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161561112857601f6000601c83815481106110b157fe5b60009182526020808320909101546001600160a01b039081168452908301939093526040918201812054825163a2e6204560e01b8152925193169263a2e6204592600480820193929182900301818387803b15801561110f57600080fd5b505af1158015611123573d6000803e3d6000fd5b505050505b600101611058565b5060085460075442031061119457633b9aca0061114b612e89565b11156111755761117061116b601954601a546143ed90919063ffffffff16565b61442f565b61118f565b61118f61116b601954601a5461439390919063ffffffff16565b426007555b816111e6576040805162461bcd60e51b815260206004820152601d60248201527f6d757374207769746864726177206e6f6e2d7a65726f20616d6f756e74000000604482015290519081900360640190fd5b33600090815260126020526040902054821115611241576040805162461bcd60e51b8152602060048201526014602482015273696e73756666696369656e742062616c616e636560601b604482015290519081900360640190fd5b6001600160a01b0381166000908152601e602052604090205460ff166112ae576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e206578697374696e6720636f6c6c61746572616c0000604482015290519081900360640190fd5b6010543360009081526013602052604090205443910111156113015760405162461bcd60e51b815260040180806020018281038252602a815260200180614ab4602a913960400191505060405180910390fd5b60115461130e90836143ed565b6011553360009081526012602052604090205461132b90836143ed565b336000908152601260209081526040808320939093556025905220546113519083614393565b3360008181526025602090815260408083209490945560138152838220439055835186815293519193600080516020614a11833981519152929081900390910190a350506001600655565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156114285780601f106113fd57610100808354040283529160200191611428565b820191906000526020600020905b81548152906001019060200180831161140b57829003601f168201915b505050505090505b90565b6000826001600160a01b03811661144957600080fd5b6001600160a01b03811630141561145f57600080fd5b600d546001600160a01b03161561168c57600e54600160a01b900460ff166114ea57600e60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156114d157600080fd5b505af11580156114e5573d6000803e3d6000fd5b505050505b600d60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561153a57600080fd5b505af115801561154e573d6000803e3d6000fd5b5050505060005b601c5481101561162d57601b6000601c838154811061157057fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161561162557601f6000601c83815481106115ae57fe5b60009182526020808320909101546001600160a01b039081168452908301939093526040918201812054825163a2e6204560e01b8152925193169263a2e6204592600480820193929182900301818387803b15801561160c57600080fd5b505af1158015611620573d6000803e3d6000fd5b505050505b600101611555565b5060085460075442031061168c57633b9aca00611648612e89565b111561166d5761166861116b601954601a546143ed90919063ffffffff16565b611687565b61168761116b601954601a5461439390919063ffffffff16565b426007555b3360008181526014602090815260408083206001600160a01b03891680855290835292819020879055805187815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6023546000906001600160a01b03163314611744576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b816117805760405162461bcd60e51b81526004018080602001828103825260228152602001806149976022913960400191505060405180910390fd5b600882905560005b601c5481101561186757601b6000601c83815481106117a357fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161561185f57601f6000601c83815481106117e157fe5b60009182526020808320909101546001600160a01b03908116845290830193909352604091820181205482516363c7560760e01b81526004810188905292519316926363c7560792602480820193929182900301818387803b15801561184657600080fd5b505af115801561185a573d6000803e3d6000fd5b505050505b600101611788565b50601654604080516363c7560760e01b81526004810185905290516001600160a01b03909216916363c756079160248082019260009290919082900301818387803b1580156118b557600080fd5b505af11580156118c9573d6000803e3d6000fd5b5050600d54604080516363c7560760e01b81526004810187905290516001600160a01b0390921693506363c75607925060248082019260009290919082900301818387803b15801561191a57600080fd5b505af115801561192e573d6000803e3d6000fd5b5050600e54600160a01b900460ff1691506119ab905057600e54604080516363c7560760e01b81526004810185905290516001600160a01b03909216916363c756079160248082019260009290919082900301818387803b15801561199257600080fd5b505af11580156119a6573d6000803e3d6000fd5b505050505b6040805183815290517ff96993476642ad4471e701dee382f1d8b7947acb089dba94a2f49e477e85c8799181900360200190a1506001919050565b601a5481565b600e546001600160a01b031681565b64174876e80081565b6017546001600160a01b031681565b60205481565b6023546001600160a01b03163314611a66576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b6001600160a01b0382166000908152601b602052604090205460ff16611ac8576040805162461bcd60e51b81526020600482015260126024820152711a5b9d985b1a590818dbdb1b185d195c985b60721b604482015290519081900360640190fd5b6001600160a01b039182166000908152601f6020526040902080546001600160a01b03191691909216179055565b600a5481565b60115490565b60008083611b52576040805162461bcd60e51b81526020600482015260186024820152771b5d5cdd081d5cd9481d985b1a59081bdb99505b5bdd5b9d60421b604482015290519081900360640190fd5b6001600160a01b0383166000908152601b602052604090205460ff16611bbf576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e20616363657074656420636f6c6c61746572616c0000604482015290519081900360640190fd5b6001600160a01b0383166000908152601d6020526040812054602154611c1891633b9aca0091611c0591600a0a90611c1290611c0b9064174876e8009085908d90614487565b906144e0565b8a906143ed565b90614487565b9050611c34611c2685613dd7565b611c0583633b9aca00614487565b925060009150505b9250929050565b6000826001600160a01b038116611c5957600080fd5b6001600160a01b038116301415611c6f57600080fd5b600d546001600160a01b031615611e9c57600e54600160a01b900460ff16611cfa57600e60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611ce157600080fd5b505af1158015611cf5573d6000803e3d6000fd5b505050505b600d60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611d4a57600080fd5b505af1158015611d5e573d6000803e3d6000fd5b5050505060005b601c54811015611e3d57601b6000601c8381548110611d8057fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff1615611e3557601f6000601c8381548110611dbe57fe5b60009182526020808320909101546001600160a01b039081168452908301939093526040918201812054825163a2e6204560e01b8152925193169263a2e6204592600480820193929182900301818387803b158015611e1c57600080fd5b505af1158015611e30573d6000803e3d6000fd5b505050505b600101611d65565b50600854600754420310611e9c57633b9aca00611e58612e89565b1115611e7d57611e7861116b601954601a546143ed90919063ffffffff16565b611e97565b611e9761116b601954601a5461439390919063ffffffff16565b426007555b6001600160a01b0385166000908152601460209081526040808320338452909152902054611eca90846143ed565b6001600160a01b038616600081815260146020908152604080832033845282528083209490945591815260129091522054611f0590846143ed565b6001600160a01b038087166000908152601260205260408082209390935590861681522054611f349084614393565b6001600160a01b038086166000818152601260209081526040918290209490945580518781529051919392891692600080516020614a1183398151915292918290030190a3506001949350505050565b6023546000906001600160a01b03163314611fd4576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b50600b80546001600160a01b0383166001600160a01b0319909116179055600e805460ff60a01b1916600160a01b1790556001919050565b600f5481565b6018546001600160a01b031681565b60026006541415612079576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600655600d546001600160a01b0316156122ab57600e54600160a01b900460ff1661210957600e60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156120f057600080fd5b505af1158015612104573d6000803e3d6000fd5b505050505b600d60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561215957600080fd5b505af115801561216d573d6000803e3d6000fd5b5050505060005b601c5481101561224c57601b6000601c838154811061218f57fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161561224457601f6000601c83815481106121cd57fe5b60009182526020808320909101546001600160a01b039081168452908301939093526040918201812054825163a2e6204560e01b8152925193169263a2e6204592600480820193929182900301818387803b15801561222b57600080fd5b505af115801561223f573d6000803e3d6000fd5b505050505b600101612174565b506008546007544203106122ab57633b9aca00612267612e89565b111561228c5761228761116b601954601a546143ed90919063ffffffff16565b6122a6565b6122a661116b601954601a5461439390919063ffffffff16565b426007555b6001600160a01b0381166000908152601e602052604090205460ff16612318576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e206578697374696e6720636f6c6c61746572616c0000604482015290519081900360640190fd5b60105433600090815260136020526040902054439101111561236b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614ab4602a913960400191505060405180910390fd5b33600090815260256020526040902054806123cd576040805162461bcd60e51b815260206004820152601d60248201527f696e73756666696369656e74206f6e6542544320746f2072656465656d000000604482015290519081900360640190fd5b3360009081526025602090815260408083208390556001600160a01b0385168352601d90915281205460215461242a91633b9aca0091611c0591600a0a90611c12906124239064174876e8009085908a90614487565b87906143ed565b9050612438611c2684613dd7565b90506000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561248957600080fd5b505afa15801561249d573d6000803e3d6000fd5b505050506040513d60208110156124b357600080fd5b50518211156124f35760405162461bcd60e51b81526004018080602001828103825260398152602001806149366039913960400191505060405180910390fd5b6124fe843384614522565b3360008181526013602090815260409182902043905560095482516001600160a01b0391821681529182019390935291861682820152606082018490526080820183905260a08201859052517fbbbdee62287b5bf3bee13cab60a29ad729cf38109bccbd2a986a11c99b8ca7049181900360c00190a1505060016006555050565b6023546000906001600160a01b031633146125cf576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b50601680546001600160a01b0383166001600160a01b03199091161790556001919050565b600e54600090600160a01b900460ff161561270d576000806000806000600b60009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561265f57600080fd5b505afa158015612673573d6000803e3d6000fd5b505050506040513d60a081101561268957600080fd5b50805160208201516040830151606084015160809094015192985090965094509092509050816126f6576040805162461bcd60e51b8152602060048201526013602482015272526f756e6473206e6f7420636f6d706c65746560681b604482015290519081900360640190fd5b61270184600a614487565b95505050505050611430565b600e5460155460408051633ddac95360e01b81526001600160a01b039283166004820152670de0b6b3a7640000602482015290516000939290921691633ddac95391604480820192602092909190829003018186803b15801561276f57600080fd5b505afa158015612783573d6000803e3d6000fd5b505050506040513d602081101561279957600080fd5b505160165460155460408051633ddac95360e01b81526001600160a01b039283166004820152670de0b6b3a7640000602482015290519394506000939190921691633ddac953916044808301926020929190829003018186803b1580156127ff57600080fd5b505afa158015612813573d6000803e3d6000fd5b505050506040513d602081101561282957600080fd5b5051600a805491925061284a918491611c0591900a611c12856103e8614487565b92505050611430565b60055460ff1690565b3360009081526014602090815260408083206001600160a01b038616845290915281205461288a9083614393565b3360008181526014602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a35060015b92915050565b60225481565b6024546001600160a01b031681565b6015546001600160a01b031681565b600d546001600160a01b031681565b6001600160a01b031660009081526025602052604090205490565b6001600160a01b031660009081526012602052604090205490565b612961614574565b60055461010090046001600160a01b039081169116146129c8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b6023546001600160a01b03163314612a65576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b600f55565b6023546000906001600160a01b03163314612aba576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b50600d80546001600160a01b0383166001600160a01b03199091161790556001919050565b6018546001600160a01b03163314612b29576040805162461bcd60e51b81526020600482015260086024820152672170656e64696e6760c01b604482015290519081900360640190fd5b60178054601880546001600160a01b03198084166001600160a01b03838116919091179586905591169091556040805192821680845293909116602083015280517f1f14cfc03e486d23acee577b07bc0b3b23f4888c91fcdba5e0fef5a2549d55239281900390910190a150565b6023546001600160a01b03163314612be4576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b6022544311612c245760405162461bcd60e51b81526004018080602001828103825260378152602001806149da6037913960400191505060405180910390fd5b600954612c3b906001600160a01b03168383614522565b5050565b6023546001600160a01b03163314612c8c576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b60208310612cd85780518252601f199092019160209182019101612cb9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612d3a576040519150601f19603f3d011682016040523d82523d6000602084013e612d3f565b606091505b5050905080612d8b576040805162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b505050565b600e54600160a01b900460ff1681565b6023546001600160a01b03163314612ded576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b601055565b6023546000906001600160a01b03163314612e42576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b50600e80546001600160a01b0319166001600160a01b03929092169190911760ff60a01b19169055600190565b60195481565b60055461010090046001600160a01b031690565b600d54600954600a805460408051633ddac95360e01b81526001600160a01b0394851660048201529190920a6024820152905160009384931691633ddac953916044808301926020929190829003018186803b158015612ee857600080fd5b505afa158015612efc573d6000803e3d6000fd5b505050506040513d6020811015612f1257600080fd5b505190506000612f206125f4565b90506000612f3683611c0584633b9aca00614487565b935050505090565b60075481565b60026006541415612f9c576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026006556001600160a01b0381166000908152601b602052604090205460ff1661300e576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e20616363657074656420636f6c6c61746572616c0000604482015290519081900360640190fd5b81613060576040805162461bcd60e51b815260206004820152601960248201527f6d757374206d696e74206e6f6e2d7a65726f20616d6f756e7400000000000000604482015290519081900360640190fd5b6010543360009081526013602052604090205443910111156130b35760405162461bcd60e51b815260040180806020018281038252602f815260200180614a31602f913960400191505060405180910390fd5b6000806130c0848461397f565b91509150826001600160a01b03166370a08231336040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561311157600080fd5b505afa158015613125573d6000803e3d6000fd5b505050506040513d602081101561313b57600080fd5b505182111561317b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614a60602a913960400191505060405180910390fd5b600954604080516370a0823160e01b815233600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156131c657600080fd5b505afa1580156131da573d6000803e3d6000fd5b505050506040513d60208110156131f057600080fd5b50518111156132305760405162461bcd60e51b815260040180806020018281038252602881526020018061496f6028913960400191505060405180910390fd5b61323c83333085614578565b600954613254906001600160a01b0316333084614578565b602054613278906132719064174876e80090611c05908890614487565b85906143ed565b6011549094506132889085614393565b601155336000908152601260205260409020546132a59085614393565b336000818152601260209081526040808320949094558351888152935192939192600080516020614a118339815191529281900390910190a33360008181526013602090815260409182902043905560095482516001600160a01b0391821681529182019390935291851682820152606082018490526080820183905260a08201869052517feca801b067fae3d181506c21fb55d44a644d16cdb863595643131a7e105b5f019181900360c00190a1505060016006555050565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156114285780601f106113fd57610100808354040283529160200191611428565b6009546001600160a01b031681565b6024546001600160a01b03163314613419576040805162461bcd60e51b81526020600482015260086024820152672170656e64696e6760c01b604482015290519081900360640190fd5b60238054602480546001600160a01b03198084166001600160a01b03838116919091179586905591169091556040805192821680845293909116602083015280517f1f14cfc03e486d23acee577b07bc0b3b23f4888c91fcdba5e0fef5a2549d55239281900390910190a150565b60105481565b3360009081526014602090815260408083206001600160a01b03861684529091528120548083106134e1573360009081526014602090815260408083206001600160a01b0388168452909152812055613510565b6134eb81846143ed565b3360009081526014602090815260408083206001600160a01b03891684529091529020555b3360008181526014602090815260408083206001600160a01b0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000826001600160a01b03811661358c57600080fd5b6001600160a01b0381163014156135a257600080fd5b600d546001600160a01b0316156137cf57600e54600160a01b900460ff1661362d57600e60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561361457600080fd5b505af1158015613628573d6000803e3d6000fd5b505050505b600d60009054906101000a90046001600160a01b03166001600160a01b031663a2e620456040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561367d57600080fd5b505af1158015613691573d6000803e3d6000fd5b5050505060005b601c5481101561377057601b6000601c83815481106136b357fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205460ff161561376857601f6000601c83815481106136f157fe5b60009182526020808320909101546001600160a01b039081168452908301939093526040918201812054825163a2e6204560e01b8152925193169263a2e6204592600480820193929182900301818387803b15801561374f57600080fd5b505af1158015613763573d6000803e3d6000fd5b505050505b600101613698565b506008546007544203106137cf57633b9aca0061378b612e89565b11156137b0576137ab61116b601954601a546143ed90919063ffffffff16565b6137ca565b6137ca61116b601954601a5461439390919063ffffffff16565b426007555b336000908152601260205260409020546137e990846143ed565b33600090815260126020526040808220929092556001600160a01b038616815220546138159084614393565b6001600160a01b038516600081815260126020908152604091829020939093558051868152905191923392600080516020614a118339815191529281900390910190a35060019392505050565b6023546001600160a01b031633146138af576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b6001600160a01b0383166000908152601e602052604090205460ff1661391b57601c80546001810182556000919091527f0e4562a10381dec21b205ed72637e6b1b523bdd0e4d4d50af5cd23dd4500a2110180546001600160a01b0319166001600160a01b0385161790555b6001600160a01b039283166000908152601e602090815260408083208054600160ff199182168117909255601b845282852080549091169091179055601d825280832094909455601f90529190912080546001600160a01b03191691909216179055565b600080836139cf576040805162461bcd60e51b81526020600482015260186024820152771b5d5cdd081d5cd9481d985b1a59081bdb99505b5bdd5b9d60421b604482015290519081900360640190fd5b6001600160a01b0383166000908152601b602052604090205460ff16613a3c576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e20616363657074656420636f6c6c61746572616c0000604482015290519081900360640190fd5b6001600160a01b0383166000908152601d6020526040812054601a54613a7e91633b9aca0091611c0591600a0a90611c129064174876e8009084908c90614487565b9050613a8c611c2685613dd7565b600d549091506001600160a01b0316613aaa57915060009050611c3c565b6000613ab46125f4565b90506000613ae564174876e800611c05613ade601a5464174876e8006143ed90919063ffffffff16565b8a90614487565b90506000613b156009600a0a611c05600a54600a0a611c1287611c05633b9aca008961448790919063ffffffff16565b93989397509295505050505050565b601c8181548110613b3157fe5b6000918252602090912001546001600160a01b0316905081565b6023546001600160a01b03163314613b98576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152601b60205260409020805460ff19169055565b6017546001600160a01b03163314613c18576040805162461bcd60e51b815260206004820152601c60248201527f4143434553533a206f6e6c79204963686920676f7665726e616e636500000000604482015290519081900360640190fd5b60218190556040805182815290517fa01cb43de193eb3a80b373fb949c09d0eedb01f39f3b6063ace0cb6b067cc1239181900360200190a150565b6016546001600160a01b031681565b600080805b601c54811015613dd15760006001600160a01b0316601c8281548110613c8957fe5b6000918252602090912001546001600160a01b031614613dc957613dc4633b9aca00611c05613cd8601c8581548110613cbe57fe5b6000918252602090912001546001600160a01b0316613dd7565b611c12601d6000601c8881548110613cec57fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002054600a0a611c05633b9aca00601c8981548110613d4357fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015613d9257600080fd5b505afa158015613da6573d6000803e3d6000fd5b505050506040513d6020811015613dbc57600080fd5b505190614487565b820191505b600101613c67565b50905090565b6001600160a01b0381166000908152601e602052604081205460ff16613e44576040805162461bcd60e51b815260206004820152601e60248201527f6d75737420626520616e206578697374696e6720636f6c6c61746572616c0000604482015290519081900360640190fd5b60165460155460408051633ddac95360e01b81526001600160a01b039283166004820152670de0b6b3a7640000602482015290516000939290921691633ddac95391604480820192602092909190829003018186803b158015613ea657600080fd5b505afa158015613eba573d6000803e3d6000fd5b505050506040513d6020811015613ed057600080fd5b50516001600160a01b038085166000908152601d6020908152604080832054601f835292819020546015548251633ddac95360e01b81529086166004820152670de0b6b3a764000060248201529151959650613f7595613f6195600a9590950a94611c0594633b9aca00949390911692633ddac9539260448083019392829003018186803b158015613d9257600080fd5b611c05633b9aca00611c12856103e8614487565b9392505050565b6023546001600160a01b031681565b6001600160a01b03918216600090815260146020908152604080832093909416825291909152205490565b601e6020526000908152604090205460ff1681565b6017546001600160a01b0316331461402a576040805162461bcd60e51b815260206004820152601c60248201527f4143434553533a206f6e6c79204963686920676f7665726e616e636500000000604482015290519081900360640190fd5b60208181556040805183815290517f6f87524b705f31734b7940b88671f37a3291d7b961b69da31bcabf882b2531da929181900390910190a150565b601f602052600090815260409020546001600160a01b031681565b60215481565b6023546001600160a01b031633146140d4576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b601955565b6017546001600160a01b03163314614138576040805162461bcd60e51b815260206004820152601c60248201527f4143434553533a206f6e6c79204963686920676f7665726e616e636500000000604482015290519081900360640190fd5b601880546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517f6163d5b9efd962645dd649e6e48a61bcb0f9df00997a2398b80d135a9ab0c61e929181900390910190a15050565b6023546001600160a01b031633146141e8576040805162461bcd60e51b815260206004820152601d6024820152600080516020614ade833981519152604482015290519081900360640190fd5b602480546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517f6ea9654b538fab06e45f7940f0aa88b14cb8aca48a29d4e0b7626009fb7dc514929181900390910190a15050565b601d6020526000908152604090205481565b614265614574565b60055461010090046001600160a01b039081169116146142cc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166143115760405162461bcd60e51b81526004018080602001828103825260268152602001806149106026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b601b6020526000908152604090205460ff1681565b60085481565b600082820183811015613f75576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000613f7583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506145d8565b64174876e80081111580156144465750600f548110155b1561448457601a8190556040805182815290517f2fbb30255fd6bab4bd8c21173ab8290d05fcef04343b7d0190495d90e6866c569181900360200190a15b50565b600082614496575060006128ea565b828202828482816144a357fe5b0414613f755760405162461bcd60e51b81526004018080602001828103825260218152602001806149b96021913960400191505060405180910390fd5b6000613f7583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061466f565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052612d8b9084906146d4565b3390565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526145d29085906146d4565b50505050565b600081848411156146675760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561462c578181015183820152602001614614565b50505050905090810190601f1680156146595780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836146be5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561462c578181015183820152602001614614565b5060008385816146ca57fe5b0495945050505050565b6060614729826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166147859092919063ffffffff16565b805190915015612d8b5780806020019051602081101561474857600080fd5b5051612d8b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614a8a602a913960400191505060405180910390fd5b6060614794848460008561479c565b949350505050565b60606147a785614909565b6147f8576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106148375780518252601f199092019160209182019101614818565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614899576040519150601f19603f3d011682016040523d82523d6000602084013e61489e565b606091505b509150915081156148b25791506147949050565b8051156148c25780518082602001fd5b60405162461bcd60e51b815260206004820181815286516024840152865187939192839260440191908501908083836000831561462c578181015183820152602001614614565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373696e73756666696369656e7420636f6c6c61746572616c207265736572766573202d2074727920616e6f7468657220636f6c6c61746572616c73656e6465722068617320696e73756666696369656e74207374696d756c75732062616c616e63656d696e696d756d20726566726573682074696d65206d7573742062652076616c6964536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776d696e426c6f636b467265657a652074696d65206c696d6974206e6f74206d657420796574202d2074727920616761696e206c61746572ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef616374696f6e20746f6f20736f6f6e202d20706c656173652077616974206120666577206d6f726520626c6f636b7373656e6465722068617320696e73756666696369656e7420636f6c6c61746572616c2062616c616e63655361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564616374696f6e20746f6f20736f6f6e202d20706c65617365207761697420612066657720626c6f636b734143434553533a206f6e6c79206274634c5020676f7665726e616e6365000000a2646970667358221220357114cf4527c6c406366a4a8feff73221d581d1987991519eeec775de43b97964736f6c634300060c0033

Verified Source Code Partial Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul Optimization: Yes (200 runs)
oneBTC.sol 1717 lines
// File: @chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol

pragma solidity >=0.6.0;

interface AggregatorV3Interface {

  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}

// File: @openzeppelin/contracts/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol

pragma solidity ^0.6.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// File: @openzeppelin/contracts/utils/Address.sol

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies in extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol

pragma solidity ^0.6.0;




/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol

pragma solidity ^0.6.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

// File: @openzeppelin/contracts/GSN/Context.sol

pragma solidity ^0.6.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol

pragma solidity ^0.6.0;





/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;
    using Address for address;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view override virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view override virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

// File: @openzeppelin/contracts/access/Ownable.sol

pragma solidity ^0.6.0;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

// File: contracts/oneBTC.sol

pragma solidity ^0.6.0;







interface IUniswapOracle {
    // We need the current prices of just about everything for the system to work!
    // 
    // Return the average time weighted price of oneBTC (the Bitcoin stable coin),
    // the collateral (USDC, DAI, etc), and the cryptocurrencies (BTC, BTC, etc).
    // This includes functions for changing the time interval for average,
    // updating the oracle price, and returning the current price.
    function changeInterval(uint256 seconds_) external;
    function update() external;
    function consult(address token, uint amountIn) external view returns (uint amountOut);
}

contract oneBTC is ERC20("oneBTC", "oneBTC"), Ownable, ReentrancyGuard {
    // oneBTC is the first fractionally backed stable coin that is especially designed for
    // the Ethereum community.  In its fractional phase, BTC will be paid into the contract
    // to mint new oneBTC.  The Ethereum community will govern this BTC treasury, spending it
    // on public goods, to re-collateralize oneBTC, or on discount and perks for consumers to
    // adopt oneBTC or BTC.
    //
    // This contract is ownable and the owner has tremendous power.  This ownership will be
    // transferred to a multi-sig contract controlled by signers elected by the community.
    //
    // Thanks for reading the contract and happy farming!
    using SafeMath for uint256;

    // At 100% reserve ratio, each oneBTC is backed 1-to-1 by $1 of existing stable coins
    uint256 constant public MAX_RESERVE_RATIO = 100 * 10 ** 9;
    uint256 private constant DECIMALS = 9;
    uint256 public lastRefreshReserve; // The last time the reserve ratio was updated by the contract
    uint256 public minimumRefreshTime; // The time between reserve ratio refreshes

    address public stimulus; // oneBTC builds a stimulus fund in BTC.
    uint256 public stimulusDecimals; // used to calculate oracle rate of Uniswap Pair

    // We get the price of BTC from Chainlink!  Thanks chainLink!  Hopefully, the chainLink
    // will provide Oracle prices for oneBTC, oneBTC, etc in the future.  For now, we will get those
    // from the ichi.farm exchange which uses Uniswap contracts.
    AggregatorV3Interface internal chainlinkStimulusOracle;
    AggregatorV3Interface internal ethPrice;


    address public oneTokenOracle; // oracle for the oneBTC stable coin
    address public stimulusOracle;  // oracle for a stimulus cryptocurrency that isn't on chainLink
    bool public chainLink;         // true means it is a chainLink oracle

    // Only governance should cause the coin to go fully agorithmic by changing the minimum reserve
    // ratio.  For now, we will set a conservative minimum reserve ratio.
    uint256 public MIN_RESERVE_RATIO;
    uint256 public MIN_DELAY;

    // Makes sure that you can't send coins to a 0 address and prevents coins from being sent to the
    // contract address. I want to protect your funds! 
    modifier validRecipient(address to) {
        require(to != address(0x0));
        require(to != address(this));
        _;
    }

    uint256 private _totalSupply;
    mapping(address => uint256) private _oneBalances;
    mapping(address => uint256) private _lastCall;
    mapping (address => mapping (address => uint256)) private _allowedOne;

    address public wethAddress;
    address public ethUsdcUniswapOracle;
    address public gov;
    // allows you to transfer the governance to a different user - they must accept it!
    address public pendingGov;
    uint256 public reserveStepSize; // step size of update of reserve rate (e.g. 5 * 10 ** 8 = 0.5%)
    uint256 public reserveRatio;    // a number between 0 and 100 * 10 ** 9.
                                    // 0 = 0%
                                    // 100 * 10 ** 9 = 100%

    // map of acceptable collaterals
    mapping (address => bool) public acceptedCollateral;
    address[] public collateralArray;

    // modifier to allow auto update of TWAP oracle prices
    // also updates reserves rate programatically
    modifier updateProtocol() {
        if (address(oneTokenOracle) != address(0)) {
            // only update if stimulusOracle is set
            if (!chainLink) IUniswapOracle(stimulusOracle).update();

            // this is always updated because we always need stablecoin oracle price
            IUniswapOracle(oneTokenOracle).update();

            for (uint i = 0; i < collateralArray.length; i++){ 
                if (acceptedCollateral[collateralArray[i]]) IUniswapOracle(collateralOracle[collateralArray[i]]).update();
            }

            // update reserve ratio if enough time has passed
            if (block.timestamp - lastRefreshReserve >= minimumRefreshTime) {
                // $Z / 1 one token
                if (getOneTokenUsd() > 1 * 10 ** 9) {
                    setReserveRatio(reserveRatio.sub(reserveStepSize));
                } else {
                    setReserveRatio(reserveRatio.add(reserveStepSize));
                }

                lastRefreshReserve = block.timestamp;
            }
        }
        
        _;
    }

    event NewPendingGov(address oldPendingGov, address newPendingGov);
    event NewGov(address oldGov, address newGov);
    event NewReserveRate(uint256 reserveRatio);
    event Mint(address stimulus, address receiver, address collateral, uint256 collateralAmount, uint256 stimulusAmount, uint256 oneAmount);
    event Withdraw(address stimulus, address receiver, address collateral, uint256 collateralAmount, uint256 stimulusAmount, uint256 oneAmount);
    event NewMinimumRefreshTime(uint256 minimumRefreshTime);

    modifier onlyIchiGov() {
        require(msg.sender == gov, "ACCESS: only Ichi governance");
        _;
    }

    bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
    mapping (address => uint256) public collateralDecimals;
    mapping (address => bool) public previouslySeenCollateral;
    mapping (address => address) public collateralOracle;       // address of the Collateral-BTC Uniswap Price

    // default to 0
    uint256 public mintFee;
    uint256 public withdrawFee;
    uint256 public minBlockFreeze;

    // fee to charge when minting oneBTC - this will go into collateral
    event MintFee(uint256 fee_);
    // fee to charge when redeeming oneBTC - this will go into collateral
    event WithdrawFee(uint256 fee_);

    // set governance access to only oneBTC - BTC pool multisig (elected after rewards)
    modifier btcLPGov() {
        require(msg.sender == lpGov, "ACCESS: only btcLP governance");
        _;
    }

    address public lpGov;
    address public pendingLPGov;

    event NewPendingLPGov(address oldPendingLPGov, address newPendingLPGov);
    event NewLPGov(address oldLPGov, address newLPGov);

    mapping (address => uint256) private _burnedStablecoin; // maps user to burned oneBTC

    // important: make sure changeInterval is a function to allow the interval of update to change
    function addCollateral(address collateral_, uint256 collateralDecimal_, address oracleAddress_)
        external
        btcLPGov
    {
        // only add collateral once
        if (!previouslySeenCollateral[collateral_]) collateralArray.push(collateral_);

        previouslySeenCollateral[collateral_] = true;
        acceptedCollateral[collateral_] = true;
        collateralDecimals[collateral_] = collateralDecimal_;
        collateralOracle[collateral_] = oracleAddress_;
    }

    function setReserveStepSize(uint256 stepSize_)
        external
        btcLPGov
    {
        reserveStepSize = stepSize_;
    }

    function setCollateralOracle(address collateral_, address oracleAddress_)
        external
        btcLPGov
    {
        require(acceptedCollateral[collateral_], "invalid collateral");
        collateralOracle[collateral_] = oracleAddress_;
    }

    function removeCollateral(address collateral_)
        external
        btcLPGov
    {
        acceptedCollateral[collateral_] = false;
    }

    // used for querying
    function getBurnedStablecoin(address _user)
        public
        view
        returns (uint256)
    {
        return _burnedStablecoin[_user];
    }

    // returns 10 ** 9 price of collateral
    function getCollateralUsd(address collateral_) public view returns (uint256) {
        require(previouslySeenCollateral[collateral_], "must be an existing collateral");
        uint256 ethUsdcTWAP = IUniswapOracle(ethUsdcUniswapOracle).consult(wethAddress, 1 * 10 ** 18);  // 1 ETH = X USDC (10 ^ 6 decimals)
        return ethUsdcTWAP.mul(10 ** 3).mul(10 ** 9).div((IUniswapOracle(collateralOracle[collateral_]).consult(wethAddress, 10 ** 18)).mul(10 ** 9).div(10 ** collateralDecimals[collateral_]));
    }

    function globalCollateralValue() public view returns (uint256) {
        uint256 totalCollateralUsd = 0; 

        for (uint i = 0; i < collateralArray.length; i++){ 
            // Exclude null addresses
            if (collateralArray[i] != address(0)){
                totalCollateralUsd += IERC20(collateralArray[i]).balanceOf(address(this)).mul(10 ** 9).div(10 ** collateralDecimals[collateralArray[i]]).mul(getCollateralUsd(collateralArray[i])).div(10 ** 9); // add stablecoin balance
            }

        }
        return totalCollateralUsd;
    }

    // return price of oneBTC in 10 ** 9 decimal
    function getOneTokenUsd()
        public
        view
        returns (uint256)
    {
        uint256 oneTokenPrice = IUniswapOracle(oneTokenOracle).consult(stimulus, 10 ** stimulusDecimals); // X one tokens (10 ** 9) / 1 stimulus token
        uint256 stimulusTWAP = getStimulusOracle(); // $Y / 1 stimulus (10 ** 9)

        uint256 oneTokenUsd = stimulusTWAP.mul(10 ** 9).div(oneTokenPrice); // 10 ** 9 decimals
        return oneTokenUsd;
    }

    /**
     * @return The total number of oneBTC.
     */
    function totalSupply()
        public
        override
        view
        returns (uint256)
    {
        return _totalSupply;
    }

    /**
     * @param who The address to query.
     * @return The balance of the specified address.
     */
    function balanceOf(address who)
        public
        override
        view
        returns (uint256)
    {
        return _oneBalances[who];
    }

    // oracle asset for collateral (oneBTC is BTC, oneWHBAR is WHBAR, etc...)
    function setChainLinkStimulusOracle(address oracle_)
        external
        btcLPGov
        returns (bool)
    {
        chainlinkStimulusOracle = AggregatorV3Interface(oracle_);
        chainLink = true;

        return true;
    }

    /**
     * @dev Transfer tokens to a specified address.
     * @param to The address to transfer to.
     * @param value The amount to be transferred.
     * @return True on success, false otherwise.
     */
    function transfer(address to, uint256 value)
        public
        override
        validRecipient(to)
        updateProtocol()
        returns (bool)
    {
        _oneBalances[msg.sender] = _oneBalances[msg.sender].sub(value);
        _oneBalances[to] = _oneBalances[to].add(value);
        emit Transfer(msg.sender, to, value);

        return true;
    }

    /**
     * @dev Function to check the amount of tokens that an owner has allowed to a spender.
     * @param owner_ The address which owns the funds.
     * @param spender The address which will spend the funds.
     * @return The number of tokens still available for the spender.
     */
    function allowance(address owner_, address spender)
        public
        override
        view
        returns (uint256)
    {
        return _allowedOne[owner_][spender];
    }

    /**
     * @dev Transfer tokens from one address to another.
     * @param from The address you want to send tokens from.
     * @param to The address you want to transfer to.
     * @param value The amount of tokens to be transferred.
     */
    function transferFrom(address from, address to, uint256 value)
        public
        override
        validRecipient(to)
        updateProtocol()
        returns (bool)
    {
        _allowedOne[from][msg.sender] = _allowedOne[from][msg.sender].sub(value);

        _oneBalances[from] = _oneBalances[from].sub(value);
        _oneBalances[to] = _oneBalances[to].add(value);
        emit Transfer(from, to, value);

        return true;
    }

    /**
     * @dev Approve the passed address to spend the specified amount of tokens on behalf of
     * msg.sender. This method is included for ERC20 compatibility.
     * increaseAllowance and decreaseAllowance should be used instead.
     * Changing an allowance with this method brings the risk that someone may transfer both
     * the old and the new allowance - if they are both greater than zero - if a transfer
     * transaction is mined before the later approve() call is mined.
     *
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     */
    function approve(address spender, uint256 value)
        public
        override
        validRecipient(spender)
        updateProtocol()
        returns (bool)
    {
        _allowedOne[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    /**
     * @dev Increase the amount of tokens that an owner has allowed to a spender.
     * This method should be used instead of approve() to avoid the double approval vulnerability
     * described above.
     * @param spender The address which will spend the funds.
     * @param addedValue The amount of tokens to increase the allowance by.
     */
    function increaseAllowance(address spender, uint256 addedV...

// [truncated — 64583 bytes total]

Read Contract

MAX_RESERVE_RATIO 0x1190016c → uint256
MIN_DELAY 0x9f81aed7 → uint256
MIN_RESERVE_RATIO 0x24552f33 → uint256
acceptedCollateral 0xf6cad255 → bool
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
chainLink 0x7dbe5f10 → bool
collateralArray 0xc522e74f → address
collateralDecimals 0xf1ae3c7f → uint256
collateralOracle 0xe9144e73 → address
consultOneDeposit 0xc072ea43 → uint256, uint256
consultOneWithdraw 0x1cf3cf31 → uint256, uint256
decimals 0x313ce567 → uint8
ethUsdcUniswapOracle 0xce72d8fd → address
getBurnedStablecoin 0x6ca2fc1b → uint256
getCollateralUsd 0xd494d586 → uint256
getOneTokenUsd 0x8fe605ad → uint256
getStimulusOracle 0x2e3d4807 → uint256
globalCollateralValue 0xd2d97b06 → uint256
gov 0x12d43a51 → address
lastRefreshReserve 0x93fab9ee → uint256
lpGov 0xda2b9bfa → address
minBlockFreeze 0x491547f5 → uint256
minimumRefreshTime 0xfdec254f → uint256
mintFee 0x13966db5 → uint256
name 0x06fdde03 → string
oneTokenOracle 0x54588637 → address
owner 0x8da5cb5b → address
pendingGov 0x25240810 → address
pendingLPGov 0x4d7efed7 → address
previouslySeenCollateral 0xe2b11a64 → bool
reserveRatio 0x0c7d5cd8 → uint256
reserveStepSize 0x89a604eb → uint256
stimulus 0x99b16efd → address
stimulusDecimals 0x17d33845 → uint256
stimulusOracle 0x0ed2dff0 → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
wethAddress 0x4f0e0ef3 → address
withdrawFee 0xe941fa78 → uint256

Write Contract 29 functions

These functions modify contract state and require a wallet transaction to execute.

acceptGov 0x7bc6729b
No parameters
acceptLPGov 0x9bf74519
No parameters
addCollateral 0xb37c5515
address collateral_
uint256 collateralDecimal_
address oracleAddress_
approve 0x095ea7b3
address spender
uint256 value
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
editMintFee 0xe56df6c6
uint256 fee_
editWithdrawFee 0xca7f171a
uint256 fee_
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0x94bf804d
uint256 oneAmount
address collateral
moveStimulus 0x7c365e1b
address location
uint256 amount
removeCollateral 0xc99d3a06
address collateral_
renounceOwnership 0x715018a6
No parameters
safeTransferETH 0x7c4368c1
address to
uint256 value
setChainLinkStimulusOracle 0x23e6f5e2
address oracle_
returns: bool
setCollateralOracle 0x1432e810
address collateral_
address oracleAddress_
setEthUsdcUniswapOracle 0x29e85c1f
address oracle_
returns: bool
setMinimumDelay 0x8028faa2
uint256 val_
setMinimumRefreshTime 0x0acac95e
uint256 val_
returns: bool
setMinimumReserveRatio 0x75e8ef5c
uint256 val_
setOneOracle 0x77be2f14
address oracle_
returns: bool
setPendingGov 0xefdf0bb0
address pendingGov_
setPendingLPGov 0xf196d018
address pendingLPGov_
setReserveStepSize 0xeb7afed0
uint256 stepSize_
setStimulusUniswapOracle 0x84233707
address oracle_
returns: bool
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x00f714ce
uint256 oneAmount
address collateral
withdrawFinal 0x25bbfee2
address collateral

Recent Transactions

No transactions found for this address