From 79d1c80d61fc11ab7ecd2784b99fe7c254ccf6bc Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Mon, 14 Sep 2020 02:02:25 +1000 Subject: [PATCH] CRV mining logics --- contracts/logics/settle/eth/crvMining.sol | 33 ++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/contracts/logics/settle/eth/crvMining.sol b/contracts/logics/settle/eth/crvMining.sol index c38b481..2430c60 100644 --- a/contracts/logics/settle/eth/crvMining.sol +++ b/contracts/logics/settle/eth/crvMining.sol @@ -5,13 +5,40 @@ import { DSMath } from "../../../libs/safeMath.sol"; contract LogicOne { - function compCrvMine(uint amt) public { - // borrow from Compound & deposit in Curve (static logic for DAI) + // borrow from Compound & deposit in Curve (static logic for DAI) + function compCrvMine(address token, uint amt, uint unitAmt, string calldata guage) public { + address[] memory _targets = new address[](3); + bytes[] memory _data = new bytes[](3); + _targets[0] = address(0); // Check9898 - address of compound connector + _data[0] = abi.encodeWithSignature("borrow(address,uint256,uint256,uint256)", token, amt, uint(0), uint(0)); + _targets[1] = address(0); // Check9898 - address of curve connector + _data[1] = abi.encodeWithSignature("deposit(address,uint256,uint256,uint256,uint256)", token, amt, unitAmt, uint(0), uint(0)); + _targets[2] = address(0); // Check9898 - address of curve guage connector + _data[2] = abi.encodeWithSignature("deposit(string,uint256,uint256,uint256)", guage, uint(-1), uint(0), uint(0)); // check if status is safe and only have assets in the specific tokens } - function compCrvRedeem(uint amt) public { + function compCrvRedeem(address token, uint amt, uint unitAmt, string calldata guage) public { // Withdraw from Curve and payback on Compound + address[] memory _targets; + bytes[] memory _data; + if (amt == uint(-1)) { + _targets = new address[](3); + _data = new bytes[](3); + } else { + _targets = new address[](4); + _data = new bytes[](4); + } + _targets[0] = address(0); // Check9898 - address of curve guage connector + _data[0] = abi.encodeWithSignature("withdraw(string,uint256,uint256,uint256,uint256,uint256)", guage, uint(-1), uint(0), uint(0), uint(0), uint(0)); + _targets[1] = address(0); // Check9898 - address of curve connector + _data[1] = abi.encodeWithSignature("withdraw(address,uint256,uint256,uint256,uint256)", token, amt, unitAmt, uint(0), uint(0)); + _targets[2] = address(0); // Check9898 - address of compound connector + _data[2] = abi.encodeWithSignature("payback(address,uint256,uint256,uint256)", token, amt, uint(0), uint(0)); + if (amt != uint(-1)) { + _targets[3] = address(0); // Check9898 - address of curve guage connector + _data[3] = abi.encodeWithSignature("deposit(string,uint256,uint256,uint256)", guage, uint(-1), uint(0), uint(0)); + } } receive() external payable {}