dsa-connectors/contracts/avalanche/connectors/paraswap/main.sol

56 lines
1.9 KiB
Solidity
Raw Normal View History

2022-03-22 14:55:14 +00:00
//SPDX-License-Identifier: MIT
2021-10-05 21:36:11 +00:00
pragma solidity ^0.7.0;
/**
* @title Paraswap.
* @dev DEX Aggregator.
*/
import { TokenInterface } from "../../common/interfaces.sol";
import { Stores } from "../../common/stores.sol";
import { Helpers } from "./helpers.sol";
abstract contract ParaswapResolver is Helpers {
/**
* @dev Sell AVAX/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 AVAX: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param sellAddr The address of the token to sell.(For AVAX: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param sellAmt The amount of the token to sell.
* @param unitAmt The amount of buyAmt/sellAmt with slippage.
* @param callData Data from paraswap 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
);
}
}
2022-01-01 16:38:52 +00:00
contract ConnectV2ParaswapV5Avalanche is ParaswapResolver {
string public constant name = "Paraswap-v5";
2021-10-05 21:36:11 +00:00
}