mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
basic logic done
This commit is contained in:
parent
66565bb1d4
commit
205a60f9d7
|
@ -1,24 +1,53 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.6.8;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
import { DSMath } from "../../../libs/safeMath.sol";
|
||||
|
||||
interface DSAInterface {
|
||||
function cast(address[] calldata _targets, bytes[] calldata _data, address _origin) external payable;
|
||||
}
|
||||
|
||||
contract LogicOne {
|
||||
|
||||
address poolToken;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
function deploy(address _dsa, uint amt) public {
|
||||
/**
|
||||
* @dev Return ethereum address
|
||||
*/
|
||||
function getEthAddr() internal pure returns (address) {
|
||||
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // ETH Address
|
||||
}
|
||||
|
||||
function deploy(address _dsa, address _token, uint amt) public {
|
||||
// check if DSA is authorised
|
||||
// transfer assets to DSA
|
||||
if (_token == getEthAddr()) {
|
||||
uint _bal = address(this).balance;
|
||||
amt = amt > _bal ? _bal : amt;
|
||||
payable(_dsa).transfer(amt);
|
||||
} else {
|
||||
IERC20 token = IERC20(_token);
|
||||
uint _bal = token.balanceOf(address(this));
|
||||
amt = amt > _bal ? _bal : amt;
|
||||
token.safeTransfer(_dsa, amt);
|
||||
}
|
||||
}
|
||||
|
||||
function redeem(address _dsa, uint amt) public {
|
||||
// withdraw assets from DSA
|
||||
// withdraw assets from DSA
|
||||
function redeem(address _dsa, address _token, uint amt) public {
|
||||
uint _bal = IERC20(_token).balanceOf(_dsa);
|
||||
amt = amt > _bal ? _bal : amt;
|
||||
address[] memory _targets = new address[](1);
|
||||
_targets[0] = address(0); // Check9898 - address of basic connector
|
||||
bytes[] memory _data = new bytes[](1);
|
||||
_data[0] = abi.encodeWithSignature("withdraw(address,uint256,address,uint256,uint256)", _token, amt, address(this), uint(0), uint(0));
|
||||
DSAInterface(_dsa).cast(_targets, _data, address(0)); // Check9898 - address of origin
|
||||
}
|
||||
|
||||
constructor (address ethPool) public {
|
||||
poolToken = address(ethPool);
|
||||
}
|
||||
constructor () public {}
|
||||
|
||||
receive() external payable {}
|
||||
|
||||
|
|
|
@ -12,12 +12,13 @@ contract LogicOne {
|
|||
|
||||
function maxComp(address _dsa, address[] calldata _targets, bytes[] calldata _data) public {
|
||||
// check if DSA is authorised for interaction
|
||||
address compoundConnector = address(0);
|
||||
address instaPoolConnector = address(0);
|
||||
// Also think on dydx flash loan connector
|
||||
address compoundConnector = address(0); // Check9898 - address of compound connector
|
||||
address instaPoolConnector = address(0); // Check9898 - address of instaPool connector
|
||||
for (uint i = 0; i < _targets.length; i++) {
|
||||
require(_targets[i] == compoundConnector || _targets[i] == instaPoolConnector, "connector-not-authorised");
|
||||
}
|
||||
DSAInterface(_dsa).cast(_targets, _data, address(0));
|
||||
DSAInterface(_dsa).cast(_targets, _data, address(0)); // Check9898 - address of basic connector
|
||||
// check if status is safe and only have assets in the specific tokens
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user