Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x29E240CFD7946BA20895a7a02eDb25C210f9f324
Balance 0 ETH
Nonce 1
Code Size 17787 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

17787 bytes
0x608060405234801561001057600080fd5b50600436106103785760003560e01c80637fd42617116101d3578063b69ef8a811610104578063de5f6268116100a2578063f7c1ec771161007c578063f7c1ec7714610ebf578063f82ce27d14610f09578063fa3ae6dc14610f53578063fc0c546a14610f5d57610378565b8063de5f626814610e4d578063f072232214610e57578063f77c479114610e7557610378565b8063cf309012116100de578063cf30901214610d6b578063d389800f14610d89578063dd62ed3e14610d93578063dd90a79114610e0b57610378565b8063b69ef8a814610cd5578063b6b55f2514610cf3578063cd3293de14610d2157610378565b80639f287e1611610171578063a75ac6081161014b578063a75ac60814610c25578063a9059cbb14610c2f578063ae2c1d5f14610c95578063b040785a14610cb757610378565b80639f287e1614610b57578063a06d083c14610ba1578063a457c2d714610bbf57610378565b806389cf3204116101ad57806389cf320414610a54578063929c884914610a7257806392eefe9b14610a9057806395d89b4114610ad457610378565b80637fd42617146109f6578063819faf7b14610a00578063853828b614610a4a57610378565b806331111708116102ad5780636ad4e2511161024b57806370a082311161022557806370a082311461095857806377c7b8fc146109b05780637d7c2a1c146109ce5780637eaef50c146109d857610378565b80636ad4e251146108ae5780636f307dc3146108f05780636fb49d731461093a57610378565b8063468f02d211610287578063468f02d2146107fc5780635aa6e6751461081a57806362f5548d146108645780636ac5db191461089057610378565b80633111170814610744578063313ce56714610772578063395093511461079657610378565b80631b93e5b01161031a57806323b872dd116102f457806323b872dd146105e057806327afd028146106665780632851e2e0146106be5780632e1a7d4d1461071657610378565b80631b93e5b01461055257806322841f011461057457806322867d781461059257610378565b80630dca59c1116103565780630dca59c1146104b45780630f15f4c0146104d257806311dddca4146104dc57806318160ddd1461053457610378565b8063018ee9b71461037d57806306fdde03146103cb578063095ea7b31461044e575b600080fd5b6103c96004803603604081101561039357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fa7565b005b6103d361117f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104135780820151818401526020810190506103f8565b50505050905090810190601f1680156104405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61049a6004803603604081101561046457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611221565b604051808215151515815260200191505060405180910390f35b6104bc61123f565b6040518082815260200191505060405180910390f35b6104da611482565b005b61051e600480360360208110156104f257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611536565b6040518082815260200191505060405180910390f35b61053c6115fe565b6040518082815260200191505060405180910390f35b61055a611608565b604051808215151515815260200191505060405180910390f35b61057c611619565b6040518082815260200191505060405180910390f35b6105de600480360360408110156105a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061161f565b005b61064c600480360360608110156105f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611892565b604051808215151515815260200191505060405180910390f35b6106a86004803603602081101561067c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061196b565b6040518082815260200191505060405180910390f35b610700600480360360208110156106d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a0c565b6040518082815260200191505060405180910390f35b6107426004803603602081101561072c57600080fd5b8101908080359060200190929190505050611a50565b005b6107706004803603602081101561075a57600080fd5b8101908080359060200190929190505050611aeb565b005b61077a611bb8565b604051808260ff1660ff16815260200191505060405180910390f35b6107e2600480360360408110156107ac57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611bcf565b604051808215151515815260200191505060405180910390f35b610804611c82565b6040518082815260200191505060405180910390f35b610822611c99565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61086c611cbf565b60405180848152602001838152602001828152602001935050505060405180910390f35b610898611e14565b6040518082815260200191505060405180910390f35b6108da600480360360208110156108c457600080fd5b8101908080359060200190929190505050611e1a565b6040518082815260200191505060405180910390f35b6108f8611fa6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610942612050565b6040518082815260200191505060405180910390f35b61099a6004803603602081101561096e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612056565b6040518082815260200191505060405180910390f35b6109b861209e565b6040518082815260200191505060405180910390f35b6109d66120e0565b005b6109e06120ec565b6040518082815260200191505060405180910390f35b6109fe6120fc565b005b610a0861210f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a52612127565b005b610a5c61213a565b6040518082815260200191505060405180910390f35b610a7a612140565b6040518082815260200191505060405180910390f35b610ad260048036036020811015610aa657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612227565b005b610adc61232e565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b1c578082015181840152602081019050610b01565b50505050905090810190601f168015610b495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610b5f6123d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610ba961246c565b6040518082815260200191505060405180910390f35b610c0b60048036036040811015610bd557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061254d565b604051808215151515815260200191505060405180910390f35b610c2d61261a565b005b610c7b60048036036040811015610c4557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612758565b604051808215151515815260200191505060405180910390f35b610c9d612776565b604051808215151515815260200191505060405180910390f35b610cbf612787565b6040518082815260200191505060405180910390f35b610cdd612818565b6040518082815260200191505060405180910390f35b610d1f60048036036020811015610d0957600080fd5b810190808035906020019092919050505061290d565b005b610d29612a20565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610d73612b01565b6040518082815260200191505060405180910390f35b610d91612b43565b005b610df560048036036040811015610da957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612dfa565b6040518082815260200191505060405180910390f35b610e3760048036036020811015610e2157600080fd5b8101908080359060200190929190505050612e81565b6040518082815260200191505060405180910390f35b610e55612f9d565b005b610e5f613081565b6040518082815260200191505060405180910390f35b610e7d613098565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610ec76130be565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610f1161315a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610f5b6131f6565b005b610f656132cc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461106a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21636f6e74726f6c6c657200000000000000000000000000000000000000000081525060200191505060405180910390fd5b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561112e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f746f6b656e00000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b61117b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b5050565b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112175780601f106111ec57610100808354040283529160200191611217565b820191906000526020600020905b8154815290600101906020018083116111fa57829003601f168201915b5050505050905090565b600061123561122e6133c3565b84846133cb565b6001905092915050565b600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166375724589306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156112e157600080fd5b505afa1580156112f5573d6000803e3d6000fd5b505050506040513d602081101561130b57600080fd5b8101908080519060200190929190505050905060006113286130be565b73ffffffffffffffffffffffffffffffffffffffff166328dd2d0183306040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001925050506101406040518083038186803b1580156113d957600080fd5b505afa1580156113ed573d6000803e3d6000fd5b505050506040513d61014081101561140457600080fd5b81019080805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050505050505050505050915050809250505090565b61148a6130be565b73ffffffffffffffffffffffffffffffffffffffff16635a3b74b96114ad611fa6565b60016040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018215151515815260200192505050600060405180830381600087803b15801561151c57600080fd5b505af1158015611530573d6000803e3d6000fd5b50505050565b60006115406123d0565b73ffffffffffffffffffffffffffffffffffffffff1663b3596f07836040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156115bc57600080fd5b505afa1580156115d0573d6000803e3d6000fd5b505050506040513d60208110156115e657600080fd5b81019080805190602001909291905050509050919050565b6000600254905090565b600080611613612140565b11905090565b60095481565b8173ffffffffffffffffffffffffffffffffffffffff1663095ea7b361164361315a565b60006040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156116ae57600080fd5b505af11580156116c2573d6000803e3d6000fd5b505050506040513d60208110156116d857600080fd5b8101908080519060200190929190505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b361170e61315a565b836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561177857600080fd5b505af115801561178c573d6000803e3d6000fd5b505050506040513d60208110156117a257600080fd5b8101908080519060200190929190505050506117bc6130be565b73ffffffffffffffffffffffffffffffffffffffff16635ceae9c48383306040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b15801561187657600080fd5b505af115801561188a573d6000803e3d6000fd5b505050505050565b600061189f8484846135c2565b611960846118ab6133c3565b61195b8560405180606001604052806028815260200161446660289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006119116133c3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138789092919063ffffffff16565b6133cb565b600190509392505050565b60008061197783612056565b905060006119af670de0b6b3a76400006119a1611992612b01565b8561393890919063ffffffff16565b6139be90919063ffffffff16565b9050818111156119c3578192505050611a07565b60006119d88284613a0890919063ffffffff16565b9050611a016119f26009548361393890919063ffffffff16565b84613a0890919063ffffffff16565b93505050505b919050565b6000611a49611a196115fe565b611a3b611a2585612056565b611a2d61123f565b61393890919063ffffffff16565b61393890919063ffffffff16565b9050919050565b6000611a85611a5d6115fe565b611a7784611a69612818565b61393890919063ffffffff16565b6139be90919063ffffffff16565b9050611a913383613a52565b611a9a81613c0a565b611ae73382600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b5050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611bae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060098190555050565b6000600560009054906101000a900460ff16905090565b6000611c78611bdc6133c3565b84611c738560016000611bed6133c3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613d1290919063ffffffff16565b6133cb565b6001905092915050565b6000611c94611c8f611fa6565b611536565b905090565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000611ccf6130be565b73ffffffffffffffffffffffffffffffffffffffff1663bf92857c306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019150506101006040518083038186803b158015611d4c57600080fd5b505afa158015611d60573d6000803e3d6000fd5b505050506040513d610100811015611d7757600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190505050505050945050935050506000611ded8284613d1290919063ffffffff16565b9050611e04600954826139be90919063ffffffff16565b8383955095509550505050909192565b600b5481565b600080611e25612a20565b90506000611e3284612e81565b9050600080611e3f611cbf565b5091509150611e6b6064611e5d60698561393890919063ffffffff16565b6139be90919063ffffffff16565b915081831115611e7e5760009150611e94565b611e918383613a0890919063ffffffff16565b91505b80821015611f98576000611ed582611ec7611eb88686613a0890919063ffffffff16565b8561393890919063ffffffff16565b6139be90919063ffffffff16565b9050611f89611ee2613081565b611f7b8773ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611f2b57600080fd5b505afa158015611f3f573d6000803e3d6000fd5b505050506040513d6020811015611f5557600080fd5b810190808051906020019092919050505060ff16600a0a8461393890919063ffffffff16565b6139be90919063ffffffff16565b90508095505050505050611fa1565b60009450505050505b919050565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166389d1a0fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561201057600080fd5b505afa158015612024573d6000803e3d6000fd5b505050506040513d602081101561203a57600080fd5b8101908080519060200190929190505050905090565b600a5481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006120db6120ab6115fe565b6120cd670de0b6b3a76400006120bf612818565b61393890919063ffffffff16565b6139be90919063ffffffff16565b905090565b6120ea6000613c0a565b565b60006120f86000611e1a565b5090565b61210d6121083361196b565b611a50565b565b7324a42fd28c976a61df5d00d0599c34c4f90748c881565b61213861213333612056565b611a50565b565b60085481565b60008061214b612a20565b90506000612157612787565b9050600081111561221d5761221461216d613081565b6122068473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156121b657600080fd5b505afa1580156121ca573d6000803e3d6000fd5b505050506040513d60208110156121e057600080fd5b810190808051906020019092919050505060ff16600a0a8461393890919063ffffffff16565b6139be90919063ffffffff16565b92505050612224565b6000925050505b90565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146122ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123c65780601f1061239b576101008083540402835291602001916123c6565b820191906000526020600020905b8154815290600101906020018083116123a957829003601f168201915b5050505050905090565b60007324a42fd28c976a61df5d00d0599c34c4f90748c873ffffffffffffffffffffffffffffffffffffffff1663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561242c57600080fd5b505afa158015612440573d6000803e3d6000fd5b505050506040513d602081101561245657600080fd5b8101908080519060200190929190505050905090565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561250d57600080fd5b505afa158015612521573d6000803e3d6000fd5b505050506040513d602081101561253757600080fd5b8101908080519060200190929190505050905090565b600061261061255a6133c3565b8461260b8560405180606001604052806025815260200161452260259139600160006125846133c3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138789092919063ffffffff16565b6133cb565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146126dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21636f6e74726f6c6c657200000000000000000000000000000000000000000081525060200191505060405180910390fd5b61274e600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600854600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b6000600881905550565b600061276c6127656133c3565b84846135c2565b6001905092915050565b6000806127816120ec565b11905090565b600080600080612795611cbf565b9250925092506127c260646127b4605f8661393890919063ffffffff16565b6139be90919063ffffffff16565b92508183111561280d57612803816127f56127e68587613a0890919063ffffffff16565b8461393890919063ffffffff16565b6139be90919063ffffffff16565b9350505050612815565b600093505050505b90565b6000612908600854600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156128bf57600080fd5b505afa1580156128d3573d6000803e3d6000fd5b505050506040513d60208110156128e957600080fd5b8101908080519060200190929190505050613a0890919063ffffffff16565b905090565b6000612917612818565b9050612968333084600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613d9a909392919063ffffffff16565b600061299261271061298460328661393890919063ffffffff16565b6139be90919063ffffffff16565b90506129a78184613a0890919063ffffffff16565b92506129be81600854613d1290919063ffffffff16565b600881905550600080905060006129d36115fe565b14156129e157839050612a10565b612a0d836129ff6129f06115fe565b8761393890919063ffffffff16565b6139be90919063ffffffff16565b90505b612a1a3382613ea0565b50505050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166375724589306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612ac157600080fd5b505afa158015612ad5573d6000803e3d6000fd5b505050506040513d6020811015612aeb57600080fd5b8101908080519060200190929190505050905090565b6000612b3e612b0e61123f565b612b30670de0b6b3a7640000612b2261246c565b61393890919063ffffffff16565b6139be90919063ffffffff16565b905090565b6000612b4d612a20565b90506000612b59612140565b90506000811115612c2157612b6c6130be565b73ffffffffffffffffffffffffffffffffffffffff1663c858f5f98383600260076040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018261ffff168152602001945050505050600060405180830381600087803b158015612c0857600080fd5b505af1158015612c1c573d6000803e3d6000fd5b505050505b60008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612ca057600080fd5b505afa158015612cb4573d6000803e3d6000fd5b505050506040513d6020811015612cca57600080fd5b810190808051906020019092919050505090506000811115612df557612d33600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828573ffffffffffffffffffffffffffffffffffffffff166132f29092919063ffffffff16565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b02bf4b930836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015612ddc57600080fd5b505af1158015612df0573d6000803e3d6000fd5b505050505b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000612f57600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612eee57600080fd5b505afa158015612f02573d6000803e3d6000fd5b505050506040513d6020811015612f1857600080fd5b810190808051906020019092919050505060ff16600a0a612f49612f3a611c82565b8561393890919063ffffffff16565b6139be90919063ffffffff16565b9150612f96600954612f88600b54612f7a600a548761393890919063ffffffff16565b6139be90919063ffffffff16565b6139be90919063ffffffff16565b9050919050565b61307f600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561303f57600080fd5b505afa158015613053573d6000803e3d6000fd5b505050506040513d602081101561306957600080fd5b810190808051906020019092919050505061290d565b565b600061309361308e612a20565b611536565b905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60007324a42fd28c976a61df5d00d0599c34c4f90748c873ffffffffffffffffffffffffffffffffffffffff16630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561311a57600080fd5b505afa15801561312e573d6000803e3d6000fd5b505050506040513d602081101561314457600080fd5b8101908080519060200190929190505050905090565b60007324a42fd28c976a61df5d00d0599c34c4f90748c873ffffffffffffffffffffffffffffffffffffffff1663ed6ff7606040518163ffffffff1660e01b815260040160206040518083038186803b1580156131b657600080fd5b505afa1580156131ca573d6000803e3d6000fd5b505050506040513d60208110156131e057600080fd5b8101908080519060200190929190505050905090565b6000613200612a20565b905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561328157600080fd5b505afa158015613295573d6000803e3d6000fd5b505050506040513d60208110156132ab57600080fd5b810190808051906020019092919050505090506132c8828261161f565b5050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6133be838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061405b565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613451576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806144d46024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156134d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806143fd6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613648576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806144af6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156136ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806143b86023913960400191505060405180910390fd5b6137398160405180606001604052806026815260200161441f602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138789092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506137cc816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613d1290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290613925576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156138ea5780820151818401526020810190506138cf565b50505050905090810190601f1680156139175780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083141561394b57600090506139b8565b600082840290508284828161395c57fe5b04146139b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806144456021913960400191505060405180910390fd5b809150505b92915050565b6000613a0083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506142a6565b905092915050565b6000613a4a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613878565b905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613ad8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061448e6021913960400191505060405180910390fd5b613b43816040518060600160405280602281526020016143db602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546138789092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b9a81600254613a0890919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000613c1582611e1a565b90506000811115613d0e57613c2861246c565b811115613c3a57613c3761246c565b90505b6000811115613d0d57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a330836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015613cec57600080fd5b505af1158015613d00573d6000803e3d6000fd5b50505050613d0c6131f6565b5b5b5050565b600080828401905083811015613d90576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b613e9a848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061405b565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613f43576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b613f5881600254613d1290919063ffffffff16565b600281905550613faf816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613d1290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b61407a8273ffffffffffffffffffffffffffffffffffffffff1661436c565b6140ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b6020831061413b5780518252602082019150602081019050602083039250614118565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461419d576040519150601f19603f3d011682016040523d82523d6000602084013e6141a2565b606091505b50915091508161421a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b6000815111156142a05780806020019051602081101561423957600080fd5b810190808051906020019092919050505061429f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806144f8602a913960400191505060405180910390fd5b5b50505050565b60008083118290614352576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156143175780820151818401526020810190506142fc565b50505050905090810190601f1680156143445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161435e57fe5b049050809150509392505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b82141580156143ae5750808214155b9250505091905056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582049fa562ba2b9370a3c7dc32c5ee3ee97734865ec2a9f9a07b7c7907ad4d17b7364736f6c63430005110032

