tests update

This commit is contained in:
Richa-iitr 2022-06-14 13:46:38 +05:30
parent 78e6a3a136
commit 16ef3fc9f4
3 changed files with 13 additions and 67 deletions

View File

@ -146,36 +146,18 @@ describe("Swap | Avalanche", function () {
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
function getSelector(connector: string, unitAmt: any, callData: any) {
function getCallData(connector: string, unitAmt: any, callData: any) {
var abi = [
"function swap(address,address,uint256,uint256,bytes,uint256)",
"function sell(address,address,uint256,uint256,bytes,uint256)"
];
var iface = new ethers.utils.Interface(abi);
var data;
if (connector == "1INCH-A") {
data = iface.encodeFunctionData("sell", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
} else {
data = iface.encodeFunctionData("swap", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
}
const spell = connector === "1INCH-A" ? "sell" : "swap";
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
return data;
}
let dataPara = ethers.utils.hexlify(await getSelector("PARASWAP-A", unitAmtParaswap, calldataPara));
let dataZeroX = ethers.utils.hexlify(await getSelector("ZEROX-A", unitAmt0x, calldataZeroX));
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
let dataZeroX = ethers.utils.hexlify(await getCallData("ZEROX-A", unitAmt0x, calldataZeroX));
let datas = [dataPara, dataZeroX];
let connectors = ["PARASWAP-A", "ZEROX-A"];

View File

@ -162,37 +162,19 @@ describe("Swap | Mainnet", function () {
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
function getSelector(connector: string, unitAmt: any, callData: any) {
function getCallData(connector: string, unitAmt: any, callData: any) {
var abi = [
"function swap(address,address,uint256,uint256,bytes,uint256)",
"function sell(address,address,uint256,uint256,bytes,uint256)"
];
var iface = new ethers.utils.Interface(abi);
var data;
if (connector == "1INCH-A") {
data = iface.encodeFunctionData("sell", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
} else {
data = iface.encodeFunctionData("swap", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
}
const spell = connector === "1INCH-A" ? "sell" : "swap";
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
return data;
}
let data1Inch = ethers.utils.hexlify(await getSelector("1INCH-A", unitAmt1Inch, calldata1Inch));
let dataPara = ethers.utils.hexlify(await getSelector("PARASWAP-A", unitAmtParaswap, calldataPara));
let dataZeroX = ethers.utils.hexlify(await getSelector("ZEROX-A", unitAmt0x, calldataZeroX));
let data1Inch = ethers.utils.hexlify(await getCallData("1INCH-A", unitAmt1Inch, calldata1Inch));
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
let dataZeroX = ethers.utils.hexlify(await getCallData("ZEROX-A", unitAmt0x, calldataZeroX));
let datas = [data1Inch, dataPara, dataZeroX];
let connectors = ["1INCH-A", "PARASWAP-A", "ZEROX-A"];

View File

@ -167,26 +167,8 @@ describe("Swap", function () {
"function sell(address,address,uint256,uint256,bytes,uint256)"
];
var iface = new ethers.utils.Interface(abi);
var data;
if (connector == "1INCH-A") {
data = iface.encodeFunctionData("sell", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
} else {
data = iface.encodeFunctionData("swap", [
buyTokenAddress,
sellTokenAddress,
srcAmount,
unitAmt,
callData,
0
]);
}
const spell = connector === "1INCH-A" ? "sell" : "swap";
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
return data;
}
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));