Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xE26348D30694aa7E879b9335252362Df3df93204
Balance 0 ETH
Nonce 1
Code Size 24205 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

24205 bytes
0x6080604052600436106101395760003560e01c8063a1789085116100ab578063ce2810411161006f578063ce28104114610346578063cfc1b41914610366578063d18343f314610386578063d8aed14514610399578063eed49c60146103b9578063f6326fb3146103d957610157565b8063a1789085146102c7578063ad5c4648146102e7578063bd1b7146146102fc578063c19d93fb14610311578063c7cdea371461032657610157565b8063415f1240116100fd578063415f124014610207578063441a3e701461022757806347e7ef24146102475780634b9698661461026757806357f256e31461028757806385d36cd71461029a57610157565b80630900f0101461015c5780630dbe671f1461017c5780630ecbcdab146101a75780631e6b6267146101c75780633221be54146101e757610157565b36610157576002546001600160a01b0316331461015557600080fd5b005b600080fd5b34801561016857600080fd5b50610155610177366004615913565b6103e1565b34801561018857600080fd5b50610191610925565b60405161019e9190615b19565b60405180910390f35b3480156101b357600080fd5b506101556101c2366004615adc565b610934565b3480156101d357600080fd5b506101556101e2366004615adc565b6117eb565b3480156101f357600080fd5b50610155610202366004615ac4565b612859565b34801561021357600080fd5b50610155610222366004615ac4565b612868565b34801561023357600080fd5b50610155610242366004615adc565b612874565b34801561025357600080fd5b5061015561026236600461594b565b612af3565b34801561027357600080fd5b50610155610282366004615913565b612c22565b610155610295366004615ac4565b612e58565b3480156102a657600080fd5b506102ba6102b5366004615913565b612f6c565b60405161019e9190615dc2565b3480156102d357600080fd5b506101556102e2366004615976565b612ff3565b3480156102f357600080fd5b50610191613109565b34801561030857600080fd5b50610191613118565b34801561031d57600080fd5b50610191613127565b34801561033257600080fd5b50610155610341366004615adc565b613136565b34801561035257600080fd5b50610155610361366004615adc565b61343e565b34801561037257600080fd5b50610155610381366004615913565b61357f565b610155610394366004615ac4565b613ace565b3480156103a557600080fd5b506101556103b4366004615adc565b613c69565b3480156103c557600080fd5b506101556103d4366004615ac4565b61409b565b610155614337565b600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561042f57600080fd5b505afa158015610443573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610467919061592f565b6001600160a01b03166391d14854600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156104c357600080fd5b505afa1580156104d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fb919061592f565b6001600160a01b031663ec87621c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561053357600080fd5b505afa158015610547573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056b91906159ca565b336040518363ffffffff1660e01b8152600401610589929190615b84565b60206040518083038186803b1580156105a157600080fd5b505afa1580156105b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d991906159aa565b6105e257600080fd5b6001600160a01b0381166105f557600080fd5b600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b15801561064357600080fd5b505afa158015610657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067b919061592f565b6001600160a01b031663095ea7b3826000196040518363ffffffff1660e01b81526004016106aa929190615b2d565b602060405180830381600087803b1580156106c457600080fd5b505af11580156106d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fc91906159aa565b61070557600080fd5b60015b600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b15801561075657600080fd5b505afa15801561076a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078e919061592f565b6001600160a01b031663d47e470d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107c657600080fd5b505afa1580156107da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107fe91906159ca565b811161092157600154604080516379502c5560e01b815290516000926001600160a01b0316916379502c55916004808301926020929190829003018186803b15801561084957600080fd5b505afa15801561085d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610881919061592f565b6001600160a01b0316634a6e0dd0836040518263ffffffff1660e01b81526004016108ac9190615dc2565b6101006040518083038186803b1580156108c557600080fd5b505afa1580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd91906159e2565b519050806109176001600160a01b038216856000196143ba565b5050600101610708565b5050565b6001546001600160a01b031681565b81336001600160a01b0316600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c5919061592f565b6001600160a01b0316633c2ecfe5836040518263ffffffff1660e01b81526004016109f09190615dc2565b60206040518083038186803b158015610a0857600080fd5b505afa158015610a1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a40919061592f565b6001600160a01b031614610a5357600080fd5b60026000541415610a7f5760405162461bcd60e51b8152600401610a7690615d35565b60405180910390fd5b6002600055610a8c6158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015610ada57600080fd5b505afa158015610aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b12919061592f565b6001600160a01b0316638c64ea4a856040518263ffffffff1660e01b8152600401610b3d9190615dc2565b60a06040518083038186803b158015610b5557600080fd5b505afa158015610b69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8d9190615a5f565b600354815160405163fe042ceb60e01b81529293506001600160a01b039091169163fe042ceb91610bc091600401615b19565b600060405180830381600087803b158015610bda57600080fd5b505af1158015610bee573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4257600080fd5b505afa158015610c56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7a919061592f565b8251604051631775a5f760e21b81526001600160a01b039290921691635dd697dc91610ca891600401615b19565b60206040518083038186803b158015610cc057600080fd5b505afa158015610cd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf891906159ca565b9050838115610d1857610d15610d0e86846144b4565b82906144eb565b90505b6001546040805163b8091c5b60e01b815290516000926001600160a01b03169163b8091c5b916004808301926020929190829003018186803b158015610d5d57600080fd5b505afa158015610d71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d95919061592f565b6001600160a01b0316633a282c0a83610db18760000151612f6c565b6040518363ffffffff1660e01b8152600401610dce929190615dcb565b60206040518083038186803b158015610de657600080fd5b505afa158015610dfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1e91906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015610e6e57600080fd5b505afa158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea6919061592f565b6001600160a01b031663ef18fcb488610ecc8488606001516144eb90919063ffffffff16565b6040518363ffffffff1660e01b8152600401610ee9929190615dcb565b600060405180830381600087803b158015610f0357600080fd5b505af1158015610f17573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f6b57600080fd5b505afa158015610f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa3919061592f565b6001600160a01b031663724091e0866000015187604001516040518363ffffffff1660e01b8152600401610fd8929190615b2d565b60206040518083038186803b158015610ff057600080fd5b505afa158015611004573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102891906159ca565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561107a57600080fd5b505afa15801561108e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b2919061592f565b6001600160a01b031663d310f49b8a6040518263ffffffff1660e01b81526004016110dd9190615dc2565b60206040518083038186803b1580156110f557600080fd5b505afa158015611109573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112d91906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b15801561117d57600080fd5b505afa158015611191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b5919061592f565b8651604051638a98b12d60e01b81526001600160a01b039290921691638a98b12d916111e391600401615b19565b60206040518083038186803b1580156111fb57600080fd5b505afa15801561120f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123391906159ca565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561128157600080fd5b505afa158015611295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b9919061592f565b87516040516309552ee360e11b81526001600160a01b0392909216916312aa5dc6916112e791600401615b19565b60206040518083038186803b1580156112ff57600080fd5b505afa158015611313573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133791906159ca565b111561134257600080fd5b600154604080516307bce81360e21b815290516000926001600160a01b031691631ef3a04c916004808301926020929190829003018186803b15801561138757600080fd5b505afa15801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf919061592f565b6001600160a01b0316630e84c2b38484600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b15801561141d57600080fd5b505afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611455919061592f565b6001600160a01b0316634a6e0dd0600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b1580156114b157600080fd5b505afa1580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e9919061592f565b8d5160405163db67c4d560e01b81526001600160a01b03929092169163db67c4d59161151791600401615b19565b60206040518083038186803b15801561152f57600080fd5b505afa158015611543573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156791906159ca565b6040518263ffffffff1660e01b81526004016115839190615dc2565b6101006040518083038186803b15801561159c57600080fd5b505afa1580156115b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d491906159e2565b606001516040518463ffffffff1660e01b81526004016115f693929190615dd9565b60206040518083038186803b15801561160e57600080fd5b505afa158015611622573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164691906159aa565b90508061165257600080fd5b600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156116a057600080fd5b505afa1580156116b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d8919061592f565b6001600160a01b03166340c10f19338b6040518363ffffffff1660e01b8152600401611705929190615b2d565b600060405180830381600087803b15801561171f57600080fd5b505af1158015611733573d6000803e3d6000fd5b505060048054604051631d3fa1c760e31b81526001600160a01b03909116935063e9fd0e389250611766918e9101615dc2565b600060405180830381600087803b15801561178057600080fd5b505af1158015611794573d6000803e3d6000fd5b50505050336001600160a01b03168a7feaf3bd02ad76e4b07064f7a219cd7722f0124fcc8b391721b63bc069aa4cbeb88b6040516117d29190615dc2565b60405180910390a3505060016000555050505050505050565b6002600054141561180e5760405162461bcd60e51b8152600401610a7690615d35565b600260005561181b6158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561186957600080fd5b505afa15801561187d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a1919061592f565b6001600160a01b0316638c64ea4a846040518263ffffffff1660e01b81526004016118cc9190615dc2565b60a06040518083038186803b1580156118e457600080fd5b505afa1580156118f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191c9190615a5f565b600354815160405163fe042ceb60e01b81529293506001600160a01b039091169163fe042ceb9161194f91600401615b19565b600060405180830381600087803b15801561196957600080fd5b505af115801561197d573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156119d157600080fd5b505afa1580156119e5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a09919061592f565b6001600160a01b031663724091e0836000015184604001516040518363ffffffff1660e01b8152600401611a3e929190615b2d565b60206040518083038186803b158015611a5657600080fd5b505afa158015611a6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8e91906159ca565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae057600080fd5b505afa158015611af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b18919061592f565b6001600160a01b031663d310f49b866040518263ffffffff1660e01b8152600401611b439190615dc2565b60206040518083038186803b158015611b5b57600080fd5b505afa158015611b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9391906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b0316631ef3a04c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611be357600080fd5b505afa158015611bf7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1b919061592f565b6001600160a01b0316630e84c2b38383600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c7957600080fd5b505afa158015611c8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb1919061592f565b6001600160a01b0316634a6e0dd0600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015611d0d57600080fd5b505afa158015611d21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d45919061592f565b895160405163db67c4d560e01b81526001600160a01b03929092169163db67c4d591611d7391600401615b19565b60206040518083038186803b158015611d8b57600080fd5b505afa158015611d9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc391906159ca565b6040518263ffffffff1660e01b8152600401611ddf9190615dc2565b6101006040518083038186803b158015611df857600080fd5b505afa158015611e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3091906159e2565b604001516040518463ffffffff1660e01b8152600401611e5293929190615dd9565b60206040518083038186803b158015611e6a57600080fd5b505afa158015611e7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea291906159aa565b15611eac57600080fd5b6000611fc3600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015611eff57600080fd5b505afa158015611f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f37919061592f565b8551604051637df10f2360e01b81526001600160a01b039290921691637df10f2391611f6591600401615b19565b60206040518083038186803b158015611f7d57600080fd5b505afa158015611f91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb591906159ca565b611fbd614510565b9061451c565b90506000611fd18383614544565b9050600081871115611fe7575094508482611ff4565b611ff187846144b4565b90505b6000612106600160009054906101000a90046001600160a01b03166001600160a01b0316631ef3a04c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561204757600080fd5b505afa15801561205b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207f919061592f565b8851604051630f81b64f60e31b81526001600160a01b039290921691637c0db278916120af918d90600401615b2d565b60206040518083038186803b1580156120c757600080fd5b505afa1580156120db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ff91906159ca565b89906144eb565b9050600086821061246c57600154604080516307bce81360e21b815290518994506000926001600160a01b031691631ef3a04c916004808301926020929190829003018186803b15801561215957600080fd5b505afa15801561216d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612191919061592f565b8951604051636b075c8d60e11b81526001600160a01b03929092169163d60eb91a916121c1918c90600401615b2d565b60206040518083038186803b1580156121d957600080fd5b505afa1580156121ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221191906159ca565b90508087111561245c57612225878261451c565b915081600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b15801561227657600080fd5b505afa15801561228a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ae919061592f565b6001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016122d99190615b19565b60206040518083038186803b1580156122f157600080fd5b505afa158015612305573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232991906159ca565b101561233457600080fd5b600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b15801561238257600080fd5b505afa158015612396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ba919061592f565b6001600160a01b0316639dc29fac30846040518363ffffffff1660e01b81526004016123e7929190615b2d565b600060405180830381600087803b15801561240157600080fd5b505af1158015612415573d6000803e3d6000fd5b50505050336001600160a01b03168b7fee59f0ab11beb3caf57d8bff0a6295df41b8a08d3adcabc7840e70ad1e4c9c57846040516124539190615dc2565b60405180910390a35b612466878361451c565b90995092505b61247f8a61247a85846144eb565b614572565b600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156124cd57600080fd5b505afa1580156124e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612505919061592f565b6001600160a01b0316639dc29fac338b6040518363ffffffff1660e01b8152600401612532929190615b2d565b600060405180830381600087803b15801561254c57600080fd5b505af1158015612560573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156125b457600080fd5b505afa1580156125c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ec919061592f565b8951604051639bfa518160e01b81526001600160a01b039290921691639bfa51819161261c918790600401615b2d565b60206040518083038186803b15801561263457600080fd5b505afa158015612648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266c91906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156126bc57600080fd5b505afa1580156126d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f4919061592f565b6001600160a01b031663c7eb222b8c61271a848d6040015161451c90919063ffffffff16565b6040518363ffffffff1660e01b8152600401612737929190615dcb565b600060405180830381600087803b15801561275157600080fd5b505af1158015612765573d6000803e3d6000fd5b50508a51915061278190506001600160a01b0382163384614a67565b600460009054906101000a90046001600160a01b03166001600160a01b031663e9fd0e388d6040518263ffffffff1660e01b81526004016127c29190615dc2565b600060405180830381600087803b1580156127dc57600080fd5b505af11580156127f0573d6000803e3d6000fd5b50505050336001600160a01b03168a602001516001600160a01b03168d7faba5d629ca14a7d184b55def9058e247debfb64f6ccebd9782b8c9c65307ccb0888660405161283e929190615dcb565b60405180910390a45050600160005550505050505050505050565b61286581600019613c69565b50565b612865816000196117eb565b81336001600160a01b0316600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156128cd57600080fd5b505afa1580156128e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612905919061592f565b6001600160a01b0316633c2ecfe5836040518263ffffffff1660e01b81526004016129309190615dc2565b60206040518083038186803b15801561294857600080fd5b505afa15801561295c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612980919061592f565b6001600160a01b03161461299357600080fd5b600260005414156129b65760405162461bcd60e51b8152600401610a7690615d35565b60026000556129c58383614a86565b6129cd6158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015612a1b57600080fd5b505afa158015612a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a53919061592f565b6001600160a01b0316638c64ea4a856040518263ffffffff1660e01b8152600401612a7e9190615dc2565b60a06040518083038186803b158015612a9657600080fd5b505afa158015612aaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ace9190615a5f565b8051909150612ae76001600160a01b0382163386614a67565b50506001600055505050565b600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015612b4157600080fd5b505afa158015612b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b79919061592f565b6001600160a01b031663db67c4d5836040518263ffffffff1660e01b8152600401612ba49190615b19565b60206040518083038186803b158015612bbc57600080fd5b505afa158015612bd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf491906159ca565b612bfd57600080fd5b81612c136001600160a01b038216333085615271565b612c1d8383615292565b505050565b600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015612c7057600080fd5b505afa158015612c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ca8919061592f565b6001600160a01b03166391d14854600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015612d0457600080fd5b505afa158015612d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3c919061592f565b6001600160a01b031663ec87621c6040518163ffffffff1660e01b815260040160206040518083038186803b158015612d7457600080fd5b505afa158015612d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dac91906159ca565b336040518363ffffffff1660e01b8152600401612dca929190615b84565b60206040518083038186803b158015612de257600080fd5b505afa158015612df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e1a91906159aa565b612e2357600080fd5b6001600160a01b038116612e3657600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b612e60614337565b600154604080516365d5528760e01b815290516000926001600160a01b0316916365d55287916004808301926020929190829003018186803b158015612ea557600080fd5b505afa158015612eb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612edd919061592f565b60025460405163bd44815f60e01b81526001600160a01b039283169263bd44815f92612f10929116903390600401615b46565b60206040518083038186803b158015612f2857600080fd5b505afa158015612f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6091906159ca565b90506109218183610934565b6003546040516385d36cd760e01b81526000916001600160a01b0316906385d36cd790612f9d908590600401615b19565b60206040518083038186803b158015612fb557600080fd5b505afa158015612fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fed91906159ca565b92915050565b612ffd8383612af3565b600154604080516365d5528760e01b815290516000926001600160a01b0316916365d55287916004808301926020929190829003018186803b15801561304257600080fd5b505afa158015613056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061307a919061592f565b6001600160a01b031663bd44815f85336040518363ffffffff1660e01b81526004016130a7929190615b46565b60206040518083038186803b1580156130bf57600080fd5b505afa1580156130d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f791906159ca565b90506131038183610934565b50505050565b6002546001600160a01b031681565b6004546001600160a01b031681565b6003546001600160a01b031681565b81336001600160a01b0316600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561318f57600080fd5b505afa1580156131a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c7919061592f565b6001600160a01b0316633c2ecfe5836040518263ffffffff1660e01b81526004016131f29190615dc2565b60206040518083038186803b15801561320a57600080fd5b505afa15801561321e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613242919061592f565b6001600160a01b03161461325557600080fd5b600260005414156132785760405162461bcd60e51b8152600401610a7690615d35565b60026000556132878383614a86565b61328f6158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156132dd57600080fd5b505afa1580156132f1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613315919061592f565b6001600160a01b0316638c64ea4a856040518263ffffffff1660e01b81526004016133409190615dc2565b60a06040518083038186803b15801561335857600080fd5b505afa15801561336c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133909190615a5f565b60025481519192506001600160a01b039182169116146133af57600080fd5b600254604051632e1a7d4d60e01b81526001600160a01b0390911690632e1a7d4d906133df908690600401615dc2565b600060405180830381600087803b1580156133f957600080fd5b505af115801561340d573d6000803e3d6000fd5b505060405133925085156108fc02915085906000818181858888f19350505050158015612ae7573d6000803e3d6000fd5b6134466158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b15801561349457600080fd5b505afa1580156134a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134cc919061592f565b6001600160a01b0316638c64ea4a846040518263ffffffff1660e01b81526004016134f79190615dc2565b60a06040518083038186803b15801561350f57600080fd5b505afa158015613523573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135479190615a5f565b80519091506001600160a01b031661355e57600080fd5b80516135756001600160a01b038216333086615271565b61310384846154a1565b600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156135cd57600080fd5b505afa1580156135e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613605919061592f565b6001600160a01b03166391d14854600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561366157600080fd5b505afa158015613675573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613699919061592f565b6001600160a01b031663ec87621c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156136d157600080fd5b505afa1580156136e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370991906159ca565b336040518363ffffffff1660e01b8152600401613727929190615b84565b60206040518083038186803b15801561373f57600080fd5b505afa158015613753573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061377791906159aa565b61378057600080fd5b600154604080516316d8a5a960e01b815290516000926001600160a01b0316916316d8a5a9916004808301926020929190829003018186803b1580156137c557600080fd5b505afa1580156137d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137fd919061592f565b90506138928230836001600160a01b03166370a08231866040518263ffffffff1660e01b81526004016138309190615b19565b60206040518083038186803b15801561384857600080fd5b505afa15801561385c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388091906159ca565b6001600160a01b038516929190615271565b60015b600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b1580156138e357600080fd5b505afa1580156138f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061391b919061592f565b6001600160a01b031663d47e470d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561395357600080fd5b505afa158015613967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061398b91906159ca565b8111612c1d57600154604080516379502c5560e01b815290516000926001600160a01b0316916379502c55916004808301926020929190829003018186803b1580156139d657600080fd5b505afa1580156139ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a0e919061592f565b6001600160a01b0316634a6e0dd0836040518263ffffffff1660e01b8152600401613a399190615dc2565b6101006040518083038186803b158015613a5257600080fd5b505afa158015613a66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a8a91906159e2565b516040516370a0823160e01b81529091508190613ac490869030906001600160a01b038516906370a0823190613830908590600401615b19565b5050600101613895565b613ad66158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015613b2457600080fd5b505afa158015613b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b5c919061592f565b6001600160a01b0316638c64ea4a836040518263ffffffff1660e01b8152600401613b879190615dc2565b60a06040518083038186803b158015613b9f57600080fd5b505afa158015613bb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd79190615a5f565b60025481519192506001600160a01b03918216911614613bf657600080fd5b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015613c4657600080fd5b505af1158015613c5a573d6000803e3d6000fd5b505050505061092182346154a1565b60026000541415613c8c5760405162461bcd60e51b8152600401610a7690615d35565b60026000908155600154604080516365d5528760e01b815290516001600160a01b03909216916365d5528791600480820192602092909190829003018186803b158015613cd857600080fd5b505afa158015613cec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d10919061592f565b6001600160a01b031663b508bc59846040518263ffffffff1660e01b8152600401613d3b9190615dc2565b60206040518083038186803b158015613d5357600080fd5b505afa158015613d67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d8b919061592f565b60035460405163fe042ceb60e01b81529192506001600160a01b03169063fe042ceb90613dbc908490600401615b19565b600060405180830381600087803b158015613dd657600080fd5b505af1158015613dea573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015613e3e57600080fd5b505afa158015613e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e76919061592f565b6001600160a01b031663d310f49b856040518263ffffffff1660e01b8152600401613ea19190615dc2565b60206040518083038186803b158015613eb957600080fd5b505afa158015613ecd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ef191906159ca565b9050808310613efe578092505b613f088484614572565b600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b158015613f5657600080fd5b505afa158015613f6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f8e919061592f565b6001600160a01b0316639dc29fac33856040518363ffffffff1660e01b8152600401613fbb929190615b2d565b600060405180830381600087803b158015613fd557600080fd5b505af1158015613fe9573d6000803e3d6000fd5b505060048054604051631d3fa1c760e31b81526001600160a01b03909116935063e9fd0e38925061401c91889101615dc2565b600060405180830381600087803b15801561403657600080fd5b505af115801561404a573d6000803e3d6000fd5b50505050336001600160a01b0316847fec0b41ca9a2a301ec07412b3c841535558e6b49d98c606aeca50e85f164182f2856040516140889190615dc2565b60405180910390a3505060016000555050565b600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156140e957600080fd5b505afa1580156140fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614121919061592f565b6001600160a01b03166391d14854600160009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561417d57600080fd5b505afa158015614191573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b5919061592f565b6001600160a01b031663ec87621c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156141ed57600080fd5b505afa158015614201573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061422591906159ca565b336040518363ffffffff1660e01b8152600401614243929190615b84565b60206040518083038186803b15801561425b57600080fd5b505afa15801561426f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061429391906159aa565b61429c57600080fd5b6128653382600160009054906101000a90046001600160a01b03166001600160a01b03166316d8a5a96040518163ffffffff1660e01b815260040160206040518083038186803b1580156142ef57600080fd5b505afa158015614303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614327919061592f565b6001600160a01b03169190614a67565b600260009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561438757600080fd5b505af115801561439b573d6000803e3d6000fd5b50506002546143b893506001600160a01b03169150349050615292565b565b8015806144425750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906143f09030908690600401615b46565b60206040518083038186803b15801561440857600080fd5b505afa15801561441c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061444091906159ca565b155b61445e5760405162461bcd60e51b8152600401610a7690615d6c565b612c1d8363095ea7b360e01b848460405160240161447d929190615b2d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526156ee565b60006144e4670de0b6b3a76400006144de6144cf868661577d565b6706f05b59d3b20000906144eb565b906157b7565b9392505050565b6000828201838110156144e45760405162461bcd60e51b8152600401610a7690615bce565b670de0b6b3a764000090565b60008282111561453e5760405162461bcd60e51b8152600401610a7690615c05565b50900390565b60006002820461456a836144de61456387670de0b6b3a764000061577d565b84906144eb565b949350505050565b600154604080516365d5528760e01b815290516000926001600160a01b0316916365d55287916004808301926020929190829003018186803b1580156145b757600080fd5b505afa1580156145cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145ef919061592f565b6001600160a01b031663b508bc59846040518263ffffffff1660e01b815260040161461a9190615dc2565b60206040518083038186803b15801561463257600080fd5b505afa158015614646573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061466a919061592f565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156146bc57600080fd5b505afa1580156146d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146f4919061592f565b6001600160a01b031663d310f49b856040518263ffffffff1660e01b815260040161471f9190615dc2565b60206040518083038186803b15801561473757600080fd5b505afa15801561474b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061476f91906159ca565b9050600061477d828561451c565b9050600061478a84612f6c565b90508161487c57600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156147df57600080fd5b505afa1580156147f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614817919061592f565b6001600160a01b031663ef18fcb48760006040518363ffffffff1660e01b8152600401614845929190615dcb565b600060405180830381600087803b15801561485f57600080fd5b505af1158015614873573d6000803e3d6000fd5b50505050614a5f565b6001546040805163b8091c5b60e01b815290516000926001600160a01b03169163b8091c5b916004808301926020929190829003018186803b1580156148c157600080fd5b505afa1580156148d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f9919061592f565b6001600160a01b0316633a282c0a84846040518363ffffffff1660e01b8152600401614926929190615dcb565b60206040518083038186803b15801561493e57600080fd5b505afa158015614952573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061497691906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156149c657600080fd5b505afa1580156149da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149fe919061592f565b6001600160a01b031663ef18fcb488836040518363ffffffff1660e01b8152600401614a2b929190615dcb565b600060405180830381600087803b158015614a4557600080fd5b505af1158015614a59573d6000803e3d6000fd5b50505050505b505050505050565b612c1d8363a9059cbb60e01b848460405160240161447d929190615b2d565b614a8e6158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015614adc57600080fd5b505afa158015614af0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b14919061592f565b6001600160a01b0316638c64ea4a846040518263ffffffff1660e01b8152600401614b3f9190615dc2565b60a06040518083038186803b158015614b5757600080fd5b505afa158015614b6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b8f9190615a5f565b90508060400151821115614ba257600080fd5b6040810151600090614bb4908461451c565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015614c0457600080fd5b505afa158015614c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c3c919061592f565b6001600160a01b031663c7eb222b85836040518363ffffffff1660e01b8152600401614c69929190615dcb565b600060405180830381600087803b158015614c8357600080fd5b505af1158015614c97573d6000803e3d6000fd5b5050505060608201511561522957600354825160405163fe042ceb60e01b81526001600160a01b039092169163fe042ceb91614cd591600401615b19565b600060405180830381600087803b158015614cef57600080fd5b505af1158015614d03573d6000803e3d6000fd5b505050506000600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015614d5757600080fd5b505afa158015614d6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d8f919061592f565b8351604051630392048f60e51b81526001600160a01b03929092169163724091e091614dbf918690600401615b2d565b60206040518083038186803b158015614dd757600080fd5b505afa158015614deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e0f91906159ca565b9050600160009054906101000a90046001600160a01b03166001600160a01b0316631ef3a04c6040518163ffffffff1660e01b815260040160206040518083038186803b158015614e5f57600080fd5b505afa158015614e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e97919061592f565b6001600160a01b0316630e84c2b382600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b158015614ef457600080fd5b505afa158015614f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f2c919061592f565b6001600160a01b031663d310f49b896040518263ffffffff1660e01b8152600401614f579190615dc2565b60206040518083038186803b158015614f6f57600080fd5b505afa158015614f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614fa791906159ca565b600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b158015614ff557600080fd5b505afa158015615009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061502d919061592f565b6001600160a01b0316634a6e0dd0600160009054906101000a90046001600160a01b03166001600160a01b03166379502c556040518163ffffffff1660e01b815260040160206040518083038186803b15801561508957600080fd5b505afa15801561509d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150c1919061592f565b895160405163db67c4d560e01b81526001600160a01b03929092169163db67c4d5916150ef91600401615b19565b60206040518083038186803b15801561510757600080fd5b505afa15801561511b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061513f91906159ca565b6040518263ffffffff1660e01b815260040161515b9190615dc2565b6101006040518083038186803b15801561517457600080fd5b505afa158015615188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151ac91906159e2565b606001516040518463ffffffff1660e01b81526004016151ce93929190615dd9565b60206040518083038186803b1580156151e657600080fd5b505afa1580156151fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061521e91906159aa565b61522757600080fd5b505b336001600160a01b0316847f02ffa641367f5b897c0f8be81bce51f2ef055b4113d7a1e4fd082feea749bf52856040516152639190615dc2565b60405180910390a350505050565b613103846323b872dd60e01b85858560405160240161447d93929190615b60565b600154604080516365d5528760e01b815290516000926001600160a01b0316916365d55287916004808301926020929190829003018186803b1580156152d757600080fd5b505afa1580156152eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061530f919061592f565b6001600160a01b031663bd44815f84336040518363ffffffff1660e01b815260040161533c929190615b46565b60206040518083038186803b15801561535457600080fd5b505afa158015615368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061538c91906159ca565b90508061549b57600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156153e157600080fd5b505afa1580156153f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190615419919061592f565b6001600160a01b031663cc92d31c84336040518363ffffffff1660e01b8152600401615446929190615b46565b602060405180830381600087803b15801561546057600080fd5b505af1158015615474573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061549891906159ca565b90505b612c1d81835b6154a96158d2565b600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156154f757600080fd5b505afa15801561550b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061552f919061592f565b6001600160a01b0316638c64ea4a846040518263ffffffff1660e01b815260040161555a9190615dc2565b60a06040518083038186803b15801561557257600080fd5b505afa158015615586573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906155aa9190615a5f565b9050600160009054906101000a90046001600160a01b03166001600160a01b03166365d552876040518163ffffffff1660e01b815260040160206040518083038186803b1580156155fa57600080fd5b505afa15801561560e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190615632919061592f565b6001600160a01b031663c7eb222b846156588585604001516144eb90919063ffffffff16565b6040518363ffffffff1660e01b8152600401615675929190615dcb565b600060405180830381600087803b15801561568f57600080fd5b505af11580156156a3573d6000803e3d6000fd5b50505050336001600160a01b0316837ffaddc2a572d923daf0944fe20bf804595e90ca57c85045b1081d338d1510bf14846040516156e19190615dc2565b60405180910390a3505050565b6060615743826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166157e99092919063ffffffff16565b805190915015612c1d578080602001905181019061576191906159aa565b612c1d5760405162461bcd60e51b8152600401610a7690615ceb565b60008261578c57506000612fed565b8282028284828161579957fe5b04146144e45760405162461bcd60e51b8152600401610a7690615c73565b60008082116157d85760405162461bcd60e51b8152600401610a7690615c3c565b8183816157e157fe5b049392505050565b606061456a8484600085856157fd85615893565b6158195760405162461bcd60e51b8152600401610a7690615cb4565b60006060866001600160a01b031685876040516158369190615afd565b60006040518083038185875af1925050503d8060008114615873576040519150601f19603f3d011682016040523d82523d6000602084013e615878565b606091505b5091509150615888828286615899565b979650505050505050565b3b151590565b606083156158a85750816144e4565b8251156158b85782518084602001fd5b8160405162461bcd60e51b8152600401610a769190615b9b565b6040518060a0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081525090565b600060208284031215615924578081fd5b81356144e481615e42565b600060208284031215615940578081fd5b81516144e481615e42565b6000806040838503121561595d578081fd5b823561596881615e42565b946020939093013593505050565b60008060006060848603121561598a578081fd5b833561599581615e42565b95602085013595506040909401359392505050565b6000602082840312156159bb578081fd5b815180151581146144e4578182fd5b6000602082840312156159db578081fd5b5051919050565b60006101008083850312156159f5578182fd5b6159fe81615def565b90508251615a0b81615e42565b808252506020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201528091505092915050565b600060a08284031215615a70578081fd5b615a7a60a0615def565b8251615a8581615e42565b81526020830151615a9581615e42565b806020830152506040830151604082015260608301516060820152608083015160808201528091505092915050565b600060208284031215615ad5578081fd5b5035919050565b60008060408385031215615aee578182fd5b50508035926020909101359150565b60008251615b0f818460208701615e16565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b9182526001600160a01b0316602082015260400190565b6000602082528251806020840152615bba816040850160208701615e16565b601f01601f19169190910160400192915050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff81118282101715615e0e57600080fd5b604052919050565b60005b83811015615e31578181015183820152602001615e19565b838111156131035750506000910152565b6001600160a01b038116811461286557600080fdfea2646970667358221220176fc10313018e75bf42d0346b5c2fd60028f95be40eb98ad7c5fece5075b12a64736f6c634300060c0033

