Apply changes to Kyber contracts

This commit is contained in:
Shriya Tyagi 2023-06-15 01:04:18 +05:30
parent 59aa71214f
commit 3450ab0ffc
24 changed files with 40 additions and 76 deletions

View File

@ -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);

View File

@ -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";
}

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}

View File

@ -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);

View File

@ -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";
}

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}

View File

@ -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);

View File

@ -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";
}

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}

View File

@ -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);

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}

View File

@ -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);

View File

@ -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";
}

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}

View File

@ -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);

View File

@ -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";
}

View File

@ -1,6 +0,0 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AugustusSwapperInterface {
function getTokenTransferProxy() external view returns (address);
}