Verified Source Code Partial Match

Compiler: v0.5.17+commit.d19bba13 EVM: istanbul Optimization: No
yDelegatedVault.sol 595 lines
/**
 *Submitted for verification at Etherscan.io on 2020-08-04
*/

pragma solidity ^0.5.16;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract Context {
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

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

contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    constructor () internal {
        _owner = _msgSender();
        emit OwnershipTransferred(address(0), _owner);
    }
    function owner() public view returns (address) {
        return _owner;
    }
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }
    function transfer(address recipient, uint256 amount) public returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }
    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }
    function approve(address spender, uint256 amount) public returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }
    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }
    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }
    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }
    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }
    function _burn(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }
    function _approve(address owner, address spender, uint256 amount) internal {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
    function _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
    }
}

contract ERC20Detailed is IERC20 {
    string private _name;
    string private _symbol;
    uint8 private _decimals;

    constructor (string memory name, string memory symbol, uint8 decimals) public {
        _name = name;
        _symbol = symbol;
        _decimals = decimals;
    }
    function name() public view returns (string memory) {
        return _name;
    }
    function symbol() public view returns (string memory) {
        return _symbol;
    }
    function decimals() public view returns (uint8) {
        return _decimals;
    }
}

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

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

        return c;
    }
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;

        return c;
    }
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

