mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
minor changes
This commit is contained in:
parent
fb79ade8fe
commit
f8e65363c9
|
@ -14,9 +14,9 @@ contract SwapHelpers {
|
||||||
/**
|
/**
|
||||||
*@dev Swap using the dex aggregators.
|
*@dev Swap using the dex aggregators.
|
||||||
*@param _connectors name of the connectors in preference order.
|
*@param _connectors name of the connectors in preference order.
|
||||||
*@param _data data for the swap cast.
|
*@param _datas data for the swap cast.
|
||||||
*/
|
*/
|
||||||
function _swap(string[] memory _connectors, bytes[] memory _data)
|
function _swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
internal
|
internal
|
||||||
returns (
|
returns (
|
||||||
bool success,
|
bool success,
|
||||||
|
@ -26,12 +26,12 @@ contract SwapHelpers {
|
||||||
{
|
{
|
||||||
uint256 _length = _connectors.length;
|
uint256 _length = _connectors.length;
|
||||||
require(_length > 0, "zero-length-not-allowed");
|
require(_length > 0, "zero-length-not-allowed");
|
||||||
require(_data.length == _length, "calldata-length-invalid");
|
require(_datas.length == _length, "calldata-length-invalid");
|
||||||
|
|
||||||
for (uint256 i = 0; i < _length; i++) {
|
for (uint256 i = 0; i < _length; i++) {
|
||||||
(success, returnData) = instaConnectors
|
(success, returnData) = instaConnectors
|
||||||
.connectors(_connectors[i])
|
.connectors(_connectors[i])
|
||||||
.delegatecall(_data[i]);
|
.delegatecall(_datas[i]);
|
||||||
if (success) {
|
if (success) {
|
||||||
connector = _connectors[i];
|
connector = _connectors[i];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,16 +16,16 @@ abstract contract Swap is SwapHelpers, Events {
|
||||||
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
||||||
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
||||||
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
||||||
* @param _data Encoded function call data including function selector encoded with parameters.
|
* @param _datas Encoded function call data including function selector encoded with parameters.
|
||||||
*/
|
*/
|
||||||
function swap(string[] memory _connectors, bytes[] memory _data)
|
function swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
(bool success, bytes memory returnData, string memory connector) = _swap(
|
(bool success, bytes memory returnData, string memory connector) = _swap(
|
||||||
_connectors,
|
_connectors,
|
||||||
_data
|
_datas
|
||||||
);
|
);
|
||||||
|
|
||||||
require(success, "swap-Aggregator-failed");
|
require(success, "swap-Aggregator-failed");
|
||||||
|
|
|
@ -14,9 +14,9 @@ contract SwapHelpers {
|
||||||
/**
|
/**
|
||||||
*@dev Swap using the dex aggregators.
|
*@dev Swap using the dex aggregators.
|
||||||
*@param _connectors name of the connectors in preference order.
|
*@param _connectors name of the connectors in preference order.
|
||||||
*@param _data data for the swap cast.
|
*@param _datas data for the swap cast.
|
||||||
*/
|
*/
|
||||||
function _swap(string[] memory _connectors, bytes[] memory _data)
|
function _swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
internal
|
internal
|
||||||
returns (
|
returns (
|
||||||
bool success,
|
bool success,
|
||||||
|
@ -26,12 +26,12 @@ contract SwapHelpers {
|
||||||
{
|
{
|
||||||
uint256 _length = _connectors.length;
|
uint256 _length = _connectors.length;
|
||||||
require(_length > 0, "zero-length-not-allowed");
|
require(_length > 0, "zero-length-not-allowed");
|
||||||
require(_data.length == _length, "calldata-length-invalid");
|
require(_datas.length == _length, "calldata-length-invalid");
|
||||||
|
|
||||||
for (uint256 i = 0; i < _length; i++) {
|
for (uint256 i = 0; i < _length; i++) {
|
||||||
(success, returnData) = instaConnectors
|
(success, returnData) = instaConnectors
|
||||||
.connectors(_connectors[i])
|
.connectors(_connectors[i])
|
||||||
.delegatecall(_data[i]);
|
.delegatecall(_datas[i]);
|
||||||
if (success) {
|
if (success) {
|
||||||
connector = _connectors[i];
|
connector = _connectors[i];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,16 +16,16 @@ abstract contract Swap is SwapHelpers, Events {
|
||||||
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
||||||
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
||||||
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
||||||
* @param _data Encoded function call data including function selector encoded with parameters.
|
* @param _datas Encoded function call data including function selector encoded with parameters.
|
||||||
*/
|
*/
|
||||||
function swap(string[] memory _connectors, bytes[] memory _data)
|
function swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
(bool success, bytes memory returnData, string memory connector) = _swap(
|
(bool success, bytes memory returnData, string memory connector) = _swap(
|
||||||
_connectors,
|
_connectors,
|
||||||
_data
|
_datas
|
||||||
);
|
);
|
||||||
|
|
||||||
require(success, "swap-Aggregator-failed");
|
require(success, "swap-Aggregator-failed");
|
||||||
|
|
|
@ -14,9 +14,9 @@ contract SwapHelpers {
|
||||||
/**
|
/**
|
||||||
*@dev Swap using the dex aggregators.
|
*@dev Swap using the dex aggregators.
|
||||||
*@param _connectors name of the connectors in preference order.
|
*@param _connectors name of the connectors in preference order.
|
||||||
*@param _data data for the swap cast.
|
*@param _datas data for the swap cast.
|
||||||
*/
|
*/
|
||||||
function _swap(string[] memory _connectors, bytes[] memory _data)
|
function _swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
internal
|
internal
|
||||||
returns (
|
returns (
|
||||||
bool success,
|
bool success,
|
||||||
|
@ -26,12 +26,12 @@ contract SwapHelpers {
|
||||||
{
|
{
|
||||||
uint256 _length = _connectors.length;
|
uint256 _length = _connectors.length;
|
||||||
require(_length > 0, "zero-length-not-allowed");
|
require(_length > 0, "zero-length-not-allowed");
|
||||||
require(_data.length == _length, "calldata-length-invalid");
|
require(_datas.length == _length, "calldata-length-invalid");
|
||||||
|
|
||||||
for (uint256 i = 0; i < _length; i++) {
|
for (uint256 i = 0; i < _length; i++) {
|
||||||
(success, returnData) = instaConnectors
|
(success, returnData) = instaConnectors
|
||||||
.connectors(_connectors[i])
|
.connectors(_connectors[i])
|
||||||
.delegatecall(_data[i]);
|
.delegatecall(_datas[i]);
|
||||||
if (success) {
|
if (success) {
|
||||||
connector = _connectors[i];
|
connector = _connectors[i];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,16 +16,16 @@ abstract contract Swap is SwapHelpers, Events {
|
||||||
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
* @dev Swap ETH/ERC20_Token using dex aggregators.
|
||||||
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
* @notice Swap tokens from exchanges like 1INCH, 0x etc, with calculation done off-chain.
|
||||||
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
* @param _connectors The name of the connectors like 1INCH-A, 0x etc, in order of their priority.
|
||||||
* @param _data Encoded function call data including function selector encoded with parameters.
|
* @param _datas Encoded function call data including function selector encoded with parameters.
|
||||||
*/
|
*/
|
||||||
function swap(string[] memory _connectors, bytes[] memory _data)
|
function swap(string[] memory _connectors, bytes[] memory _datas)
|
||||||
external
|
external
|
||||||
payable
|
payable
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
{
|
{
|
||||||
(bool success, bytes memory returnData, string memory connector) = _swap(
|
(bool success, bytes memory returnData, string memory connector) = _swap(
|
||||||
_connectors,
|
_connectors,
|
||||||
_data
|
_datas
|
||||||
);
|
);
|
||||||
|
|
||||||
require(success, "swap-Aggregator-failed");
|
require(success, "swap-Aggregator-failed");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user