Verified Source Code Partial Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul Optimization: Yes (200 runs)
SafeMath.sol 214 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

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

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}
IERC20.sol 77 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
SafeERC20.sol 75 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

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

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

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

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

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

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

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

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

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
ReentrancyGuard.sol 62 lines
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

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

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

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
AggregatorV3Interface.sol 33 lines
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.12;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  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
    );
}
VaultsCore.sol 447 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";

import "../libraries/WadRayMath.sol";
import "../interfaces/IVaultsCore.sol";
import "../interfaces/IAddressProvider.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/IVaultsCoreState.sol";
import "../liquidityMining/interfaces/IDebtNotifier.sol";

contract VaultsCore is IVaultsCore, ReentrancyGuard {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;
  using WadRayMath for uint256;

  uint256 internal constant _MAX_INT = 2 ** 256 - 1;

  IAddressProvider public override a;
  IWETH public override WETH;
  IVaultsCoreState public override state;
  IDebtNotifier public override debtNotifier;

  modifier onlyManager() {
    require(a.controller().hasRole(a.controller().MANAGER_ROLE(), msg.sender));
    _;
  }

  modifier onlyVaultOwner(uint256 _vaultId) {
    require(a.vaultsData().vaultOwner(_vaultId) == msg.sender);
    _;
  }

  constructor(IAddressProvider _addresses, IWETH _IWETH, IVaultsCoreState _vaultsCoreState) public {
    require(address(_addresses) != address(0));
    require(address(_IWETH) != address(0));
    require(address(_vaultsCoreState) != address(0));
    a = _addresses;
    WETH = _IWETH;
    state = _vaultsCoreState;
  }

  // For a contract to receive ETH, it needs to have a payable fallback function
  // https://ethereum.stackexchange.com/a/47415
  receive() external payable {
    require(msg.sender == address(WETH));
  }

  /*
    Allow smooth upgrading of the vaultscore.
    @dev this function approves token transfers to the new vaultscore of
    both stablex and all configured collateral types
    @param _newVaultsCore address of the new vaultscore
  */
  function upgrade(address payable _newVaultsCore) public override onlyManager {
    require(address(_newVaultsCore) != address(0));
    require(a.stablex().approve(_newVaultsCore, _MAX_INT));

    for (uint256 i = 1; i <= a.config().numCollateralConfigs(); i++) {
      address collateralType = a.config().collateralConfigs(i).collateralType;
      IERC20 asset = IERC20(collateralType);
      asset.safeApprove(_newVaultsCore, _MAX_INT);
    }
  }

  /*
    Allow smooth upgrading of the VaultsCore.
    @dev this function transfers both PAR and all configured collateral
    types to the new vaultscore.
  */
  function acceptUpgrade(address payable _oldVaultsCore) public override onlyManager {
    IERC20 stableX = IERC20(a.stablex());
    stableX.safeTransferFrom(_oldVaultsCore, address(this), stableX.balanceOf(_oldVaultsCore));

    for (uint256 i = 1; i <= a.config().numCollateralConfigs(); i++) {
      address collateralType = a.config().collateralConfigs(i).collateralType;
      IERC20 asset = IERC20(collateralType);
      asset.safeTransferFrom(_oldVaultsCore, address(this), asset.balanceOf(_oldVaultsCore));
    }
  }

  /*
    Allow manager to withdraw stablex
    @dev this function transfers stablex amount to the caller
    @param _amount amount of stablex to be withdrawn
  */
  function withdrawStableX(uint256 _amount) public onlyManager {
    IERC20(a.stablex()).safeTransfer(msg.sender, _amount);
  }

  /**
    Configure the debt notifier.
    @param _debtNotifier the new DebtNotifier module address.
  **/
  function setDebtNotifier(IDebtNotifier _debtNotifier) public override onlyManager {
    require(address(_debtNotifier) != address(0));
    debtNotifier = _debtNotifier;
  }

  /**
    Deposit an ERC20 token into the vault of the msg.sender as collateral
    @dev A new vault is created if no vault exists for the `msg.sender` with the specified collateral type.
    this function uses `transferFrom()` and requires pre-approval via `approve()` on the ERC20.
    @param _collateralType the address of the collateral type to be deposited
    @param _amount the amount of tokens to be deposited in WEI.
  **/
  function deposit(address _collateralType, uint256 _amount) public override {
    require(a.config().collateralIds(_collateralType) != 0);

    IERC20 asset = IERC20(_collateralType);
    asset.safeTransferFrom(msg.sender, address(this), _amount);

    _addCollateralToVault(_collateralType, _amount);
  }

  /**
    Wraps ETH and deposits WETH into the vault of the msg.sender as collateral
    @dev A new vault is created if no WETH vault exists
  **/
  function depositETH() public payable override {
    WETH.deposit{ value: msg.value }();
    _addCollateralToVault(address(WETH), msg.value);
  }

  /**
    Deposit an ERC20 token into the specified vault as collateral
    @dev this function uses `transferFrom()` and requires pre-approval via `approve()` on the ERC20.
    @param _vaultId the address of the collateral type to be deposited
    @param _amount the amount of tokens to be deposited in WEI.
  **/
  function depositByVaultId(uint256 _vaultId, uint256 _amount) public override {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);
    require(v.collateralType != address(0));

    IERC20 asset = IERC20(v.collateralType);
    asset.safeTransferFrom(msg.sender, address(this), _amount);

    _addCollateralToVaultById(_vaultId, _amount);
  }

  /**
    Wraps ETH and deposits WETH into the specified vault as collateral
    @dev this function uses `transferFrom()` and requires pre-approval via `approve()` on the ERC20.
    @param _vaultId the address of the collateral type to be deposited
  **/
  function depositETHByVaultId(uint256 _vaultId) public payable override {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);
    require(v.collateralType == address(WETH));

    WETH.deposit{ value: msg.value }();

    _addCollateralToVaultById(_vaultId, msg.value);
  }

  /**
    Deposit an ERC20 token into the vault of the msg.sender as collateral and borrows the specified amount of tokens in WEI
    @dev see deposit() and borrow()
    @param _collateralType the address of the collateral type to be deposited
    @param _depositAmount the amount of tokens to be deposited in WEI.
    @param _borrowAmount the amount of borrowed StableX tokens in WEI.
  **/
  function depositAndBorrow(address _collateralType, uint256 _depositAmount, uint256 _borrowAmount) public override {
    deposit(_collateralType, _depositAmount);
    uint256 vaultId = a.vaultsData().vaultId(_collateralType, msg.sender);
    borrow(vaultId, _borrowAmount);
  }

  /**
    Wraps ETH and deposits WETH into the vault of the msg.sender as collateral and borrows the specified amount of tokens in WEI
    @dev see depositETH() and borrow()
    @param _borrowAmount the amount of borrowed StableX tokens in WEI.
  **/
  function depositETHAndBorrow(uint256 _borrowAmount) public payable override {
    depositETH();
    uint256 vaultId = a.vaultsData().vaultId(address(WETH), msg.sender);
    borrow(vaultId, _borrowAmount);
  }

  function _addCollateralToVault(address _collateralType, uint256 _amount) internal {
    uint256 vaultId = a.vaultsData().vaultId(_collateralType, msg.sender);
    if (vaultId == 0) {
      vaultId = a.vaultsData().createVault(_collateralType, msg.sender);
    }

    _addCollateralToVaultById(vaultId, _amount);
  }

  function _addCollateralToVaultById(uint256 _vaultId, uint256 _amount) internal {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);

    a.vaultsData().setCollateralBalance(_vaultId, v.collateralBalance.add(_amount));

    emit Deposited(_vaultId, _amount, msg.sender);
  }

  /**
    Withdraws ERC20 tokens from a vault.
    @dev Only the owner of a vault can withdraw collateral from it.
    `withdraw()` will fail if it would bring the vault below the minimum collateralization treshold.
    @param _vaultId the ID of the vault from which to withdraw the collateral.
    @param _amount the amount of ERC20 tokens to be withdrawn in WEI.
  **/
  function withdraw(uint256 _vaultId, uint256 _amount) public override onlyVaultOwner(_vaultId) nonReentrant {
    _removeCollateralFromVault(_vaultId, _amount);
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);

    IERC20 asset = IERC20(v.collateralType);
    asset.safeTransfer(msg.sender, _amount);
  }

  /**
    Withdraws ETH from a WETH vault.
    @dev Only the owner of a vault can withdraw collateral from it.
    `withdraw()` will fail if it would bring the vault below the minimum collateralization treshold.
    @param _vaultId the ID of the vault from which to withdraw the collateral.
    @param _amount the amount of ETH to be withdrawn in WEI.
  **/
  function withdrawETH(uint256 _vaultId, uint256 _amount) public override onlyVaultOwner(_vaultId) nonReentrant {
    _removeCollateralFromVault(_vaultId, _amount);
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);

    require(v.collateralType == address(WETH));

    WETH.withdraw(_amount);
    msg.sender.transfer(_amount);
  }

  function _removeCollateralFromVault(uint256 _vaultId, uint256 _amount) internal {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);
    require(_amount <= v.collateralBalance);
    uint256 newCollateralBalance = v.collateralBalance.sub(_amount);
    a.vaultsData().setCollateralBalance(_vaultId, newCollateralBalance);
    if (v.baseDebt > 0) {
      // Save gas cost when withdrawing from 0 debt vault
      state.refreshCollateral(v.collateralType);
      uint256 newCollateralValue = a.priceFeed().convertFrom(v.collateralType, newCollateralBalance);
      require(
        a.liquidationManager().isHealthy(
          newCollateralValue,
          a.vaultsData().vaultDebt(_vaultId),
          a.config().collateralConfigs(a.config().collateralIds(v.collateralType)).minCollateralRatio
        )
      );
    }

    emit Withdrawn(_vaultId, _amount, msg.sender);
  }

  /**
    Borrow new PAR tokens from a vault.
    @dev Only the owner of a vault can borrow from it.
    `borrow()` will update the outstanding vault debt to the current time before attempting the withdrawal.
     `borrow()` will fail if it would bring the vault below the minimum collateralization treshold.
    @param _vaultId the ID of the vault from which to borrow.
    @param _amount the amount of borrowed PAR tokens in WEI.
  **/
  function borrow(uint256 _vaultId, uint256 _amount) public override onlyVaultOwner(_vaultId) nonReentrant {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);

    // Make sure current rate is up to date
    state.refreshCollateral(v.collateralType);

    uint256 originationFeePercentage = a.config().collateralOriginationFee(v.collateralType);
    uint256 newDebt = _amount;
    if (originationFeePercentage > 0) {
      newDebt = newDebt.add(_amount.wadMul(originationFeePercentage));
    }

    // Increment vault borrow balance
    uint256 newBaseDebt = a.ratesManager().calculateBaseDebt(newDebt, cumulativeRates(v.collateralType));

    a.vaultsData().setBaseDebt(_vaultId, v.baseDebt.add(newBaseDebt));

    uint256 collateralValue = a.priceFeed().convertFrom(v.collateralType, v.collateralBalance);
    uint256 newVaultDebt = a.vaultsData().vaultDebt(_vaultId);

    require(a.vaultsData().collateralDebt(v.collateralType) <= a.config().collateralDebtLimit(v.collateralType));

    bool isHealthy = a.liquidationManager().isHealthy(
      collateralValue,
      newVaultDebt,
      a.config().collateralConfigs(a.config().collateralIds(v.collateralType)).minCollateralRatio
    );
    require(isHealthy);

    a.stablex().mint(msg.sender, _amount);
    debtNotifier.debtChanged(_vaultId);
    emit Borrowed(_vaultId, _amount, msg.sender);
  }

  /**
    Convenience function to repay all debt of a vault
    @dev `repayAll()` will update the outstanding vault debt to the current time.
    @param _vaultId the ID of the vault for which to repay the debt.
  **/
  function repayAll(uint256 _vaultId) public override {
    repay(_vaultId, _MAX_INT);
  }

  /**
    Repay an outstanding PAR balance to a vault.
    @dev `repay()` will update the outstanding vault debt to the current time.
    @param _vaultId the ID of the vault for which to repay the outstanding debt balance.
    @param _amount the amount of PAR tokens in WEI to be repaid.
  **/
  function repay(uint256 _vaultId, uint256 _amount) public override nonReentrant {
    address collateralType = a.vaultsData().vaultCollateralType(_vaultId);

    // Make sure current rate is up to date
    state.refreshCollateral(collateralType);

    uint256 currentVaultDebt = a.vaultsData().vaultDebt(_vaultId);
    // Decrement vault borrow balance
    if (_amount >= currentVaultDebt) {
      //full repayment
      _amount = currentVaultDebt; //only pay back what's outstanding
    }
    _reduceVaultDebt(_vaultId, _amount);
    a.stablex().burn(msg.sender, _amount);
    debtNotifier.debtChanged(_vaultId);
    emit Repaid(_vaultId, _amount, msg.sender);
  }

  /**
    Internal helper function to reduce the debt of a vault.
    @dev assumes cumulative rates for the vault's collateral type are up to date.
    please call `refreshCollateral()` before calling this function.
    @param _vaultId the ID of the vault for which to reduce the debt.
    @param _amount the amount of debt to be reduced.
  **/
  function _reduceVaultDebt(uint256 _vaultId, uint256 _amount) internal {
    address collateralType = a.vaultsData().vaultCollateralType(_vaultId);

    uint256 currentVaultDebt = a.vaultsData().vaultDebt(_vaultId);
    uint256 remainder = currentVaultDebt.sub(_amount);
    uint256 cumulativeRate = cumulativeRates(collateralType);

    if (remainder == 0) {
      a.vaultsData().setBaseDebt(_vaultId, 0);
    } else {
      uint256 newBaseDebt = a.ratesManager().calculateBaseDebt(remainder, cumulativeRate);
      a.vaultsData().setBaseDebt(_vaultId, newBaseDebt);
    }
  }

  /**
    Liquidate a vault that is below the liquidation treshold by repaying its outstanding debt.
    @dev `liquidate()` will update the outstanding vault debt to the current time and pay a `liquidationBonus`
    to the liquidator. `liquidate()` can be called by anyone.
    @param _vaultId the ID of the vault to be liquidated.
  **/
  function liquidate(uint256 _vaultId) public override {
    liquidatePartial(_vaultId, _MAX_INT);
  }

  /**
    Liquidate a vault partially that is below the liquidation treshold by repaying part of its outstanding debt.
    @dev `liquidatePartial()` will update the outstanding vault debt to the current time and pay a `liquidationBonus`
    to the liquidator. A LiquidationFee will be applied to the borrower during the liquidation.
    This means that the change in outstanding debt can be smaller than the repaid amount.
    `liquidatePartial()` can be called by anyone.
    @param _vaultId the ID of the vault to be liquidated.
    @param _amount the amount of debt+liquidationFee to repay.
  **/
  function liquidatePartial(uint256 _vaultId, uint256 _amount) public override nonReentrant {
    IVaultsDataProvider.Vault memory v = a.vaultsData().vaults(_vaultId);

    state.refreshCollateral(v.collateralType);

    uint256 collateralValue = a.priceFeed().convertFrom(v.collateralType, v.collateralBalance);
    uint256 currentVaultDebt = a.vaultsData().vaultDebt(_vaultId);

    require(
      !a.liquidationManager().isHealthy(
        collateralValue,
        currentVaultDebt,
        a.config().collateralConfigs(a.config().collateralIds(v.collateralType)).liquidationRatio
      )
    );

    uint256 repaymentAfterLiquidationFeeRatio = WadRayMath.wad().sub(
      a.config().collateralLiquidationFee(v.collateralType)
    );
    uint256 maxLiquiditionCost = currentVaultDebt.wadDiv(repaymentAfterLiquidationFeeRatio);

    uint256 repayAmount;

    if (_amount > maxLiquiditionCost) {
      _amount = maxLiquiditionCost;
      repayAmount = currentVaultDebt;
    } else {
      repayAmount = _amount.wadMul(repaymentAfterLiquidationFeeRatio);
    }

    // collateral value to be received by the liquidator is based on the total amount repaid (including the liquidationFee).
    uint256 collateralValueToReceive = _amount.add(a.liquidationManager().liquidationBonus(v.collateralType, _amount));
    uint256 insuranceAmount = 0;
    if (collateralValueToReceive >= collateralValue) {
      // Not enough collateral for debt & liquidation fee
      collateralValueToReceive = collateralValue;
      uint256 discountedCollateralValue = a.liquidationManager().applyLiquidationDiscount(
        v.collateralType,
        collateralValue
      );

      if (currentVaultDebt > discountedCollateralValue) {
        // Not enough collateral for debt alone
        insuranceAmount = currentVaultDebt.sub(discountedCollateralValue);
        require(a.stablex().balanceOf(address(this)) >= insuranceAmount);
        a.stablex().burn(address(this), insuranceAmount); // Insurance uses local reserves to pay down debt
        emit InsurancePaid(_vaultId, insuranceAmount, msg.sender);
      }

      repayAmount = currentVaultDebt.sub(insuranceAmount);
      _amount = discountedCollateralValue;
    }

    // reduce the vault debt by repayAmount
    _reduceVaultDebt(_vaultId, repayAmount.add(insuranceAmount));
    a.stablex().burn(msg.sender, _amount);

    // send the claimed collateral to the liquidator
    uint256 collateralToReceive = a.priceFeed().convertTo(v.collateralType, collateralValueToReceive);
    a.vaultsData().setCollateralBalance(_vaultId, v.collateralBalance.sub(collateralToReceive));
    IERC20 asset = IERC20(v.collateralType);
    asset.safeTransfer(msg.sender, collateralToReceive);

    debtNotifier.debtChanged(_vaultId);

    emit Liquidated(_vaultId, repayAmount, collateralToReceive, v.owner, msg.sender);
  }

  /**
    Returns the cumulativeRate of a collateral type. This function exists for
    backwards compatibility with the VaultsDataProvider.
    @param _collateralType the address of the collateral type.
  **/
  function cumulativeRates(address _collateralType) public view override returns (uint256) {
    return state.cumulativeRates(_collateralType);
  }
}
IGovernanceAddressProvider.sol 39 lines
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity >=0.6.12;