library Address {
    function isContract(address account) internal view returns (bool) {
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != 0x0 && codehash != accountHash);
    }
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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));
    }

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        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));
    }
    function callOptionalReturn(IERC20 token, bytes memory data) private {
        require(address(token).isContract(), "SafeERC20: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "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");
        }
    }
}

interface Controller {
    function withdraw(address, uint) external;
    function balanceOf(address) external view returns (uint);
    function earn(address, uint) external;
    function want(address) external view returns (address);
}

interface Aave {
    function borrow(address _reserve, uint _amount, uint _interestRateModel, uint16 _referralCode) external;
    function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral) external;
    function repay(address _reserve, uint _amount, address payable _onBehalfOf) external payable;
    function getUserAccountData(address _user)
        external
        view
        returns (
            uint totalLiquidityETH,
            uint totalCollateralETH,
            uint totalBorrowsETH,
            uint totalFeesETH,
            uint availableBorrowsETH,
            uint currentLiquidationThreshold,
            uint ltv,
            uint healthFactor
        );
    function getUserReserveData(address _reserve, address _user)
        external
        view
        returns (
            uint currentATokenBalance,
            uint currentBorrowBalance,
            uint principalBorrowBalance,
            uint borrowRateMode,
            uint borrowRate,
            uint liquidityRate,
            uint originationFee,
            uint variableBorrowIndex,
            uint lastUpdateTimestamp,
            bool usageAsCollateralEnabled
        );
}

