added onDeferredLiquidityCheck

This commit is contained in:
Shriya Tyagi 2022-08-05 00:20:17 +08:00
parent 21cc81553c
commit 5682362f34
2 changed files with 34 additions and 25 deletions

View File

@ -83,13 +83,14 @@ contract EulerHelpers is Basic {
ImportInputData memory inputData,
ImportData memory data
) internal view returns (ImportData memory) {
if (inputData.borrowTokens.length > 0) {
data._borrowTokens = new address[](inputData.borrowTokens.length);
data.borrowAmts = new uint256[](
inputData.borrowTokens.length
);
for (uint256 i = 0; i < inputData.borrowTokens.length; i++) {
for (uint256 j = i; j < inputData.borrowTokens.length; j++) {
uint _borrowTokensLength = inputData.borrowTokens.length;
if (_borrowTokensLength > 0) {
data._borrowTokens = new address[](_borrowTokensLength);
data.dTokens = new EulerTokenInterface[](_borrowTokensLength);
data.borrowAmts = new uint256[](_borrowTokensLength);
for (uint256 i = 0; i < _borrowTokensLength; i++) {
for (uint256 j = i; j < _borrowTokensLength; j++) {
if (j != i) {
require(
inputData.borrowTokens[i] !=
@ -99,7 +100,8 @@ contract EulerHelpers is Basic {
}
}
}
for (uint256 i = 0; i < inputData.borrowTokens.length; i++) {
for (uint256 i = 0; i < _borrowTokensLength; i++) {
address _token = inputData.borrowTokens[i] == ethAddr
? wethAddr
: inputData.borrowTokens[i];
@ -166,7 +168,4 @@ contract EulerHelpers is Basic {
}
}
}
}
}

View File

@ -53,7 +53,29 @@ contract EulerImport is EulerHelpers {
data = getBorrowAmounts(_sourceAccount, inputData, data);
data = getSupplyAmounts(_targetAccount, inputData, data);
IEulerExecute(eulerExec).deferLiquidityCheck(_sourceAccount, "0x0");
eulerExec.deferLiquidityCheck(_sourceAccount, abi.encode(data, enterMarket, _sourceAccount, _targetAccount, targetId));
_eventName = "LogEulerImport(address,uint256,uint256,address[],address[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
sourceId,
targetId,
inputData.supplyTokens,
inputData.borrowTokens,
data.supplyAmts,
data.borrowAmts,
enterMarket
);
}
function onDeferredLiquidityCheck(bytes memory encodedData) external {
(
ImportData memory data,
bool[] memory enterMarket,
address _sourceAccount,
address _targetAccount,
uint targetId
) = abi.decode(encodedData, (ImportData, bool[], address, address, uint));
_TransferEtokens(
data._supplyTokens.length,
@ -74,18 +96,6 @@ contract EulerImport is EulerHelpers {
_sourceAccount,
_targetAccount
);
_eventName = "LogEulerImport(address,uint256,uint256,address[],address[],uint256[],uint256[],bool[])";
_eventParam = abi.encode(
userAccount,
sourceId,
targetId,
inputData.supplyTokens,
inputData.borrowTokens,
data.supplyAmts,
data.borrowAmts,
enterMarket
);
}
}