mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Remove refianceMaker
This commit is contained in:
parent
64f85d51a7
commit
f4146016f6
|
@ -1394,74 +1394,6 @@ contract RefinanceResolver is MakerHelpers {
|
||||||
revert("invalid-options");
|
revert("invalid-options");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function refinanceMaker(RefinanceMakerData calldata data) external payable {
|
|
||||||
|
|
||||||
AaveV2Interface aaveV2 = AaveV2Interface(getAaveV2Provider().getLendingPool());
|
|
||||||
AaveV1Interface aaveV1 = AaveV1Interface(getAaveProvider().getLendingPool());
|
|
||||||
AaveV1CoreInterface aaveCore = AaveV1CoreInterface(getAaveProvider().getLendingPoolCore());
|
|
||||||
AaveV2DataProviderInterface aaveData = getAaveV2DataProvider();
|
|
||||||
|
|
||||||
TokenInterface dai = TokenInterface(getMcdDai());
|
|
||||||
TokenInterface token = TokenInterface(data.token == getEthAddr() ? getWethAddr() : data.token);
|
|
||||||
|
|
||||||
uint depositAmt;
|
|
||||||
uint borrowAmt;
|
|
||||||
|
|
||||||
if (data.isFrom) {
|
|
||||||
(depositAmt, borrowAmt) = _makerPaybackAndWithdraw(
|
|
||||||
data.fromVaultId,
|
|
||||||
data.collateral,
|
|
||||||
data.debt
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.target == Protocol.Aave) {
|
|
||||||
_aaveV1DepositOne(aaveV1, aaveCore, data.collateralFee, token, depositAmt);
|
|
||||||
_aaveV1BorrowOne(aaveV1, data.debtFee, Protocol.AaveV2, dai, CTokenInterface(address(0)), borrowAmt, data.borrowRateMode, 2);
|
|
||||||
} else if (data.target == Protocol.AaveV2) {
|
|
||||||
_aaveV2DepositOne(aaveV2, aaveData, data.collateralFee, token, depositAmt);
|
|
||||||
_aaveV2BorrowOne(aaveV2, data.debtFee, Protocol.AaveV2, dai, CTokenInterface(address(0)), borrowAmt, data.borrowRateMode);
|
|
||||||
} else if (data.target == Protocol.Compound) {
|
|
||||||
address[] memory tokens = new address[](2);
|
|
||||||
tokens[0] = address(dai);
|
|
||||||
tokens[1] = data.token;
|
|
||||||
|
|
||||||
CTokenInterface[] memory _ctokens = getCtokenInterfaces(2, tokens);
|
|
||||||
|
|
||||||
_compEnterMarkets(2, _ctokens);
|
|
||||||
|
|
||||||
_compDepositOne(data.collateralFee, _ctokens[1], token, depositAmt);
|
|
||||||
_compBorrowOne(data.debtFee, _ctokens[0], dai, borrowAmt, Protocol.Aave, 2);
|
|
||||||
} else {
|
|
||||||
revert("invalid-option");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (data.toVaultId == 0) {
|
|
||||||
_makerOpen(data.colType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.source == Protocol.Aave) {
|
|
||||||
borrowAmt = _aaveV1PaybackOne(aaveV1, aaveCore, dai, data.debt);
|
|
||||||
depositAmt = _aaveV1WithdrawOne(aaveV1, aaveCore, token, data.collateral);
|
|
||||||
} else if (data.source == Protocol.AaveV2) {
|
|
||||||
borrowAmt = _aaveV2PaybackOne(aaveV2, aaveData, dai, data.debt, data.paybackRateMode);
|
|
||||||
depositAmt = _aaveV2WithdrawOne(aaveV2, aaveData, token, data.collateral);
|
|
||||||
} else if (data.source == Protocol.Compound) {
|
|
||||||
address _cDai = InstaMapping(getMappingAddr()).cTokenMapping(address(dai));
|
|
||||||
address _cToken = InstaMapping(getMappingAddr()).cTokenMapping(data.token);
|
|
||||||
|
|
||||||
CTokenInterface cDai = CTokenInterface(_cDai);
|
|
||||||
CTokenInterface cToken = CTokenInterface(_cToken);
|
|
||||||
|
|
||||||
borrowAmt = _compPaybackOne(cDai, dai, data.debt);
|
|
||||||
depositAmt = _compWithdrawOne(cToken, token, data.collateral);
|
|
||||||
} else {
|
|
||||||
revert("invalid-option");
|
|
||||||
}
|
|
||||||
|
|
||||||
_makerDepositAndBorrow(data.toVaultId, depositAmt, borrowAmt, data.collateralFee, data.debtFee);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectRefinance is RefinanceResolver {
|
contract ConnectRefinance is RefinanceResolver {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user