interface AaveToken {
    function underlyingAssetAddress() external view returns (address);
}

interface Oracle {
    function getAssetPrice(address reserve) external view returns (uint);
    function latestAnswer() external view returns (uint);
}

interface LendingPoolAddressesProvider {
    function getLendingPool() external view returns (address);
    function getLendingPoolCore() external view returns (address);
    function getPriceOracle() external view returns (address);
}

contract yDelegatedVault is ERC20, ERC20Detailed {
    using SafeERC20 for IERC20;
    using Address for address;
    using SafeMath for uint256;
    
    IERC20 public token;
    
    address public governance;
    address public controller;
    uint public insurance;
    uint public healthFactor = 4;
    
    uint public ltv = 65;
    uint public max = 100;
    
    address public constant aave = address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8);
    
    constructor (address _token, address _controller) public ERC20Detailed(
        string(abi.encodePacked("yearn ", ERC20Detailed(_token).name())),
        string(abi.encodePacked("y", ERC20Detailed(_token).symbol())),
        ERC20Detailed(_token).decimals()
    ) {
        token = IERC20(_token);
        governance = msg.sender;
        controller = _controller;
    }
    
    function debt() public view returns (uint) {
        address _reserve = Controller(controller).want(address(this));
        (,uint currentBorrowBalance,,,,,,,,) = Aave(getAave()).getUserReserveData(_reserve, address(this));
        return currentBorrowBalance;
    }
    
    function credit() public view returns (uint) {
        return Controller(controller).balanceOf(address(this));
    }
    
    // % of tokens locked and cannot be withdrawn per user
    // this is impermanent locked, unless the debt out accrues the strategy
    function locked() public view returns (uint) {
        return credit().mul(1e18).div(debt());
    }
    
    function debtShare(address _lp) public view returns (uint) {
        return debt().mul(balanceOf(_lp)).mul(totalSupply());
    }
    
    function getAave() public view returns (address) {
        return LendingPoolAddressesProvider(aave).getLendingPool();
    }
    
    function getAaveCore() public view returns (address) {
        return LendingPoolAddressesProvider(aave).getLendingPoolCore();
    }
    
    function setHealthFactor(uint _hf) external {
        require(msg.sender == governance, "!governance");
        healthFactor = _hf;
    }
    
    function activate() public {
        Aave(getAave()).setUserUseReserveAsCollateral(underlying(), true);
    }
    
    function repay(address reserve, uint amount) public  {
        // Required for certain stable coins (USDT for example)
        IERC20(reserve).approve(address(getAaveCore()), 0);
        IERC20(reserve).approve(address(getAaveCore()), amount);
        Aave(getAave()).repay(reserve, amount, address(uint160(address(this))));
    }
    
    function repayAll() public {
        address _reserve = reserve();
        uint _amount = IERC20(_reserve).balanceOf(address(this));
        repay(_reserve, _amount);
    }
    
    // Used to swap any borrowed reserve over the debt limit to liquidate to 'token'
    function harvest(address reserve, uint amount) external {
        require(msg.sender == controller, "!controller");
        require(reserve != address(token), "token");
        IERC20(reserve).safeTransfer(controller, amount);
    }
    
    // Ignore insurance fund for balance calculations
    function balance() public view returns (uint) {
        return token.balanceOf(address(this)).sub(insurance);
    }
    
    function setController(address _controller) external {
        require(msg.sender == governance, "!governance");
        controller = _controller;
    }
    
    function getAaveOracle() public view returns (address) {
        return LendingPoolAddressesProvider(aave).getPriceOracle();
    }
    
    function getReservePriceETH(address reserve) public view returns (uint) {
        return Oracle(getAaveOracle()).getAssetPrice(reserve);
    }
    
    function shouldRebalance() external view returns (bool) {
        return (over() > 0);
    }
    
    function over() public view returns (uint) {
        over(0);
    }
    
    function getUnderlyingPriceETH(uint _amount) public view returns (uint) {
        _amount = _amount.mul(getUnderlyingPrice()).div(uint(10)**ERC20Detailed(address(token)).decimals()); // Calculate the amount we are withdrawing in ETH
        return _amount.mul(ltv).div(max).div(healthFactor);
    }
    
    function over(uint _amount) public view returns (uint) {
        address _reserve = reserve();
        uint _eth = getUnderlyingPriceETH(_amount);
        (uint _maxSafeETH,uint _totalBorrowsETH,) = maxSafeETH();
        _maxSafeETH = _maxSafeETH.mul(105).div(100); // 5% buffer so we don't go into a earn/rebalance loop
        if (_eth > _maxSafeETH) {
            _maxSafeETH = 0;
        } else {
            _maxSafeETH = _maxSafeETH.sub(_eth); // Add the ETH we are withdrawing
        }
        if (_maxSafeETH < _totalBorrowsETH) {
            uint _over = _totalBorrowsETH.mul(_totalBorrowsETH.sub(_maxSafeETH)).div(_totalBorrowsETH);
            _over = _over.mul(uint(10)**ERC20Detailed(_reserve).decimals()).div(getReservePrice());
            return _over;
        } else {
            return 0;
        }
    }
    
    function _rebalance(uint _amount) internal {
        uint _over = over(_amount);
        if (_over > 0) {
            if (_over > credit()) {
                _over = credit();
            }
            if (_over > 0) {
                Controller(controller).withdraw(address(this), _over);
                repayAll();
            }
        }
    }
    
    function rebalance() external {
        _rebalance(0);
    }
    
    function claimInsurance() external {
        require(msg.sender == controller, "!controller");
        token.safeTransfer(controller, insurance);
        insurance = 0;
    }
    
    function maxSafeETH() public view returns (uint maxBorrowsETH, uint totalBorrowsETH, uint availableBorrowsETH) {
         (,,uint _totalBorrowsETH,,uint _availableBorrowsETH,,,) = Aave(getAave()).getUserAccountData(address(this));
        uint _maxBorrowETH = (_totalBorrowsETH.add(_availableBorrowsETH));
        return (_maxBorrowETH.div(healthFactor), _totalBorrowsETH, _availableBorrowsETH);
    }
    
    function shouldBorrow() external view returns (bool) {
        return (availableToBorrowReserve() > 0);
    }
    
    function availableToBorrowETH() public view returns (uint) {
        (uint _maxSafeETH,uint _totalBorrowsETH, uint _availableBorrowsETH) = maxSafeETH();
        _maxSafeETH = _maxSafeETH.mul(95).div(100); // 5% buffer so we don't go into a earn/rebalance loop
        if (_maxSafeETH > _totalBorrowsETH) {
            return _availableBorrowsETH.mul(_maxSafeETH.sub(_totalBorrowsETH)).div(_availableBorrowsETH);
        } else {
            return 0;
        }
    }
    
    function availableToBorrowReserve() public view returns (uint) {
        address _reserve = reserve();
        uint _available = availableToBorrowETH();
        if (_available > 0) {
            return _available.mul(uint(10)**ERC20Detailed(_reserve).decimals()).div(getReservePrice());
        } else {
            return 0;
        }
    }
    
    function getReservePrice() public view returns (uint) {
        return getReservePriceETH(reserve());
    }
    
    function getUnderlyingPrice() public view returns (uint) {
        return getReservePriceETH(underlying());
    }
    
    function earn() external {
        address _reserve = reserve();
        uint _borrow = availableToBorrowReserve();
        if (_borrow > 0) {
            Aave(getAave()).borrow(_reserve, _borrow, 2, 7);
        }
        //rebalance here
        uint _balance = IERC20(_reserve).balanceOf(address(this));
        if (_balance > 0) {
            IERC20(_reserve).safeTransfer(controller, _balance);
            Controller(controller).earn(address(this), _balance);
        }
    }
    
    function depositAll() external {
        deposit(token.balanceOf(msg.sender));
    }
    
    function deposit(uint _amount) public {
        uint _pool = balance();
        token.safeTransferFrom(msg.sender, address(this), _amount);
        
        // 0.5% of deposits go into an insurance fund incase of negative profits to protect withdrawals
        // At a 4 health factor, this is a -2% position
        uint _insurance = _amount.mul(50).div(10000);
        _amount = _amount.sub(_insurance);
        insurance = insurance.add(_insurance);
        
        
        //Controller can claim insurance to liquidate to cover interest
        
        uint shares = 0;
        if (totalSupply() == 0) {
            shares = _amount;
        } else {
            shares = (_amount.mul(totalSupply())).div(_pool);
        }
        _mint(msg.sender, shares);
    }
    
    function reserve() public view returns (address) {
        return Controller(controller).want(address(this));
    }
    
    function underlying() public view returns (address) {
        return AaveToken(address(token)).underlyingAssetAddress();
    }
    
    function withdrawAll() public {
        withdraw(balanceOf(msg.sender));
    }
    
    // Calculates in impermanent lock due to debt
    function maxWithdrawal(address account) public view returns (uint) {
        uint _balance = balanceOf(account);
        uint _safeWithdraw = _balance.mul(locked()).div(1e18);
        if (_safeWithdraw > _balance) {
            return _balance;
        } else {
            uint _diff = _balance.sub(_safeWithdraw);
            return _balance.sub(_diff.mul(healthFactor)); // technically 150%, not 200%, but adding buffer
        }
    }
    
    function safeWithdraw() external {
        withdraw(maxWithdrawal(msg.sender));
    }
    
    // No rebalance implementation for lower fees and faster swaps
    function withdraw(uint _shares) public {
        uint r = (balance().mul(_shares)).div(totalSupply());
        _burn(msg.sender, _shares);
        _rebalance(r);
        token.safeTransfer(msg.sender, r);
    }
    
    function getPricePerFullShare() external view returns (uint) {
        return balance().mul(1e18).div(totalSupply());
    }
}