import "./IGovernorAlpha.sol";
import "./ITimelock.sol";
import "./IVotingEscrow.sol";
import "../../interfaces/IAccessController.sol";
import "../../interfaces/IAddressProvider.sol";
import "../../liquidityMining/interfaces/IMIMO.sol";
import "../../liquidityMining/interfaces/IDebtNotifier.sol";

interface IGovernanceAddressProvider {
  function setParallelAddressProvider(IAddressProvider _parallel) external;

  function setMIMO(IMIMO _mimo) external;

  function setDebtNotifier(IDebtNotifier _debtNotifier) external;

  function setGovernorAlpha(IGovernorAlpha _governorAlpha) external;

  function setTimelock(ITimelock _timelock) external;

  function setVotingEscrow(IVotingEscrow _votingEscrow) external;

  function controller() external view returns (IAccessController);

  function parallel() external view returns (IAddressProvider);

  function mimo() external view returns (IMIMO);

  function debtNotifier() external view returns (IDebtNotifier);

  function governorAlpha() external view returns (IGovernorAlpha);

  function timelock() external view returns (ITimelock);

  function votingEscrow() external view returns (IVotingEscrow);
}
IGovernorAlpha.sol 109 lines
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

interface IGovernorAlpha {
  /// @notice Possible states that a proposal may be in
  enum ProposalState { Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed }

