mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge pull request #31 from Instadapp/refinance-update
Refinance update
This commit is contained in:
commit
ede9bd73c1
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||||
|
@ -32,9 +32,9 @@ interface CETHInterface {
|
||||||
function repayBorrow() external payable;
|
function repayBorrow() external payable;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InstaMapping {
|
interface CompoundMappingInterface {
|
||||||
function cTokenMapping(address) external view returns (address);
|
function cTokenMapping(string calldata tokenId) external view returns (address);
|
||||||
function gemJoinMapping(bytes32) external view returns (address);
|
function getMapping(string calldata tokenId) external view returns (address, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ComptrollerInterface {
|
interface ComptrollerInterface {
|
||||||
|
@ -174,18 +174,11 @@ contract Helpers is DSMath {
|
||||||
// return 0xd0A1E359811322d97991E03f863a0C30C2cF029C; // Kovan WETH Address
|
// return 0xd0A1E359811322d97991E03f863a0C30C2cF029C; // Kovan WETH Address
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Connector Details.
|
|
||||||
*/
|
|
||||||
function connectorID() public pure returns(uint _type, uint _id) {
|
|
||||||
(_type, _id) = (1, 73);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Return InstaDApp Mapping Address
|
* @dev Return InstaDApp Mapping Address
|
||||||
*/
|
*/
|
||||||
function getMappingAddr() internal pure returns (address) {
|
function getMappingAddr() internal pure returns (address) {
|
||||||
return 0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88; // InstaMapping Address
|
return 0xA8F9D4aA7319C54C04404765117ddBf9448E2082; // CompoundMapping Address
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,11 +304,12 @@ contract Helpers is DSMath {
|
||||||
return _tokens;
|
return _tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCtokenInterfaces(uint length, address[] memory tokens) internal view returns (CTokenInterface[] memory) {
|
function getCtokenInterfaces(uint length, string[] memory tokenIds) internal view returns (CTokenInterface[] memory) {
|
||||||
CTokenInterface[] memory _ctokens = new CTokenInterface[](length);
|
CTokenInterface[] memory _ctokens = new CTokenInterface[](length);
|
||||||
for (uint i = 0; i < length; i++) {
|
for (uint i = 0; i < length; i++) {
|
||||||
address _cToken = InstaMapping(getMappingAddr()).cTokenMapping(tokens[i]);
|
(address token, address cToken) = CompoundMappingInterface(getMappingAddr()).getMapping(tokenIds[i]);
|
||||||
_ctokens[i] = CTokenInterface(_cToken);
|
require(token != address(0) && cToken != address(0), "invalid token/ctoken address");
|
||||||
|
_ctokens[i] = CTokenInterface(cToken);
|
||||||
}
|
}
|
||||||
return _ctokens;
|
return _ctokens;
|
||||||
}
|
}
|
||||||
|
@ -842,6 +836,7 @@ contract RefinanceResolver is AaveV2Helpers {
|
||||||
uint collateralFee;
|
uint collateralFee;
|
||||||
uint debtFee;
|
uint debtFee;
|
||||||
address[] tokens;
|
address[] tokens;
|
||||||
|
string[] ctokenIds;
|
||||||
uint[] borrowAmts;
|
uint[] borrowAmts;
|
||||||
uint[] withdrawAmts;
|
uint[] withdrawAmts;
|
||||||
uint[] borrowRateModes;
|
uint[] borrowRateModes;
|
||||||
|
@ -858,6 +853,7 @@ contract RefinanceResolver is AaveV2Helpers {
|
||||||
require(data.withdrawAmts.length == length, "length-mismatch");
|
require(data.withdrawAmts.length == length, "length-mismatch");
|
||||||
require(data.borrowRateModes.length == length, "length-mismatch");
|
require(data.borrowRateModes.length == length, "length-mismatch");
|
||||||
require(data.paybackRateModes.length == length, "length-mismatch");
|
require(data.paybackRateModes.length == length, "length-mismatch");
|
||||||
|
require(data.ctokenIds.length == length, "length-mismatch");
|
||||||
|
|
||||||
AaveV2Interface aaveV2 = AaveV2Interface(getAaveV2Provider().getLendingPool());
|
AaveV2Interface aaveV2 = AaveV2Interface(getAaveV2Provider().getLendingPool());
|
||||||
AaveV1Interface aaveV1 = AaveV1Interface(getAaveProvider().getLendingPool());
|
AaveV1Interface aaveV1 = AaveV1Interface(getAaveProvider().getLendingPool());
|
||||||
|
@ -868,7 +864,7 @@ contract RefinanceResolver is AaveV2Helpers {
|
||||||
uint[] memory paybackAmts;
|
uint[] memory paybackAmts;
|
||||||
|
|
||||||
TokenInterface[] memory tokens = getTokenInterfaces(length, data.tokens);
|
TokenInterface[] memory tokens = getTokenInterfaces(length, data.tokens);
|
||||||
CTokenInterface[] memory _ctokens = getCtokenInterfaces(length, data.tokens);
|
CTokenInterface[] memory _ctokens = getCtokenInterfaces(length, data.ctokenIds);
|
||||||
|
|
||||||
if (data.source == Protocol.Aave && data.target == Protocol.AaveV2) {
|
if (data.source == Protocol.Aave && data.target == Protocol.AaveV2) {
|
||||||
AaveV2BorrowData memory _aaveV2BorrowData;
|
AaveV2BorrowData memory _aaveV2BorrowData;
|
||||||
|
@ -1048,5 +1044,12 @@ contract RefinanceResolver is AaveV2Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectRefinance is RefinanceResolver {
|
contract ConnectRefinance is RefinanceResolver {
|
||||||
string public name = "Refinance-v1.1";
|
/**
|
||||||
|
* @dev Connector Details.
|
||||||
|
*/
|
||||||
|
function connectorID() public pure returns(uint _type, uint _id) {
|
||||||
|
(_type, _id) = (1, 96);
|
||||||
|
}
|
||||||
|
|
||||||
|
string public name = "Refinance-v1.2";
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user