mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
test: _cast
This commit is contained in:
parent
8c7ac0ed3c
commit
673dada3bb
12
.example.env
Normal file
12
.example.env
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Infra
|
||||||
|
ALCHEMY_ID=""
|
||||||
|
INFURA_ID=""
|
||||||
|
|
||||||
|
# PK
|
||||||
|
DEPLOYER_PK_MAINNET=""
|
||||||
|
DEPLOYER_PK_RINKEBY=""
|
||||||
|
|
||||||
|
# For verifying contracts on Etherscan
|
||||||
|
ETHERSCAN_API_KEY=""
|
||||||
|
|
||||||
|
COINMARKETCAP_API_KEY=""
|
|
@ -1,3 +1,7 @@
|
||||||
|
/**
|
||||||
|
*Submitted for verification at Etherscan.io on 2020-03-26
|
||||||
|
*/
|
||||||
|
|
||||||
pragma solidity 0.6.0;
|
pragma solidity 0.6.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +35,7 @@ contract Controllers is DSMath {
|
||||||
|
|
||||||
// InstaIndex Address.
|
// InstaIndex Address.
|
||||||
address public constant instaIndex =
|
address public constant instaIndex =
|
||||||
0x0000000000000000000000000000000000000000;
|
0x2971AdFa57b20E5a416aE5a708A8655A9c74f723;
|
||||||
|
|
||||||
// Enabled Chief(Address of Chief => bool).
|
// Enabled Chief(Address of Chief => bool).
|
||||||
mapping(address => bool) public chief;
|
mapping(address => bool) public chief;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pragma solidity 0.7.4;
|
pragma solidity 0.7.4;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
// import {console} from "hardhat/console.sol"; // Uncomment this line for using gasLeft Method
|
// import "hardhat/console.sol"; // Uncomment this line for using gasLeft Method
|
||||||
import {
|
import {
|
||||||
TaskReceipt
|
TaskReceipt
|
||||||
} from "@gelatonetwork/core/contracts/gelato_core/interfaces/IGelatoCore.sol";
|
} from "@gelatonetwork/core/contracts/gelato_core/interfaces/IGelatoCore.sol";
|
||||||
|
@ -47,48 +47,60 @@ contract MockDebtBridgeETHBExecutor {
|
||||||
function execViaRoute0(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute0(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log("Gas Cost execViaRoute0: %s", gasLeft - gasleft());
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute0AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute0AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log(
|
||||||
|
// "Gas Cost execViaRoute0AndOpenVault: %s",
|
||||||
|
// gasLeft - gasleft()
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute1(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute1(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log("Gas Cost execViaRoute1: %s", gasLeft - gasleft());
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute1AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute1AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log(
|
||||||
|
// "Gas Cost execViaRoute1AndOpenVault: %s",
|
||||||
|
// gasLeft - gasleft()
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute2(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute2(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log("Gas Cost execViaRoute2: %s", gasLeft - gasleft());
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute2AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute2AndOpenVault(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log(
|
||||||
|
// "Gas Cost execViaRoute2AndOpenVault %s",
|
||||||
|
// gasLeft - gasleft()
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute3(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute3(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log("Gas Cost execViaRoute3: %s", gasLeft - gasleft());
|
||||||
}
|
}
|
||||||
|
|
||||||
function execViaRoute3AndOpenVAult(TaskReceipt memory _taskReceipt) public {
|
function execViaRoute3AndOpenVAult(TaskReceipt memory _taskReceipt) public {
|
||||||
// uint256 gasLeft = gasleft();
|
// uint256 gasLeft = gasleft();
|
||||||
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
IGelatoCore(gelatoCore).exec(_taskReceipt);
|
||||||
// console.log("Gas Cost for Task Execution %s", gasLeft - gasleft());
|
// console.log(
|
||||||
|
// "Gas Cost execViaRoute3AndOpenVAult: %s",
|
||||||
|
// gasLeft - gasleft()
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const { ethers } = hre;
|
const { ethers } = hre;
|
||||||
const { sleep } = require("@gelatonetwork/core");
|
const { sleep } = require("@gelatonetwork/core");
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
|
||||||
|
|
||||||
module.exports = async (hre) => {
|
module.exports = async (hre) => {
|
||||||
if (hre.network.name === "mainnet") {
|
if (hre.network.name === "mainnet") {
|
||||||
|
@ -33,7 +32,7 @@ module.exports = async (hre) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const instaConnectors = await hre.ethers.getContractAt(
|
const instaConnectors = await hre.ethers.getContractAt(
|
||||||
InstaConnector.abi,
|
"InstaConnectors",
|
||||||
hre.network.config.InstaConnectors
|
hre.network.config.InstaConnectors
|
||||||
);
|
);
|
||||||
const connectorLength = await instaConnectors.connectorLength();
|
const connectorLength = await instaConnectors.connectorLength();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const { ethers } = hre;
|
const { ethers } = hre;
|
||||||
const { sleep } = require("@gelatonetwork/core");
|
const { sleep } = require("@gelatonetwork/core");
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
|
||||||
|
|
||||||
module.exports = async (hre) => {
|
module.exports = async (hre) => {
|
||||||
if (hre.network.name === "mainnet") {
|
if (hre.network.name === "mainnet") {
|
||||||
|
@ -32,7 +31,7 @@ module.exports = async (hre) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const instaConnectors = await hre.ethers.getContractAt(
|
const instaConnectors = await hre.ethers.getContractAt(
|
||||||
InstaConnector.abi,
|
"InstaConnectors",
|
||||||
hre.network.config.InstaConnectors
|
hre.network.config.InstaConnectors
|
||||||
);
|
);
|
||||||
const connectorLength = await instaConnectors.connectorLength();
|
const connectorLength = await instaConnectors.connectorLength();
|
||||||
|
@ -63,7 +62,6 @@ module.exports = async (hre) => {
|
||||||
gelatoProvider,
|
gelatoProvider,
|
||||||
],
|
],
|
||||||
gasPrice: hre.network.config.gasPrice,
|
gasPrice: hre.network.config.gasPrice,
|
||||||
nonce: 170,
|
|
||||||
log: true,
|
log: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ module.exports = {
|
||||||
{
|
{
|
||||||
version: "0.6.0",
|
version: "0.6.0",
|
||||||
settings: {
|
settings: {
|
||||||
optimizer: { enabled: process.env.DEBUG ? false : true },
|
optimizer: { enabled: false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@codechecks/client": "0.1.10",
|
"@codechecks/client": "0.1.10",
|
||||||
"@gelatonetwork/core": "1.3.1",
|
"@gelatonetwork/core": "1.4.1",
|
||||||
"@nomiclabs/hardhat-ethers": "2.0.0",
|
"@nomiclabs/hardhat-ethers": "2.0.0",
|
||||||
"@nomiclabs/hardhat-waffle": "2.0.0",
|
"@nomiclabs/hardhat-waffle": "2.0.0",
|
||||||
"@openzeppelin/contracts": "^3.2.0",
|
"@openzeppelin/contracts": "3.2.0",
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"eslint": "7.14.0",
|
"eslint": "7.14.0",
|
||||||
"eslint-config-prettier": "6.15.0",
|
"eslint-config-prettier": "6.15.0",
|
||||||
"ethereum-waffle": "3.2.0",
|
"ethereum-waffle": "3.2.1",
|
||||||
"ethers": "5.0.22",
|
"ethers": "5.0.22",
|
||||||
"hardhat": "2.0.3",
|
"hardhat": "2.0.3",
|
||||||
"hardhat-deploy": "0.7.0-beta.30",
|
"hardhat-deploy": "0.7.0-beta.30",
|
||||||
|
|
|
@ -3,8 +3,8 @@ const hre = require("hardhat");
|
||||||
const { deployments } = hre;
|
const { deployments } = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const setupFullRefinanceMakerToMakerWithVaultBCreationMock = require("./helpers/setupFullRefinanceMakerToMakerWithVaultBCreationMock.mock");
|
const mockSetupFullRefinanceMakerToNewMaker = require("./helpers/setupFullRefinanceMakerToNewMaker.mock");
|
||||||
const exec_ETHA_ETHB_With_Vault_Creation = require("./helpers/services/exec-ETHA-ETHB-WITH-Vault-Creation");
|
const mockExec_ETHA_newETHB = require("./helpers/services/exec-ETHA-newETHB.mock");
|
||||||
|
|
||||||
describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", function () {
|
describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
@ -47,9 +47,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
// Reset back to a fresh forked state during runtime
|
// Reset back to a fresh forked state during runtime
|
||||||
await deployments.fixture();
|
await deployments.fixture();
|
||||||
|
|
||||||
const result = await setupFullRefinanceMakerToMakerWithVaultBCreationMock(
|
const result = await mockSetupFullRefinanceMakerToNewMaker(mockRoute);
|
||||||
mockRoute
|
|
||||||
);
|
|
||||||
|
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
|
@ -162,7 +160,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
expiryDate,
|
expiryDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
await exec_ETHA_ETHB_With_Vault_Creation(
|
await mockExec_ETHA_newETHB(
|
||||||
constants,
|
constants,
|
||||||
contracts,
|
contracts,
|
||||||
wallets,
|
wallets,
|
||||||
|
@ -209,7 +207,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
expiryDate,
|
expiryDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
await exec_ETHA_ETHB_With_Vault_Creation(
|
await mockExec_ETHA_newETHB(
|
||||||
constants,
|
constants,
|
||||||
contracts,
|
contracts,
|
||||||
wallets,
|
wallets,
|
||||||
|
@ -256,7 +254,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
expiryDate,
|
expiryDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
await exec_ETHA_ETHB_With_Vault_Creation(
|
await mockExec_ETHA_newETHB(
|
||||||
constants,
|
constants,
|
||||||
contracts,
|
contracts,
|
||||||
wallets,
|
wallets,
|
||||||
|
@ -303,7 +301,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
expiryDate,
|
expiryDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
await exec_ETHA_ETHB_With_Vault_Creation(
|
await mockExec_ETHA_newETHB(
|
||||||
constants,
|
constants,
|
||||||
contracts,
|
contracts,
|
||||||
wallets,
|
wallets,
|
|
@ -7,7 +7,7 @@ const addProviderModuleDSA = require("../../../../../helpers/services/gelato/add
|
||||||
const createDSA = require("../../../../../helpers/services/InstaDapp/createDSA");
|
const createDSA = require("../../../../../helpers/services/InstaDapp/createDSA");
|
||||||
const initializeMakerCdp = require("../../../../../helpers/services/maker/initializeMakerCdp");
|
const initializeMakerCdp = require("../../../../../helpers/services/maker/initializeMakerCdp");
|
||||||
const createVaultForETHB = require("../../../../../helpers/services/maker/createVaultForETHB");
|
const createVaultForETHB = require("../../../../../helpers/services/maker/createVaultForETHB");
|
||||||
const mockGetSpellsETHAETHBWithVaultCreation = require("./services/getSpells-ETHA-ETHB-With-Vault-Creation.mock");
|
const getMockSpellsETHAnewETHB = require("./services/getSpells-ETHA-newETHB.mock");
|
||||||
const getABI = require("../../../../../helpers/services/getABI");
|
const getABI = require("../../../../../helpers/services/getABI");
|
||||||
|
|
||||||
module.exports = async function (mockRoute) {
|
module.exports = async function (mockRoute) {
|
||||||
|
@ -55,7 +55,7 @@ module.exports = async function (mockRoute) {
|
||||||
contracts.getCdps,
|
contracts.getCdps,
|
||||||
contracts.dssCdpManager
|
contracts.dssCdpManager
|
||||||
);
|
);
|
||||||
const spells = await mockGetSpellsETHAETHBWithVaultCreation(
|
const spells = await getMockSpellsETHAnewETHB(
|
||||||
wallets,
|
wallets,
|
||||||
contracts,
|
contracts,
|
||||||
constants,
|
constants,
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports = async () => {
|
|
||||||
return {
|
|
||||||
PREMIUM: 20,
|
|
||||||
VAULT_CREATION_COST: 100000,
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -4,9 +4,9 @@ const { deployments, ethers } = hre;
|
||||||
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const setupFullRefinanceMakerToCompound = require("./helpers/setupFullRefinanceMakerToCompound");
|
const setupMakerToCompound = require("../helpers/setupMakerToCompound");
|
||||||
const getInstaPoolV2Route = require("../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
const getInstaPoolV2Route = require("../../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
||||||
const getGasCostForFullRefinance = require("../../../../helpers/services/gelato/getGasCostForFullRefinance");
|
const getGasCost = require("../helpers/services/getGasCost");
|
||||||
|
|
||||||
// This test showcases how to submit a task refinancing a Users debt position from
|
// This test showcases how to submit a task refinancing a Users debt position from
|
||||||
// Maker to Compound using Gelato
|
// Maker to Compound using Gelato
|
||||||
|
@ -34,7 +34,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await deployments.fixture();
|
await deployments.fixture();
|
||||||
|
|
||||||
const result = await setupFullRefinanceMakerToCompound();
|
const result = await setupMakerToCompound();
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
vaultId = result.vaultId;
|
vaultId = result.vaultId;
|
||||||
|
@ -205,7 +205,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
contracts.instaPoolResolver
|
contracts.instaPoolResolver
|
||||||
);
|
);
|
||||||
|
|
||||||
const gasCost = await getGasCostForFullRefinance(route);
|
const gasCost = await getGasCost(route);
|
||||||
|
|
||||||
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
||||||
gelatoGasPrice
|
gelatoGasPrice
|
|
@ -3,9 +3,9 @@ const hre = require("hardhat");
|
||||||
const { deployments, ethers } = hre;
|
const { deployments, ethers } = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const setupFullRefinanceMakerToMakerWithVaultBCreation = require("./helpers/setupFullRefinanceMakerToMakerWithVaultBCreation");
|
const setupMakerToNewMaker = require("../helpers/setupMakerToNewMaker");
|
||||||
const getInstaPoolV2Route = require("../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
const getInstaPoolV2Route = require("../../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
||||||
const getGasCostForFullRefinance = require("./../../../../helpers/services/gelato/getGasCostForFullRefinance");
|
const getGasCost = require("../helpers/services/getGasCost");
|
||||||
|
|
||||||
// This test showcases how to submit a task refinancing a Users debt position from
|
// This test showcases how to submit a task refinancing a Users debt position from
|
||||||
// Maker to Compound using Gelato
|
// Maker to Compound using Gelato
|
||||||
|
@ -34,7 +34,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
||||||
// Reset back to a fresh forked state during runtime
|
// Reset back to a fresh forked state during runtime
|
||||||
await deployments.fixture();
|
await deployments.fixture();
|
||||||
|
|
||||||
const result = await setupFullRefinanceMakerToMakerWithVaultBCreation();
|
const result = await setupMakerToNewMaker();
|
||||||
|
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
|
@ -223,7 +223,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gasCost = await getGasCostForFullRefinance(route, true);
|
const gasCost = await getGasCost(route, true);
|
||||||
|
|
||||||
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
||||||
gelatoGasPrice
|
gelatoGasPrice
|
|
@ -3,9 +3,9 @@ const hre = require("hardhat");
|
||||||
const { deployments, ethers } = hre;
|
const { deployments, ethers } = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const setupFullRefinanceMakerToMaker = require("./helpers/setupFullRefinanceMakerToMaker");
|
const setupMakerToMaker = require("../helpers/setupMakerToMaker");
|
||||||
const getInstaPoolV2Route = require("../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
const getInstaPoolV2Route = require("../../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
||||||
const getGasCostForFullRefinance = require("../../../../helpers/services/gelato/getGasCostForFullRefinance");
|
const getGasCost = require("../helpers/services/getGasCost");
|
||||||
|
|
||||||
// This test showcases how to submit a task refinancing a Users debt position from
|
// This test showcases how to submit a task refinancing a Users debt position from
|
||||||
// Maker to Compound using Gelato
|
// Maker to Compound using Gelato
|
||||||
|
@ -35,7 +35,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
// Reset back to a fresh forked state during runtime
|
// Reset back to a fresh forked state during runtime
|
||||||
await deployments.fixture();
|
await deployments.fixture();
|
||||||
|
|
||||||
const result = await setupFullRefinanceMakerToMaker();
|
const result = await setupMakerToMaker();
|
||||||
|
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
|
@ -225,7 +225,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gasCost = await getGasCostForFullRefinance(route);
|
const gasCost = await getGasCost(route);
|
||||||
|
|
||||||
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
||||||
gelatoGasPrice
|
gelatoGasPrice
|
|
@ -3,9 +3,9 @@ const hre = require("hardhat");
|
||||||
const { deployments, ethers } = hre;
|
const { deployments, ethers } = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const setupFullRefinanceMakerToMaker = require("./helpers/setupFullRefinanceMakerToMaker");
|
const setupMakerToMaker = require("../helpers/setupMakerToMaker");
|
||||||
const getInstaPoolV2Route = require("../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
const getInstaPoolV2Route = require("../../../../../helpers/services/InstaDapp/getInstaPoolV2Route");
|
||||||
const getGasCostForFullRefinance = require("../../../../helpers/services/gelato/getGasCostForFullRefinance");
|
const getGasCost = require("../helpers/services/getGasCost");
|
||||||
|
|
||||||
// This test showcases how to submit a task refinancing a Users debt position from
|
// This test showcases how to submit a task refinancing a Users debt position from
|
||||||
// Maker to Compound using Gelato
|
// Maker to Compound using Gelato
|
||||||
|
@ -35,7 +35,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
||||||
// Reset back to a fresh forked state during runtime
|
// Reset back to a fresh forked state during runtime
|
||||||
await deployments.fixture();
|
await deployments.fixture();
|
||||||
|
|
||||||
const result = await setupFullRefinanceMakerToMaker();
|
const result = await setupMakerToMaker();
|
||||||
|
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
|
@ -244,7 +244,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gasCost = await getGasCostForFullRefinance(route, true);
|
const gasCost = await getGasCost(route, true);
|
||||||
|
|
||||||
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
const gasFeesPaidFromCol = ethers.BigNumber.from(gasCost).mul(
|
||||||
gelatoGasPrice
|
gelatoGasPrice
|
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = {
|
||||||
|
PREMIUM: 20,
|
||||||
|
VAULT_CREATION_COST: 100000,
|
||||||
|
};
|
|
@ -1,8 +1,7 @@
|
||||||
const gasConstants = require("../../constants/GasConstant");
|
const { PREMIUM, VAULT_CREATION_COST } = require("../constants/costs");
|
||||||
|
|
||||||
module.exports = async function (route, withVaultCreation) {
|
module.exports = (route, withVaultCreation) => {
|
||||||
let rawGasCost;
|
let rawGasCost;
|
||||||
const gasCons = await gasConstants();
|
|
||||||
switch (route) {
|
switch (route) {
|
||||||
case 0:
|
case 0:
|
||||||
rawGasCost = 2519000; // 2290000 * 1,1 // gas left method measure : 2290000 - 2106637 = 183363 | gas reporter : 2290000 - 1789126 = 500874
|
rawGasCost = 2519000; // 2290000 * 1,1 // gas left method measure : 2290000 - 2106637 = 183363 | gas reporter : 2290000 - 1789126 = 500874
|
||||||
|
@ -21,7 +20,6 @@ module.exports = async function (route, withVaultCreation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return withVaultCreation
|
return withVaultCreation
|
||||||
? ((rawGasCost + gasCons.VAULT_CREATION_COST) * (100 + gasCons.PREMIUM)) /
|
? ((rawGasCost + VAULT_CREATION_COST) * (100 + PREMIUM)) / 100
|
||||||
100
|
: (rawGasCost * (100 + PREMIUM)) / 100;
|
||||||
: (rawGasCost * (100 + gasCons.PREMIUM)) / 100;
|
|
||||||
};
|
};
|
|
@ -7,7 +7,7 @@ const providerAssignsExecutor = require("../../../../../helpers/services/gelato/
|
||||||
const addProviderModuleDSA = require("../../../../../helpers/services/gelato/addProviderModuleDSA");
|
const addProviderModuleDSA = require("../../../../../helpers/services/gelato/addProviderModuleDSA");
|
||||||
const createDSA = require("../../../../../helpers/services/InstaDapp/createDSA");
|
const createDSA = require("../../../../../helpers/services/InstaDapp/createDSA");
|
||||||
const initializeMakerCdp = require("../../../../../helpers/services/maker/initializeMakerCdp");
|
const initializeMakerCdp = require("../../../../../helpers/services/maker/initializeMakerCdp");
|
||||||
const getSpellsEthAEthBWithVaultCreation = require("./services/getSpells-ETHA-ETHB-With-Vault-Creation");
|
const getSpellsEthAEthBWithVaultCreation = require("./services/getSpells-ETHA-newETHB");
|
||||||
const getABI = require("../../../../../helpers/services/getABI");
|
const getABI = require("../../../../../helpers/services/getABI");
|
||||||
|
|
||||||
module.exports = async function () {
|
module.exports = async function () {
|
|
@ -0,0 +1,263 @@
|
||||||
|
const { expect } = require("chai");
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const { deployments, ethers } = hre;
|
||||||
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
|
const setupMakerToMaker = require("../helpers/setupMakerToMaker");
|
||||||
|
|
||||||
|
// This test showcases how to submit a task refinancing a Users debt position from
|
||||||
|
// Maker to Compound using Gelato
|
||||||
|
describe("Security: _cast function by example of ETHA-ETHB with disabled ConnectGelatoProviderPayment", function () {
|
||||||
|
this.timeout(0);
|
||||||
|
if (hre.network.name !== "hardhat") {
|
||||||
|
console.error("Test Suite is meant to be run on hardhat only");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let contracts;
|
||||||
|
let wallets;
|
||||||
|
let constants;
|
||||||
|
let ABI;
|
||||||
|
|
||||||
|
// Payload Params for ConnectGelatoFullDebtBridgeFromMaker and ConditionMakerVaultUnsafe
|
||||||
|
let vaultAId;
|
||||||
|
let vaultBId;
|
||||||
|
|
||||||
|
// For TaskSpec and for Task
|
||||||
|
let gelatoDebtBridgeSpells = [];
|
||||||
|
|
||||||
|
// Cross test var
|
||||||
|
let taskReceipt;
|
||||||
|
|
||||||
|
before(async function () {
|
||||||
|
// Reset back to a fresh forked state during runtime
|
||||||
|
await deployments.fixture();
|
||||||
|
|
||||||
|
const result = await setupMakerToMaker();
|
||||||
|
|
||||||
|
wallets = result.wallets;
|
||||||
|
contracts = result.contracts;
|
||||||
|
vaultAId = result.vaultAId;
|
||||||
|
vaultBId = result.vaultBId;
|
||||||
|
gelatoDebtBridgeSpells = result.spells;
|
||||||
|
|
||||||
|
ABI = result.ABI;
|
||||||
|
constants = result.constants;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#1: DSA authorizes Gelato to cast spells.", async function () {
|
||||||
|
//#region User give authorization to gelato to use his DSA on his behalf.
|
||||||
|
|
||||||
|
// Instadapp DSA contract give the possibility to the user to delegate
|
||||||
|
// action by giving authorization.
|
||||||
|
// In this case user give authorization to gelato to execute
|
||||||
|
// task for him if needed.
|
||||||
|
|
||||||
|
await contracts.dsa.cast(
|
||||||
|
[hre.network.config.ConnectAuth],
|
||||||
|
[
|
||||||
|
await hre.run("abi-encode-withselector", {
|
||||||
|
abi: ABI.ConnectAuthABI,
|
||||||
|
functionname: "add",
|
||||||
|
inputs: [contracts.gelatoCore.address],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
wallets.userAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await contracts.dsa.isAuth(contracts.gelatoCore.address)).to.be.true;
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#2: User submits automated Debt Bridge task to Gelato via DSA", async function () {
|
||||||
|
//#region User submit a Debt Refinancing task if market move against him
|
||||||
|
|
||||||
|
// User submit the refinancing task if market move against him.
|
||||||
|
// So in this case if the maker vault go to the unsafe area
|
||||||
|
// the refinancing task will be executed and the position
|
||||||
|
// will be split on two position on maker and compound.
|
||||||
|
// It will be done through a algorithm that will optimize the
|
||||||
|
// total borrow rate.
|
||||||
|
|
||||||
|
const conditionMakerVaultUnsafeObj = new GelatoCoreLib.Condition({
|
||||||
|
inst: contracts.conditionMakerVaultUnsafe.address,
|
||||||
|
data: await contracts.conditionMakerVaultUnsafe.getConditionData(
|
||||||
|
vaultAId,
|
||||||
|
contracts.priceOracleResolver.address,
|
||||||
|
await hre.run("abi-encode-withselector", {
|
||||||
|
abi: (await deployments.getArtifact("PriceOracleResolver")).abi,
|
||||||
|
functionname: "getMockPrice",
|
||||||
|
inputs: [wallets.userAddress],
|
||||||
|
}),
|
||||||
|
constants.MIN_COL_RATIO_MAKER
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
const conditionDebtBridgeIsAffordableObj = new GelatoCoreLib.Condition({
|
||||||
|
inst: contracts.conditionDebtBridgeIsAffordable.address,
|
||||||
|
data: await contracts.conditionDebtBridgeIsAffordable.getConditionData(
|
||||||
|
vaultAId,
|
||||||
|
constants.MAX_FEES_IN_PERCENT
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
const conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
||||||
|
inst: contracts.conditionDestVaultWillBeSafe.address,
|
||||||
|
data: await contracts.conditionDestVaultWillBeSafe.getConditionData(
|
||||||
|
vaultAId,
|
||||||
|
vaultBId,
|
||||||
|
"ETH-B"
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
// ======= GELATO TASK SETUP ======
|
||||||
|
const refinanceFromEthAToBIfVaultUnsafe = new GelatoCoreLib.Task({
|
||||||
|
conditions: [
|
||||||
|
conditionMakerVaultUnsafeObj,
|
||||||
|
conditionDebtBridgeIsAffordableObj,
|
||||||
|
conditionDestVaultWillBeSafe,
|
||||||
|
],
|
||||||
|
actions: gelatoDebtBridgeSpells,
|
||||||
|
});
|
||||||
|
|
||||||
|
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
||||||
|
addr: wallets.gelatoProviderAddress, // Gelato Provider Address
|
||||||
|
module: contracts.dsaProviderModule.address, // Gelato DSA module
|
||||||
|
});
|
||||||
|
|
||||||
|
const expiryDate = 0;
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
contracts.dsa.cast(
|
||||||
|
[contracts.connectGelato.address], // targets
|
||||||
|
[
|
||||||
|
await hre.run("abi-encode-withselector", {
|
||||||
|
abi: ABI.ConnectGelatoABI,
|
||||||
|
functionname: "submitTask",
|
||||||
|
inputs: [
|
||||||
|
gelatoExternalProvider,
|
||||||
|
refinanceFromEthAToBIfVaultUnsafe,
|
||||||
|
expiryDate,
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
], // datas
|
||||||
|
wallets.userAddress, // origin
|
||||||
|
{
|
||||||
|
gasLimit: 5000000,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
).to.emit(contracts.gelatoCore, "LogTaskSubmitted");
|
||||||
|
|
||||||
|
taskReceipt = new GelatoCoreLib.TaskReceipt({
|
||||||
|
id: await contracts.gelatoCore.currentTaskReceiptId(),
|
||||||
|
userProxy: contracts.dsa.address,
|
||||||
|
provider: gelatoExternalProvider,
|
||||||
|
tasks: [refinanceFromEthAToBIfVaultUnsafe],
|
||||||
|
expiryDate,
|
||||||
|
});
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
});
|
||||||
|
|
||||||
|
// This test showcases the part which is automatically done by the Gelato Executor Network on mainnet
|
||||||
|
// Bots constatly check whether the submitted task is executable (by calling canExec)
|
||||||
|
// If the task becomes executable (returns "OK"), the "exec" function will be called
|
||||||
|
// which will execute the debt refinancing on behalf of the user
|
||||||
|
it("#3: Test Case: Task execution with LogExecReverted due to disabled connector", async function () {
|
||||||
|
// Steps
|
||||||
|
// Step 1: Market Move against the user (Mock)
|
||||||
|
// Step 2: Executor execute the user's task
|
||||||
|
|
||||||
|
//#region Step 1 Market Move against the user (Mock)
|
||||||
|
|
||||||
|
// Ether market price went from the current price to 250$
|
||||||
|
|
||||||
|
const gelatoGasPrice = await hre.run("fetchGelatoGasPrice");
|
||||||
|
expect(gelatoGasPrice).to.be.lte(constants.GAS_PRICE_CEIL);
|
||||||
|
|
||||||
|
// TO DO: base mock price off of real price data
|
||||||
|
await contracts.priceOracleResolver.setMockPrice(
|
||||||
|
ethers.utils.parseUnits("400", 18)
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
|
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||||
|
|
||||||
|
// TO DO: base mock price off of real price data
|
||||||
|
await contracts.priceOracleResolver.setMockPrice(
|
||||||
|
ethers.utils.parseUnits("250", 18)
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
// SECURITY TEST CASE: we disable a connector to be called as part of the Task
|
||||||
|
// and expect this to cause the _cast
|
||||||
|
const instaConnectors = await hre.ethers.getContractAt(
|
||||||
|
"InstaConnectors",
|
||||||
|
hre.network.config.InstaConnectors
|
||||||
|
);
|
||||||
|
|
||||||
|
const { address: connectGelatoProviderPayment } = await ethers.getContract(
|
||||||
|
"ConnectGelatoProviderPayment"
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await instaConnectors.isConnector([connectGelatoProviderPayment])).to
|
||||||
|
.be.true;
|
||||||
|
|
||||||
|
const instaMaster = await ethers.provider.getSigner(
|
||||||
|
hre.network.config.InstaMaster
|
||||||
|
);
|
||||||
|
|
||||||
|
await wallets.userWallet.sendTransaction({
|
||||||
|
to: await instaMaster.getAddress(),
|
||||||
|
value: ethers.utils.parseEther("0.1"),
|
||||||
|
});
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_impersonateAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
|
|
||||||
|
await instaConnectors
|
||||||
|
.connect(instaMaster)
|
||||||
|
.disable(connectGelatoProviderPayment);
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_stopImpersonatingAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
|
|
||||||
|
// await expect(
|
||||||
|
// contracts.gelatoCore
|
||||||
|
// .connect(wallets.gelatoExecutorWallet)
|
||||||
|
// .exec(taskReceipt, {
|
||||||
|
// gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||||
|
// gasLimit: constants.GAS_LIMIT,
|
||||||
|
// })
|
||||||
|
// ).to.emit(contracts.gelatoCore, "LogExecReverted");
|
||||||
|
|
||||||
|
const txResponse = await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
|
.exec(taskReceipt, {
|
||||||
|
gasPrice: gelatoGasPrice,
|
||||||
|
gasLimit: constants.GAS_LIMIT,
|
||||||
|
});
|
||||||
|
const { blockHash } = await txResponse.wait();
|
||||||
|
const logs = await ethers.provider.getLogs({ blockHash });
|
||||||
|
expect(
|
||||||
|
logs.some(
|
||||||
|
(log) =>
|
||||||
|
contracts.gelatoCore.interface.parseLog(log).args.reason ===
|
||||||
|
"GelatoCore._exec:ConnectGelatoDataFullMakerToMaker._cast:not-connector"
|
||||||
|
)
|
||||||
|
).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,7 +3,7 @@ const hre = require("hardhat");
|
||||||
const { deployments, ethers } = hre;
|
const { deployments, ethers } = hre;
|
||||||
|
|
||||||
const InstaPoolResolver = require("../../../artifacts/contracts/interfaces/InstaDapp/resolvers/IInstaPoolResolver.sol/IInstaPoolResolver.json");
|
const InstaPoolResolver = require("../../../artifacts/contracts/interfaces/InstaDapp/resolvers/IInstaPoolResolver.sol/IInstaPoolResolver.json");
|
||||||
const getGasCostForFullRefinance = require("./../../helpers/services/gelato/getGasCostForFullRefinance");
|
const getGasCost = require("../../integration/debt_bridge/from_maker/full/helpers/services/getGasCost");
|
||||||
const DAI = hre.network.config.DAI;
|
const DAI = hre.network.config.DAI;
|
||||||
|
|
||||||
describe("FGelatoDebtBridge Unit Tests", function () {
|
describe("FGelatoDebtBridge Unit Tests", function () {
|
||||||
|
@ -76,56 +76,56 @@ describe("FGelatoDebtBridge Unit Tests", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 3142800 gas limit for route 0 (Dydx) and new vault", async function () {
|
it("getGasCostMakerToMaker should return 3142800 gas limit for route 0 (Dydx) and new vault", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(0, true);
|
const expectedGasCost = await getGasCost(0, true);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 0)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 0)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 3022800 gas limit for route 0 (Dydx)", async function () {
|
it("getGasCostMakerToMaker should return 3022800 gas limit for route 0 (Dydx)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(0);
|
const expectedGasCost = await getGasCost(0);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 0)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 0)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 3888600 gas limit for route 1 (maker) and new vault", async function () {
|
it("getGasCostMakerToMaker should return 3888600 gas limit for route 1 (maker) and new vault", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(1, true);
|
const expectedGasCost = await getGasCost(1, true);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 1)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 1)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 3768600 gas limit for route 1 (maker)", async function () {
|
it("getGasCostMakerToMaker should return 3768600 gas limit for route 1 (maker)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(1);
|
const expectedGasCost = await getGasCost(1);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 1)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 1)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 4885200 gas limit for route 2 (compound) and new vault", async function () {
|
it("getGasCostMakerToMaker should return 4885200 gas limit for route 2 (compound) and new vault", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(2, true);
|
const expectedGasCost = await getGasCost(2, true);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 2)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 2)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 4765200 gas limit for route 2 (compound)", async function () {
|
it("getGasCostMakerToMaker should return 4765200 gas limit for route 2 (compound)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(2);
|
const expectedGasCost = await getGasCost(2);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 2)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 2)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 5334000 gas limit for route 3 (aave) and new vault", async function () {
|
it("getGasCostMakerToMaker should return 5334000 gas limit for route 3 (aave) and new vault", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(3, true);
|
const expectedGasCost = await getGasCost(3, true);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 3)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(true, 3)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToMaker should return 5214000 gas limit for route 3 (aave)", async function () {
|
it("getGasCostMakerToMaker should return 5214000 gas limit for route 3 (aave)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(3);
|
const expectedGasCost = await getGasCost(3);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 3)
|
await fGelatoDebtBridgeMock.getGasCostMakerToMaker(false, 3)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
|
@ -140,28 +140,28 @@ describe("FGelatoDebtBridge Unit Tests", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToCompound should return 3022800 gas limit for route 0 (Dydx)", async function () {
|
it("getGasCostMakerToCompound should return 3022800 gas limit for route 0 (Dydx)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(0);
|
const expectedGasCost = await getGasCost(0);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(0)
|
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(0)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToCompound should return 3768600 gas limit for route 1 (Maker)", async function () {
|
it("getGasCostMakerToCompound should return 3768600 gas limit for route 1 (Maker)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(1);
|
const expectedGasCost = await getGasCost(1);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(1)
|
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(1)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToCompound should return 4765200 gas limit for route 2 (Compound)", async function () {
|
it("getGasCostMakerToCompound should return 4765200 gas limit for route 2 (Compound)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(2);
|
const expectedGasCost = await getGasCost(2);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(2)
|
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(2)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getGasCostMakerToCompound should return 5214000 gas limit for route 3 (Aave)", async function () {
|
it("getGasCostMakerToCompound should return 5214000 gas limit for route 3 (Aave)", async function () {
|
||||||
const expectedGasCost = await getGasCostForFullRefinance(3);
|
const expectedGasCost = await getGasCost(3);
|
||||||
expect(
|
expect(
|
||||||
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(3)
|
await fGelatoDebtBridgeMock.getGasCostMakerToCompound(3)
|
||||||
).to.be.equal(expectedGasCost);
|
).to.be.equal(expectedGasCost);
|
||||||
|
|
70
yarn.lock
70
yarn.lock
|
@ -81,18 +81,18 @@
|
||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
strip-json-comments "^3.1.1"
|
strip-json-comments "^3.1.1"
|
||||||
|
|
||||||
"@ethereum-waffle/chai@^3.2.0":
|
"@ethereum-waffle/chai@^3.2.1":
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@ethereum-waffle/chai/-/chai-3.2.0.tgz#f75465e447358db0fde967b26cf10adbe5365380"
|
resolved "https://registry.yarnpkg.com/@ethereum-waffle/chai/-/chai-3.2.1.tgz#5cb542b2a323adf0bc2dda00f48b0eb85944d8ab"
|
||||||
integrity sha512-3mvI7luX8FSAX2yjklSN8rw8F8RNaMzZDadDkS9JvmoM4khByGe3mDn8rVroneBAcFusXJfL6BEssGj5S4mD7Q==
|
integrity sha512-0aG946J1+2Gg7WnEjtwPEWe+xwLTeBTy6LpCnGecosMf3YINkaf9Xv3Sd7CrXBR88ihCoUhfzfmOloMHIAQPAg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ethereum-waffle/provider" "^3.2.0"
|
"@ethereum-waffle/provider" "^3.2.1"
|
||||||
ethers "^5.0.0"
|
ethers "^5.0.0"
|
||||||
|
|
||||||
"@ethereum-waffle/compiler@^3.2.0":
|
"@ethereum-waffle/compiler@^3.2.1":
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@ethereum-waffle/compiler/-/compiler-3.2.0.tgz#3d5cccc8171ff61a0069d9558fb567ddd45b6b4e"
|
resolved "https://registry.yarnpkg.com/@ethereum-waffle/compiler/-/compiler-3.2.1.tgz#612a9056285a94ce28eb57b895770ad10e438bf9"
|
||||||
integrity sha512-Tg8YjbcVKQkNwhbiBf9Z4kKPolPO0IB+iYwAdpXNwgyMOH74guIHhFGtKOCPoY4VXR75erGgeQIt2PzIn/szCA==
|
integrity sha512-URSsbTp4g8HPHAaA4KiAD6Aya9WPx/TULfOr+YpjCJ6YWXqE9wwi3ubf9qJUQxu6W6PsiczBaQhVhpI9RLoVUA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@resolver-engine/imports" "^0.3.3"
|
"@resolver-engine/imports" "^0.3.3"
|
||||||
"@resolver-engine/imports-fs" "^0.3.3"
|
"@resolver-engine/imports-fs" "^0.3.3"
|
||||||
|
@ -103,29 +103,29 @@
|
||||||
node-fetch "^2.6.0"
|
node-fetch "^2.6.0"
|
||||||
solc "^0.6.3"
|
solc "^0.6.3"
|
||||||
|
|
||||||
"@ethereum-waffle/ens@^3.2.0":
|
"@ethereum-waffle/ens@^3.2.1":
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@ethereum-waffle/ens/-/ens-3.2.0.tgz#26f7b2048a422eae5ce39a855e519e01ebc06953"
|
resolved "https://registry.yarnpkg.com/@ethereum-waffle/ens/-/ens-3.2.1.tgz#9f369112d62f7aa88d010be4d133b6d0f5e8c492"
|
||||||
integrity sha512-n4EYJDLAwN2X+2EsZMasXRlz5gYp39Tmy18RU4f6ZdnTNuVNw1BNkCC9VzrQooHGvHLjKZFPvcl+FRfBO+Xcyw==
|
integrity sha512-dXv/Mb8EgEYOKv2jjmkFNFCmSjNv8nPk1Gaegc0J/KXWuTU6CBOhWet7YS5joGO8ORK21MvN2qVgcQj+FYw0Dw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ensdomains/ens" "^0.4.4"
|
"@ensdomains/ens" "^0.4.4"
|
||||||
"@ensdomains/resolver" "^0.2.4"
|
"@ensdomains/resolver" "^0.2.4"
|
||||||
ethers "^5.0.1"
|
ethers "^5.0.1"
|
||||||
|
|
||||||
"@ethereum-waffle/mock-contract@^3.2.0":
|
"@ethereum-waffle/mock-contract@^3.2.1":
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@ethereum-waffle/mock-contract/-/mock-contract-3.2.0.tgz#be9441060f8b58f1d7e344f74e5dd158d41a7c45"
|
resolved "https://registry.yarnpkg.com/@ethereum-waffle/mock-contract/-/mock-contract-3.2.1.tgz#bf5f63f61c9749eb3270108893a88ff161e68f58"
|
||||||
integrity sha512-TfBt9ka2DXVxxIBee3WB0gSLgWCo9ZegqcdXjCz0QGlu+dEhL8W3+aLDYQoyx3kwlecfNl8EQ1V7g7GH8wrlMg==
|
integrity sha512-39GMp/IqsHF+3j3XK38cWA+nX7Q6ABfMsYkuAjtfpTguTFQKXx2C1/VJZwGOyb4de2pl4bssmN37VEraB3NWbQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ethersproject/abi" "^5.0.1"
|
"@ethersproject/abi" "^5.0.1"
|
||||||
ethers "^5.0.1"
|
ethers "^5.0.1"
|
||||||
|
|
||||||
"@ethereum-waffle/provider@^3.2.0":
|
"@ethereum-waffle/provider@^3.2.1":
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/@ethereum-waffle/provider/-/provider-3.2.0.tgz#501d4bbf04ffc01dced0107dcc9e20f24354387f"
|
resolved "https://registry.yarnpkg.com/@ethereum-waffle/provider/-/provider-3.2.1.tgz#d84c0603936f09afa69ecb671d56f527e9818e71"
|
||||||
integrity sha512-U9KyjMKIZuK4gi2kzWIJkAXYjtg0aIlEQ0F4yKqHMRyqAiSM6M4VJgn6tHisxe3Ev9z/jSnutKT8dyAEwlIYdw==
|
integrity sha512-doG18hThqldsYcZIIO0YoiwV+ERx0dCVY6bkg4FKZtoymNelf15zNycb881c6QD9RnLuz6A2Jp9lmnrAD+IvYQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ethereum-waffle/ens" "^3.2.0"
|
"@ethereum-waffle/ens" "^3.2.1"
|
||||||
ethers "^5.0.1"
|
ethers "^5.0.1"
|
||||||
ganache-core "^2.10.2"
|
ganache-core "^2.10.2"
|
||||||
patch-package "^6.2.2"
|
patch-package "^6.2.2"
|
||||||
|
@ -872,10 +872,10 @@
|
||||||
"@ethersproject/properties" "^5.0.3"
|
"@ethersproject/properties" "^5.0.3"
|
||||||
"@ethersproject/strings" "^5.0.4"
|
"@ethersproject/strings" "^5.0.4"
|
||||||
|
|
||||||
"@gelatonetwork/core@1.3.1":
|
"@gelatonetwork/core@1.4.1":
|
||||||
version "1.3.1"
|
version "1.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/@gelatonetwork/core/-/core-1.3.1.tgz#cff0cb4d06a2bbb7859f3918995f44efc692bb11"
|
resolved "https://registry.yarnpkg.com/@gelatonetwork/core/-/core-1.4.1.tgz#4e13368da1a0346217cf76e1ef5c1d0adcfdc870"
|
||||||
integrity sha512-xnl9jskZfAwwaJlIxmiXI+Cm1eKnPoDDBbMPlkNJ2NCDxoDOq/6tjHm9VXIVPDTjpqmNSPzQJjDxFWDrKUrosQ==
|
integrity sha512-6heuXhIewQ4B2qGe8QGg0het9/ixwIYfIE02QU9ATK/ULpBvZKsmj0NQ5K8l54XyoRvpNXhQYRendmSBE7Z7Sw==
|
||||||
|
|
||||||
"@nomiclabs/ethereumjs-vm@^4.1.1":
|
"@nomiclabs/ethereumjs-vm@^4.1.1":
|
||||||
version "4.2.0"
|
version "4.2.0"
|
||||||
|
@ -911,7 +911,7 @@
|
||||||
"@types/sinon-chai" "^3.2.3"
|
"@types/sinon-chai" "^3.2.3"
|
||||||
"@types/web3" "1.0.19"
|
"@types/web3" "1.0.19"
|
||||||
|
|
||||||
"@openzeppelin/contracts@^3.2.0":
|
"@openzeppelin/contracts@3.2.0":
|
||||||
version "3.2.0"
|
version "3.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.2.0.tgz#3e6b3a7662d8ed64271ade96ef42655db983fd9d"
|
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.2.0.tgz#3e6b3a7662d8ed64271ade96ef42655db983fd9d"
|
||||||
integrity sha512-bUOmkSoPkjnUyMiKo6RYnb0VHBk5D9KKDAgNLzF41aqAM3TeE0yGdFF5dVRcV60pZdJLlyFT/jjXIZCWyyEzAQ==
|
integrity sha512-bUOmkSoPkjnUyMiKo6RYnb0VHBk5D9KKDAgNLzF41aqAM3TeE0yGdFF5dVRcV60pZdJLlyFT/jjXIZCWyyEzAQ==
|
||||||
|
@ -3739,15 +3739,15 @@ ethereum-cryptography@^0.1.2, ethereum-cryptography@^0.1.3:
|
||||||
secp256k1 "^4.0.1"
|
secp256k1 "^4.0.1"
|
||||||
setimmediate "^1.0.5"
|
setimmediate "^1.0.5"
|
||||||
|
|
||||||
ethereum-waffle@3.2.0:
|
ethereum-waffle@3.2.1:
|
||||||
version "3.2.0"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.2.0.tgz#1cea66fece731ea281e9d68046056caed2f2af84"
|
resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.2.1.tgz#9d6d6b93484c5e1b77dfdeb646c050ed877e836e"
|
||||||
integrity sha512-XmLvbGE47u+6haOT/vBwx/2ifemlKv4Uop1ebnccnBXD0xmTK2Qnk/FonwHtkHX+cUxj+Ax+3c/1fYDogEvcZw==
|
integrity sha512-Fhg7BaBuV+Xo5XT+NEC3UTKGunvpq+iQPglZbIAJF6ZcwQwkiKfJUDuB0ZSkg5ntbRS4gpahfoXj1nTzdtx8UA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@ethereum-waffle/chai" "^3.2.0"
|
"@ethereum-waffle/chai" "^3.2.1"
|
||||||
"@ethereum-waffle/compiler" "^3.2.0"
|
"@ethereum-waffle/compiler" "^3.2.1"
|
||||||
"@ethereum-waffle/mock-contract" "^3.2.0"
|
"@ethereum-waffle/mock-contract" "^3.2.1"
|
||||||
"@ethereum-waffle/provider" "^3.2.0"
|
"@ethereum-waffle/provider" "^3.2.1"
|
||||||
ethers "^5.0.1"
|
ethers "^5.0.1"
|
||||||
|
|
||||||
ethereumjs-abi@0.6.5:
|
ethereumjs-abi@0.6.5:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user