  struct Proposal {
    // Unique id for looking up a proposal
    uint256 id;
    // Creator of the proposal
    address proposer;
    // The timestamp that the proposal will be available for execution, set once the vote succeeds
    uint256 eta;
    // the ordered list of target addresses for calls to be made
    address[] targets;
    // The ordered list of values (i.e. msg.value) to be passed to the calls to be made
    uint256[] values;
    // The ordered list of function signatures to be called
    string[] signatures;
    // The ordered list of calldata to be passed to each call
    bytes[] calldatas;
    // The timestamp at which voting begins: holders must delegate their votes prior to this timestamp
    uint256 startTime;
    // The timestamp at which voting ends: votes must be cast prior to this timestamp
    uint256 endTime;
    // Current number of votes in favor of this proposal
    uint256 forVotes;
    // Current number of votes in opposition to this proposal
    uint256 againstVotes;
    // Flag marking whether the proposal has been canceled
    bool canceled;
    // Flag marking whether the proposal has been executed
    bool executed;
    // Receipts of ballots for the entire set of voters
    mapping(address => Receipt) receipts;
  }

  /// @notice Ballot receipt record for a voter
  struct Receipt {
    // Whether or not a vote has been cast
    bool hasVoted;
    // Whether or not the voter supports the proposal
    bool support;
    // The number of votes the voter had, which were cast
    uint256 votes;
  }

