mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
chore: hardhat optimizer settings
This commit is contained in:
parent
71226fba45
commit
9e951120e8
|
@ -27,9 +27,18 @@ jobs: # a collection of steps
|
|||
- run: # Linting
|
||||
name: ESLint
|
||||
command: yarn eslint . && yarn lint:sol
|
||||
- restore_cache: # special step to restore the Hardhat Network Fork Cache
|
||||
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
|
||||
name: Restore Hardhat Network Fork Cache
|
||||
key: hardhat-network-fork
|
||||
- run: # Tests
|
||||
name: Tests using hardhat mainnet fork
|
||||
command: npx hardhat test
|
||||
- save_cache: # special step to save the Hardhat Network Fork cache
|
||||
name: Save Hardhat Network Fork Cache
|
||||
key: hardhat-network-fork
|
||||
paths:
|
||||
- ./cache/hardhat-network-fork
|
||||
# - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
|
||||
# path: coverage
|
||||
# prefix: coverage
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
node_modules/
|
||||
contracts/constants
|
||||
contracts/functions
|
||||
contracts/vendor
|
|
@ -22,7 +22,7 @@ Furtheremore the following contracts were added to showcase the automation of th
|
|||
|
||||
- `ConditionCompareUintsFromTwoSource`: a generic Gelato Condition that allows you to read and compare data from 2 arbitrary on-chain sources (returndata expected to be uint256 and normalized => hence MockDSR and MockCDAI). This Condition was used to compare DSR to CDAI rates and in the test suite we showcase how a change in the CDAI rate (it going above the DSR) can trigger an automatic rebalancing from DSR to CDAI via DSA Connectors.
|
||||
|
||||
- `ProviderModuleDSA`: this is needed for any Gelato integration. It tells Gelato how the execution payload should be formatted. In this prototype, it formats the payload for the `DSA.cast` function.
|
||||
- `ProviderModuleDsa`: this is needed for any Gelato integration. It tells Gelato how the execution payload should be formatted. In this prototype, it formats the payload for the `DSA.cast` function.
|
||||
|
||||
- `ConnectGelato`: this is a Connector needed for the DSA to be able to submit Tasks to Gelato. In the test suite we unlock the DSA MultiSig Master account at 0xfCD22438AD6eD564a1C26151Df73F6B33B817B56, in order to be able to enable this Connector in our mainnet fork running on the local hardhat network instance.
|
||||
|
||||
|
|
4
contracts/constants/CMaker.sol
Normal file
4
contracts/constants/CMaker.sol
Normal file
|
@ -0,0 +1,4 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
address constant MCD_MANAGER = 0x5ef30b9986345249bc32d8928B7ee64DE9435E39;
|
|
@ -42,12 +42,14 @@ contract DebtBridgeFromMakerForFullRefinance {
|
|||
uint256 public constant GAS_COST = 1490779 + (14908 * 2); // 1933080 + ~2% (Estimated Value)
|
||||
|
||||
// To retrieve when the connector is deployed and replace with the address of the deployed instance
|
||||
address public connectGelatoProviderPayment;
|
||||
address public immutable connectGelatoProviderPayment;
|
||||
|
||||
constructor(address _connectGelatoProviderPayment) {
|
||||
connectGelatoProviderPayment = _connectGelatoProviderPayment;
|
||||
}
|
||||
|
||||
/* solhint-disable function-max-lines */
|
||||
|
||||
/// @notice Generate Task for a full refinancing between Maker to Compound.
|
||||
/// @param _vaultId Id of the unsafe vault of the client.
|
||||
/// @param _token vault's col token address .
|
||||
|
@ -166,6 +168,8 @@ contract DebtBridgeFromMakerForFullRefinance {
|
|||
);
|
||||
}
|
||||
|
||||
/* solhint-enable function-max-lines */
|
||||
|
||||
/// @notice Generate Data for calling execPayloadForFullRefinanceFromMakerToMaker via a static call.
|
||||
/// @param _vaultId Id of the unsafe vault of the client.
|
||||
/// @param _token vault's col token address .
|
||||
|
|
|
@ -59,12 +59,14 @@ contract DebtBridgeFromMakerForPartialRefinance {
|
|||
uint256 public constant GAS_COST = 1490779 + (14908 * 2); // 1933080 + ~2% (Estimated Value)
|
||||
|
||||
// To retrieve when the connector is deployed and replace with the address of the deployed instance
|
||||
address public connectGelatoProviderPayment;
|
||||
address public immutable connectGelatoProviderPayment;
|
||||
|
||||
constructor(address _connectGelatoProviderPayment) {
|
||||
connectGelatoProviderPayment = _connectGelatoProviderPayment;
|
||||
}
|
||||
|
||||
/* solhint-disable function-max-lines */
|
||||
|
||||
/// @notice Generate Task for a full refinancing between Maker to Compound.
|
||||
/// @param _payload contain :
|
||||
// @param _vaultId Id of the unsafe vault of the client.
|
||||
|
@ -225,6 +227,8 @@ contract DebtBridgeFromMakerForPartialRefinance {
|
|||
);
|
||||
}
|
||||
|
||||
/* solhint-enable function-max-lines */
|
||||
|
||||
/// @notice Computes values needed for DebtBridge Maker->ProtocolB
|
||||
/// @dev Use wad for colRatios.
|
||||
/// @param _vaultId The id of the makerDAO vault.
|
||||
|
@ -356,7 +360,7 @@ contract DebtBridgeFromMakerForPartialRefinance {
|
|||
/// method e.g. the function selector of MakerOracle's read function.
|
||||
/// @param _colType colType of the new vault, exemple : ETH-B, ETH-A.
|
||||
/// @param _provider address of the paying provider.
|
||||
/// @return a call data for a static call of execPayloadForPartialRefinanceFromMakerToMaker.
|
||||
/// @return payload for execPayloadForPartialRefinanceFromMakerToMaker.
|
||||
function getDebtBridgePartialRefinanceMakerToMakerData(
|
||||
uint256 _vaultId,
|
||||
address _token,
|
||||
|
|
|
@ -51,12 +51,18 @@ contract ProviderModuleDsaFromMakerToCompound is GelatoProviderModuleStandard {
|
|||
bool gelatoCoreIsAuth
|
||||
) {
|
||||
if (!gelatoCoreIsAuth)
|
||||
return "ProviderModuleDSA.isProvided:GelatoCoreNotAuth";
|
||||
return
|
||||
"ProviderModuleDsaFromMakerToCompound.isProvided:GelatoCoreNotAuth";
|
||||
} catch Error(string memory err) {
|
||||
return
|
||||
string(abi.encodePacked("ProviderModuleDSA.isProvided:", err));
|
||||
string(
|
||||
abi.encodePacked(
|
||||
"ProviderModuleDsaFromMakerToCompound.isProvided:",
|
||||
err
|
||||
)
|
||||
);
|
||||
} catch {
|
||||
return "ProviderModuleDSA.isProvided:undefined";
|
||||
return "ProviderModuleDsaFromMakerToCompound.isProvided:undefined";
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
|
|
@ -51,12 +51,18 @@ contract ProviderModuleDsaFromMakerToMaker is GelatoProviderModuleStandard {
|
|||
bool gelatoCoreIsAuth
|
||||
) {
|
||||
if (!gelatoCoreIsAuth)
|
||||
return "ProviderModuleDSA.isProvided:GelatoCoreNotAuth";
|
||||
return
|
||||
"ProviderModuleDsaFromMakerToMaker.isProvided:GelatoCoreNotAuth";
|
||||
} catch Error(string memory err) {
|
||||
return
|
||||
string(abi.encodePacked("ProviderModuleDSA.isProvided:", err));
|
||||
string(
|
||||
abi.encodePacked(
|
||||
"ProviderModuleDsaFromMakerToMaker.isProvided:",
|
||||
err
|
||||
)
|
||||
);
|
||||
} catch {
|
||||
return "ProviderModuleDSA.isProvided:undefined";
|
||||
return "ProviderModuleDsaFromMakerToMaker.isProvided:undefined";
|
||||
}
|
||||
|
||||
return OK;
|
|
@ -1,23 +1,16 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
import {IManager} from "../../interfaces/Maker/IManager.sol";
|
||||
import {IVat} from "../../interfaces/Maker/IVat.sol";
|
||||
import {MCD_MANAGER} from "../../constants/CMaker.sol";
|
||||
import {IMcdManager} from "../../interfaces/dapps/Maker/IMcdManager.sol";
|
||||
import {IVat} from "../../interfaces/dapps/Maker/IVat.sol";
|
||||
import {RAY, sub, mul} from "../../vendor/DSMath.sol";
|
||||
|
||||
function _getMcdManager() pure returns (address) {
|
||||
return 0x5ef30b9986345249bc32d8928B7ee64DE9435E39;
|
||||
}
|
||||
|
||||
function _getManager() pure returns (IManager) {
|
||||
return IManager(_getMcdManager());
|
||||
}
|
||||
|
||||
function _getMakerVaultDebt(uint256 _vaultId) view returns (uint256 wad) {
|
||||
IManager cdpManager = _getManager();
|
||||
IMcdManager manager = IMcdManager(MCD_MANAGER);
|
||||
|
||||
(bytes32 ilk, address urn) = _getVaultData(cdpManager, _vaultId);
|
||||
IVat vat = IVat(cdpManager.vat());
|
||||
(bytes32 ilk, address urn) = _getVaultData(manager, _vaultId);
|
||||
IVat vat = IVat(manager.vat());
|
||||
(, uint256 rate, , , ) = vat.ilks(ilk);
|
||||
(, uint256 art) = vat.urns(ilk, urn);
|
||||
uint256 dai = vat.dai(urn);
|
||||
|
@ -32,19 +25,19 @@ function _getMakerVaultCollateralBalance(uint256 _vaultId)
|
|||
view
|
||||
returns (uint256)
|
||||
{
|
||||
IManager cdpManager = _getManager();
|
||||
IMcdManager manager = IMcdManager(MCD_MANAGER);
|
||||
|
||||
IVat vat = IVat(cdpManager.vat());
|
||||
(bytes32 ilk, address urn) = _getVaultData(cdpManager, _vaultId);
|
||||
IVat vat = IVat(manager.vat());
|
||||
(bytes32 ilk, address urn) = _getVaultData(manager, _vaultId);
|
||||
(uint256 ink, ) = vat.urns(ilk, urn);
|
||||
|
||||
return ink;
|
||||
}
|
||||
|
||||
function _getVaultData(IManager cdpManager, uint256 vault)
|
||||
function _getVaultData(IMcdManager manager, uint256 vault)
|
||||
view
|
||||
returns (bytes32 ilk, address urn)
|
||||
{
|
||||
ilk = cdpManager.ilks(vault);
|
||||
urn = cdpManager.urns(vault);
|
||||
ilk = manager.ilks(vault);
|
||||
urn = manager.urns(vault);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
interface IManager {
|
||||
interface IMcdManager {
|
||||
function ilks(uint256) external view returns (bytes32);
|
||||
|
||||
function urns(uint256) external view returns (address);
|
|
@ -51,12 +51,14 @@ module.exports = {
|
|||
CETH: "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||
DssCdpManager: "0x5ef30b9986345249bc32d8928B7ee64DE9435E39",
|
||||
GetCdps: "0x36a724Bd100c39f0Ea4D3A20F7097eE01A8Ff573",
|
||||
ProviderModuleDSA: "0x0C25452d20cdFeEd2983fa9b9b9Cf4E81D6f2fE2",
|
||||
ProviderModuleDsa: "0x0C25452d20cdFeEd2983fa9b9b9Cf4E81D6f2fE2",
|
||||
},
|
||||
},
|
||||
solidity: {
|
||||
version: "0.7.4",
|
||||
optimizer: {enabled: process.env.DEBUG ? false : true},
|
||||
settings: {
|
||||
optimizer: {enabled: process.env.DEBUG ? false : true},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
"compile": "npx hardhat compile",
|
||||
"format": "prettier --write .",
|
||||
"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",
|
||||
"test": "yarn compile --force && npx hardhat test",
|
||||
"debug": "DEBUG=true yarn compile --force && npx hardhat test"
|
||||
"test": "yarn compile && npx hardhat test",
|
||||
"debug": "DEBUG=true yarn compile && npx hardhat test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gelatonetwork/core": "1.0.0",
|
||||
|
|
|
@ -16,7 +16,7 @@ const InstaConnectors = require("../pre-compiles/InstaConnectors.json");
|
|||
const InstaAccount = require("../pre-compiles/InstaAccount.json");
|
||||
const ConnectAuth = require("../pre-compiles/ConnectAuth.json");
|
||||
const ConnectBasic = require("../pre-compiles/ConnectBasic.json");
|
||||
const ProviderModuleDSA_ABI = require("../pre-compiles/ProviderModuleDSA_ABI.json");
|
||||
const ProviderModuleDsa_ABI = require("../pre-compiles/ProviderModuleDsa_ABI.json");
|
||||
|
||||
describe("DSA setup with Gelato Tests", function () {
|
||||
this.timeout(50000);
|
||||
|
@ -89,8 +89,8 @@ describe("DSA setup with Gelato Tests", function () {
|
|||
hre.network.config.GelatoCore
|
||||
);
|
||||
providerModuleDSA = await ethers.getContractAt(
|
||||
ProviderModuleDSA_ABI,
|
||||
hre.network.config.ProviderModuleDSA
|
||||
ProviderModuleDsa_ABI,
|
||||
hre.network.config.ProviderModuleDsa
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -183,7 +183,7 @@ describe("DSA setup with Gelato Tests", function () {
|
|||
).to.be.true;
|
||||
});
|
||||
|
||||
it("#6: Gelato ProviderModuleDSA returns correct execPayload", async function () {
|
||||
it("#6: Gelato ProviderModuleDsa returns correct execPayload", async function () {
|
||||
// Deposit 1 ETH into DSA
|
||||
await userWallet.sendTransaction({
|
||||
to: dsaAddress,
|
||||
|
|
|
@ -237,10 +237,10 @@ describe("Move DAI lending from DSR to Compound", function () {
|
|||
// A GelatoProvider is an object with the address of the provider - in our case
|
||||
// the DSA address - and the address of the "ProviderModule". This module
|
||||
// fulfills certain functions like encoding the execution payload for the Gelato
|
||||
// protocol. Check out ./contracts/ProviderModuleDSA.sol to see what it does.
|
||||
// protocol. Check out ./contracts/ProviderModuleDsa.sol to see what it does.
|
||||
const gelatoSelfProvider = new GelatoCoreLib.GelatoProvider({
|
||||
addr: dsa.address,
|
||||
module: hre.network.config.ProviderModuleDSA,
|
||||
module: hre.network.config.ProviderModuleDsa,
|
||||
});
|
||||
|
||||
// ======= Executor Setup =========
|
||||
|
@ -271,7 +271,7 @@ describe("Move DAI lending from DSR to Compound", function () {
|
|||
inputs: [
|
||||
userAddress,
|
||||
[],
|
||||
[hre.network.config.ProviderModuleDSA],
|
||||
[hre.network.config.ProviderModuleDsa],
|
||||
TASK_AUTOMATION_FUNDS,
|
||||
0, // _getId
|
||||
0, // _setId
|
||||
|
@ -296,7 +296,7 @@ describe("Move DAI lending from DSR to Compound", function () {
|
|||
expect(
|
||||
await gelatoCore.isModuleProvided(
|
||||
dsa.address,
|
||||
hre.network.config.ProviderModuleDSA
|
||||
hre.network.config.ProviderModuleDsa
|
||||
)
|
||||
).to.be.true;
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ async function getAllContracts() {
|
|||
);
|
||||
await debtBridgeFromMakerForFullRefinance.deployed();
|
||||
|
||||
const ProviderModuleDSA = await ethers.getContractFactory(
|
||||
const ProviderModuleDsa = await ethers.getContractFactory(
|
||||
"ProviderModuleDsaFromMakerToCompound"
|
||||
);
|
||||
dsaProviderModule = await ProviderModuleDSA.deploy(
|
||||
dsaProviderModule = await ProviderModuleDsa.deploy(
|
||||
hre.network.config.GelatoCore,
|
||||
contracts.connectGelatoProviderPayment.address
|
||||
);
|
||||
|
|
|
@ -25,10 +25,10 @@ async function getAllContracts() {
|
|||
);
|
||||
await debtBridgeFromMakerForFullRefinance.deployed();
|
||||
|
||||
const ProviderModuleDSA = await ethers.getContractFactory(
|
||||
const ProviderModuleDsa = await ethers.getContractFactory(
|
||||
"ProviderModuleDsaFromMakerToMaker"
|
||||
);
|
||||
dsaProviderModule = await ProviderModuleDSA.deploy(
|
||||
dsaProviderModule = await ProviderModuleDsa.deploy(
|
||||
hre.network.config.GelatoCore,
|
||||
contracts.connectGelatoProviderPayment.address
|
||||
);
|
||||
|
|
|
@ -267,10 +267,10 @@ describe("Debt Bridge with External Provider", function () {
|
|||
);
|
||||
await connectGelatoProviderPayment.deployed();
|
||||
|
||||
const ProviderModuleDSA = await ethers.getContractFactory(
|
||||
"ProviderModuleDSA"
|
||||
const ProviderModuleDsa = await ethers.getContractFactory(
|
||||
"ProviderModuleDsa"
|
||||
);
|
||||
dsaProviderModule = await ProviderModuleDSA.deploy(
|
||||
dsaProviderModule = await ProviderModuleDsa.deploy(
|
||||
hre.network.config.GelatoCore,
|
||||
connectGelatoProviderPayment.address
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user