minor changes

This commit is contained in:
Richa-iitr 2022-06-13 14:15:21 +05:30
parent 32429d2b05
commit 8e98da39fd
6 changed files with 31 additions and 38 deletions

View File

@ -47,19 +47,18 @@ contract SwapHelpers {
// require _connectors[i] == "1INCH-A" || "ZEROX-A" || "PARASWAP-A" || similar connectors
for (uint256 i = 0; i < _length; i++) {
bytes4 swapData = bytes4(
keccak256("swap(address,address,uint256,uint256,bytes,uint256)")
);
if (
keccak256(bytes(_connectors[i])) == keccak256(bytes("1INCH-A"))
) {
swapData = bytes4(
bytes4 swapData = (keccak256(bytes(_connectors[i])) ==
keccak256(bytes("1INCH-A")))
? bytes4(
keccak256(
"sell(address,address,uint256,uint256,bytes,uint256)"
)
)
: bytes4(
keccak256(
"swap(address,address,uint256,uint256,bytes,uint256)"
)
);
}
bytes memory _data = abi.encodeWithSelector(
swapData,

View File

@ -54,11 +54,8 @@ abstract contract Swap is SwapHelpers, Events {
uint256 _buyAmt;
uint256 _sellAmt;
if (!success) {
revert("swap-failed");
} else {
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
}
require(success, "swap-Aggregator-failed");
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
_eventName = "LogSwapAggregator(string,address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(

View File

@ -19,6 +19,7 @@ contract SwapHelpers {
bytes[] callDatas;
uint256 setId;
}
/**
*@dev Swap using the dex aggregators.
*@param _connectors name of the connectors in preference order.
@ -46,17 +47,18 @@ contract SwapHelpers {
// require _connectors[i] == "1INCH-A" || "ZEROX-A" || "PARASWAP-A" || similar connectors
for (uint256 i = 0; i < _length; i++) {
bytes4 swapData = bytes4(
keccak256("swap(address,address,uint256,uint256,bytes,uint256)")
);
if (keccak256(bytes(_connectors[i])) == keccak256(bytes("1INCH-A"))) {
swapData = bytes4(
bytes4 swapData = (keccak256(bytes(_connectors[i])) ==
keccak256(bytes("1INCH-A")))
? bytes4(
keccak256(
"sell(address,address,uint256,uint256,bytes,uint256)"
)
)
: bytes4(
keccak256(
"swap(address,address,uint256,uint256,bytes,uint256)"
)
);
}
bytes memory _data = abi.encodeWithSelector(
swapData,

View File

@ -54,11 +54,8 @@ abstract contract Swap is SwapHelpers, Events {
uint256 _buyAmt;
uint256 _sellAmt;
if (!success) {
revert("swap-failed");
} else {
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
}
require(success, "swap-Aggregator-failed");
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
_eventName = "LogSwapAggregator(string,address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(

View File

@ -47,17 +47,18 @@ contract SwapHelpers {
// require _connectors[i] == "1INCH-A" || "ZEROX-A" || "PARASWAP-A" || similar connectors
for (uint256 i = 0; i < _length; i++) {
bytes4 swapData = bytes4(
keccak256("swap(address,address,uint256,uint256,bytes,uint256)")
);
if (keccak256(bytes(_connectors[i])) == keccak256(bytes("1INCH-A"))) {
swapData = bytes4(
bytes4 swapData = (keccak256(bytes(_connectors[i])) ==
keccak256(bytes("1INCH-A")))
? bytes4(
keccak256(
"sell(address,address,uint256,uint256,bytes,uint256)"
)
)
: bytes4(
keccak256(
"swap(address,address,uint256,uint256,bytes,uint256)"
)
);
}
bytes memory _data = abi.encodeWithSelector(
swapData,

View File

@ -54,11 +54,8 @@ abstract contract Swap is SwapHelpers, Events {
uint256 _buyAmt;
uint256 _sellAmt;
if (!success) {
revert("swap-failed");
} else {
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
}
require(success, "swap-Aggregator-failed");
(_buyAmt, _sellAmt) = decodeEvents(_connector, returnData);
_eventName = "LogSwapAggregator(string,address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(