Fix KyberSwap testcases

This commit is contained in:
Shriya Tyagi 2023-06-14 20:06:35 +05:30
parent 52ecac01a3
commit cb6563b816
2 changed files with 14 additions and 11 deletions

View File

@ -54,6 +54,6 @@ abstract contract KyberResolver is Helpers {
} }
} }
contract ConnectV2KyberV3 is KyberResolver { contract ConnectV2KyberAggregator is KyberResolver {
string public name = "Kyber-v3"; string public name = "Kyber-aggregator-v1.0";
} }

View File

@ -6,7 +6,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { import {
ConnectV2KyberV3__factory, ConnectV2KyberAggregator__factory,
} from "../../../typechain" } from "../../../typechain"
import { parseEther } from "@ethersproject/units"; import { parseEther } from "@ethersproject/units";
import { encodeSpells } from "../../../scripts/tests/encodeSpells"; import { encodeSpells } from "../../../scripts/tests/encodeSpells";
@ -47,7 +47,7 @@ describe("Kyberswap", function() {
connector = await deployAndEnableConnector({ connector = await deployAndEnableConnector({
connectorName, connectorName,
contractArtifact: ConnectV2KyberV3__factory, contractArtifact: ConnectV2KyberAggregator__factory,
signer: masterSigner, signer: masterSigner,
connectors: instaConnectorsV2, connectors: instaConnectorsV2,
}); });
@ -74,8 +74,10 @@ describe("Kyberswap", function() {
); );
}); });
}); });
describe("Main", function() { describe("Main", async function() {
it("should swap successfully", async function() { it("should swap successfully", async function() {
const latestBlock = await hre.ethers.provider.getBlock("latest");
console.log('latestBlock: ', latestBlock.number)
async function getArg() { async function getArg() {
const slippage = 1; const slippage = 1;
/* eth -> USDT */ /* eth -> USDT */
@ -97,19 +99,18 @@ describe("Kyberswap", function() {
const routeSummary = await axios const routeSummary = await axios
.get(url, { params: params }) .get(url, { params: params })
.then((data) => data.data.routeSummary); .then((response) => response.data.data.routeSummary);
let txConfig = { let txConfig = {
routeSummary: routeSummary, routeSummary: routeSummary,
sender: fromAddress, sender: fromAddress,
recipient: fromAddress, recipient: fromAddress,
}; };
let url2 = "https://aggregator-api.kyberswap.com/ethereum/api/v1/route/build"; let url2 = "https://aggregator-api.kyberswap.com/ethereum/api/v1/route/build";
const calldata = await axios const calldata = await axios
.post(url2, txConfig) .post(url2, txConfig)
.then((data) => data.data.data); .then((response) => response.data.data);
function caculateUnitAmt( function caculateUnitAmt(
buyAmount: any, buyAmount: any,
@ -134,17 +135,19 @@ describe("Kyberswap", function() {
sellTokenDecimals, sellTokenDecimals,
1 1
); );
console.log('----------------unitAmt-------------', unitAmt.toString()) console.log('unitAmt: ', unitAmt.toString())
return [ return [
buyTokenAddress, buyTokenAddress,
sellTokenAddress, sellTokenAddress,
srcAmount, srcAmount,
unitAmt, unitAmt,
calldata, calldata.data,
0, 0,
]; ];
} }
let arg = await getArg(); let arg = await getArg();
const spells = [ const spells = [
{ {
connector: connectorName, connector: connectorName,