dsa-connectors/contracts/polygon/connectors/paraswap/main.sol
Ardhead 0ef4667258
Checker for solidity code (#32)
* raw logic

* rename and output update

* checks update

* name & comments checks update

* Updated comments for reflexer

* Updated comments

* colors and line numbers

* commit test

* commit test 2

* commit test 3

* commit test 4

* commit test 5

* commit test 6

* commit test 7

* reset branch

* commit test 1

* commit test 1

* test commit 1

* test commit

* test

* test

* test workflow

Co-authored-by: Thrilok Kumar <thrilok2000@gmail.com>
2021-05-07 22:06:52 +05:30

50 lines
1.8 KiB
Solidity

pragma solidity ^0.7.0;
import { TokenInterface } from "../../common/interfaces.sol";
import { Stores } from "../../common/stores.sol";
import { Helpers } from "./helpers.sol";
abstract contract ParaswapResolver is Helpers {
/**
* @dev Sell ETH/ERC20_Token using ParaSwap.
* @notice Swap tokens from exchanges like kyber, 0x etc, with calculation done off-chain.
* @param buyAddr The address of the token to buy.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param sellAddr The address of the token to sell.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param sellAmt The amount of the token to sell.
* @param unitAmt The amount of buyAmt/sellAmt with slippage.
* @param callData Data from 1inch API.
* @param setId ID stores the amount of token brought.
*/
function swap(
address buyAddr,
address sellAddr,
uint256 sellAmt,
uint256 unitAmt,
bytes calldata callData,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
Helpers.SwapData memory swapData = Helpers.SwapData({
buyToken: TokenInterface(buyAddr),
sellToken: TokenInterface(sellAddr),
unitAmt: unitAmt,
callData: callData,
_sellAmt: sellAmt,
_buyAmt: 0
});
swapData = _swap(swapData, setId);
_eventName = "LogSwap(address,address,uint256,uint256,uint256)";
_eventParam = abi.encode(
address(swapData.buyToken),
address(swapData.sellToken),
swapData._buyAmt,
swapData._sellAmt,
setId
);
}
}
contract ConnectV2Paraswap is ParaswapResolver {
string public name = "Paraswap-v1";
}