yield-contract/contracts/logics/settle/eth/crvMining.sol

98 lines
3.9 KiB
Solidity
Raw Normal View History

2020-09-10 07:26:30 +00:00
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.8;
2020-09-25 16:59:22 +00:00
pragma experimental ABIEncoderV2;
2020-09-10 07:26:30 +00:00
import { DSMath } from "../../../libs/safeMath.sol";
2020-09-25 16:59:22 +00:00
interface DSAInterface {
function cast(address[] calldata _targets, bytes[] calldata _data, address _origin) external payable;
}
2020-09-10 07:26:30 +00:00
contract LogicOne {
2020-09-25 16:59:22 +00:00
function getEthAddress() private pure returns(address) {
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
}
function getCrvAddress() private pure returns(address) {
return 0xD533a949740bb3306d119CC777fa900bA034cd52;
}
function getOriginAddress() private pure returns(address) {
2020-09-25 17:27:10 +00:00
return 0xB7fA44c2E964B6EB24893f7082Ecc08c8d0c0F87;
2020-09-25 16:59:22 +00:00
}
function getDsaAddress() private pure returns(address) {
return address(0); // DSA address
}
function getGuageAddress() private pure returns(address) {
2020-09-25 17:27:10 +00:00
return 0xAf615b36Db171fD5A369A0060b9bCB88fFf0190d;
2020-09-25 16:59:22 +00:00
}
function getGuageName() private pure returns(string memory) {
2020-09-25 17:27:10 +00:00
return "guage-3";
2020-09-25 16:59:22 +00:00
}
function getCurveConnectAddress() private pure returns(address) {
return 0x1568a9D336A7aC051DCC4bdcc4A0B09299DE5Daf;
}
function getCurveGuageConnectAddress() private pure returns(address) {
return 0xAf615b36Db171fD5A369A0060b9bCB88fFf0190d;
}
function getUniswapConnectAddress() private pure returns(address) {
return 0x62EbfF47B2Ba3e47796efaE7C51676762dC961c0;
}
function mineCrv(address token, uint amt, uint unitAmt) external {
address[] memory _targets = new address[](2);
bytes[] memory _data = new bytes[](2);
2020-09-25 17:27:10 +00:00
_targets[1] = getCurveConnectAddress();
2020-09-13 16:02:25 +00:00
_data[1] = abi.encodeWithSignature("deposit(address,uint256,uint256,uint256,uint256)", token, amt, unitAmt, uint(0), uint(0));
2020-09-25 17:27:10 +00:00
_targets[2] = getCurveGuageConnectAddress();
2020-09-25 16:59:22 +00:00
_data[2] = abi.encodeWithSignature("deposit(string,uint256,uint256,uint256)", getGuageName(), uint(-1), uint(0), uint(0));
DSAInterface(getDsaAddress()).cast(_targets, _data, getOriginAddress());
2020-09-10 07:26:30 +00:00
}
2020-09-25 16:59:22 +00:00
function redeemCrv(address token, uint amt, uint unitAmt) external {
2020-09-13 16:02:25 +00:00
address[] memory _targets;
bytes[] memory _data;
if (amt == uint(-1)) {
2020-09-25 16:59:22 +00:00
_targets = new address[](2);
_data = new bytes[](2);
} else {
2020-09-13 16:02:25 +00:00
_targets = new address[](3);
_data = new bytes[](3);
}
2020-09-25 17:27:10 +00:00
_targets[0] = getCurveGuageConnectAddress();
2020-09-25 16:59:22 +00:00
_data[0] = abi.encodeWithSignature("withdraw(string,uint256,uint256,uint256,uint256,uint256)", getGuageName(), uint(-1), uint(0), uint(0), uint(0), uint(0));
2020-09-25 17:27:10 +00:00
_targets[1] = getCurveConnectAddress();
2020-09-13 16:02:25 +00:00
_data[1] = abi.encodeWithSignature("withdraw(address,uint256,uint256,uint256,uint256)", token, amt, unitAmt, uint(0), uint(0));
if (amt != uint(-1)) {
2020-09-25 17:27:10 +00:00
_targets[2] = getCurveGuageConnectAddress();
2020-09-25 16:59:22 +00:00
_data[2] = abi.encodeWithSignature("deposit(string,uint256,uint256,uint256)", getGuageName(), uint(-1), uint(0), uint(0));
2020-09-13 16:02:25 +00:00
}
2020-09-25 16:59:22 +00:00
DSAInterface(getDsaAddress()).cast(_targets, _data, getOriginAddress());
}
function claimCrv() external {
address[] memory _target = new address[](1);
bytes[] memory _data = new bytes[](1);
2020-09-25 17:27:10 +00:00
_target[0] = getCurveGuageConnectAddress();
2020-09-25 16:59:22 +00:00
_data[0] = abi.encodeWithSignature("claimReward(string,uint256,uint256)", getGuageName(), 0, 0);
DSAInterface(getDsaAddress()).cast(_target, _data, getOriginAddress());
}
function claimCrvAndSwap(uint amt, uint unitAmt) external {
address crv = getCrvAddress();
address eth = getEthAddress();
address[] memory _target = new address[](1);
bytes[] memory _data = new bytes[](1);
2020-09-25 17:27:10 +00:00
_target[0] = getUniswapConnectAddress();
2020-09-25 16:59:22 +00:00
_data[0] = abi.encodeWithSignature("sell(address,address,unit256,unit256,unit256,unit256)", eth, crv, amt, unitAmt, 0, 0);
DSAInterface(getDsaAddress()).cast(_target, _data, getOriginAddress());
2020-09-10 07:26:30 +00:00
}
}