  /// @notice An event emitted when a new proposal is created
  event ProposalCreated(
    uint256 id,
    address proposer,
    address[] targets,
    uint256[] values,
    string[] signatures,
    bytes[] calldatas,
    uint256 startTime,
    uint256 endTime,
    string description
  );

  /// @notice An event emitted when a vote has been cast on a proposal
  event VoteCast(address voter, uint256 proposalId, bool support, uint256 votes);

  /// @notice An event emitted when a proposal has been canceled
  event ProposalCanceled(uint256 id);

  /// @notice An event emitted when a proposal has been queued in the Timelock
  event ProposalQueued(uint256 id, uint256 eta);

  /// @notice An event emitted when a proposal has been executed in the Timelock
  event ProposalExecuted(uint256 id);

  function propose(
    address[] memory targets,
    uint256[] memory values,
    string[] memory signatures,
    bytes[] memory calldatas,
    string memory description,
    uint256 endTime
  ) external returns (uint256);

  function queue(uint256 proposalId) external;

  function execute(uint256 proposalId) external payable;

  function cancel(uint256 proposalId) external;

  function castVote(uint256 proposalId, bool support) external;

  function getActions(uint256 proposalId)
    external
    view
    returns (
      address[] memory targets,
      uint256[] memory values,
      string[] memory signatures,
      bytes[] memory calldatas
    );

