mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
tests update
This commit is contained in:
parent
78e6a3a136
commit
16ef3fc9f4
|
@ -146,36 +146,18 @@ describe("Swap | Avalanche", function () {
|
||||||
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
|
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
|
||||||
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
|
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
|
||||||
|
|
||||||
function getSelector(connector: string, unitAmt: any, callData: any) {
|
function getCallData(connector: string, unitAmt: any, callData: any) {
|
||||||
var abi = [
|
var abi = [
|
||||||
"function swap(address,address,uint256,uint256,bytes,uint256)",
|
"function swap(address,address,uint256,uint256,bytes,uint256)",
|
||||||
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
||||||
];
|
];
|
||||||
var iface = new ethers.utils.Interface(abi);
|
var iface = new ethers.utils.Interface(abi);
|
||||||
var data;
|
const spell = connector === "1INCH-A" ? "sell" : "swap";
|
||||||
if (connector == "1INCH-A") {
|
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
|
||||||
data = iface.encodeFunctionData("sell", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
data = iface.encodeFunctionData("swap", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
let dataPara = ethers.utils.hexlify(await getSelector("PARASWAP-A", unitAmtParaswap, calldataPara));
|
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
|
||||||
let dataZeroX = ethers.utils.hexlify(await getSelector("ZEROX-A", unitAmt0x, calldataZeroX));
|
let dataZeroX = ethers.utils.hexlify(await getCallData("ZEROX-A", unitAmt0x, calldataZeroX));
|
||||||
let datas = [dataPara, dataZeroX];
|
let datas = [dataPara, dataZeroX];
|
||||||
|
|
||||||
let connectors = ["PARASWAP-A", "ZEROX-A"];
|
let connectors = ["PARASWAP-A", "ZEROX-A"];
|
||||||
|
|
|
@ -162,37 +162,19 @@ describe("Swap | Mainnet", function () {
|
||||||
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
|
let unitAmt0x = calculateUnitAmt(buyTokenAmountZeroX);
|
||||||
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
|
let unitAmtParaswap = calculateUnitAmt(buyTokenAmountParaswap);
|
||||||
|
|
||||||
function getSelector(connector: string, unitAmt: any, callData: any) {
|
function getCallData(connector: string, unitAmt: any, callData: any) {
|
||||||
var abi = [
|
var abi = [
|
||||||
"function swap(address,address,uint256,uint256,bytes,uint256)",
|
"function swap(address,address,uint256,uint256,bytes,uint256)",
|
||||||
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
||||||
];
|
];
|
||||||
var iface = new ethers.utils.Interface(abi);
|
var iface = new ethers.utils.Interface(abi);
|
||||||
var data;
|
const spell = connector === "1INCH-A" ? "sell" : "swap";
|
||||||
if (connector == "1INCH-A") {
|
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
|
||||||
data = iface.encodeFunctionData("sell", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
data = iface.encodeFunctionData("swap", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
let data1Inch = ethers.utils.hexlify(await getSelector("1INCH-A", unitAmt1Inch, calldata1Inch));
|
let data1Inch = ethers.utils.hexlify(await getCallData("1INCH-A", unitAmt1Inch, calldata1Inch));
|
||||||
let dataPara = ethers.utils.hexlify(await getSelector("PARASWAP-A", unitAmtParaswap, calldataPara));
|
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
|
||||||
let dataZeroX = ethers.utils.hexlify(await getSelector("ZEROX-A", unitAmt0x, calldataZeroX));
|
let dataZeroX = ethers.utils.hexlify(await getCallData("ZEROX-A", unitAmt0x, calldataZeroX));
|
||||||
let datas = [data1Inch, dataPara, dataZeroX];
|
let datas = [data1Inch, dataPara, dataZeroX];
|
||||||
|
|
||||||
let connectors = ["1INCH-A", "PARASWAP-A", "ZEROX-A"];
|
let connectors = ["1INCH-A", "PARASWAP-A", "ZEROX-A"];
|
||||||
|
|
|
@ -167,26 +167,8 @@ describe("Swap", function () {
|
||||||
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
"function sell(address,address,uint256,uint256,bytes,uint256)"
|
||||||
];
|
];
|
||||||
var iface = new ethers.utils.Interface(abi);
|
var iface = new ethers.utils.Interface(abi);
|
||||||
var data;
|
const spell = connector === "1INCH-A" ? "sell" : "swap";
|
||||||
if (connector == "1INCH-A") {
|
let data = iface.encodeFunctionData(spell, [buyTokenAddress, sellTokenAddress, srcAmount, unitAmt, callData, 0]);
|
||||||
data = iface.encodeFunctionData("sell", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
data = iface.encodeFunctionData("swap", [
|
|
||||||
buyTokenAddress,
|
|
||||||
sellTokenAddress,
|
|
||||||
srcAmount,
|
|
||||||
unitAmt,
|
|
||||||
callData,
|
|
||||||
0
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
|
let dataPara = ethers.utils.hexlify(await getCallData("PARASWAP-A", unitAmtParaswap, calldataPara));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user