mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Update logic
This commit is contained in:
parent
fce46257cc
commit
e0ee6b8752
|
|
@ -560,6 +560,7 @@ contract CompoundHelpers is Helpers {
|
|||
}
|
||||
|
||||
function _compBorrowOne(uint fee, address token, uint amt) internal {
|
||||
if (amt > 0) {
|
||||
address cToken = InstaMapping(getMappingAddr()).cTokenMapping(token);
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
uint _amt = add(amt, feeAmt);
|
||||
|
|
@ -571,6 +572,7 @@ contract CompoundHelpers is Helpers {
|
|||
TokenInterface(token).transfer(feeCollector, feeAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compBorrow(
|
||||
uint length,
|
||||
|
|
@ -579,13 +581,12 @@ contract CompoundHelpers is Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_compBorrowOne(fee, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compDepositOne(uint fee, address token, uint amt) internal {
|
||||
if (amt > 0) {
|
||||
address cToken = InstaMapping(getMappingAddr()).cTokenMapping(token);
|
||||
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
|
|
@ -601,6 +602,7 @@ contract CompoundHelpers is Helpers {
|
|||
feeCollector.transfer(feeAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compDeposit(
|
||||
uint length,
|
||||
|
|
@ -609,13 +611,12 @@ contract CompoundHelpers is Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_compDepositOne(fee, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compWithdrawOne(address token, uint amt) internal {
|
||||
if (amt > 0) {
|
||||
address cToken = InstaMapping(getMappingAddr()).cTokenMapping(token);
|
||||
CTokenInterface cTokenContract = CTokenInterface(cToken);
|
||||
if (amt == uint(-1)) {
|
||||
|
|
@ -623,6 +624,7 @@ contract CompoundHelpers is Helpers {
|
|||
}
|
||||
require(cTokenContract.redeemUnderlying(amt) == 0, "withdraw-failed");
|
||||
}
|
||||
}
|
||||
|
||||
function _compWithdraw(
|
||||
uint length,
|
||||
|
|
@ -630,13 +632,12 @@ contract CompoundHelpers is Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_compWithdrawOne(tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compPaybackOne(address token, uint amt) internal {
|
||||
if (amt > 0) {
|
||||
address cToken = InstaMapping(getMappingAddr()).cTokenMapping(token);
|
||||
CTokenInterface cTokenContract = CTokenInterface(cToken);
|
||||
|
||||
|
|
@ -651,6 +652,7 @@ contract CompoundHelpers is Helpers {
|
|||
CETHInterface(cToken).repayBorrow.value(amt)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _compPayback(
|
||||
uint length,
|
||||
|
|
@ -658,12 +660,10 @@ contract CompoundHelpers is Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_compPaybackOne(tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract AaveV1Helpers is CompoundHelpers {
|
||||
|
||||
|
|
@ -674,6 +674,7 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
uint amt,
|
||||
uint rateMode
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
uint _amt = add(amt, feeAmt);
|
||||
|
||||
|
|
@ -684,6 +685,7 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
TokenInterface(token).transfer(feeCollector, feeAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1Borrow(
|
||||
AaveV1Interface aave,
|
||||
|
|
@ -694,11 +696,9 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
uint[] memory rateModes
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV1BorrowOne(aave, fee, tokens[i], amts[i], rateModes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1DepositOne(
|
||||
AaveV1Interface aave,
|
||||
|
|
@ -706,6 +706,7 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
address token,
|
||||
uint amt
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
uint ethAmt;
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
uint _amt = sub(amt, feeAmt);
|
||||
|
|
@ -725,6 +726,7 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
if (!getIsColl(aave, token))
|
||||
aave.setUserUseReserveAsCollateral(token, true);
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1Deposit(
|
||||
AaveV1Interface aave,
|
||||
|
|
@ -734,20 +736,20 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV1DepositOne(aave, fee, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1WithdrawOne(
|
||||
AaveV1CoreInterface aaveCore,
|
||||
address token,
|
||||
uint amt
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
ATokenV1Interface atoken = ATokenV1Interface(aaveCore.getReserveATokenAddress(token));
|
||||
atoken.redeem(amt);
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1Withdraw(
|
||||
AaveV1CoreInterface aaveCore,
|
||||
|
|
@ -756,17 +758,16 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV1WithdrawOne(aaveCore, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1PaybackOne(
|
||||
AaveV1Interface aave,
|
||||
address token,
|
||||
uint amt
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
uint ethAmt;
|
||||
bool isEth = token == getEthAddr();
|
||||
if (isEth) {
|
||||
|
|
@ -778,6 +779,7 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
|
||||
aave.repay.value(ethAmt)(token, amt, payable(address(this)));
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV1Payback(
|
||||
AaveV1Interface aave,
|
||||
|
|
@ -786,12 +788,10 @@ contract AaveV1Helpers is CompoundHelpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV1PaybackOne(aave, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract AaveV2Helpers is AaveV1Helpers {
|
||||
|
||||
|
|
@ -802,6 +802,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint amt,
|
||||
uint rateMode
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
uint _amt = add(amt, feeAmt);
|
||||
|
||||
|
|
@ -817,6 +818,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
TokenInterface(_token).transfer(feeCollector, feeAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2Borrow(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -827,11 +829,9 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint[] memory rateModes
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV2BorrowOne(aave, fee, tokens[i], amts[i], rateModes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2DepositOne(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -840,6 +840,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
address token,
|
||||
uint amt
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
uint feeAmt = wmul(amt, fee);
|
||||
uint _amt = sub(amt, feeAmt);
|
||||
|
||||
|
|
@ -863,6 +864,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2Deposit(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -873,11 +875,9 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV2DepositOne(aave, aaveData, fee, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2WithdrawOne(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -885,6 +885,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
address token,
|
||||
uint amt
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
bool isEth = token == getEthAddr();
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
|
@ -895,6 +896,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
|
||||
convertWethToEth(isEth, tokenContract, _amt);
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2Withdraw(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -904,11 +906,9 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint[] memory amts
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV2WithdrawOne(aave, aaveData, tokens[i], amts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2PaybackOne(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -917,6 +917,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint amt,
|
||||
uint rateMode
|
||||
) internal {
|
||||
if (amt > 0) {
|
||||
bool isEth = token == getEthAddr();
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
|
@ -927,6 +928,7 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
|
||||
aave.repay(_token, _amt, rateMode, address(this));
|
||||
}
|
||||
}
|
||||
|
||||
function _aaveV2Payback(
|
||||
AaveV2Interface aave,
|
||||
|
|
@ -937,12 +939,10 @@ contract AaveV2Helpers is AaveV1Helpers {
|
|||
uint[] memory rateModes
|
||||
) internal {
|
||||
for (uint i = 0; i < length; i++) {
|
||||
if (amts[i] > 0) {
|
||||
_aaveV2PaybackOne(aave, aaveData, tokens[i], amts[i], rateModes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract MakerHelpers is AaveV2Helpers {
|
||||
|
||||
|
|
@ -1019,8 +1019,8 @@ contract MakerHelpers is AaveV2Helpers {
|
|||
VatLike(managerContract.vat()).frob(
|
||||
ilk,
|
||||
urn,
|
||||
_this,
|
||||
_this,
|
||||
address(this),
|
||||
address(this),
|
||||
intAmt,
|
||||
0
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user