  function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory);

  function state(uint256 proposalId) external view returns (ProposalState);

  function quorumVotes() external view returns (uint256);

  function proposalThreshold() external view returns (uint256);
}
ITimelock.sol 64 lines
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.6.12;

interface ITimelock {
  event NewAdmin(address indexed newAdmin);
  event NewPendingAdmin(address indexed newPendingAdmin);
  event NewDelay(uint256 indexed newDelay);
  event CancelTransaction(
    bytes32 indexed txHash,
    address indexed target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
  );
  event ExecuteTransaction(
    bytes32 indexed txHash,
    address indexed target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
  );
  event QueueTransaction(
    bytes32 indexed txHash,
    address indexed target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
  );

  function acceptAdmin() external;

  function queueTransaction(
    address target,
    uint256 value,
    string calldata signature,
    bytes calldata data,
    uint256 eta
  ) external returns (bytes32);

  function cancelTransaction(
    address target,
    uint256 value,
    string calldata signature,
    bytes calldata data,
    uint256 eta
  ) external;

  function executeTransaction(
    address target,
    uint256 value,
    string calldata signature,
    bytes calldata data,
    uint256 eta
  ) external payable returns (bytes memory);

  function delay() external view returns (uint256);

  function GRACE_PERIOD() external view returns (uint256);

  function queuedTransactions(bytes32 hash) external view returns (bool);
}
IVotingEscrow.sol 45 lines
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../liquidityMining/interfaces/IGenericMiner.sol";

interface IVotingEscrow {
  enum LockAction { CREATE_LOCK, INCREASE_LOCK_AMOUNT, INCREASE_LOCK_TIME }

  struct LockedBalance {
    uint256 amount;
    uint256 end;
  }

  /** Shared Events */
  event Deposit(address indexed provider, uint256 value, uint256 locktime, LockAction indexed action, uint256 ts);
  event Withdraw(address indexed provider, uint256 value, uint256 ts);
  event Expired();

  function createLock(uint256 _value, uint256 _unlockTime) external;

  function increaseLockAmount(uint256 _value) external;

  function increaseLockLength(uint256 _unlockTime) external;

  function withdraw() external;

  function expireContract() external;

  function setMiner(IGenericMiner _miner) external;

  function setMinimumLockTime(uint256 _minimumLockTime) external;

  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint256);

  function balanceOf(address _owner) external view returns (uint256);

  function balanceOfAt(address _owner, uint256 _blockTime) external view returns (uint256);

  function stakingToken() external view returns (IERC20);
}
IAccessController.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IAccessController {
  event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
  event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
  event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

  function grantRole(bytes32 role, address account) external;

  function revokeRole(bytes32 role, address account) external;

  function renounceRole(bytes32 role, address account) external;

  function MANAGER_ROLE() external view returns (bytes32);

  function MINTER_ROLE() external view returns (bytes32);

  function hasRole(bytes32 role, address account) external view returns (bool);

  function getRoleMemberCount(bytes32 role) external view returns (uint256);

  function getRoleMember(bytes32 role, uint256 index) external view returns (address);

  function getRoleAdmin(bytes32 role) external view returns (bytes32);
}
IAddressProvider.sol 51 lines
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "./IAccessController.sol";
import "./IConfigProvider.sol";
import "./ISTABLEX.sol";
import "./IPriceFeed.sol";
import "./IRatesManager.sol";
import "./ILiquidationManager.sol";
import "./IVaultsCore.sol";
import "./IVaultsDataProvider.sol";
import "./IFeeDistributor.sol";

interface IAddressProvider {
  function setAccessController(IAccessController _controller) external;

  function setConfigProvider(IConfigProvider _config) external;

  function setVaultsCore(IVaultsCore _core) external;

  function setStableX(ISTABLEX _stablex) external;

  function setRatesManager(IRatesManager _ratesManager) external;

  function setPriceFeed(IPriceFeed _priceFeed) external;

  function setLiquidationManager(ILiquidationManager _liquidationManager) external;

  function setVaultsDataProvider(IVaultsDataProvider _vaultsData) external;

  function setFeeDistributor(IFeeDistributor _feeDistributor) external;

  function controller() external view returns (IAccessController);

  function config() external view returns (IConfigProvider);

  function core() external view returns (IVaultsCore);

  function stablex() external view returns (ISTABLEX);

  function ratesManager() external view returns (IRatesManager);

  function priceFeed() external view returns (IPriceFeed);

  function liquidationManager() external view returns (ILiquidationManager);

  function vaultsData() external view returns (IVaultsDataProvider);

  function feeDistributor() external view returns (IFeeDistributor);
}
IConfigProvider.sol 96 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../interfaces/IAddressProvider.sol";

interface IConfigProvider {
  struct CollateralConfig {
    address collateralType;
    uint256 debtLimit;
    uint256 liquidationRatio;
    uint256 minCollateralRatio;
    uint256 borrowRate;
    uint256 originationFee;
    uint256 liquidationBonus;
    uint256 liquidationFee;
  }

  event CollateralUpdated(
    address indexed collateralType,
    uint256 debtLimit,
    uint256 liquidationRatio,
    uint256 minCollateralRatio,
    uint256 borrowRate,
    uint256 originationFee,
    uint256 liquidationBonus,
    uint256 liquidationFee
  );
  event CollateralRemoved(address indexed collateralType);

  function setCollateralConfig(
    address _collateralType,
    uint256 _debtLimit,
    uint256 _liquidationRatio,
    uint256 _minCollateralRatio,
    uint256 _borrowRate,
    uint256 _originationFee,
    uint256 _liquidationBonus,
    uint256 _liquidationFee
  ) external;

  function removeCollateral(address _collateralType) external;

  function setCollateralDebtLimit(address _collateralType, uint256 _debtLimit) external;

  function setCollateralLiquidationRatio(address _collateralType, uint256 _liquidationRatio) external;

  function setCollateralMinCollateralRatio(address _collateralType, uint256 _minCollateralRatio) external;