Read Contract

aave 0x819faf7b → address
allowance 0xdd62ed3e → uint256
availableToBorrowETH 0xb040785a → uint256
availableToBorrowReserve 0x929c8849 → uint256
balance 0xb69ef8a8 → uint256
balanceOf 0x70a08231 → uint256
controller 0xf77c4791 → address
credit 0xa06d083c → uint256
debt 0x0dca59c1 → uint256
debtShare 0x2851e2e0 → uint256
decimals 0x313ce567 → uint8
getAave 0xf7c1ec77 → address
getAaveCore 0xf82ce27d → address
getAaveOracle 0x9f287e16 → address
getPricePerFullShare 0x77c7b8fc → uint256
getReservePrice 0xf0722322 → uint256
getReservePriceETH 0x11dddca4 → uint256
getUnderlyingPrice 0x468f02d2 → uint256
getUnderlyingPriceETH 0xdd90a791 → uint256
governance 0x5aa6e675 → address
healthFactor 0x22841f01 → uint256
insurance 0x89cf3204 → uint256
locked 0xcf309012 → uint256
ltv 0x6fb49d73 → uint256
max 0x6ac5db19 → uint256
maxSafeETH 0x62f5548d → uint256, uint256, uint256
maxWithdrawal 0x27afd028 → uint256
name 0x06fdde03 → string
over 0x6ad4e251 → uint256
over 0x7eaef50c → uint256
reserve 0xcd3293de → address
shouldBorrow 0x1b93e5b0 → bool
shouldRebalance 0xae2c1d5f → bool
symbol 0x95d89b41 → string
token 0xfc0c546a → address
totalSupply 0x18160ddd → uint256
underlying 0x6f307dc3 → address

Write Contract 19 functions

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

activate 0x0f15f4c0
No parameters
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
claimInsurance 0xa75ac608
No parameters
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
deposit 0xb6b55f25
uint256 _amount
depositAll 0xde5f6268
No parameters
earn 0xd389800f
No parameters
harvest 0x018ee9b7
address reserve
uint256 amount
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
rebalance 0x7d7c2a1c
No parameters
repay 0x22867d78
address reserve
uint256 amount
repayAll 0xfa3ae6dc
No parameters
safeWithdraw 0x7fd42617
No parameters
setController 0x92eefe9b
address _controller
setHealthFactor 0x31111708
uint256 _hf
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
withdraw 0x2e1a7d4d
uint256 _shares
withdrawAll 0x853828b6
No parameters

Recent Transactions

No transactions found for this address