2022-03-22 16:17:41 +00:00
|
|
|
//SPDX-License-Identifier: MIT
|
2021-04-21 12:34:43 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
2021-05-11 16:19:12 +00:00
|
|
|
/**
|
|
|
|
* @title Paraswap.
|
|
|
|
* @dev DEX Aggregator.
|
|
|
|
*/
|
|
|
|
|
2021-04-21 12:34:43 +00:00
|
|
|
import { TokenInterface } from "../../common/interfaces.sol";
|
|
|
|
import { Stores } from "../../common/stores.sol";
|
|
|
|
import { Helpers } from "./helpers.sol";
|
|
|
|
|
|
|
|
abstract contract ParaswapResolver is Helpers {
|
2021-05-07 16:36:52 +00:00
|
|
|
/**
|
|
|
|
* @dev Sell ETH/ERC20_Token using ParaSwap.
|
|
|
|
* @notice Swap tokens from exchanges like kyber, 0x etc, with calculation done off-chain.
|
2021-05-11 13:52:01 +00:00
|
|
|
* @param buyAddr The address of the token to buy.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
|
|
|
* @param sellAddr The address of the token to sell.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
2021-05-07 16:36:52 +00:00
|
|
|
* @param sellAmt The amount of the token to sell.
|
|
|
|
* @param unitAmt The amount of buyAmt/sellAmt with slippage.
|
2021-05-11 15:58:15 +00:00
|
|
|
* @param callData Data from paraswap API.
|
2021-05-07 16:36:52 +00:00
|
|
|
* @param setId ID stores the amount of token brought.
|
|
|
|
*/
|
2021-04-21 12:34:43 +00:00
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
2021-04-21 12:36:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 16:47:50 +00:00
|
|
|
contract ConnectV2ParaswapV5Polygon is ParaswapResolver {
|
2021-12-29 17:36:04 +00:00
|
|
|
string public name = "Paraswap-v5";
|
2021-04-21 12:34:43 +00:00
|
|
|
}
|