  function setCollateralBorrowRate(address _collateralType, uint256 _borrowRate) external;

  function setCollateralOriginationFee(address _collateralType, uint256 _originationFee) external;

  function setCollateralLiquidationBonus(address _collateralType, uint256 _liquidationBonus) external;

  function setCollateralLiquidationFee(address _collateralType, uint256 _liquidationFee) external;

  function setMinVotingPeriod(uint256 _minVotingPeriod) external;

  function setMaxVotingPeriod(uint256 _maxVotingPeriod) external;

  function setVotingQuorum(uint256 _votingQuorum) external;

  function setProposalThreshold(uint256 _proposalThreshold) external;

  function a() external view returns (IAddressProvider);

  function collateralConfigs(uint256 _id) external view returns (CollateralConfig memory);

  function collateralIds(address _collateralType) external view returns (uint256);

  function numCollateralConfigs() external view returns (uint256);

  function minVotingPeriod() external view returns (uint256);

  function maxVotingPeriod() external view returns (uint256);

  function votingQuorum() external view returns (uint256);

  function proposalThreshold() external view returns (uint256);

  function collateralDebtLimit(address _collateralType) external view returns (uint256);

  function collateralLiquidationRatio(address _collateralType) external view returns (uint256);

  function collateralMinCollateralRatio(address _collateralType) external view returns (uint256);

  function collateralBorrowRate(address _collateralType) external view returns (uint256);

  function collateralOriginationFee(address _collateralType) external view returns (uint256);

  function collateralLiquidationBonus(address _collateralType) external view returns (uint256);

  function collateralLiquidationFee(address _collateralType) external view returns (uint256);
}
IFeeDistributor.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../interfaces/IAddressProvider.sol";

interface IFeeDistributor {
  event PayeeAdded(address indexed account, uint256 shares);
  event FeeReleased(uint256 income, uint256 releasedAt);

  function release() external;

  function changePayees(address[] memory _payees, uint256[] memory _shares) external;

  function a() external view returns (IAddressProvider);

  function lastReleasedAt() external view returns (uint256);

  function getPayees() external view returns (address[] memory);

  function totalShares() external view returns (uint256);

  function shares(address payee) external view returns (uint256);
}
ILiquidationManager.sol 29 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../interfaces/IAddressProvider.sol";

interface ILiquidationManager {
  function a() external view returns (IAddressProvider);

  function calculateHealthFactor(
    uint256 _collateralValue,
    uint256 _vaultDebt,
    uint256 _minRatio
  ) external view returns (uint256 healthFactor);

  function liquidationBonus(address _collateralType, uint256 _amount) external view returns (uint256 bonus);

  function applyLiquidationDiscount(address _collateralType, uint256 _amount)
    external
    view
    returns (uint256 discountedAmount);

  function isHealthy(
    uint256 _collateralValue,
    uint256 _vaultDebt,
    uint256 _minRatio
  ) external view returns (bool);
}
IPriceFeed.sol 27 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../chainlink/AggregatorV3Interface.sol";
import "../interfaces/IAddressProvider.sol";

interface IPriceFeed {
  event OracleUpdated(address indexed asset, address oracle, address sender);
  event EurOracleUpdated(address oracle, address sender);

  function setAssetOracle(address _asset, address _oracle) external;

  function setEurOracle(address _oracle) external;

  function a() external view returns (IAddressProvider);

  function assetOracles(address _asset) external view returns (AggregatorV3Interface);

  function eurOracle() external view returns (AggregatorV3Interface);

  function getAssetPrice(address _asset) external view returns (uint256);

  function convertFrom(address _asset, uint256 _amount) external view returns (uint256);

  function convertTo(address _asset, uint256 _amount) external view returns (uint256);
}
IRatesManager.sol 26 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../interfaces/IAddressProvider.sol";

interface IRatesManager {
  function a() external view returns (IAddressProvider);

  //current annualized borrow rate
  function annualizedBorrowRate(uint256 _currentBorrowRate) external pure returns (uint256);

  //uses current cumulative rate to calculate totalDebt based on baseDebt at time T0
  function calculateDebt(uint256 _baseDebt, uint256 _cumulativeRate) external pure returns (uint256);

  //uses current cumulative rate to calculate baseDebt at time T0
  function calculateBaseDebt(uint256 _debt, uint256 _cumulativeRate) external pure returns (uint256);

  //calculate a new cumulative rate
  function calculateCumulativeRate(
    uint256 _borrowRate,
    uint256 _cumulativeRate,
    uint256 _timeElapsed
  ) external view returns (uint256);
}
ISTABLEX.sol 13 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/IAddressProvider.sol";

interface ISTABLEX is IERC20 {
  function mint(address account, uint256 amount) external;

  function burn(address account, uint256 amount) external;

  function a() external view returns (IAddressProvider);
}
IVaultsCore.sol 73 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../interfaces/IAddressProvider.sol";
import "../interfaces/IVaultsCoreState.sol";
import "../interfaces/IWETH.sol";
import "../liquidityMining/interfaces/IDebtNotifier.sol";

interface IVaultsCore {
  event Opened(uint256 indexed vaultId, address indexed collateralType, address indexed owner);
  event Deposited(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Withdrawn(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Borrowed(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Repaid(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Liquidated(
    uint256 indexed vaultId,
    uint256 debtRepaid,
    uint256 collateralLiquidated,
    address indexed owner,
    address indexed sender
  );

  event InsurancePaid(uint256 indexed vaultId, uint256 insuranceAmount, address indexed sender);

  function deposit(address _collateralType, uint256 _amount) external;

  function depositETH() external payable;

  function depositByVaultId(uint256 _vaultId, uint256 _amount) external;

  function depositETHByVaultId(uint256 _vaultId) external payable;

  function depositAndBorrow(
    address _collateralType,
    uint256 _depositAmount,
    uint256 _borrowAmount
  ) external;

  function depositETHAndBorrow(uint256 _borrowAmount) external payable;

  function withdraw(uint256 _vaultId, uint256 _amount) external;

  function withdrawETH(uint256 _vaultId, uint256 _amount) external;

  function borrow(uint256 _vaultId, uint256 _amount) external;

  function repayAll(uint256 _vaultId) external;

  function repay(uint256 _vaultId, uint256 _amount) external;

  function liquidate(uint256 _vaultId) external;

  function liquidatePartial(uint256 _vaultId, uint256 _amount) external;

  function upgrade(address payable _newVaultsCore) external;

  function acceptUpgrade(address payable _oldVaultsCore) external;

  function setDebtNotifier(IDebtNotifier _debtNotifier) external;

  //Read only
  function a() external view returns (IAddressProvider);

  function WETH() external view returns (IWETH);

  function debtNotifier() external view returns (IDebtNotifier);

  function state() external view returns (IVaultsCoreState);

  function cumulativeRates(address _collateralType) external view returns (uint256);
}
IVaultsCoreState.sol 33 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;
import "./IAddressProvider.sol";
import "../v1/interfaces/IVaultsCoreV1.sol";

interface IVaultsCoreState {
  event CumulativeRateUpdated(address indexed collateralType, uint256 elapsedTime, uint256 newCumulativeRate); //cumulative interest rate from deployment time T0

  event BridgeableTokenUpdated(address indexed bridgeableToken);

  function initializeRates(address _collateralType) external;

  function refresh() external;

  function refreshCollateral(address collateralType) external;

  function syncState(IVaultsCoreState _stateAddress) external;

  function syncStateFromV1(IVaultsCoreV1 _core) external;

  //Read only
  function a() external view returns (IAddressProvider);

  function availableIncome() external view returns (uint256);

  function cumulativeRates(address _collateralType) external view returns (uint256);

  function lastRefresh(address _collateralType) external view returns (uint256);

  function synced() external view returns (bool);
}
IVaultsDataProvider.sol 50 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;
import "../interfaces/IAddressProvider.sol";

interface IVaultsDataProvider {
  struct Vault {
    // borrowedType support USDX / PAR
    address collateralType;
    address owner;
    uint256 collateralBalance;
    uint256 baseDebt;
    uint256 createdAt;
  }

  //Write
  function createVault(address _collateralType, address _owner) external returns (uint256);

  function setCollateralBalance(uint256 _id, uint256 _balance) external;

  function setBaseDebt(uint256 _id, uint256 _newBaseDebt) external;

  // Read
  function a() external view returns (IAddressProvider);

  function baseDebt(address _collateralType) external view returns (uint256);

  function vaultCount() external view returns (uint256);

  function vaults(uint256 _id) external view returns (Vault memory);

  function vaultOwner(uint256 _id) external view returns (address);

  function vaultCollateralType(uint256 _id) external view returns (address);

  function vaultCollateralBalance(uint256 _id) external view returns (uint256);

  function vaultBaseDebt(uint256 _id) external view returns (uint256);

  function vaultId(address _collateralType, address _owner) external view returns (uint256);

  function vaultExists(uint256 _id) external view returns (bool);

  function vaultDebt(uint256 _vaultId) external view returns (uint256);

  function debt() external view returns (uint256);

  function collateralDebt(address _collateralType) external view returns (uint256);
}
IWETH.sol 14 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

interface IWETH {
  function deposit() external payable;

  function transfer(address to, uint256 value) external returns (bool);

  function withdraw(uint256 wad) external;

  function approve(address guy, uint256 wad) external returns (bool);
}
WadRayMath.sol 87 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/math/SafeMath.sol";

/******************
@title WadRayMath library
@author Aave
@dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
 */

library WadRayMath {
  using SafeMath for uint256;

  uint256 internal constant _WAD = 1e18;
  uint256 internal constant _HALF_WAD = _WAD / 2;

  uint256 internal constant _RAY = 1e27;
  uint256 internal constant _HALF_RAY = _RAY / 2;

  uint256 internal constant _WAD_RAY_RATIO = 1e9;

  function ray() internal pure returns (uint256) {
    return _RAY;
  }

  function wad() internal pure returns (uint256) {
    return _WAD;
  }

  function halfRay() internal pure returns (uint256) {
    return _HALF_RAY;
  }

  function halfWad() internal pure returns (uint256) {
    return _HALF_WAD;
  }

  function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
    return _HALF_WAD.add(a.mul(b)).div(_WAD);
  }

  function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 halfB = b / 2;

    return halfB.add(a.mul(_WAD)).div(b);
  }

  function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
    return _HALF_RAY.add(a.mul(b)).div(_RAY);
  }

  function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 halfB = b / 2;

    return halfB.add(a.mul(_RAY)).div(b);
  }

