mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
feat: refactored test-suite for hardhat-deploy-ethers
This commit is contained in:
parent
ce4584a6a5
commit
3da14b7e90
|
|
@ -38,12 +38,22 @@ contract ConnectGelatoProviderPayment is
|
||||||
uint256 internal immutable _id;
|
uint256 internal immutable _id;
|
||||||
address internal immutable _this;
|
address internal immutable _this;
|
||||||
|
|
||||||
constructor(uint256 id, address _gelatoProvider) {
|
constructor(uint256 id, address _gelatoProvider)
|
||||||
|
noAddressZeroProvider(_gelatoProvider)
|
||||||
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_this = address(this);
|
_this = address(this);
|
||||||
gelatoProvider = _gelatoProvider;
|
gelatoProvider = _gelatoProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifier noAddressZeroProvider(address _gelatoProvider) {
|
||||||
|
require(
|
||||||
|
_gelatoProvider != address(0x0),
|
||||||
|
"ConnectGelatoProviderPayment.noAddressZeroProvider"
|
||||||
|
);
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Connector Details
|
/// @dev Connector Details
|
||||||
function connectorID()
|
function connectorID()
|
||||||
external
|
external
|
||||||
|
|
@ -55,7 +65,12 @@ contract ConnectGelatoProviderPayment is
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Set the gelatoProvider address that will be paid for executing a task
|
/// @notice Set the gelatoProvider address that will be paid for executing a task
|
||||||
function setProvider(address _gelatoProvider) external override onlyOwner {
|
function setProvider(address _gelatoProvider)
|
||||||
|
external
|
||||||
|
override
|
||||||
|
onlyOwner
|
||||||
|
noAddressZeroProvider(_gelatoProvider)
|
||||||
|
{
|
||||||
gelatoProvider = _gelatoProvider;
|
gelatoProvider = _gelatoProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,10 +92,6 @@ contract ConnectGelatoProviderPayment is
|
||||||
) external payable override {
|
) external payable override {
|
||||||
address provider = IConnectGelatoProviderPayment(_this)
|
address provider = IConnectGelatoProviderPayment(_this)
|
||||||
.gelatoProvider();
|
.gelatoProvider();
|
||||||
require(
|
|
||||||
provider != address(0x0),
|
|
||||||
"ConnectGelatoProviderPayment.payProvider:!provider"
|
|
||||||
);
|
|
||||||
|
|
||||||
uint256 amt = _getUint(_getId, _amt);
|
uint256 amt = _getUint(_getId, _amt);
|
||||||
_setUint(_setId, amt);
|
_setUint(_setId, amt);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {ethers} = hre;
|
||||||
|
|
||||||
const {sleep} = require("@gelatonetwork/core");
|
const {sleep} = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
||||||
|
|
@ -32,6 +35,34 @@ module.exports = async (hre) => {
|
||||||
gasPrice: hre.network.config.gasPrice,
|
gasPrice: hre.network.config.gasPrice,
|
||||||
log: hre.network.name === "mainnet" ? true : false,
|
log: hre.network.name === "mainnet" ? true : false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hre.network.name === "hardhat") {
|
||||||
|
const deployerWallet = await ethers.provider.getSigner(deployer);
|
||||||
|
const instaMaster = await ethers.provider.getSigner(
|
||||||
|
hre.network.config.InstaMaster
|
||||||
|
);
|
||||||
|
|
||||||
|
await deployerWallet.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)
|
||||||
|
.enable(
|
||||||
|
(await ethers.getContract("ConnectGelatoDataForFullRefinance")).address
|
||||||
|
);
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_stopImpersonatingAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {ethers} = hre;
|
||||||
|
|
||||||
const {sleep} = require("@gelatonetwork/core");
|
const {sleep} = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
||||||
|
|
@ -32,6 +35,35 @@ module.exports = async (hre) => {
|
||||||
gasPrice: hre.network.config.gasPrice,
|
gasPrice: hre.network.config.gasPrice,
|
||||||
log: hre.network.name === "mainnet" ? true : false,
|
log: hre.network.name === "mainnet" ? true : false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hre.network.name === "hardhat") {
|
||||||
|
const deployerWallet = await ethers.provider.getSigner(deployer);
|
||||||
|
const instaMaster = await ethers.provider.getSigner(
|
||||||
|
hre.network.config.InstaMaster
|
||||||
|
);
|
||||||
|
|
||||||
|
await deployerWallet.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)
|
||||||
|
.enable(
|
||||||
|
(await ethers.getContract("ConnectGelatoDataForPartialRefinance"))
|
||||||
|
.address
|
||||||
|
);
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_stopImpersonatingAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.skip = async (hre) => {
|
module.exports.skip = async (hre) => {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {ethers} = hre;
|
||||||
|
|
||||||
const {sleep} = require("@gelatonetwork/core");
|
const {sleep} = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
||||||
|
|
@ -28,6 +31,34 @@ module.exports = async (hre) => {
|
||||||
gasPrice: hre.network.config.gasPrice,
|
gasPrice: hre.network.config.gasPrice,
|
||||||
log: hre.network.name === "mainnet" ? true : false,
|
log: hre.network.name === "mainnet" ? true : false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hre.network.name === "hardhat") {
|
||||||
|
const deployerWallet = await ethers.provider.getSigner(deployer);
|
||||||
|
const instaMaster = await ethers.provider.getSigner(
|
||||||
|
hre.network.config.InstaMaster
|
||||||
|
);
|
||||||
|
|
||||||
|
await deployerWallet.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)
|
||||||
|
.enable(
|
||||||
|
(await ethers.getContract("ConnectGelatoProviderPayment")).address
|
||||||
|
);
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_stopImpersonatingAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.tags = ["ConnectGelatoProviderPayment"];
|
module.exports.tags = ["ConnectGelatoProviderPayment"];
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ const {task, types} = require("hardhat/config");
|
||||||
require("@nomiclabs/hardhat-ethers");
|
require("@nomiclabs/hardhat-ethers");
|
||||||
require("@nomiclabs/hardhat-waffle");
|
require("@nomiclabs/hardhat-waffle");
|
||||||
require("hardhat-deploy");
|
require("hardhat-deploy");
|
||||||
|
require("hardhat-deploy-ethers");
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
|
|
@ -31,6 +32,9 @@ module.exports = {
|
||||||
default: 0,
|
default: 0,
|
||||||
mainnet: DEPLOYER,
|
mainnet: DEPLOYER,
|
||||||
},
|
},
|
||||||
|
user: {
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
gelatoProvider: {
|
gelatoProvider: {
|
||||||
default: 1,
|
default: 1,
|
||||||
mainnet: DEPLOYER,
|
mainnet: DEPLOYER,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"lint": "eslint --cache . && yarn lint:sol",
|
"lint": "eslint --cache . && yarn lint:sol",
|
||||||
"lint:sol": "solhint 'contracts/**/*.sol'",
|
"lint:sol": "solhint 'contracts/**/*.sol'",
|
||||||
"lint:fix": "eslint --cache --fix . && solhint --fix contracts/**/*.sol",
|
"lint:fix": "eslint --cache --fix . && solhint --fix contracts/**/*.sol",
|
||||||
"test": "yarn compile && npx hardhat test",
|
"test": "npx hardhat test",
|
||||||
"debug": "DEBUG=true yarn compile && npx hardhat test"
|
"debug": "DEBUG=true yarn compile && npx hardhat test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
"ethers": "5.0.19",
|
"ethers": "5.0.19",
|
||||||
"hardhat": "2.0.2",
|
"hardhat": "2.0.2",
|
||||||
"hardhat-deploy": "0.7.0-beta.28",
|
"hardhat-deploy": "0.7.0-beta.28",
|
||||||
|
"hardhat-deploy-ethers": "^0.3.0-beta.5",
|
||||||
"husky": ">=4",
|
"husky": ">=4",
|
||||||
"lint-staged": "10.5.1",
|
"lint-staged": "10.5.1",
|
||||||
"prettier": "2.1.2",
|
"prettier": "2.1.2",
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,13 @@
|
||||||
// => only dependency we need is "chai"
|
// => only dependency we need is "chai"
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
//const { sleep } = GelatoCoreLib;
|
//const { sleep } = GelatoCoreLib;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const DAI_100 = ethers.utils.parseUnits("100", 18);
|
const DAI_100 = ethers.utils.parseUnits("100", 18);
|
||||||
const APY_2_PERCENT_IN_SECONDS = ethers.BigNumber.from(
|
|
||||||
"1000000000627937192491029810"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Contracts
|
// Contracts
|
||||||
const InstaIndex = require("../pre-compiles/InstaIndex.json");
|
const InstaIndex = require("../pre-compiles/InstaIndex.json");
|
||||||
|
|
@ -48,6 +46,9 @@ describe("Move DAI lending from DSR to Compound", function () {
|
||||||
let conditionCompareUints;
|
let conditionCompareUints;
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
// Reset back to a fresh forked state during runtime
|
||||||
|
await deployments.fixture();
|
||||||
|
|
||||||
// Get Test Wallet for local testnet
|
// Get Test Wallet for local testnet
|
||||||
[userWallet] = await ethers.getSigners();
|
[userWallet] = await ethers.getSigners();
|
||||||
userAddress = await userWallet.getAddress();
|
userAddress = await userWallet.getAddress();
|
||||||
|
|
@ -107,21 +108,14 @@ describe("Move DAI lending from DSR to Compound", function () {
|
||||||
);
|
);
|
||||||
expect(await dsa.isAuth(gelatoCore.address)).to.be.true;
|
expect(await dsa.isAuth(gelatoCore.address)).to.be.true;
|
||||||
|
|
||||||
// Deploy Mocks for Testing
|
// Deployed Mocks for Testing
|
||||||
const MockCDAI = await ethers.getContractFactory("MockCDAI");
|
mockCDAI = await ethers.getContract("MockCDAI");
|
||||||
mockCDAI = await MockCDAI.deploy(APY_2_PERCENT_IN_SECONDS);
|
mockDSR = await ethers.getContract("MockDSR");
|
||||||
await mockCDAI.deployed();
|
|
||||||
|
|
||||||
const MockDSR = await ethers.getContractFactory("MockDSR");
|
// Deployed Gelato Conditions for Testing
|
||||||
mockDSR = await MockDSR.deploy(APY_2_PERCENT_IN_SECONDS);
|
conditionCompareUints = await ethers.getContract(
|
||||||
await mockDSR.deployed();
|
|
||||||
|
|
||||||
// Deploy Gelato Conditions for Testing
|
|
||||||
const ConditionCompareUintsFromTwoSources = await ethers.getContractFactory(
|
|
||||||
"ConditionCompareUintsFromTwoSources"
|
"ConditionCompareUintsFromTwoSources"
|
||||||
);
|
);
|
||||||
conditionCompareUints = await ConditionCompareUintsFromTwoSources.deploy();
|
|
||||||
await conditionCompareUints.deployed();
|
|
||||||
|
|
||||||
// ===== Dapp Dependencies SETUP ==================
|
// ===== Dapp Dependencies SETUP ==================
|
||||||
// This test assumes our user has 100 DAI deposited in Maker DSR
|
// This test assumes our user has 100 DAI deposited in Maker DSR
|
||||||
|
|
@ -351,7 +345,7 @@ describe("Move DAI lending from DSR to Compound", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Let's first check if our Task is executable. Since both MockDSR and MockCDAI
|
// Let's first check if our Task is executable. Since both MockDSR and MockCDAI
|
||||||
// start with a normalized per second rate of APY_2_PERCENT_IN_SECONDS
|
// are deployed with a normalized per second rate of APY_2_PERCENT_IN_SECONDS
|
||||||
// (1000000000627937192491029810 in 10**27 precision) in both of them, we
|
// (1000000000627937192491029810 in 10**27 precision) in both of them, we
|
||||||
// expect ConditionNotOk because ANotGreaterOrEqualToBbyMinspread.
|
// expect ConditionNotOk because ANotGreaterOrEqualToBbyMinspread.
|
||||||
// Check out contracts/ConditionCompareUintsFromTwoSources.sol to see how
|
// Check out contracts/ConditionCompareUintsFromTwoSources.sol to see how
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const makerToCompoundSetup = require("./helpers/Full-Refinance-Maker-To-Compound.helper");
|
const setupFullRefinanceMakerToCompound = require("./helpers/setupFullRefinanceMakerToCompound");
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -29,7 +30,9 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
let taskReceipt;
|
let taskReceipt;
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const result = await makerToCompoundSetup();
|
await deployments.fixture();
|
||||||
|
|
||||||
|
const result = await setupFullRefinanceMakerToCompound();
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
vaultId = result.vaultId;
|
vaultId = result.vaultId;
|
||||||
|
|
@ -79,7 +82,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
vaultId,
|
vaultId,
|
||||||
contracts.priceOracleResolver.address,
|
contracts.priceOracleResolver.address,
|
||||||
await hre.run("abi-encode-withselector", {
|
await hre.run("abi-encode-withselector", {
|
||||||
abi: ABI.PriceOracleResolverABI,
|
abi: (await deployments.getArtifact("PriceOracleResolver")).abi,
|
||||||
functionname: "getMockPrice",
|
functionname: "getMockPrice",
|
||||||
inputs: [wallets.userAddress],
|
inputs: [wallets.userAddress],
|
||||||
}),
|
}),
|
||||||
|
|
@ -94,7 +97,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
});
|
});
|
||||||
|
|
||||||
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
||||||
addr: wallets.providerAddress, // Gelato Provider Address
|
addr: wallets.gelatoProviderAddress, // Gelato Provider Address
|
||||||
module: contracts.dsaProviderModule.address, // Gelato DSA module
|
module: contracts.dsaProviderModule.address, // Gelato DSA module
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -154,7 +157,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore
|
await contracts.gelatoCore
|
||||||
.connect(wallets.executorWallet)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||||
|
|
||||||
|
|
@ -165,7 +168,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore
|
await contracts.gelatoCore
|
||||||
.connect(wallets.executorWallet)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("OK");
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
|
@ -193,19 +196,21 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||||
wallets.providerAddress
|
wallets.gelatoProviderAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
contracts.gelatoCore.connect(wallets.executorWallet).exec(taskReceipt, {
|
contracts.gelatoCore
|
||||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
gasLimit: constants.GAS_LIMIT,
|
.exec(taskReceipt, {
|
||||||
})
|
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||||
|
gasLimit: constants.GAS_LIMIT,
|
||||||
|
})
|
||||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||||
|
|
||||||
// 🚧 For Debugging:
|
// 🚧 For Debugging:
|
||||||
// const txResponse2 = await contracts.gelatoCore
|
// const txResponse2 = await contracts.gelatoCore
|
||||||
// .connect(wallets.executorWallet)
|
// .connect(wallets.gelatoExecutorWallet)
|
||||||
// .exec(taskReceipt, {
|
// .exec(taskReceipt, {
|
||||||
// gasPrice: gelatoGasPrice,
|
// gasPrice: gelatoGasPrice,
|
||||||
// gasLimit: constants.GAS_LIMIT,
|
// gasLimit: constants.GAS_LIMIT,
|
||||||
|
|
@ -219,7 +224,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
||||||
// await GelatoCoreLib.sleep(10000);
|
// await GelatoCoreLib.sleep(10000);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore.providerFunds(wallets.providerAddress)
|
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||||
).to.be.gt(
|
).to.be.gt(
|
||||||
providerBalanceBeforeExecution.sub(
|
providerBalanceBeforeExecution.sub(
|
||||||
gasFeesPaidFromCol
|
gasFeesPaidFromCol
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const makerETHAToMakerETHBSetup = require("./helpers/Full-Refinance-Maker-To-Maker.helper");
|
const setupFullRefinanceMakerToMaker = require("./helpers/setupFullRefinanceMakerToMaker");
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -30,8 +30,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
// Reset back to a fresh forked state during runtime
|
// Reset back to a fresh forked state during runtime
|
||||||
await hre.run("hardhatReset");
|
await deployments.fixture();
|
||||||
const result = await makerETHAToMakerETHBSetup();
|
|
||||||
|
const result = await setupFullRefinanceMakerToMaker();
|
||||||
|
|
||||||
wallets = result.wallets;
|
wallets = result.wallets;
|
||||||
contracts = result.contracts;
|
contracts = result.contracts;
|
||||||
|
|
@ -83,7 +84,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
vaultAId,
|
vaultAId,
|
||||||
contracts.priceOracleResolver.address,
|
contracts.priceOracleResolver.address,
|
||||||
await hre.run("abi-encode-withselector", {
|
await hre.run("abi-encode-withselector", {
|
||||||
abi: ABI.PriceOracleResolverABI,
|
abi: (await deployments.getArtifact("PriceOracleResolver")).abi,
|
||||||
functionname: "getMockPrice",
|
functionname: "getMockPrice",
|
||||||
inputs: [wallets.userAddress],
|
inputs: [wallets.userAddress],
|
||||||
}),
|
}),
|
||||||
|
|
@ -98,7 +99,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
||||||
addr: wallets.providerAddress, // Gelato Provider Address
|
addr: wallets.gelatoProviderAddress, // Gelato Provider Address
|
||||||
module: contracts.dsaProviderModule.address, // Gelato DSA module
|
module: contracts.dsaProviderModule.address, // Gelato DSA module
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -159,7 +160,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore
|
await contracts.gelatoCore
|
||||||
.connect(wallets.executorWallet)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||||
|
|
||||||
|
|
@ -170,7 +171,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore
|
await contracts.gelatoCore
|
||||||
.connect(wallets.executorWallet)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("OK");
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
|
@ -197,19 +198,21 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||||
wallets.providerAddress
|
wallets.gelatoProviderAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
contracts.gelatoCore.connect(wallets.executorWallet).exec(taskReceipt, {
|
contracts.gelatoCore
|
||||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
.connect(wallets.gelatoExecutorWallet)
|
||||||
gasLimit: constants.GAS_LIMIT,
|
.exec(taskReceipt, {
|
||||||
})
|
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||||
|
gasLimit: constants.GAS_LIMIT,
|
||||||
|
})
|
||||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||||
|
|
||||||
// 🚧 For Debugging:
|
// 🚧 For Debugging:
|
||||||
// const txResponse2 = await contracts.gelatoCore
|
// const txResponse2 = await contracts.gelatoCore
|
||||||
// .connect(wallets.executorWallet)
|
// .connect(wallets.gelatoExecutorWallet)
|
||||||
// .exec(taskReceipt, {
|
// .exec(taskReceipt, {
|
||||||
// gasPrice: gelatoGasPrice,
|
// gasPrice: gelatoGasPrice,
|
||||||
// gasLimit: constants.GAS_LIMIT,
|
// gasLimit: constants.GAS_LIMIT,
|
||||||
|
|
@ -237,7 +240,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await contracts.gelatoCore.providerFunds(wallets.providerAddress)
|
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||||
).to.be.gt(
|
).to.be.gt(
|
||||||
providerBalanceBeforeExecution.sub(
|
providerBalanceBeforeExecution.sub(
|
||||||
gasFeesPaidFromCol
|
gasFeesPaidFromCol
|
||||||
|
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
||||||
const {expect} = require("chai");
|
|
||||||
const hre = require("hardhat");
|
|
||||||
const {ethers} = hre;
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
|
||||||
|
|
||||||
const executorDoStaking = require("./setups/Doing-Staking-As-Executor.helper");
|
|
||||||
const providerDoFunding = require("./setups/Doing-Funding-As-Provider.helper");
|
|
||||||
const providerAddCustomModuleForPayment = require("./setups/Adding-Custom-Module-As-Provider.helper");
|
|
||||||
const providerChooseExecutor = require("./setups/Choosing-Executor-As-Provider.helper");
|
|
||||||
const userCreateADSA = require("./setups/Creating-DSA-As-User.helper");
|
|
||||||
const userOpenDepositBorrowOnMakerVault = require("./setups/Open-Deposit-Borrow-On-Maker-As-User.helper");
|
|
||||||
const getWallets = require("./setups/Wallets.helper");
|
|
||||||
const getConstants = require("./setups/Constants.helper");
|
|
||||||
const getABI = require("./setups/ABI.helper");
|
|
||||||
const getAllContracts = require("./setups/Contracts-For-Full-Refinancing.helper");
|
|
||||||
const enableGelatoConnectorsForFromMaker = require("./setups/Enabling-New-Connectors-For-Full-Refinance.helper");
|
|
||||||
|
|
||||||
const ConnectGelatoDataForFullRefinanceABI = require("../../artifacts/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol/ConnectGelatoDataForFullRefinance.json")
|
|
||||||
.abi;
|
|
||||||
|
|
||||||
async function makerToCompoundSetup() {
|
|
||||||
const wallets = await getWallets();
|
|
||||||
const contracts = await getAllContracts(wallets.providerAddress);
|
|
||||||
const constants = await getConstants();
|
|
||||||
let vaultId;
|
|
||||||
// Gelato Testing environment setup.
|
|
||||||
await enableGelatoConnectorsForFromMaker(
|
|
||||||
wallets.userWallet,
|
|
||||||
contracts.connectGelatoProviderPayment.address,
|
|
||||||
contracts.connectGelatoData.address,
|
|
||||||
contracts.instaMaster,
|
|
||||||
contracts.instaConnectors
|
|
||||||
);
|
|
||||||
await executorDoStaking(wallets.executorWallet, contracts.gelatoCore);
|
|
||||||
await providerDoFunding(
|
|
||||||
wallets.providerWallet,
|
|
||||||
contracts.gelatoCore,
|
|
||||||
constants.GAS_LIMIT,
|
|
||||||
constants.GAS_PRICE_CEIL
|
|
||||||
);
|
|
||||||
await providerChooseExecutor(
|
|
||||||
wallets.providerWallet,
|
|
||||||
wallets.executorAddress,
|
|
||||||
contracts.gelatoCore
|
|
||||||
);
|
|
||||||
await providerAddCustomModuleForPayment(
|
|
||||||
wallets.providerWallet,
|
|
||||||
contracts.gelatoCore,
|
|
||||||
contracts.dsaProviderModule.address
|
|
||||||
);
|
|
||||||
contracts.dsa = await userCreateADSA(
|
|
||||||
wallets.userAddress,
|
|
||||||
contracts.instaIndex,
|
|
||||||
contracts.instaList
|
|
||||||
);
|
|
||||||
vaultId = await userOpenDepositBorrowOnMakerVault(
|
|
||||||
wallets.userAddress,
|
|
||||||
contracts.DAI,
|
|
||||||
contracts.dsa,
|
|
||||||
contracts.getCdps,
|
|
||||||
contracts.dssCdpManager,
|
|
||||||
constants.MAKER_INITIAL_ETH,
|
|
||||||
constants.MAKER_INITIAL_DEBT
|
|
||||||
);
|
|
||||||
|
|
||||||
let ABI = await getABI();
|
|
||||||
|
|
||||||
const spells = await providerWhiteListTaskForMakerToCompound(
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
constants,
|
|
||||||
vaultId
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
vaultId,
|
|
||||||
spells,
|
|
||||||
constants,
|
|
||||||
ABI,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instadapp UI should do the same implementation for submitting debt bridge task
|
|
||||||
async function providerWhiteListTaskForMakerToCompound(
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
constants,
|
|
||||||
vaultId
|
|
||||||
) {
|
|
||||||
//#region Step 9 Provider should whitelist task
|
|
||||||
|
|
||||||
// By WhiteList task, the provider can constrain the type
|
|
||||||
// of task the user can submitting.
|
|
||||||
|
|
||||||
//#region Actions
|
|
||||||
|
|
||||||
const spells = [];
|
|
||||||
|
|
||||||
const debtBridgeCalculationForFullRefinance = new GelatoCoreLib.Action({
|
|
||||||
addr: contracts.connectGelatoData.address,
|
|
||||||
data: await hre.run("abi-encode-withselector", {
|
|
||||||
abi: ConnectGelatoDataForFullRefinanceABI,
|
|
||||||
functionname: "getDataAndCastForFromMakerToCompound",
|
|
||||||
inputs: [vaultId, constants.ETH],
|
|
||||||
}),
|
|
||||||
operation: GelatoCoreLib.Operation.Delegatecall,
|
|
||||||
});
|
|
||||||
|
|
||||||
spells.push(debtBridgeCalculationForFullRefinance);
|
|
||||||
|
|
||||||
const gasPriceCeil = ethers.constants.MaxUint256;
|
|
||||||
|
|
||||||
const connectGelatoFullDebtBridgeFromMakerTaskSpec = new GelatoCoreLib.TaskSpec(
|
|
||||||
{
|
|
||||||
conditions: [contracts.conditionMakerVaultUnsafe.address],
|
|
||||||
actions: spells,
|
|
||||||
gasPriceCeil,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
|
||||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.isTaskSpecProvided(
|
|
||||||
wallets.providerAddress,
|
|
||||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
|
||||||
)
|
|
||||||
).to.be.equal("OK");
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.taskSpecGasPriceCeil(
|
|
||||||
wallets.providerAddress,
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
|
||||||
)
|
|
||||||
).to.be.equal(gasPriceCeil);
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
return spells;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = makerToCompoundSetup;
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
const {expect} = require("chai");
|
|
||||||
const hre = require("hardhat");
|
|
||||||
const {ethers} = hre;
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
|
||||||
|
|
||||||
const executorDoStaking = require("./setups/Doing-Staking-As-Executor.helper");
|
|
||||||
const providerDoFunding = require("./setups/Doing-Funding-As-Provider.helper");
|
|
||||||
const providerAddCustomModuleForPayment = require("./setups/Adding-Custom-Module-As-Provider.helper");
|
|
||||||
const providerChooseExecutor = require("./setups/Choosing-Executor-As-Provider.helper");
|
|
||||||
const userCreateADSA = require("./setups/Creating-DSA-As-User.helper");
|
|
||||||
const masterAddETHBOnGemJoinMapping = require("./setups/Adding-ETHB-On-InstaMapping-As-InstaMaster.helper");
|
|
||||||
const userOpenDepositBorrowOnMakerVault = require("./setups/Open-Deposit-Borrow-On-Maker-As-User.helper");
|
|
||||||
const getWallets = require("./setups/Wallets.helper");
|
|
||||||
const getConstants = require("./setups/Constants.helper");
|
|
||||||
const getABI = require("./setups/ABI.helper");
|
|
||||||
const getAllContracts = require("./setups/Contracts-For-Full-Refinancing.helper");
|
|
||||||
const enableGelatoConnectorsForFromMaker = require("./setups/Enabling-New-Connectors-For-Full-Refinance.helper");
|
|
||||||
|
|
||||||
const ConnectGelatoDataForFullRefinanceABI = require("../../artifacts/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol/ConnectGelatoDataForFullRefinance.json")
|
|
||||||
.abi;
|
|
||||||
|
|
||||||
async function makerETHAToMakerETHBSetup() {
|
|
||||||
const wallets = await getWallets();
|
|
||||||
const contracts = await getAllContracts(wallets.providerAddress);
|
|
||||||
const constants = await getConstants();
|
|
||||||
let vaultAId;
|
|
||||||
// Gelato Testing environment setup.
|
|
||||||
await enableGelatoConnectorsForFromMaker(
|
|
||||||
wallets.userWallet,
|
|
||||||
contracts.connectGelatoProviderPayment.address,
|
|
||||||
contracts.connectGelatoData.address,
|
|
||||||
contracts.instaMaster,
|
|
||||||
contracts.instaConnectors
|
|
||||||
);
|
|
||||||
await executorDoStaking(wallets.executorWallet, contracts.gelatoCore);
|
|
||||||
await providerDoFunding(
|
|
||||||
wallets.providerWallet,
|
|
||||||
contracts.gelatoCore,
|
|
||||||
constants.GAS_LIMIT,
|
|
||||||
constants.GAS_PRICE_CEIL
|
|
||||||
);
|
|
||||||
await providerChooseExecutor(
|
|
||||||
wallets.providerWallet,
|
|
||||||
wallets.executorAddress,
|
|
||||||
contracts.gelatoCore
|
|
||||||
);
|
|
||||||
await providerAddCustomModuleForPayment(
|
|
||||||
wallets.providerWallet,
|
|
||||||
contracts.gelatoCore,
|
|
||||||
contracts.dsaProviderModule.address
|
|
||||||
);
|
|
||||||
contracts.dsa = await userCreateADSA(
|
|
||||||
wallets.userAddress,
|
|
||||||
contracts.instaIndex,
|
|
||||||
contracts.instaList
|
|
||||||
);
|
|
||||||
await masterAddETHBOnGemJoinMapping(
|
|
||||||
wallets.userWallet,
|
|
||||||
contracts.instaMapping,
|
|
||||||
contracts.instaMaster
|
|
||||||
);
|
|
||||||
vaultAId = await userOpenDepositBorrowOnMakerVault(
|
|
||||||
wallets.userAddress,
|
|
||||||
contracts.DAI,
|
|
||||||
contracts.dsa,
|
|
||||||
contracts.getCdps,
|
|
||||||
contracts.dssCdpManager,
|
|
||||||
constants.MAKER_INITIAL_ETH,
|
|
||||||
constants.MAKER_INITIAL_DEBT
|
|
||||||
);
|
|
||||||
|
|
||||||
let ABI = await getABI();
|
|
||||||
|
|
||||||
const spells = await providerWhiteListTaskForMakerETHAToMakerETHB(
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
constants,
|
|
||||||
vaultAId
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
vaultAId,
|
|
||||||
spells,
|
|
||||||
constants,
|
|
||||||
ABI,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instadapp UI should do the same implementation for submitting debt bridge task
|
|
||||||
async function providerWhiteListTaskForMakerETHAToMakerETHB(
|
|
||||||
wallets,
|
|
||||||
contracts,
|
|
||||||
constants,
|
|
||||||
vaultId
|
|
||||||
) {
|
|
||||||
//#region Step 9 Provider should whitelist task
|
|
||||||
|
|
||||||
// By WhiteList task, the provider can constrain the type
|
|
||||||
// of task the user can submitting.
|
|
||||||
|
|
||||||
//#region Actions
|
|
||||||
|
|
||||||
const spells = [];
|
|
||||||
|
|
||||||
const debtBridgeCalculationForFullRefinance = new GelatoCoreLib.Action({
|
|
||||||
addr: contracts.connectGelatoData.address,
|
|
||||||
data: await hre.run("abi-encode-withselector", {
|
|
||||||
abi: ConnectGelatoDataForFullRefinanceABI,
|
|
||||||
functionname: "getDataAndCastForFromMakerToMaker",
|
|
||||||
inputs: [vaultId, constants.ETH, "ETH-B"],
|
|
||||||
}),
|
|
||||||
operation: GelatoCoreLib.Operation.Delegatecall,
|
|
||||||
});
|
|
||||||
|
|
||||||
spells.push(debtBridgeCalculationForFullRefinance);
|
|
||||||
|
|
||||||
const gasPriceCeil = ethers.constants.MaxUint256;
|
|
||||||
|
|
||||||
const connectGelatoFullDebtBridgeFromMakerTaskSpec = new GelatoCoreLib.TaskSpec(
|
|
||||||
{
|
|
||||||
conditions: [contracts.conditionMakerVaultUnsafe.address],
|
|
||||||
actions: spells,
|
|
||||||
gasPriceCeil,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
|
||||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.isTaskSpecProvided(
|
|
||||||
wallets.providerAddress,
|
|
||||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
|
||||||
)
|
|
||||||
).to.be.equal("OK");
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.taskSpecGasPriceCeil(
|
|
||||||
wallets.providerAddress,
|
|
||||||
await contracts.gelatoCore
|
|
||||||
.connect(wallets.providerWallet)
|
|
||||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
|
||||||
)
|
|
||||||
).to.be.equal(gasPriceCeil);
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
return spells;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = makerETHAToMakerETHBSetup;
|
|
||||||
|
|
@ -2,11 +2,7 @@ const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {ethers} = hre;
|
||||||
|
|
||||||
async function masterAddETHBOnGemJoinMapping(
|
async function addETHBGemJoinMapping(userWallet, instaMapping, instaMaster) {
|
||||||
userWallet,
|
|
||||||
instaMapping,
|
|
||||||
instaMaster
|
|
||||||
) {
|
|
||||||
await userWallet.sendTransaction({
|
await userWallet.sendTransaction({
|
||||||
to: hre.network.config.InstaMaster,
|
to: hre.network.config.InstaMaster,
|
||||||
value: ethers.utils.parseEther("0.1"),
|
value: ethers.utils.parseEther("0.1"),
|
||||||
|
|
@ -21,6 +17,11 @@ async function masterAddETHBOnGemJoinMapping(
|
||||||
await expect(
|
await expect(
|
||||||
instaMapping.connect(instaMaster).addGemJoinMapping([ethBGemJoin])
|
instaMapping.connect(instaMaster).addGemJoinMapping([ethBGemJoin])
|
||||||
).to.emit(instaMapping, "LogAddGemJoinMapping");
|
).to.emit(instaMapping, "LogAddGemJoinMapping");
|
||||||
|
|
||||||
|
await hre.network.provider.request({
|
||||||
|
method: "hardhat_stopImpersonatingAccount",
|
||||||
|
params: [await instaMaster.getAddress()],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = masterAddETHBOnGemJoinMapping;
|
module.exports = addETHBGemJoinMapping;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
|
|
||||||
async function providerAddCustomModuleForPayment(
|
async function addProviderModuleDSA(
|
||||||
providerWallet,
|
gelatoProviderWallet,
|
||||||
gelatoCore,
|
gelatoCore,
|
||||||
dsaProviderModuleAddr
|
dsaProviderModuleAddr
|
||||||
) {
|
) {
|
||||||
|
|
@ -11,21 +11,21 @@ async function providerAddCustomModuleForPayment(
|
||||||
// payload by adding some specificity like his address to the
|
// payload by adding some specificity like his address to the
|
||||||
// Payment connector for receiving payment of User.
|
// Payment connector for receiving payment of User.
|
||||||
|
|
||||||
let providerAddress = await providerWallet.getAddress();
|
const gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore
|
gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.addProviderModules([dsaProviderModuleAddr])
|
.addProviderModules([dsaProviderModuleAddr])
|
||||||
).to.emit(gelatoCore, "LogProviderModuleAdded");
|
).to.emit(gelatoCore, "LogProviderModuleAdded");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.isModuleProvided(providerAddress, dsaProviderModuleAddr)
|
.isModuleProvided(gelatoProviderAddress, dsaProviderModuleAddr)
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = providerAddCustomModuleForPayment;
|
module.exports = addProviderModuleDSA;
|
||||||
|
|
@ -4,7 +4,7 @@ const {ethers} = hre;
|
||||||
|
|
||||||
const InstaAccount = require("../../../pre-compiles/InstaAccount.json");
|
const InstaAccount = require("../../../pre-compiles/InstaAccount.json");
|
||||||
|
|
||||||
async function userCreateADSA(userAddress, instaIndex, instaList) {
|
async function createDSA(userAddress, instaIndex, instaList) {
|
||||||
//#region User create a DeFi Smart Account
|
//#region User create a DeFi Smart Account
|
||||||
|
|
||||||
// User create a Instadapp DeFi Smart Account
|
// User create a Instadapp DeFi Smart Account
|
||||||
|
|
@ -19,7 +19,7 @@ async function userCreateADSA(userAddress, instaIndex, instaList) {
|
||||||
"LogAccountCreated"
|
"LogAccountCreated"
|
||||||
);
|
);
|
||||||
const dsaID = dsaAccountCount.add(1);
|
const dsaID = dsaAccountCount.add(1);
|
||||||
await expect(await instaList.accounts()).to.be.equal(dsaID);
|
expect(await instaList.accounts()).to.be.equal(dsaID);
|
||||||
|
|
||||||
// Instantiate the DSA
|
// Instantiate the DSA
|
||||||
const dsa = await ethers.getContractAt(
|
const dsa = await ethers.getContractAt(
|
||||||
|
|
@ -32,4 +32,4 @@ async function userCreateADSA(userAddress, instaIndex, instaList) {
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = userCreateADSA;
|
module.exports = createDSA;
|
||||||
|
|
@ -22,7 +22,7 @@ async function enableGelatoConnectorsForFromMaker(
|
||||||
|
|
||||||
await userWallet.sendTransaction({
|
await userWallet.sendTransaction({
|
||||||
to: hre.network.config.InstaMaster,
|
to: hre.network.config.InstaMaster,
|
||||||
value: ethers.utils.parseEther("0.1"),
|
value: ethers.utils.parseEther("0.01"),
|
||||||
});
|
});
|
||||||
|
|
||||||
await hre.network.provider.request({
|
await hre.network.provider.request({
|
||||||
12
test/helpers/services/getABI.js
Normal file
12
test/helpers/services/getABI.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
const ConnectGelatoABI = require("../../../pre-compiles/ConnectGelato.json")
|
||||||
|
.abi;
|
||||||
|
const ConnectAuthABI = require("../../../pre-compiles/ConnectAuth.json").abi;
|
||||||
|
|
||||||
|
function getABI() {
|
||||||
|
return {
|
||||||
|
ConnectGelatoABI: ConnectGelatoABI,
|
||||||
|
ConnectAuthABI: ConnectAuthABI,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getABI;
|
||||||
|
|
@ -18,126 +18,93 @@ const CTokenInterface = require("../../../pre-compiles/CTokenInterface.json");
|
||||||
const CompoundResolver = require("../../../pre-compiles/InstaCompoundResolver.json");
|
const CompoundResolver = require("../../../pre-compiles/InstaCompoundResolver.json");
|
||||||
const DsaProviderModuleABI = require("../../../pre-compiles/ProviderModuleDsa_ABI.json");
|
const DsaProviderModuleABI = require("../../../pre-compiles/ProviderModuleDsa_ABI.json");
|
||||||
|
|
||||||
async function getContracts(providerAddress) {
|
async function getContracts() {
|
||||||
// Deployed instances
|
const instaMaster = await ethers.provider.getSigner(
|
||||||
let connectGelato;
|
hre.network.config.InstaMaster
|
||||||
let connectMaker;
|
);
|
||||||
let connectInstaPool;
|
|
||||||
let connectCompound;
|
|
||||||
let instaIndex;
|
|
||||||
let instaList;
|
|
||||||
let dssCdpManager;
|
|
||||||
let getCdps;
|
|
||||||
let DAI;
|
|
||||||
let gelatoCore;
|
|
||||||
let cDaiToken;
|
|
||||||
let cEthToken;
|
|
||||||
let instaMaster;
|
|
||||||
let instaMapping;
|
|
||||||
let instaConnectors;
|
|
||||||
let compoundResolver;
|
|
||||||
let dsaProviderModule;
|
|
||||||
// Contracts to deploy and use for local testing
|
|
||||||
let conditionMakerVaultUnsafe;
|
|
||||||
let connectGelatoProviderPayment;
|
|
||||||
let priceOracleResolver;
|
|
||||||
let connectGelatoData;
|
|
||||||
let debtBridgeFromMakerForFullRefinance;
|
|
||||||
|
|
||||||
instaMaster = await ethers.provider.getSigner(hre.network.config.InstaMaster);
|
|
||||||
|
|
||||||
// ===== Get Deployed Contract Instance ==================
|
// ===== Get Deployed Contract Instance ==================
|
||||||
instaIndex = await ethers.getContractAt(
|
const instaIndex = await ethers.getContractAt(
|
||||||
InstaIndex.abi,
|
InstaIndex.abi,
|
||||||
hre.network.config.InstaIndex
|
hre.network.config.InstaIndex
|
||||||
);
|
);
|
||||||
instaMapping = await ethers.getContractAt(
|
const instaMapping = await ethers.getContractAt(
|
||||||
InstaMapping.abi,
|
InstaMapping.abi,
|
||||||
hre.network.config.InstaMapping
|
hre.network.config.InstaMapping
|
||||||
);
|
);
|
||||||
instaList = await ethers.getContractAt(
|
const instaList = await ethers.getContractAt(
|
||||||
InstaList.abi,
|
InstaList.abi,
|
||||||
hre.network.config.InstaList
|
hre.network.config.InstaList
|
||||||
);
|
);
|
||||||
connectGelato = await ethers.getContractAt(
|
const connectGelato = await ethers.getContractAt(
|
||||||
ConnectGelato.abi,
|
ConnectGelato.abi,
|
||||||
hre.network.config.ConnectGelato
|
hre.network.config.ConnectGelato
|
||||||
);
|
);
|
||||||
connectMaker = await ethers.getContractAt(
|
const connectMaker = await ethers.getContractAt(
|
||||||
ConnectMaker.abi,
|
ConnectMaker.abi,
|
||||||
hre.network.config.ConnectMaker
|
hre.network.config.ConnectMaker
|
||||||
);
|
);
|
||||||
connectInstaPool = await ethers.getContractAt(
|
const connectInstaPool = await ethers.getContractAt(
|
||||||
ConnectInstaPool.abi,
|
ConnectInstaPool.abi,
|
||||||
hre.network.config.ConnectInstaPool
|
hre.network.config.ConnectInstaPool
|
||||||
);
|
);
|
||||||
connectCompound = await ethers.getContractAt(
|
const connectCompound = await ethers.getContractAt(
|
||||||
ConnectCompound.abi,
|
ConnectCompound.abi,
|
||||||
hre.network.config.ConnectCompound
|
hre.network.config.ConnectCompound
|
||||||
);
|
);
|
||||||
dssCdpManager = await ethers.getContractAt(
|
const dssCdpManager = await ethers.getContractAt(
|
||||||
DssCdpManager.abi,
|
DssCdpManager.abi,
|
||||||
hre.network.config.DssCdpManager
|
hre.network.config.DssCdpManager
|
||||||
);
|
);
|
||||||
getCdps = await ethers.getContractAt(GetCdps.abi, hre.network.config.GetCdps);
|
const getCdps = await ethers.getContractAt(
|
||||||
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
GetCdps.abi,
|
||||||
gelatoCore = await ethers.getContractAt(
|
hre.network.config.GetCdps
|
||||||
|
);
|
||||||
|
const DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||||
|
const gelatoCore = await ethers.getContractAt(
|
||||||
GelatoCoreLib.GelatoCore.abi,
|
GelatoCoreLib.GelatoCore.abi,
|
||||||
hre.network.config.GelatoCore
|
hre.network.config.GelatoCore
|
||||||
);
|
);
|
||||||
cDaiToken = await ethers.getContractAt(
|
const cDaiToken = await ethers.getContractAt(
|
||||||
CTokenInterface.abi,
|
CTokenInterface.abi,
|
||||||
hre.network.config.CDAI
|
hre.network.config.CDAI
|
||||||
);
|
);
|
||||||
cEthToken = await ethers.getContractAt(
|
const cEthToken = await ethers.getContractAt(
|
||||||
CTokenInterface.abi,
|
CTokenInterface.abi,
|
||||||
hre.network.config.CETH
|
hre.network.config.CETH
|
||||||
);
|
);
|
||||||
instaConnectors = await ethers.getContractAt(
|
const instaConnectors = await ethers.getContractAt(
|
||||||
InstaConnector.abi,
|
InstaConnector.abi,
|
||||||
hre.network.config.InstaConnectors
|
hre.network.config.InstaConnectors
|
||||||
);
|
);
|
||||||
compoundResolver = await ethers.getContractAt(
|
const compoundResolver = await ethers.getContractAt(
|
||||||
CompoundResolver.abi,
|
CompoundResolver.abi,
|
||||||
hre.network.config.CompoundResolver
|
hre.network.config.CompoundResolver
|
||||||
);
|
);
|
||||||
dsaProviderModule = await ethers.getContractAt(
|
const dsaProviderModule = await ethers.getContractAt(
|
||||||
DsaProviderModuleABI,
|
DsaProviderModuleABI,
|
||||||
hre.network.config.ProviderModuleDsa
|
hre.network.config.ProviderModuleDsa
|
||||||
);
|
);
|
||||||
|
|
||||||
// ===== Deploy Needed Contract ==================
|
// ===== Get deployed contracts ==================
|
||||||
|
const priceOracleResolver = await ethers.getContract("PriceOracleResolver");
|
||||||
const PriceOracleResolver = await ethers.getContractFactory(
|
const conditionMakerVaultUnsafe = await ethers.getContract(
|
||||||
"PriceOracleResolver"
|
|
||||||
);
|
|
||||||
priceOracleResolver = await PriceOracleResolver.deploy();
|
|
||||||
await priceOracleResolver.deployed();
|
|
||||||
|
|
||||||
const ConditionMakerVaultUnsafe = await ethers.getContractFactory(
|
|
||||||
"ConditionMakerVaultUnsafe"
|
"ConditionMakerVaultUnsafe"
|
||||||
);
|
);
|
||||||
conditionMakerVaultUnsafe = await ConditionMakerVaultUnsafe.deploy();
|
const connectGelatoProviderPayment = await ethers.getContract(
|
||||||
await conditionMakerVaultUnsafe.deployed();
|
|
||||||
|
|
||||||
const ConnectGelatoProviderPayment = await ethers.getContractFactory(
|
|
||||||
"ConnectGelatoProviderPayment"
|
"ConnectGelatoProviderPayment"
|
||||||
);
|
);
|
||||||
connectGelatoProviderPayment = await ConnectGelatoProviderPayment.deploy(
|
const makerResolver = await ethers.getContract("MakerResolver");
|
||||||
(await instaConnectors.connectorLength()).add(2),
|
const connectGelatoDataForFullRefinance = await ethers.getContract(
|
||||||
providerAddress
|
"ConnectGelatoDataForFullRefinance"
|
||||||
);
|
);
|
||||||
await connectGelatoProviderPayment.deployed();
|
|
||||||
|
|
||||||
const MakerResolver = await ethers.getContractFactory("MakerResolver");
|
|
||||||
const makerResolver = await MakerResolver.deploy();
|
|
||||||
await makerResolver.deployed();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
connectGelato,
|
connectGelato,
|
||||||
connectMaker,
|
connectMaker,
|
||||||
connectInstaPool,
|
connectInstaPool,
|
||||||
connectCompound,
|
connectCompound,
|
||||||
|
connectGelatoDataForFullRefinance,
|
||||||
instaIndex,
|
instaIndex,
|
||||||
instaList,
|
instaList,
|
||||||
instaMapping,
|
instaMapping,
|
||||||
|
|
@ -154,8 +121,6 @@ async function getContracts(providerAddress) {
|
||||||
connectGelatoProviderPayment,
|
connectGelatoProviderPayment,
|
||||||
priceOracleResolver,
|
priceOracleResolver,
|
||||||
dsa: ethers.constants.AddressZero,
|
dsa: ethers.constants.AddressZero,
|
||||||
connectGelatoData,
|
|
||||||
debtBridgeFromMakerForFullRefinance,
|
|
||||||
makerResolver,
|
makerResolver,
|
||||||
dsaProviderModule,
|
dsaProviderModule,
|
||||||
};
|
};
|
||||||
35
test/helpers/services/getWallets.js
Normal file
35
test/helpers/services/getWallets.js
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
const {expect} = require("chai");
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {ethers} = hre;
|
||||||
|
|
||||||
|
async function getWallets() {
|
||||||
|
let userWallet;
|
||||||
|
let userAddress;
|
||||||
|
let gelatoProviderWallet;
|
||||||
|
let gelatoProviderAddress;
|
||||||
|
let gelatoExecutorWallet;
|
||||||
|
let gelatoExecutorAddress;
|
||||||
|
|
||||||
|
[
|
||||||
|
userWallet,
|
||||||
|
gelatoProviderWallet,
|
||||||
|
gelatoExecutorWallet,
|
||||||
|
] = await ethers.getSigners();
|
||||||
|
userAddress = await userWallet.getAddress();
|
||||||
|
gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
|
gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||||
|
|
||||||
|
// Hardhat default wallets prefilled with 100 ETH
|
||||||
|
expect(await userWallet.getBalance()).to.be.gt(ethers.utils.parseEther("10"));
|
||||||
|
|
||||||
|
return {
|
||||||
|
userWallet: userWallet,
|
||||||
|
userAddress: userAddress,
|
||||||
|
gelatoProviderWallet: gelatoProviderWallet,
|
||||||
|
gelatoProviderAddress: gelatoProviderAddress,
|
||||||
|
gelatoExecutorWallet: gelatoExecutorWallet,
|
||||||
|
gelatoExecutorAddress: gelatoExecutorAddress,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getWallets;
|
||||||
|
|
@ -3,7 +3,7 @@ const hre = require("hardhat");
|
||||||
|
|
||||||
const ConnectMaker = require("../../../pre-compiles/ConnectMaker.json");
|
const ConnectMaker = require("../../../pre-compiles/ConnectMaker.json");
|
||||||
|
|
||||||
async function userOpenDepositBorrowOnMakerVault(
|
async function initializeMakerCdp(
|
||||||
userAddress,
|
userAddress,
|
||||||
DAI,
|
DAI,
|
||||||
dsa,
|
dsa,
|
||||||
|
|
@ -63,4 +63,4 @@ async function userOpenDepositBorrowOnMakerVault(
|
||||||
return vaultId;
|
return vaultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = userOpenDepositBorrowOnMakerVault;
|
module.exports = initializeMakerCdp;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
|
|
||||||
async function providerDoFunding(
|
async function provideFunds(
|
||||||
providerWallet,
|
gelatoProviderWallet,
|
||||||
gelatoCore,
|
gelatoCore,
|
||||||
gasLimit,
|
gasLimit,
|
||||||
gasPriceCeil
|
gasPriceCeil
|
||||||
|
|
@ -13,7 +13,7 @@ async function providerDoFunding(
|
||||||
// Provider. At each provider's task execution, some funds (approximatively
|
// Provider. At each provider's task execution, some funds (approximatively
|
||||||
// the gas cost value) will be transfered to the Executor stake.
|
// the gas cost value) will be transfered to the Executor stake.
|
||||||
|
|
||||||
let providerAddress = await providerWallet.getAddress();
|
let gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
|
|
||||||
const TASK_AUTOMATION_FUNDS = await gelatoCore.minExecProviderFunds(
|
const TASK_AUTOMATION_FUNDS = await gelatoCore.minExecProviderFunds(
|
||||||
gasLimit,
|
gasLimit,
|
||||||
|
|
@ -21,16 +21,18 @@ async function providerDoFunding(
|
||||||
);
|
);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore.connect(providerWallet).provideFunds(providerAddress, {
|
gelatoCore
|
||||||
value: TASK_AUTOMATION_FUNDS,
|
.connect(gelatoProviderWallet)
|
||||||
})
|
.provideFunds(gelatoProviderAddress, {
|
||||||
|
value: TASK_AUTOMATION_FUNDS,
|
||||||
|
})
|
||||||
).to.emit(gelatoCore, "LogFundsProvided");
|
).to.emit(gelatoCore, "LogFundsProvided");
|
||||||
|
|
||||||
expect(await gelatoCore.providerFunds(providerAddress)).to.be.equal(
|
expect(await gelatoCore.providerFunds(gelatoProviderAddress)).to.be.equal(
|
||||||
TASK_AUTOMATION_FUNDS
|
TASK_AUTOMATION_FUNDS
|
||||||
);
|
);
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = providerDoFunding;
|
module.exports = provideFunds;
|
||||||
28
test/helpers/services/providerAssignsExecutor.js
Normal file
28
test/helpers/services/providerAssignsExecutor.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
const {expect} = require("chai");
|
||||||
|
|
||||||
|
async function providerAssignsExecutor(
|
||||||
|
gelatoProviderWallet,
|
||||||
|
gelatoExecutorAddress,
|
||||||
|
gelatoCore
|
||||||
|
) {
|
||||||
|
//#region Provider choose a executor
|
||||||
|
|
||||||
|
// Provider choose a executor who will execute futur task
|
||||||
|
// for the provider, it will be compensated by the provider.
|
||||||
|
|
||||||
|
const gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
gelatoCore
|
||||||
|
.connect(gelatoProviderWallet)
|
||||||
|
.providerAssignsExecutor(gelatoExecutorAddress)
|
||||||
|
).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await gelatoCore.executorByProvider(gelatoProviderAddress)
|
||||||
|
).to.be.equal(gelatoExecutorAddress);
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = providerAssignsExecutor;
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
const {expect} = require("chai");
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {deployments, ethers} = hre;
|
||||||
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
|
// Instadapp UI should do the same implementation for submitting debt bridge task
|
||||||
|
async function providerWhiteListTaskForMakerETHAToMakerETHB(
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultId
|
||||||
|
) {
|
||||||
|
//#region Step 9 Provider should whitelist task
|
||||||
|
|
||||||
|
// By WhiteList task, the provider can constrain the type
|
||||||
|
// of task the user can submitting.
|
||||||
|
|
||||||
|
//#region Actions
|
||||||
|
|
||||||
|
const spells = [];
|
||||||
|
|
||||||
|
const debtBridgeCalculationForFullRefinance = new GelatoCoreLib.Action({
|
||||||
|
addr: contracts.connectGelatoDataForFullRefinance.address,
|
||||||
|
data: await hre.run("abi-encode-withselector", {
|
||||||
|
abi: (await deployments.getArtifact("ConnectGelatoDataForFullRefinance"))
|
||||||
|
.abi,
|
||||||
|
functionname: "getDataAndCastForFromMakerToMaker",
|
||||||
|
inputs: [vaultId, constants.ETH, "ETH-B"],
|
||||||
|
}),
|
||||||
|
operation: GelatoCoreLib.Operation.Delegatecall,
|
||||||
|
});
|
||||||
|
|
||||||
|
spells.push(debtBridgeCalculationForFullRefinance);
|
||||||
|
|
||||||
|
const gasPriceCeil = ethers.constants.MaxUint256;
|
||||||
|
|
||||||
|
const connectGelatoFullDebtBridgeFromMakerTaskSpec = new GelatoCoreLib.TaskSpec(
|
||||||
|
{
|
||||||
|
conditions: [contracts.conditionMakerVaultUnsafe.address],
|
||||||
|
actions: spells,
|
||||||
|
gasPriceCeil,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||||
|
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.isTaskSpecProvided(
|
||||||
|
wallets.gelatoProviderAddress,
|
||||||
|
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||||
|
)
|
||||||
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.taskSpecGasPriceCeil(
|
||||||
|
wallets.gelatoProviderAddress,
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||||
|
)
|
||||||
|
).to.be.equal(gasPriceCeil);
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
return spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = providerWhiteListTaskForMakerETHAToMakerETHB;
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
const {expect} = require("chai");
|
||||||
|
const hre = require("hardhat");
|
||||||
|
const {ethers, deployments} = hre;
|
||||||
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
|
// Instadapp UI should do the same implementation for submitting debt bridge task
|
||||||
|
async function providerWhiteListTaskForMakerToCompound(
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultId
|
||||||
|
) {
|
||||||
|
//#region Step 9 Provider should whitelist task
|
||||||
|
|
||||||
|
// By WhiteList task, the provider can constrain the type
|
||||||
|
// of task the user can submitting.
|
||||||
|
|
||||||
|
//#region Actions
|
||||||
|
|
||||||
|
const spells = [];
|
||||||
|
|
||||||
|
const debtBridgeCalculationForFullRefinance = new GelatoCoreLib.Action({
|
||||||
|
addr: contracts.connectGelatoDataForFullRefinance.address,
|
||||||
|
data: await hre.run("abi-encode-withselector", {
|
||||||
|
abi: (await deployments.getArtifact("ConnectGelatoDataForFullRefinance"))
|
||||||
|
.abi,
|
||||||
|
functionname: "getDataAndCastForFromMakerToCompound",
|
||||||
|
inputs: [vaultId, constants.ETH],
|
||||||
|
}),
|
||||||
|
operation: GelatoCoreLib.Operation.Delegatecall,
|
||||||
|
});
|
||||||
|
|
||||||
|
spells.push(debtBridgeCalculationForFullRefinance);
|
||||||
|
|
||||||
|
const gasPriceCeil = ethers.constants.MaxUint256;
|
||||||
|
|
||||||
|
const connectGelatoFullDebtBridgeFromMakerTaskSpec = new GelatoCoreLib.TaskSpec(
|
||||||
|
{
|
||||||
|
conditions: [contracts.conditionMakerVaultUnsafe.address],
|
||||||
|
actions: spells,
|
||||||
|
gasPriceCeil,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||||
|
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.isTaskSpecProvided(
|
||||||
|
wallets.gelatoProviderAddress,
|
||||||
|
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||||
|
)
|
||||||
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.taskSpecGasPriceCeil(
|
||||||
|
wallets.gelatoProviderAddress,
|
||||||
|
await contracts.gelatoCore
|
||||||
|
.connect(wallets.gelatoProviderWallet)
|
||||||
|
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||||
|
)
|
||||||
|
).to.be.equal(gasPriceCeil);
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
return spells;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = providerWhiteListTaskForMakerToCompound;
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
|
|
||||||
async function executorDoStaking(executorWallet, gelatoCore) {
|
async function stakeExecutor(gelatoExecutorWallet, gelatoCore) {
|
||||||
//#region Executor Stake on Gelato
|
//#region Executor Stake on Gelato
|
||||||
|
|
||||||
// For task execution provider will ask a executor to watch the
|
// For task execution provider will ask a executor to watch the
|
||||||
|
|
@ -10,15 +10,16 @@ async function executorDoStaking(executorWallet, gelatoCore) {
|
||||||
// For safety measure Gelato ask the executor to stake a minimum
|
// For safety measure Gelato ask the executor to stake a minimum
|
||||||
// amount.
|
// amount.
|
||||||
|
|
||||||
let executorAddress = await executorWallet.getAddress();
|
const gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||||
|
|
||||||
await gelatoCore.connect(executorWallet).stakeExecutor({
|
await gelatoCore.connect(gelatoExecutorWallet).stakeExecutor({
|
||||||
value: await gelatoCore.minExecutorStake(),
|
value: await gelatoCore.minExecutorStake(),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await gelatoCore.isExecutorMinStaked(executorAddress)).to.be.true;
|
expect(await gelatoCore.isExecutorMinStaked(gelatoExecutorAddress)).to.be
|
||||||
|
.true;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = executorDoStaking;
|
module.exports = stakeExecutor;
|
||||||
70
test/helpers/setupFullRefinanceMakerToCompound.js
Normal file
70
test/helpers/setupFullRefinanceMakerToCompound.js
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
const getWallets = require("./services/getWallets");
|
||||||
|
const getConstants = require("./services/getConstants");
|
||||||
|
const getContracts = require("./services/getContracts");
|
||||||
|
const stakeExecutor = require("./services/stakeExecutor");
|
||||||
|
const provideFunds = require("./services/provideFunds");
|
||||||
|
const providerAssignsExecutor = require("./services/providerAssignsExecutor");
|
||||||
|
const addProviderModuleDSA = require("./services/addProviderModuleDSA");
|
||||||
|
const createDSA = require("./services/createDSA");
|
||||||
|
const initializeMakerCdp = require("./services/initializeMakerCdp");
|
||||||
|
const providerWhiteListTaskForMakerToCompound = require("./services/providerWhiteListTaskForMakerToCompound");
|
||||||
|
const getABI = require("./services/getABI");
|
||||||
|
|
||||||
|
async function setupFullRefinanceMakerToCompound() {
|
||||||
|
const wallets = await getWallets();
|
||||||
|
const contracts = await getContracts();
|
||||||
|
const constants = await getConstants();
|
||||||
|
|
||||||
|
// Gelato Testing environment setup.
|
||||||
|
await stakeExecutor(wallets.gelatoExecutorWallet, contracts.gelatoCore);
|
||||||
|
await provideFunds(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
contracts.gelatoCore,
|
||||||
|
constants.GAS_LIMIT,
|
||||||
|
constants.GAS_PRICE_CEIL
|
||||||
|
);
|
||||||
|
await providerAssignsExecutor(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
wallets.gelatoExecutorAddress,
|
||||||
|
contracts.gelatoCore
|
||||||
|
);
|
||||||
|
await addProviderModuleDSA(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
contracts.gelatoCore,
|
||||||
|
contracts.dsaProviderModule.address
|
||||||
|
);
|
||||||
|
contracts.dsa = await createDSA(
|
||||||
|
wallets.userAddress,
|
||||||
|
contracts.instaIndex,
|
||||||
|
contracts.instaList
|
||||||
|
);
|
||||||
|
const vaultId = await initializeMakerCdp(
|
||||||
|
wallets.userAddress,
|
||||||
|
contracts.DAI,
|
||||||
|
contracts.dsa,
|
||||||
|
contracts.getCdps,
|
||||||
|
contracts.dssCdpManager,
|
||||||
|
constants.MAKER_INITIAL_ETH,
|
||||||
|
constants.MAKER_INITIAL_DEBT
|
||||||
|
);
|
||||||
|
|
||||||
|
const spells = await providerWhiteListTaskForMakerToCompound(
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultId
|
||||||
|
);
|
||||||
|
|
||||||
|
const ABI = getABI();
|
||||||
|
|
||||||
|
return {
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultId,
|
||||||
|
spells,
|
||||||
|
ABI,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setupFullRefinanceMakerToCompound;
|
||||||
76
test/helpers/setupFullRefinanceMakerToMaker.js
Normal file
76
test/helpers/setupFullRefinanceMakerToMaker.js
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
const getWallets = require("./services/getWallets");
|
||||||
|
const getContracts = require("./services/getContracts");
|
||||||
|
const getConstants = require("./services/getConstants");
|
||||||
|
const stakeExecutor = require("./services/stakeExecutor");
|
||||||
|
const provideFunds = require("./services/provideFunds");
|
||||||
|
const providerAssignsExecutor = require("./services/providerAssignsExecutor");
|
||||||
|
const addProviderModuleDSA = require("./services/addProviderModuleDSA");
|
||||||
|
const createDSA = require("./services/createDSA");
|
||||||
|
const addETHBGemJoinMapping = require("./services/addETHBGemJoinMapping");
|
||||||
|
const initializeMakerCdp = require("./services/initializeMakerCdp");
|
||||||
|
const providerWhiteListTaskForMakerETHAToMakerETHB = require("./services/providerWhiteListTaskForMakerETHAToMakerETHB");
|
||||||
|
const getABI = require("./services/getABI");
|
||||||
|
|
||||||
|
async function setupFullRefinanceMakerToMaker() {
|
||||||
|
const wallets = await getWallets();
|
||||||
|
const contracts = await getContracts();
|
||||||
|
const constants = await getConstants();
|
||||||
|
|
||||||
|
// Gelato Testing environment setup.
|
||||||
|
await stakeExecutor(wallets.gelatoExecutorWallet, contracts.gelatoCore);
|
||||||
|
await provideFunds(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
contracts.gelatoCore,
|
||||||
|
constants.GAS_LIMIT,
|
||||||
|
constants.GAS_PRICE_CEIL
|
||||||
|
);
|
||||||
|
await providerAssignsExecutor(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
wallets.gelatoExecutorAddress,
|
||||||
|
contracts.gelatoCore
|
||||||
|
);
|
||||||
|
await addProviderModuleDSA(
|
||||||
|
wallets.gelatoProviderWallet,
|
||||||
|
contracts.gelatoCore,
|
||||||
|
contracts.dsaProviderModule.address
|
||||||
|
);
|
||||||
|
contracts.dsa = await createDSA(
|
||||||
|
wallets.userAddress,
|
||||||
|
contracts.instaIndex,
|
||||||
|
contracts.instaList
|
||||||
|
);
|
||||||
|
await addETHBGemJoinMapping(
|
||||||
|
wallets.userWallet,
|
||||||
|
contracts.instaMapping,
|
||||||
|
contracts.instaMaster
|
||||||
|
);
|
||||||
|
const vaultAId = await initializeMakerCdp(
|
||||||
|
wallets.userAddress,
|
||||||
|
contracts.DAI,
|
||||||
|
contracts.dsa,
|
||||||
|
contracts.getCdps,
|
||||||
|
contracts.dssCdpManager,
|
||||||
|
constants.MAKER_INITIAL_ETH,
|
||||||
|
constants.MAKER_INITIAL_DEBT
|
||||||
|
);
|
||||||
|
|
||||||
|
const spells = await providerWhiteListTaskForMakerETHAToMakerETHB(
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultAId
|
||||||
|
);
|
||||||
|
|
||||||
|
const ABI = getABI();
|
||||||
|
|
||||||
|
return {
|
||||||
|
wallets,
|
||||||
|
contracts,
|
||||||
|
constants,
|
||||||
|
vaultAId,
|
||||||
|
spells,
|
||||||
|
ABI,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setupFullRefinanceMakerToMaker;
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
const ConnectGelatoABI = require("./../../../pre-compiles/ConnectGelato.json")
|
|
||||||
.abi;
|
|
||||||
const PriceOracleResolverABI = require("./../../../artifacts/contracts/contracts/resolvers/PriceOracleResolver.sol/PriceOracleResolver.json")
|
|
||||||
.abi;
|
|
||||||
const ConnectAuthABI = require("./../../../pre-compiles/ConnectAuth.json").abi;
|
|
||||||
|
|
||||||
async function getABI() {
|
|
||||||
return {
|
|
||||||
PriceOracleResolverABI: PriceOracleResolverABI,
|
|
||||||
ConnectGelatoABI: ConnectGelatoABI,
|
|
||||||
ConnectAuthABI: ConnectAuthABI,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = getABI;
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
const {expect} = require("chai");
|
|
||||||
|
|
||||||
async function providerChooseExecutor(
|
|
||||||
providerWallet,
|
|
||||||
executorAddress,
|
|
||||||
gelatoCore
|
|
||||||
) {
|
|
||||||
//#region Provider choose a executor
|
|
||||||
|
|
||||||
// Provider choose a executor who will execute futur task
|
|
||||||
// for the provider, it will be compensated by the provider.
|
|
||||||
|
|
||||||
let providerAddress = await providerWallet.getAddress();
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
gelatoCore.connect(providerWallet).providerAssignsExecutor(executorAddress)
|
|
||||||
).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
|
||||||
|
|
||||||
expect(await gelatoCore.executorByProvider(providerAddress)).to.be.equal(
|
|
||||||
executorAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = providerChooseExecutor;
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
const hre = require("hardhat");
|
|
||||||
const {ethers} = hre;
|
|
||||||
|
|
||||||
const getContracts = require("./Common-Contracts.helper");
|
|
||||||
|
|
||||||
async function getAllContracts(providerAddress) {
|
|
||||||
let connectGelatoData;
|
|
||||||
let contracts = await getContracts(providerAddress);
|
|
||||||
|
|
||||||
const ConnectGelatoData = await ethers.getContractFactory(
|
|
||||||
"ConnectGelatoDataForFullRefinance"
|
|
||||||
);
|
|
||||||
connectGelatoData = await ConnectGelatoData.deploy(
|
|
||||||
(await contracts.instaConnectors.connectorLength()).add(1),
|
|
||||||
contracts.connectGelatoProviderPayment.address
|
|
||||||
);
|
|
||||||
await connectGelatoData.deployed();
|
|
||||||
|
|
||||||
contracts.connectGelatoData = connectGelatoData;
|
|
||||||
|
|
||||||
return contracts;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = getAllContracts;
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
const {expect} = require("chai");
|
|
||||||
const hre = require("hardhat");
|
|
||||||
const {ethers} = hre;
|
|
||||||
|
|
||||||
async function getWallets() {
|
|
||||||
let userWallet;
|
|
||||||
let userAddress;
|
|
||||||
let providerWallet;
|
|
||||||
let providerAddress;
|
|
||||||
let executorWallet;
|
|
||||||
let executorAddress;
|
|
||||||
|
|
||||||
[userWallet, providerWallet, executorWallet] = await ethers.getSigners();
|
|
||||||
userAddress = await userWallet.getAddress();
|
|
||||||
providerAddress = await providerWallet.getAddress();
|
|
||||||
executorAddress = await executorWallet.getAddress();
|
|
||||||
|
|
||||||
// Hardhat default wallets prefilled with 100 ETH
|
|
||||||
expect(await userWallet.getBalance()).to.be.gt(ethers.utils.parseEther("10"));
|
|
||||||
|
|
||||||
return {
|
|
||||||
userWallet: userWallet,
|
|
||||||
userAddress: userAddress,
|
|
||||||
providerWallet: providerWallet,
|
|
||||||
providerAddress: providerAddress,
|
|
||||||
executorWallet: executorWallet,
|
|
||||||
executorAddress: executorAddress,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = getWallets;
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
|
|
||||||
// #region Contracts ABI
|
// #region Contracts ABI
|
||||||
|
|
||||||
|
|
@ -40,7 +40,10 @@ describe("ConditionMakerVaultUnsafe Unit Test", function () {
|
||||||
let cdpId;
|
let cdpId;
|
||||||
let dsa;
|
let dsa;
|
||||||
|
|
||||||
before(async function () {
|
beforeEach(async function () {
|
||||||
|
// Deploy contract dependencies
|
||||||
|
await deployments.fixture();
|
||||||
|
|
||||||
// Get Test Wallet for local testnet
|
// Get Test Wallet for local testnet
|
||||||
[userWallet] = await ethers.getSigners();
|
[userWallet] = await ethers.getSigners();
|
||||||
userAddress = await userWallet.getAddress();
|
userAddress = await userWallet.getAddress();
|
||||||
|
|
@ -69,21 +72,11 @@ describe("ConditionMakerVaultUnsafe Unit Test", function () {
|
||||||
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||||
|
|
||||||
// ========== Test Setup ============
|
// ========== Test Setup ============
|
||||||
|
priceOracleResolver = await ethers.getContract("PriceOracleResolver");
|
||||||
const PriceOracleResolver = await ethers.getContractFactory(
|
conditionMakerVaultUnsafe = await ethers.getContract(
|
||||||
"PriceOracleResolver"
|
|
||||||
);
|
|
||||||
|
|
||||||
priceOracleResolver = await PriceOracleResolver.deploy();
|
|
||||||
await priceOracleResolver.deployed();
|
|
||||||
|
|
||||||
const ConditionMakerVaultUnsafe = await ethers.getContractFactory(
|
|
||||||
"ConditionMakerVaultUnsafe"
|
"ConditionMakerVaultUnsafe"
|
||||||
);
|
);
|
||||||
|
|
||||||
conditionMakerVaultUnsafe = await ConditionMakerVaultUnsafe.deploy();
|
|
||||||
await conditionMakerVaultUnsafe.deployed();
|
|
||||||
|
|
||||||
// Create DeFi Smart Account
|
// Create DeFi Smart Account
|
||||||
|
|
||||||
const dsaAccountCount = await instaList.accounts();
|
const dsaAccountCount = await instaList.accounts();
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {ethers, deployments} = hre;
|
||||||
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
|
|
@ -14,7 +14,6 @@ const InstaList = require("../../pre-compiles/InstaList.json");
|
||||||
const InstaAccount = require("../../pre-compiles/InstaAccount.json");
|
const InstaAccount = require("../../pre-compiles/InstaAccount.json");
|
||||||
const InstaIndex = require("../../pre-compiles/InstaIndex.json");
|
const InstaIndex = require("../../pre-compiles/InstaIndex.json");
|
||||||
const IERC20 = require("../../pre-compiles/IERC20.json");
|
const IERC20 = require("../../pre-compiles/IERC20.json");
|
||||||
const InstaConnector = require("../../pre-compiles/InstaConnectors.json");
|
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
|
@ -27,16 +26,14 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
|
|
||||||
let userWallet;
|
let userWallet;
|
||||||
let userAddress;
|
let userAddress;
|
||||||
let providerWallet;
|
let gelatoProviderWallet;
|
||||||
let providerAddress;
|
let gelatoProviderAddress;
|
||||||
|
|
||||||
let gelatoCore;
|
let gelatoCore;
|
||||||
|
|
||||||
let instaList;
|
let instaList;
|
||||||
let instaIndex;
|
let instaIndex;
|
||||||
let DAI;
|
let DAI;
|
||||||
let instaConnectors;
|
|
||||||
let instaMaster;
|
|
||||||
let connectBasic;
|
let connectBasic;
|
||||||
let getCdps;
|
let getCdps;
|
||||||
let dssCdpManager;
|
let dssCdpManager;
|
||||||
|
|
@ -46,17 +43,14 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
let dsa;
|
let dsa;
|
||||||
let cdpId;
|
let cdpId;
|
||||||
|
|
||||||
before(async function () {
|
beforeEach(async function () {
|
||||||
|
// Deploy dependencies
|
||||||
|
await deployments.fixture();
|
||||||
|
|
||||||
// Get Test Wallet for local testnet
|
// Get Test Wallet for local testnet
|
||||||
[userWallet] = await ethers.getSigners();
|
[userWallet, gelatoProviderWallet] = await ethers.getSigners();
|
||||||
userAddress = await userWallet.getAddress();
|
userAddress = await userWallet.getAddress();
|
||||||
|
gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
[, providerWallet] = await ethers.getSigners();
|
|
||||||
providerAddress = await providerWallet.getAddress();
|
|
||||||
|
|
||||||
instaMaster = await ethers.provider.getSigner(
|
|
||||||
hre.network.config.InstaMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
gelatoCore = await ethers.getContractAt(
|
gelatoCore = await ethers.getContractAt(
|
||||||
GelatoCoreLib.GelatoCore.abi,
|
GelatoCoreLib.GelatoCore.abi,
|
||||||
|
|
@ -80,10 +74,6 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
ConnectBasic.abi,
|
ConnectBasic.abi,
|
||||||
hre.network.config.ConnectBasic
|
hre.network.config.ConnectBasic
|
||||||
);
|
);
|
||||||
instaConnectors = await ethers.getContractAt(
|
|
||||||
InstaConnector.abi,
|
|
||||||
hre.network.config.InstaConnectors
|
|
||||||
);
|
|
||||||
getCdps = await ethers.getContractAt(
|
getCdps = await ethers.getContractAt(
|
||||||
GetCdps.abi,
|
GetCdps.abi,
|
||||||
hre.network.config.GetCdps
|
hre.network.config.GetCdps
|
||||||
|
|
@ -95,41 +85,9 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||||
|
|
||||||
// ========== Test Setup ============
|
// ========== Test Setup ============
|
||||||
|
connectGelatoProviderPayment = await ethers.getContract(
|
||||||
const connectorLength = await instaConnectors.connectorLength();
|
|
||||||
const connectorId = connectorLength.add(1);
|
|
||||||
|
|
||||||
const ConnectGelatoProviderPayment = await ethers.getContractFactory(
|
|
||||||
"ConnectGelatoProviderPayment"
|
"ConnectGelatoProviderPayment"
|
||||||
);
|
);
|
||||||
connectGelatoProviderPayment = await ConnectGelatoProviderPayment.deploy(
|
|
||||||
connectorId,
|
|
||||||
ethers.constants.AddressZero
|
|
||||||
);
|
|
||||||
connectGelatoProviderPayment.deployed();
|
|
||||||
|
|
||||||
await userWallet.sendTransaction({
|
|
||||||
to: hre.network.config.InstaMaster,
|
|
||||||
value: ethers.utils.parseEther("0.1"),
|
|
||||||
});
|
|
||||||
|
|
||||||
await hre.network.provider.request({
|
|
||||||
method: "hardhat_impersonateAccount",
|
|
||||||
params: [await instaMaster.getAddress()],
|
|
||||||
});
|
|
||||||
|
|
||||||
await instaConnectors
|
|
||||||
.connect(instaMaster)
|
|
||||||
.enable(connectGelatoProviderPayment.address);
|
|
||||||
|
|
||||||
await hre.network.provider.request({
|
|
||||||
method: "hardhat_stopImpersonatingAccount",
|
|
||||||
params: [await instaMaster.getAddress()],
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await instaConnectors.isConnector([connectGelatoProviderPayment.address])
|
|
||||||
).to.be.true;
|
|
||||||
|
|
||||||
// ========== Create DeFi Smart Account for User account ============
|
// ========== Create DeFi Smart Account for User account ============
|
||||||
|
|
||||||
|
|
@ -149,51 +107,28 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#1: payProvider should return error message ConnectGelatoProviderPayment.payProvider:INVALIDADDESS when provider is Zero Address", async function () {
|
it("#1: ConnectGelatoProviderPayment should have been deployed with providerAddress", async function () {
|
||||||
|
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.eq(
|
||||||
|
gelatoProviderAddress
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#2: setProvider should revert for AddressZero", async function () {
|
||||||
await expect(
|
await expect(
|
||||||
dsa.cast(
|
connectGelatoProviderPayment.setProvider(ethers.constants.AddressZero)
|
||||||
[connectBasic.address, connectGelatoProviderPayment.address],
|
).to.be.revertedWith("ConnectGelatoProviderPayment.noAddressZeroProvider");
|
||||||
[
|
|
||||||
await hre.run("abi-encode-withselector", {
|
|
||||||
abi: ConnectBasic.abi,
|
|
||||||
functionname: "deposit",
|
|
||||||
inputs: [
|
|
||||||
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
||||||
ethers.utils.parseEther("1"),
|
|
||||||
0,
|
|
||||||
"105",
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
await hre.run("abi-encode-withselector", {
|
|
||||||
abi: (
|
|
||||||
await hre.artifacts.readArtifact("ConnectGelatoProviderPayment")
|
|
||||||
).abi,
|
|
||||||
functionname: "payProvider",
|
|
||||||
inputs: ["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 0, "105", 0],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
userAddress,
|
|
||||||
{
|
|
||||||
value: ethers.utils.parseEther("1"),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
).to.be.revertedWith("ConnectGelatoProviderPayment.payProvider:!provider");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#2: setProvider should change the provider address", async function () {
|
it("#3: setProvider should change the provider address", async function () {
|
||||||
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
await connectGelatoProviderPayment.setProvider(userAddress);
|
||||||
ethers.constants.AddressZero
|
|
||||||
);
|
|
||||||
|
|
||||||
await connectGelatoProviderPayment.setProvider(providerAddress);
|
|
||||||
|
|
||||||
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
||||||
providerAddress
|
userAddress
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#3: payProvider should pay to Provider 300 Dai", async function () {
|
it("#4: payProvider should pay to Provider 300 Dai", async function () {
|
||||||
const providerDAIBalanceBefore = await DAI.balanceOf(providerAddress);
|
const providerDAIBalanceBefore = await DAI.balanceOf(gelatoProviderAddress);
|
||||||
|
|
||||||
await dsa.cast(
|
await dsa.cast(
|
||||||
[hre.network.config.ConnectMaker],
|
[hre.network.config.ConnectMaker],
|
||||||
|
|
@ -256,14 +191,14 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
userAddress
|
userAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(await DAI.balanceOf(providerAddress)).to.be.equal(
|
expect(await DAI.balanceOf(gelatoProviderAddress)).to.be.equal(
|
||||||
providerDAIBalanceBefore.add(ethers.utils.parseUnits("300", 18))
|
providerDAIBalanceBefore.add(ethers.utils.parseUnits("300", 18))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#4: payProvider should pay to Provider 1 ether", async function () {
|
it("#5: payProvider should pay to Provider 1 ether", async function () {
|
||||||
const providerBalanceOnGelatoCoreBefore = await gelatoCore.providerFunds(
|
const providerBalanceOnGelatoCoreBefore = await gelatoCore.providerFunds(
|
||||||
providerAddress
|
gelatoProviderAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
await dsa.cast(
|
await dsa.cast(
|
||||||
|
|
@ -293,7 +228,7 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(await gelatoCore.providerFunds(providerAddress)).to.be.equal(
|
expect(await gelatoCore.providerFunds(gelatoProviderAddress)).to.be.equal(
|
||||||
providerBalanceOnGelatoCoreBefore.add(ethers.utils.parseEther("1"))
|
providerBalanceOnGelatoCoreBefore.add(ethers.utils.parseEther("1"))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
|
|
||||||
const WAD = ethers.utils.parseUnits("1", 18);
|
const WAD = ethers.utils.parseUnits("1", 18);
|
||||||
|
|
||||||
|
|
@ -24,15 +24,10 @@ describe("Debt Partial Refinance Math Unit Test", function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
let fGelatoDebtBridgeMock;
|
let fGelatoDebtBridgeMock;
|
||||||
before(async function () {
|
beforeEach(async function () {
|
||||||
const FGelatoDebtBridgeMock = await ethers.getContractFactory(
|
await deployments.fixture();
|
||||||
"FGelatoDebtBridgeMock"
|
|
||||||
);
|
fGelatoDebtBridgeMock = await ethers.getContract("FGelatoDebtBridgeMock");
|
||||||
fGelatoDebtBridgeMock = await FGelatoDebtBridgeMock
|
|
||||||
.deploy
|
|
||||||
//ethers.constants.AddressZero
|
|
||||||
();
|
|
||||||
fGelatoDebtBridgeMock.deployed();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#1: wCalcCollateralToWithdraw should return the amount of collateral to withdraw on protocol 1 and to put on protocol 2", async function () {
|
it("#1: wCalcCollateralToWithdraw should return the amount of collateral to withdraw on protocol 1 and to put on protocol 2", async function () {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
|
|
||||||
const ORACLE_MAKER_ETH_USD = "ETH/USD-Maker-v1";
|
const ORACLE_MAKER_ETH_USD = "ETH/USD-Maker-v1";
|
||||||
const ORACLE_MAKER_ETH_USD_ADDR = "0x729D19f657BD0614b4985Cf1D82531c67569197B";
|
const ORACLE_MAKER_ETH_USD_ADDR = "0x729D19f657BD0614b4985Cf1D82531c67569197B";
|
||||||
|
|
@ -15,12 +15,9 @@ describe("PriceOracleResolver Unit Test", function () {
|
||||||
|
|
||||||
let priceOracleResolver;
|
let priceOracleResolver;
|
||||||
|
|
||||||
before(async function () {
|
beforeEach(async function () {
|
||||||
const PriceOracleResolver = await ethers.getContractFactory(
|
await deployments.fixture();
|
||||||
"PriceOracleResolver"
|
priceOracleResolver = await ethers.getContract("PriceOracleResolver");
|
||||||
);
|
|
||||||
priceOracleResolver = await PriceOracleResolver.deploy();
|
|
||||||
priceOracleResolver.deployed();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#1: addOracle should add a maker medianizer for a currencyPair", async function () {
|
it("#1: addOracle should add a maker medianizer for a currencyPair", async function () {
|
||||||
|
|
@ -38,6 +35,11 @@ describe("PriceOracleResolver Unit Test", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#2: addOracle should revert when adding a maker medianizer and for this currency pair it was been already added", async function () {
|
it("#2: addOracle should revert when adding a maker medianizer and for this currency pair it was been already added", async function () {
|
||||||
|
await priceOracleResolver.addOracle(
|
||||||
|
ORACLE_MAKER_ETH_USD,
|
||||||
|
ORACLE_MAKER_ETH_USD_ADDR,
|
||||||
|
PRICE_ORACLE_MAKER_PAYLOAD
|
||||||
|
);
|
||||||
await expect(
|
await expect(
|
||||||
priceOracleResolver.addOracle(
|
priceOracleResolver.addOracle(
|
||||||
ORACLE_MAKER_ETH_USD,
|
ORACLE_MAKER_ETH_USD,
|
||||||
|
|
@ -48,6 +50,11 @@ describe("PriceOracleResolver Unit Test", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#3: getPrice returns price", async function () {
|
it("#3: getPrice returns price", async function () {
|
||||||
|
await priceOracleResolver.addOracle(
|
||||||
|
ORACLE_MAKER_ETH_USD,
|
||||||
|
ORACLE_MAKER_ETH_USD_ADDR,
|
||||||
|
PRICE_ORACLE_MAKER_PAYLOAD
|
||||||
|
);
|
||||||
expect((await priceOracleResolver.getPrice(ORACLE_MAKER_ETH_USD)).isZero())
|
expect((await priceOracleResolver.getPrice(ORACLE_MAKER_ETH_USD)).isZero())
|
||||||
.to.be.false;
|
.to.be.false;
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const {expect} = require("chai");
|
const {expect} = require("chai");
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
const {ethers} = hre;
|
const {deployments, ethers} = hre;
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
// #region Contracts ABI and Constants
|
// #region Contracts ABI and Constants
|
||||||
|
|
@ -23,9 +23,6 @@ const GetCdps = require("../pre-compiles/GetCdps.json");
|
||||||
const IERC20 = require("../pre-compiles/IERC20.json");
|
const IERC20 = require("../pre-compiles/IERC20.json");
|
||||||
const CTokenInterface = require("../pre-compiles/CTokenInterface.json");
|
const CTokenInterface = require("../pre-compiles/CTokenInterface.json");
|
||||||
const CompoundResolver = require("../pre-compiles/InstaCompoundResolver.json");
|
const CompoundResolver = require("../pre-compiles/InstaCompoundResolver.json");
|
||||||
const PriceOracleResolverABI = require("../artifacts/contracts/contracts/resolvers/PriceOracleResolver.sol/PriceOracleResolver.json")
|
|
||||||
.abi;
|
|
||||||
|
|
||||||
const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||||
const GAS_LIMIT = "4000000";
|
const GAS_LIMIT = "4000000";
|
||||||
const GAS_PRICE_CEIL = ethers.utils.parseUnits("1000", "gwei");
|
const GAS_PRICE_CEIL = ethers.utils.parseUnits("1000", "gwei");
|
||||||
|
|
@ -124,10 +121,10 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
// Wallet to use for local testing
|
// Wallet to use for local testing
|
||||||
let userWallet;
|
let userWallet;
|
||||||
let userAddress;
|
let userAddress;
|
||||||
let providerWallet;
|
let gelatoProviderWallet;
|
||||||
let providerAddress;
|
let gelatoProviderAddress;
|
||||||
let executorWallet;
|
let gelatoExecutorWallet;
|
||||||
let executorAddress;
|
let gelatoExecutorAddress;
|
||||||
|
|
||||||
// Deployed instances
|
// Deployed instances
|
||||||
let connectGelato;
|
let connectGelato;
|
||||||
|
|
@ -164,10 +161,14 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
// Get Test Wallet for local testnet
|
// Get Test Wallet for local testnet
|
||||||
[userWallet, providerWallet, executorWallet] = await ethers.getSigners();
|
[
|
||||||
|
userWallet,
|
||||||
|
gelatoProviderWallet,
|
||||||
|
gelatoExecutorWallet,
|
||||||
|
] = await ethers.getSigners();
|
||||||
userAddress = await userWallet.getAddress();
|
userAddress = await userWallet.getAddress();
|
||||||
providerAddress = await providerWallet.getAddress();
|
gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||||
executorAddress = await executorWallet.getAddress();
|
gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||||
|
|
||||||
instaMaster = await ethers.provider.getSigner(
|
instaMaster = await ethers.provider.getSigner(
|
||||||
hre.network.config.InstaMaster
|
hre.network.config.InstaMaster
|
||||||
|
|
@ -363,11 +364,13 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
// For safety measure Gelato ask the executor to stake a minimum
|
// For safety measure Gelato ask the executor to stake a minimum
|
||||||
// amount.
|
// amount.
|
||||||
|
|
||||||
await gelatoCore.connect(executorWallet).stakeExecutor({
|
await gelatoCore.connect(gelatoExecutorWallet).stakeExecutor({
|
||||||
value: await gelatoCore.minExecutorStake(),
|
value: await gelatoCore.minExecutorStake(),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await gelatoCore.isExecutorMinStaked(executorAddress)).to.be.true;
|
expect(
|
||||||
|
await gelatoCore.isExecutorMinStaked(gelatoExecutorAddress)
|
||||||
|
).to.be.true;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -384,12 +387,14 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore.connect(providerWallet).provideFunds(providerAddress, {
|
gelatoCore
|
||||||
value: TASK_AUTOMATION_FUNDS,
|
.connect(gelatoProviderWallet)
|
||||||
})
|
.provideFunds(gelatoProviderAddress, {
|
||||||
|
value: TASK_AUTOMATION_FUNDS,
|
||||||
|
})
|
||||||
).to.emit(gelatoCore, "LogFundsProvided");
|
).to.emit(gelatoCore, "LogFundsProvided");
|
||||||
|
|
||||||
expect(await gelatoCore.providerFunds(providerAddress)).to.be.equal(
|
expect(await gelatoCore.providerFunds(gelatoProviderAddress)).to.be.equal(
|
||||||
TASK_AUTOMATION_FUNDS
|
TASK_AUTOMATION_FUNDS
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -402,13 +407,13 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore
|
gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.providerAssignsExecutor(executorAddress)
|
.providerAssignsExecutor(gelatoExecutorAddress)
|
||||||
).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
||||||
|
|
||||||
expect(await gelatoCore.executorByProvider(providerAddress)).to.be.equal(
|
expect(
|
||||||
executorAddress
|
await gelatoCore.executorByProvider(gelatoProviderAddress)
|
||||||
);
|
).to.be.equal(gelatoExecutorAddress);
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -420,14 +425,14 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore
|
gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.addProviderModules([dsaProviderModule.address])
|
.addProviderModules([dsaProviderModule.address])
|
||||||
).to.emit(gelatoCore, "LogProviderModuleAdded");
|
).to.emit(gelatoCore, "LogProviderModuleAdded");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.isModuleProvided(providerAddress, dsaProviderModule.address)
|
.isModuleProvided(gelatoProviderAddress, dsaProviderModule.address)
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
@ -546,7 +551,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
MIN_COL_RATIO_B,
|
MIN_COL_RATIO_B,
|
||||||
priceOracleResolver.address,
|
priceOracleResolver.address,
|
||||||
await hre.run("abi-encode-withselector", {
|
await hre.run("abi-encode-withselector", {
|
||||||
abi: PriceOracleResolverABI,
|
abi: (await deployments.getArtifcat("PriceOracleResolver")).abi,
|
||||||
functionname: "getMockPrice",
|
functionname: "getMockPrice",
|
||||||
inputs: [userAddress],
|
inputs: [userAddress],
|
||||||
}),
|
}),
|
||||||
|
|
@ -636,7 +641,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
data: await hre.run("abi-encode-withselector", {
|
data: await hre.run("abi-encode-withselector", {
|
||||||
abi: ConnectGelatoProviderPaymentABI,
|
abi: ConnectGelatoProviderPaymentABI,
|
||||||
functionname: "payProvider",
|
functionname: "payProvider",
|
||||||
inputs: [providerAddress, ETH, 0, "605", 0],
|
inputs: [gelatoProviderAddress, ETH, 0, "605", 0],
|
||||||
}),
|
}),
|
||||||
operation: GelatoCoreLib.Operation.Delegatecall,
|
operation: GelatoCoreLib.Operation.Delegatecall,
|
||||||
});
|
});
|
||||||
|
|
@ -655,26 +660,26 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore
|
gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||||
).to.emit(gelatoCore, "LogTaskSpecProvided");
|
).to.emit(gelatoCore, "LogTaskSpecProvided");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.isTaskSpecProvided(
|
.isTaskSpecProvided(
|
||||||
providerAddress,
|
gelatoProviderAddress,
|
||||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||||
)
|
)
|
||||||
).to.be.equal("OK");
|
).to.be.equal("OK");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.taskSpecGasPriceCeil(
|
.taskSpecGasPriceCeil(
|
||||||
providerAddress,
|
gelatoProviderAddress,
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(providerWallet)
|
.connect(gelatoProviderWallet)
|
||||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||||
)
|
)
|
||||||
).to.be.equal(gasPriceCeil);
|
).to.be.equal(gasPriceCeil);
|
||||||
|
|
@ -705,7 +710,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
vaultId,
|
vaultId,
|
||||||
priceOracleResolver.address,
|
priceOracleResolver.address,
|
||||||
await hre.run("abi-encode-withselector", {
|
await hre.run("abi-encode-withselector", {
|
||||||
abi: PriceOracleResolverABI,
|
abi: (await deployments.getArtifact("PriceOracleResolver")).abi,
|
||||||
functionname: "getMockPrice",
|
functionname: "getMockPrice",
|
||||||
inputs: [userAddress],
|
inputs: [userAddress],
|
||||||
}),
|
}),
|
||||||
|
|
@ -720,7 +725,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
const gelatoExternalProvider = new GelatoCoreLib.GelatoProvider({
|
||||||
addr: providerAddress,
|
addr: gelatoProviderAddress,
|
||||||
module: dsaProviderModule.address,
|
module: dsaProviderModule.address,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -769,7 +774,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(executorWallet)
|
.connect(gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||||
|
|
||||||
|
|
@ -778,7 +783,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await gelatoCore
|
await gelatoCore
|
||||||
.connect(executorWallet)
|
.connect(gelatoExecutorWallet)
|
||||||
.canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
.canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
||||||
).to.be.equal("OK");
|
).to.be.equal("OK");
|
||||||
|
|
||||||
|
|
@ -826,10 +831,10 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
//console.log(String(wdiv(pricedCollateral.sub(wmul(expectedColWithdrawAmount, latestPrice).add(gasFeesPaidFromCol)),debt.sub(expectedBorAmountToPayBack))));
|
//console.log(String(wdiv(pricedCollateral.sub(wmul(expectedColWithdrawAmount, latestPrice).add(gasFeesPaidFromCol)),debt.sub(expectedBorAmountToPayBack))));
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
const providerBalanceBeforeExecution = await providerWallet.getBalance();
|
const providerBalanceBeforeExecution = await gelatoProviderWallet.getBalance();
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
gelatoCore.connect(executorWallet).exec(taskReceipt, {
|
gelatoCore.connect(gelatoExecutorWallet).exec(taskReceipt, {
|
||||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||||
gasLimit: GAS_LIMIT,
|
gasLimit: GAS_LIMIT,
|
||||||
})
|
})
|
||||||
|
|
@ -837,7 +842,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
|
|
||||||
// 🚧 For Debugging:
|
// 🚧 For Debugging:
|
||||||
// const txResponse2 = await gelatoCore
|
// const txResponse2 = await gelatoCore
|
||||||
// .connect(providerWallet)
|
// .connect(gelatoProviderWallet)
|
||||||
// .exec(taskReceipt, {
|
// .exec(taskReceipt, {
|
||||||
// gasPrice: gelatoGasPrice,
|
// gasPrice: gelatoGasPrice,
|
||||||
// gasLimit: GAS_LIMIT,
|
// gasLimit: GAS_LIMIT,
|
||||||
|
|
@ -850,7 +855,7 @@ describe("Debt Bridge with External Provider", function () {
|
||||||
// }
|
// }
|
||||||
// await GelatoCoreLib.sleep(10000);
|
// await GelatoCoreLib.sleep(10000);
|
||||||
|
|
||||||
expect(await providerWallet.getBalance()).to.be.gt(
|
expect(await gelatoProviderWallet.getBalance()).to.be.gt(
|
||||||
providerBalanceBeforeExecution
|
providerBalanceBeforeExecution
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4214,6 +4214,11 @@ har-validator@~5.1.3:
|
||||||
ajv "^6.12.3"
|
ajv "^6.12.3"
|
||||||
har-schema "^2.0.0"
|
har-schema "^2.0.0"
|
||||||
|
|
||||||
|
hardhat-deploy-ethers@^0.3.0-beta.5:
|
||||||
|
version "0.3.0-beta.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.3.0-beta.5.tgz#c365ebb5c29e7474b2b35912f27dc9699a0e63b3"
|
||||||
|
integrity sha512-KoUswkCPSuARGjZQIf8kItL5rPFt6srgVj+q0B9YTQ7Vyw/k2N0R8u7aYWq4Piy9mjDKcEGQTPBXhaX02BMkVw==
|
||||||
|
|
||||||
hardhat-deploy@0.7.0-beta.28:
|
hardhat-deploy@0.7.0-beta.28:
|
||||||
version "0.7.0-beta.28"
|
version "0.7.0-beta.28"
|
||||||
resolved "https://registry.yarnpkg.com/hardhat-deploy/-/hardhat-deploy-0.7.0-beta.28.tgz#e71dc7d7a97903773c717818e8ecb7eef8f97a5c"
|
resolved "https://registry.yarnpkg.com/hardhat-deploy/-/hardhat-deploy-0.7.0-beta.28.tgz#e71dc7d7a97903773c717818e8ecb7eef8f97a5c"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user