mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Apply changes to Kyber contracts
This commit is contained in:
parent
59aa71214f
commit
3450ab0ffc
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 ethAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: ethAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
|
@ -54,6 +54,6 @@ abstract contract KyberArbitrumResolver is Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectV2KyberV3Arbitrum is KyberArbitrumResolver {
|
||||
string public name = "Kyber-v3";
|
||||
contract ConnectV2KyberAggregatorArbitrum is KyberArbitrumResolver {
|
||||
string public name = "Kyber-aggregator-v1.0";
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 avaxAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: avaxAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
||||
|
@ -50,14 +50,14 @@ abstract contract Helpers is DSMath, Basic {
|
|||
{
|
||||
TokenInterface _sellAddr = swapData.sellToken;
|
||||
|
||||
uint256 ethAmt;
|
||||
uint256 avaxAmt;
|
||||
|
||||
if (address(_sellAddr) == avaxAddr) {
|
||||
ethAmt = swapData._sellAmt;
|
||||
avaxAmt = swapData._sellAmt;
|
||||
} else {
|
||||
approve(TokenInterface(_sellAddr), kyberswap, swapData._sellAmt);
|
||||
}
|
||||
swapData._buyAmt = _swapHelper(swapData, ethAmt);
|
||||
swapData._buyAmt = _swapHelper(swapData, avaxAmt);
|
||||
|
||||
setUint(setId, swapData._buyAmt);
|
||||
|
|
@ -12,10 +12,10 @@ import {Helpers} from "./helpers.sol";
|
|||
|
||||
abstract contract KyberAvalancheResolver is Helpers {
|
||||
/**
|
||||
* @dev Sell ETH/ERC20_Token using KyberSwap.
|
||||
* @dev Sell AVAX/ERC20_Token using KyberSwap.
|
||||
* @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 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 kyberswap API.
|
||||
|
@ -54,6 +54,6 @@ abstract contract KyberAvalancheResolver is Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectV2KyberV3Avalanche is KyberAvalancheResolver {
|
||||
string public name = "Kyber-v3";
|
||||
contract ConnectV2KyberAggregatorAvalanche is KyberAvalancheResolver {
|
||||
string public name = "Kyber-aggregator-v1.0";
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 ftmAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: ftmAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
||||
|
@ -50,14 +50,14 @@ abstract contract Helpers is DSMath, Basic {
|
|||
{
|
||||
TokenInterface _sellAddr = swapData.sellToken;
|
||||
|
||||
uint256 ethAmt;
|
||||
uint256 ftmAmt;
|
||||
|
||||
if (address(_sellAddr) == ftmAddr) {
|
||||
ethAmt = swapData._sellAmt;
|
||||
ftmAmt = swapData._sellAmt;
|
||||
} else {
|
||||
approve(TokenInterface(_sellAddr), kyberswap, swapData._sellAmt);
|
||||
}
|
||||
swapData._buyAmt = _swapHelper(swapData, ethAmt);
|
||||
swapData._buyAmt = _swapHelper(swapData, ftmAmt);
|
||||
|
||||
setUint(setId, swapData._buyAmt);
|
||||
|
|
@ -12,10 +12,10 @@ import {Helpers} from "./helpers.sol";
|
|||
|
||||
abstract contract KyberFantomResolver is Helpers {
|
||||
/**
|
||||
* @dev Sell ETH/ERC20_Token using KyberSwap.
|
||||
* @dev Sell ftm/ERC20_Token using KyberSwap.
|
||||
* @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 buyAddr The address of the token to buy.(For FTM: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param sellAddr The address of the token to sell.(For FTM: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param sellAmt The amount of the token to sell.
|
||||
* @param unitAmt The amount of buyAmt/sellAmt with slippage.
|
||||
* @param callData Data from kyberswap API.
|
||||
|
@ -54,6 +54,6 @@ abstract contract KyberFantomResolver is Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectV2KyberV3Fantom is KyberFantomResolver {
|
||||
string public name = "Kyber-v3";
|
||||
contract ConnectV2KyberAggregatorFantom is KyberFantomResolver {
|
||||
string public name = "Kyber-aggregator-v1.0";
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 ethAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: ethAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 ethAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: ethAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
|
@ -54,6 +54,6 @@ abstract contract KyberOptimismResolver is Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectV2KyberV3Optimism is KyberOptimismResolver {
|
||||
string public name = "Kyber-v3";
|
||||
contract ConnectV2KyberAggregatorOptimism is KyberOptimismResolver {
|
||||
string public name = "Kyber-aggregator-v1.0";
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
|
@ -18,7 +18,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address internal constant kyberswap =
|
||||
0x6131B5fae19EA4f9D964eAc0408E4408b66337b5;
|
||||
|
||||
function _swapHelper(SwapData memory swapData, uint256 wethAmt)
|
||||
function _swapHelper(SwapData memory swapData, uint256 maticAmt)
|
||||
internal
|
||||
returns (uint256 buyAmt)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
|
||||
uint256 initalBal = getTokenBal(buyToken);
|
||||
(bool success, ) = kyberswap.call{value: wethAmt}(swapData.callData);
|
||||
(bool success, ) = kyberswap.call{value: maticAmt}(swapData.callData);
|
||||
if (!success) revert("kyberswap-failed");
|
||||
|
||||
uint256 finalBal = getTokenBal(buyToken);
|
||||
|
@ -50,14 +50,14 @@ abstract contract Helpers is DSMath, Basic {
|
|||
{
|
||||
TokenInterface _sellAddr = swapData.sellToken;
|
||||
|
||||
uint256 ethAmt;
|
||||
uint256 maticAmt;
|
||||
|
||||
if (address(_sellAddr) == maticAddr) {
|
||||
ethAmt = swapData._sellAmt;
|
||||
maticAmt = swapData._sellAmt;
|
||||
} else {
|
||||
approve(TokenInterface(_sellAddr), kyberswap, swapData._sellAmt);
|
||||
}
|
||||
swapData._buyAmt = _swapHelper(swapData, ethAmt);
|
||||
swapData._buyAmt = _swapHelper(swapData, maticAmt);
|
||||
|
||||
setUint(setId, swapData._buyAmt);
|
||||
|
|
@ -12,10 +12,10 @@ import {Helpers} from "./helpers.sol";
|
|||
|
||||
abstract contract KyberPolygonResolver is Helpers {
|
||||
/**
|
||||
* @dev Sell ETH/ERC20_Token using KyberSwap.
|
||||
* @dev Sell MATIC/ERC20_Token using KyberSwap.
|
||||
* @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 buyAddr The address of the token to buy.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param sellAddr The address of the token to sell.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param sellAmt The amount of the token to sell.
|
||||
* @param unitAmt The amount of buyAmt/sellAmt with slippage.
|
||||
* @param callData Data from kyberswap API.
|
||||
|
@ -54,6 +54,6 @@ abstract contract KyberPolygonResolver is Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
contract ConnectV2KyberV3Polygon is KyberPolygonResolver {
|
||||
string public name = "Kyber-v3";
|
||||
contract ConnectV2KyberAggregatorPolygon is KyberPolygonResolver {
|
||||
string public name = "Kyber-aggregator-v1.0";
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AugustusSwapperInterface {
|
||||
function getTokenTransferProxy() external view returns (address);
|
||||
}
|
Loading…
Reference in New Issue
Block a user