  function rayToWad(uint256 a) internal pure returns (uint256) {
    uint256 halfRatio = _WAD_RAY_RATIO / 2;

    return halfRatio.add(a).div(_WAD_RAY_RATIO);
  }

  function wadToRay(uint256 a) internal pure returns (uint256) {
    return a.mul(_WAD_RAY_RATIO);
  }

  /**
   * @dev calculates x^n, in ray. The code uses the ModExp precompile
   * @param x base
   * @param n exponent
   * @return z = x^n, in ray
   */
  function rayPow(uint256 x, uint256 n) internal pure returns (uint256 z) {
    z = n % 2 != 0 ? x : _RAY;

    for (n /= 2; n != 0; n /= 2) {
      x = rayMul(x, x);

      if (n % 2 != 0) {
        z = rayMul(z, x);
      }
    }
  }
}
IDebtNotifier.sol 17 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../../governance/interfaces/IGovernanceAddressProvider.sol";
import "./ISupplyMiner.sol";

interface IDebtNotifier {
  function debtChanged(uint256 _vaultId) external;

  function setCollateralSupplyMiner(address collateral, ISupplyMiner supplyMiner) external;

  function a() external view returns (IGovernanceAddressProvider);

  function collateralSupplyMinerMapping(address collateral) external view returns (ISupplyMiner);
}
IGenericMiner.sol 34 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "../../interfaces/IAddressProvider.sol";
import "../../governance/interfaces/IGovernanceAddressProvider.sol";

interface IGenericMiner {
  struct UserInfo {
    uint256 stake;
    uint256 accAmountPerShare; // User's accAmountPerShare
  }

  /// @dev This emit when a users' productivity has changed
  /// It emits with the user's address and the the value after the change.
  event StakeIncreased(address indexed user, uint256 stake);

  /// @dev This emit when a users' productivity has changed
  /// It emits with the user's address and the the value after the change.
  event StakeDecreased(address indexed user, uint256 stake);

  function releaseMIMO(address _user) external;

  function a() external view returns (IGovernanceAddressProvider);

  function stake(address _user) external view returns (uint256);

  function pendingMIMO(address _user) external view returns (uint256);

  function totalStake() external view returns (uint256);

  function userInfo(address _user) external view returns (UserInfo memory);
}
IMIMO.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMIMO is IERC20 {
  function burn(address account, uint256 amount) external;

  function mint(address account, uint256 amount) external;
}
ISupplyMiner.sol 8 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

interface ISupplyMiner {
  function baseDebtChanged(address user, uint256 newBaseDebt) external;
}
IAddressProviderV1.sol 52 lines
// SPDX-License-Identifier: MIT
pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "./IConfigProviderV1.sol";
import "./ILiquidationManagerV1.sol";
import "./IVaultsCoreV1.sol";
import "../../interfaces/IVaultsCore.sol";
import "../../interfaces/IAccessController.sol";
import "../../interfaces/ISTABLEX.sol";
import "../../interfaces/IPriceFeed.sol";
import "../../interfaces/IRatesManager.sol";
import "../../interfaces/IVaultsDataProvider.sol";
import "../../interfaces/IFeeDistributor.sol";

interface IAddressProviderV1 {
  function setAccessController(IAccessController _controller) external;

  function setConfigProvider(IConfigProviderV1 _config) external;

  function setVaultsCore(IVaultsCoreV1 _core) external;

  function setStableX(ISTABLEX _stablex) external;

  function setRatesManager(IRatesManager _ratesManager) external;

  function setPriceFeed(IPriceFeed _priceFeed) external;

  function setLiquidationManager(ILiquidationManagerV1 _liquidationManager) external;

  function setVaultsDataProvider(IVaultsDataProvider _vaultsData) external;

  function setFeeDistributor(IFeeDistributor _feeDistributor) external;

  function controller() external view returns (IAccessController);

  function config() external view returns (IConfigProviderV1);

  function core() external view returns (IVaultsCoreV1);

  function stablex() external view returns (ISTABLEX);

  function ratesManager() external view returns (IRatesManager);

  function priceFeed() external view returns (IPriceFeed);

  function liquidationManager() external view returns (ILiquidationManagerV1);

  function vaultsData() external view returns (IVaultsDataProvider);

  function feeDistributor() external view returns (IFeeDistributor);
}
IConfigProviderV1.sol 63 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "./IAddressProviderV1.sol";

interface IConfigProviderV1 {
  struct CollateralConfig {
    address collateralType;
    uint256 debtLimit;
    uint256 minCollateralRatio;
    uint256 borrowRate;
    uint256 originationFee;
  }

  event CollateralUpdated(
    address indexed collateralType,
    uint256 debtLimit,
    uint256 minCollateralRatio,
    uint256 borrowRate,
    uint256 originationFee
  );
  event CollateralRemoved(address indexed collateralType);

  function setCollateralConfig(
    address _collateralType,
    uint256 _debtLimit,
    uint256 _minCollateralRatio,
    uint256 _borrowRate,
    uint256 _originationFee
  ) external;

  function removeCollateral(address _collateralType) external;

  function setCollateralDebtLimit(address _collateralType, uint256 _debtLimit) external;

  function setCollateralMinCollateralRatio(address _collateralType, uint256 _minCollateralRatio) external;

  function setCollateralBorrowRate(address _collateralType, uint256 _borrowRate) external;

  function setCollateralOriginationFee(address _collateralType, uint256 _originationFee) external;

  function setLiquidationBonus(uint256 _bonus) external;

  function a() external view returns (IAddressProviderV1);

  function collateralConfigs(uint256 _id) external view returns (CollateralConfig memory);

  function collateralIds(address _collateralType) external view returns (uint256);

  function numCollateralConfigs() external view returns (uint256);

  function liquidationBonus() external view returns (uint256);

  function collateralDebtLimit(address _collateralType) external view returns (uint256);

  function collateralMinCollateralRatio(address _collateralType) external view returns (uint256);

  function collateralBorrowRate(address _collateralType) external view returns (uint256);

  function collateralOriginationFee(address _collateralType) external view returns (uint256);
}
ILiquidationManagerV1.sol 26 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;

import "./IAddressProviderV1.sol";

interface ILiquidationManagerV1 {
  function a() external view returns (IAddressProviderV1);

  function calculateHealthFactor(
    address _collateralType,
    uint256 _collateralValue,
    uint256 _vaultDebt
  ) external view returns (uint256 healthFactor);

  function liquidationBonus(uint256 _amount) external view returns (uint256 bonus);

  function applyLiquidationDiscount(uint256 _amount) external view returns (uint256 discountedAmount);

  function isHealthy(
    address _collateralType,
    uint256 _collateralValue,
    uint256 _vaultDebt
  ) external view returns (bool);
}
IVaultsCoreV1.sol 58 lines
// SPDX-License-Identifier: MIT

pragma experimental ABIEncoderV2;
pragma solidity 0.6.12;
import "./IAddressProviderV1.sol";

interface IVaultsCoreV1 {
  event Opened(uint256 indexed vaultId, address indexed collateralType, address indexed owner);
  event Deposited(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Withdrawn(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Borrowed(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Repaid(uint256 indexed vaultId, uint256 amount, address indexed sender);
  event Liquidated(
    uint256 indexed vaultId,
    uint256 debtRepaid,
    uint256 collateralLiquidated,
    address indexed owner,
    address indexed sender
  );

  event CumulativeRateUpdated(address indexed collateralType, uint256 elapsedTime, uint256 newCumulativeRate); //cumulative interest rate from deployment time T0

  event InsurancePaid(uint256 indexed vaultId, uint256 insuranceAmount, address indexed sender);

  function deposit(address _collateralType, uint256 _amount) external;

  function withdraw(uint256 _vaultId, uint256 _amount) external;

  function withdrawAll(uint256 _vaultId) external;

  function borrow(uint256 _vaultId, uint256 _amount) external;

  function repayAll(uint256 _vaultId) external;

  function repay(uint256 _vaultId, uint256 _amount) external;

  function liquidate(uint256 _vaultId) external;

  //Refresh
  function initializeRates(address _collateralType) external;

  function refresh() external;

  function refreshCollateral(address collateralType) external;

  //upgrade
  function upgrade(address _newVaultsCore) external;

  //Read only

  function a() external view returns (IAddressProviderV1);

  function availableIncome() external view returns (uint256);

  function cumulativeRates(address _collateralType) external view returns (uint256);

  function lastRefresh(address _collateralType) external view returns (uint256);
}

Read Contract

WETH 0xad5c4648 → address
a 0x0dbe671f → address
cumulativeRates 0x85d36cd7 → uint256
debtNotifier 0xbd1b7146 → address
state 0xc19d93fb → address

Write Contract 17 functions

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

acceptUpgrade 0xcfc1b419
address _oldVaultsCore
borrow 0x0ecbcdab
uint256 _vaultId
uint256 _amount
deposit 0x47e7ef24
address _collateralType
uint256 _amount
depositAndBorrow 0xa1789085
address _collateralType
uint256 _depositAmount
uint256 _borrowAmount
depositByVaultId 0xce281041
uint256 _vaultId
uint256 _amount
depositETH 0xf6326fb3
No parameters
depositETHAndBorrow 0x57f256e3
uint256 _borrowAmount
depositETHByVaultId 0xd18343f3
uint256 _vaultId
liquidate 0x415f1240
uint256 _vaultId
liquidatePartial 0x1e6b6267
uint256 _vaultId
uint256 _amount
repay 0xd8aed145
uint256 _vaultId
uint256 _amount
repayAll 0x3221be54
uint256 _vaultId
setDebtNotifier 0x4b969866
address _debtNotifier
upgrade 0x0900f010
address _newVaultsCore
withdraw 0x441a3e70
uint256 _vaultId
uint256 _amount
withdrawETH 0xc7cdea37
uint256 _vaultId
uint256 _amount
withdrawStableX 0xeed49c60
uint256 _amount

Recent Transactions

No transactions found for this address