mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
feat: replace ConnectGelatoProviderPayment with ConnectGelatoExecutorPayment
This commit is contained in:
parent
9b197be90c
commit
7bbbe0d158
|
@ -36,13 +36,13 @@ Debt Bridge is a financial process that aims to make the user position safer. In
|
|||
|
||||
### Full Refinancing from Maker's Vault to Compound.
|
||||
|
||||
Based on the [debt bridge](https://docs.instadapp.io/usecases/debt-bridge/) documentation of Instadapp, we automated this process by adding two connectors `ConnectGelatoDataFullRefinanceMaker`, `ConnectGelatoProviderPayment` and a Gelato condition contract.
|
||||
Based on the [debt bridge](https://docs.instadapp.io/usecases/debt-bridge/) documentation of Instadapp, we automated this process by adding two connectors `ConnectGelatoDataFullRefinanceMaker`, `ConnectGelatoExecutorPayment` and a Gelato condition contract.
|
||||
|
||||
- `ConditionMakerVaultIsSafe.sol`: determine if a specific vault is on an unsafe position.
|
||||
|
||||
- `ConnectGelatoDataFullRefinanceMaker.sol`: generates the required data which will be assigned to the different inputs needed by `ConnectMaker` and `ConnectCompound`. Examples are the amount of DAI to pay back or the amount of Ether to withdraw from Maker. He will create the chain of connectors call needed to perform the debt refinance, he will generate the data wanted by the flashloan connector and he will call this flashloan connector through the cast function of Dsa.
|
||||
|
||||
- `ConnectGelatoProviderPayment.sol`: makes sure part of the moved collateral is used to pay the Gelato provider for the incurred transaction fee. The Gelato Provider will in turn pay the executor who executed the task.
|
||||
- `ConnectGelatoExecutorPayment.sol`: makes sure part of the moved collateral is used to pay the Gelato provider for the incurred transaction fee. The Gelato Provider will in turn pay the executor who executed the task.
|
||||
|
||||
In this example, the executor will be refunded for the incurred transaction fees by subtracting the estimated gas costs from the collateral which is moved from Maker to Compound. This means the user does not have to pre pay in order to incentivize the execution of the task.
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ import {
|
|||
_encodeBorrowMakerVault
|
||||
} from "../../functions/InstaDapp/connectors/FConnectMaker.sol";
|
||||
import {
|
||||
_encodePayGelatoProvider
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoProviderPayment.sol";
|
||||
_encodePayExecutor
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoExecutorPayment.sol";
|
||||
import {
|
||||
_encodeDepositCompound,
|
||||
_encodeBorrowCompound
|
||||
} from "../../functions/InstaDapp/connectors/FConnectCompound.sol";
|
||||
import {_getGelatoProviderFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {
|
||||
_getGasCostMakerToMaker,
|
||||
_getGasCostMakerToCompound,
|
||||
|
@ -52,11 +52,11 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
string public constant override name =
|
||||
"MockConnectGelatoDataFullRefinanceMaker-v1.0";
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _connectGelatoProviderPayment;
|
||||
address internal immutable _connectGelatoExecutorPayment;
|
||||
|
||||
constructor(uint256 id, address connectGelatoProviderPayment) {
|
||||
constructor(uint256 id, address connectGelatoExecutorPayment) {
|
||||
_id = id;
|
||||
_connectGelatoProviderPayment = connectGelatoProviderPayment;
|
||||
_connectGelatoExecutorPayment = connectGelatoExecutorPayment;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
|
@ -147,7 +147,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
_getMakerVaultCollateralBalance(_vaultAId);
|
||||
uint256 route = _route;
|
||||
uint256 gasCost = _getGasCostMakerToMaker(_vaultBId == 0, route);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(gasCost);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoExecutorFees(gasCost);
|
||||
|
||||
(address[] memory _targets, bytes[] memory _datas) =
|
||||
_vaultBId == 0
|
||||
|
@ -192,7 +192,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
targets[2] = CONNECT_MAKER; // open new B vault
|
||||
targets[3] = CONNECT_MAKER; // deposit
|
||||
targets[4] = CONNECT_MAKER; // borrow
|
||||
targets[5] = _connectGelatoProviderPayment; // payProvider
|
||||
targets[5] = _connectGelatoExecutorPayment; // payExecutor
|
||||
targets[6] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
datas = new bytes[](7);
|
||||
|
@ -206,12 +206,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
datas[4] = _encodeBorrowMakerVault(0, 0, 600, 0);
|
||||
datas[5] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
_gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
datas[5] = _encodePayExecutor(_colToken, _gasFeesPaidFromCol, 0, 0);
|
||||
datas[6] = _encodeFlashPayback(DAI, _wDaiToBorrow, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -228,7 +223,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
targets[1] = CONNECT_MAKER; // withdraw
|
||||
targets[2] = CONNECT_MAKER; // deposit
|
||||
targets[3] = CONNECT_MAKER; // borrow
|
||||
targets[4] = _connectGelatoProviderPayment; // payProvider
|
||||
targets[4] = _connectGelatoExecutorPayment; // payExecutor
|
||||
targets[5] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
datas = new bytes[](6);
|
||||
|
@ -241,12 +236,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
datas[3] = _encodeBorrowMakerVault(_vaultBId, 0, 600, 0);
|
||||
datas[4] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
_gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
datas[4] = _encodePayExecutor(_colToken, _gasFeesPaidFromCol, 0, 0);
|
||||
datas[5] = _encodeFlashPayback(DAI, _wDaiToBorrow, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -264,14 +254,14 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
_getMakerVaultCollateralBalance(_vaultId);
|
||||
uint256 route = _route;
|
||||
uint256 gasCost = _getGasCostMakerToCompound(route);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(gasCost);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoExecutorFees(gasCost);
|
||||
|
||||
address[] memory _targets = new address[](6);
|
||||
_targets[0] = CONNECT_MAKER; // payback
|
||||
_targets[1] = CONNECT_MAKER; // withdraw
|
||||
_targets[2] = CONNECT_COMPOUND; // deposit
|
||||
_targets[3] = CONNECT_COMPOUND; // borrow
|
||||
_targets[4] = _connectGelatoProviderPayment; // payProvider
|
||||
_targets[4] = _connectGelatoExecutorPayment; // payExecutor
|
||||
_targets[5] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
bytes[] memory _datas = new bytes[](6);
|
||||
|
@ -284,12 +274,7 @@ contract MockConnectGelatoDataFullRefinanceMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
_datas[3] = _encodeBorrowCompound(DAI, 0, 600, 0);
|
||||
_datas[4] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
_datas[4] = _encodePayExecutor(_colToken, gasFeesPaidFromCol, 0, 0);
|
||||
_datas[5] = _encodeFlashPayback(DAI, wDaiToBorrow, 0, 0);
|
||||
|
||||
datas = new bytes[](1);
|
||||
|
|
|
@ -33,13 +33,13 @@ import {
|
|||
_encodeBorrowMakerVault
|
||||
} from "../../functions/InstaDapp/connectors/FConnectMaker.sol";
|
||||
import {
|
||||
_encodePayGelatoProvider
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoProviderPayment.sol";
|
||||
_encodePayExecutor
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoExecutorPayment.sol";
|
||||
import {
|
||||
_encodeDepositCompound,
|
||||
_encodeBorrowCompound
|
||||
} from "../../functions/InstaDapp/connectors/FConnectCompound.sol";
|
||||
import {_getGelatoProviderFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {
|
||||
_getFlashLoanRoute,
|
||||
_getGasCostMakerToMaker,
|
||||
|
@ -59,11 +59,11 @@ contract ConnectGelatoDataFullMakerToCompound is ConnectorInterface {
|
|||
string public constant override name =
|
||||
"ConnectGelatoDataFullMakerToCompound-v1.0";
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _connectGelatoProviderPayment;
|
||||
address internal immutable _connectGelatoExecutorPayment;
|
||||
|
||||
constructor(uint256 id, address connectGelatoProviderPayment) {
|
||||
constructor(uint256 id, address connectGelatoExecutorPayment) {
|
||||
_id = id;
|
||||
_connectGelatoProviderPayment = connectGelatoProviderPayment;
|
||||
_connectGelatoExecutorPayment = connectGelatoExecutorPayment;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
|
@ -146,14 +146,14 @@ contract ConnectGelatoDataFullMakerToCompound is ConnectorInterface {
|
|||
_getMakerVaultCollateralBalance(_vaultId);
|
||||
uint256 route = _getFlashLoanRoute(DAI, wDaiToBorrow);
|
||||
uint256 gasCost = _getGasCostMakerToCompound(route);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(gasCost);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoExecutorFees(gasCost);
|
||||
|
||||
address[] memory _targets = new address[](6);
|
||||
_targets[0] = CONNECT_MAKER; // payback
|
||||
_targets[1] = CONNECT_MAKER; // withdraw
|
||||
_targets[2] = CONNECT_COMPOUND; // deposit
|
||||
_targets[3] = CONNECT_COMPOUND; // borrow
|
||||
_targets[4] = _connectGelatoProviderPayment; // payProvider
|
||||
_targets[4] = _connectGelatoExecutorPayment; // payExecutor
|
||||
_targets[5] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
bytes[] memory _datas = new bytes[](6);
|
||||
|
@ -166,12 +166,7 @@ contract ConnectGelatoDataFullMakerToCompound is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
_datas[3] = _encodeBorrowCompound(DAI, 0, 600, 0);
|
||||
_datas[4] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
_datas[4] = _encodePayExecutor(_colToken, gasFeesPaidFromCol, 0, 0);
|
||||
_datas[5] = _encodeFlashPayback(DAI, wDaiToBorrow, 0, 0);
|
||||
|
||||
datas = new bytes[](1);
|
||||
|
|
|
@ -33,13 +33,13 @@ import {
|
|||
_encodeBorrowMakerVault
|
||||
} from "../../functions/InstaDapp/connectors/FConnectMaker.sol";
|
||||
import {
|
||||
_encodePayGelatoProvider
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoProviderPayment.sol";
|
||||
_encodePayExecutor
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoExecutorPayment.sol";
|
||||
import {
|
||||
_encodeDepositCompound,
|
||||
_encodeBorrowCompound
|
||||
} from "../../functions/InstaDapp/connectors/FConnectCompound.sol";
|
||||
import {_getGelatoProviderFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {
|
||||
_getFlashLoanRoute,
|
||||
_getGasCostMakerToMaker,
|
||||
|
@ -59,11 +59,11 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
string public constant override name =
|
||||
"ConnectGelatoDataFullMakerToMaker-v1.0";
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _connectGelatoProviderPayment;
|
||||
address internal immutable _connectGelatoExecutorPayment;
|
||||
|
||||
constructor(uint256 id, address connectGelatoProviderPayment) {
|
||||
constructor(uint256 id, address connectGelatoExecutorPayment) {
|
||||
_id = id;
|
||||
_connectGelatoProviderPayment = connectGelatoProviderPayment;
|
||||
_connectGelatoExecutorPayment = connectGelatoExecutorPayment;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
|
@ -152,7 +152,7 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
_getMakerVaultCollateralBalance(_vaultAId);
|
||||
uint256 route = _getFlashLoanRoute(DAI, wDaiToBorrow);
|
||||
uint256 gasCost = _getGasCostMakerToMaker(_vaultBId == 0, route);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(gasCost);
|
||||
uint256 gasFeesPaidFromCol = _getGelatoExecutorFees(gasCost);
|
||||
|
||||
(address[] memory _targets, bytes[] memory _datas) =
|
||||
_vaultBId == 0
|
||||
|
@ -197,7 +197,7 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
targets[2] = CONNECT_MAKER; // open new B vault
|
||||
targets[3] = CONNECT_MAKER; // deposit
|
||||
targets[4] = CONNECT_MAKER; // borrow
|
||||
targets[5] = _connectGelatoProviderPayment; // payProvider
|
||||
targets[5] = _connectGelatoExecutorPayment; // payExecutor
|
||||
targets[6] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
datas = new bytes[](7);
|
||||
|
@ -211,12 +211,7 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
datas[4] = _encodeBorrowMakerVault(0, 0, 600, 0);
|
||||
datas[5] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
_gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
datas[5] = _encodePayExecutor(_colToken, _gasFeesPaidFromCol, 0, 0);
|
||||
datas[6] = _encodeFlashPayback(DAI, _wDaiToBorrow, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -233,7 +228,7 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
targets[1] = CONNECT_MAKER; // withdraw
|
||||
targets[2] = CONNECT_MAKER; // deposit
|
||||
targets[3] = CONNECT_MAKER; // borrow
|
||||
targets[4] = _connectGelatoProviderPayment; // payProvider
|
||||
targets[4] = _connectGelatoExecutorPayment; // payExecutor
|
||||
targets[5] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
datas = new bytes[](6);
|
||||
|
@ -246,12 +241,7 @@ contract ConnectGelatoDataFullMakerToMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
datas[3] = _encodeBorrowMakerVault(_vaultBId, 0, 600, 0);
|
||||
datas[4] = _encodePayGelatoProvider(
|
||||
_colToken,
|
||||
_gasFeesPaidFromCol,
|
||||
0,
|
||||
0
|
||||
);
|
||||
datas[4] = _encodePayExecutor(_colToken, _gasFeesPaidFromCol, 0, 0);
|
||||
datas[5] = _encodeFlashPayback(DAI, _wDaiToBorrow, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ import {
|
|||
_encodeBorrowMakerVault
|
||||
} from "../../functions/InstaDapp/connectors/FConnectMaker.sol";
|
||||
import {
|
||||
_encodePayGelatoProvider
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoProviderPayment.sol";
|
||||
_encodePayExecutor
|
||||
} from "../../functions/InstaDapp/connectors/FConnectGelatoExecutorPayment.sol";
|
||||
import {
|
||||
_encodeDepositCompound,
|
||||
_encodeBorrowCompound
|
||||
} from "../../functions/InstaDapp/connectors/FConnectCompound.sol";
|
||||
import {_getGelatoProviderFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../functions/gelato/FGelato.sol";
|
||||
import {
|
||||
_wCalcCollateralToWithdraw,
|
||||
_wCalcDebtToRepay
|
||||
|
@ -69,13 +69,13 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
string public constant override name =
|
||||
"ConnectGelatoDataPartialRefinanceMaker-v1.0";
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _connectGelatoProviderPayment;
|
||||
address internal immutable _connectGelatoExecutorPayment;
|
||||
|
||||
uint256 public constant GAS_COST = 1850000;
|
||||
|
||||
constructor(uint256 id, address connectGelatoProviderPayment) {
|
||||
constructor(uint256 id, address connectGelatoExecutorPayment) {
|
||||
_id = id;
|
||||
_connectGelatoProviderPayment = connectGelatoProviderPayment;
|
||||
_connectGelatoExecutorPayment = connectGelatoExecutorPayment;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
|
@ -159,7 +159,7 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
_targets[2] = CONNECT_MAKER; // open ETH-B vault
|
||||
_targets[3] = CONNECT_MAKER; // deposit
|
||||
_targets[4] = CONNECT_MAKER; // borrow
|
||||
_targets[5] = _connectGelatoProviderPayment; // payProvider
|
||||
_targets[5] = _connectGelatoExecutorPayment; // payExecutor
|
||||
_targets[6] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
bytes[] memory _datas = new bytes[](7);
|
||||
|
@ -183,7 +183,7 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
_datas[4] = _encodeBorrowMakerVault(0, wDaiDebtToMove, 0, 0);
|
||||
_datas[5] = _encodePayGelatoProvider(
|
||||
_datas[5] = _encodePayExecutor(
|
||||
_payload.colToken,
|
||||
gasFeesPaidFromCol,
|
||||
0,
|
||||
|
@ -227,7 +227,7 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
_targets[1] = CONNECT_MAKER; // withdraw
|
||||
_targets[2] = CONNECT_COMPOUND; // deposit
|
||||
_targets[3] = CONNECT_COMPOUND; // borrow
|
||||
_targets[4] = _connectGelatoProviderPayment; // payProvider
|
||||
_targets[4] = _connectGelatoExecutorPayment; // payExecutor
|
||||
_targets[5] = INSTA_POOL_V2; // flashPayback
|
||||
|
||||
bytes[] memory _datas = new bytes[](6);
|
||||
|
@ -250,7 +250,7 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
0
|
||||
);
|
||||
_datas[3] = _encodeBorrowCompound(DAI, wDaiDebtToMove, 0, 0);
|
||||
_datas[4] = _encodePayGelatoProvider(
|
||||
_datas[4] = _encodePayExecutor(
|
||||
_payload.colToken,
|
||||
gasFeesPaidFromCol,
|
||||
0,
|
||||
|
@ -315,7 +315,7 @@ contract ConnectGelatoDataPartialRefinanceMaker is ConnectorInterface {
|
|||
|
||||
// TO DO: add fee mechanism for non-ETH collateral debt bridge
|
||||
// uint256 gasFeesPaidFromCol = _mul(GAS_COST, wmul(_getGelatoGasPrice(), latestPrice));
|
||||
gasFeesPaidFromCol = _getGelatoProviderFees(GAS_COST);
|
||||
gasFeesPaidFromCol = _getGelatoExecutorFees(GAS_COST);
|
||||
|
||||
uint256 wPricedCol =
|
||||
wmul(
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
import {
|
||||
IConnectGelatoExecutorPayment
|
||||
} from "../../interfaces/InstaDapp/connectors/IConnectGelatoExecutorPayment.sol";
|
||||
import {Address} from "../../vendor/Address.sol";
|
||||
import {IERC20} from "../../vendor/IERC20.sol";
|
||||
import {SafeERC20} from "../../vendor/SafeERC20.sol";
|
||||
import {_getUint, _setUint} from "../../functions/InstaDapp/FInstaDapp.sol";
|
||||
import {ETH} from "../../constants/CInstaDapp.sol";
|
||||
|
||||
/// @title ConnectGelatoExecutorPayment
|
||||
/// @notice InstaDapp Connector to compensate Gelato Executors for automation-gas.
|
||||
/// @author Gelato Team
|
||||
contract ConnectGelatoExecutorPayment is IConnectGelatoExecutorPayment {
|
||||
using Address for address payable;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
// solhint-disable-next-line const-name-snakecase
|
||||
string public constant override name = "ConnectGelatoExecutorPayment-v1.0";
|
||||
|
||||
uint256 internal immutable _id;
|
||||
|
||||
constructor(uint256 id) {
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
function connectorID()
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (uint256 _type, uint256 id)
|
||||
{
|
||||
(_type, id) = (1, _id); // Should put specific value.
|
||||
}
|
||||
|
||||
/// @notice Transfers automation gas fees to Gelato Executor
|
||||
/// @dev Gelato Executor risks:
|
||||
/// - _getId does not match actual InstaMemory executor payment slot
|
||||
/// - _token balance not in DSA
|
||||
/// - worthless _token risk
|
||||
/// payable to be compatible in conjunction with DSA.cast payable target
|
||||
/// @param _token The token used to pay the Executor.
|
||||
/// @param _amt The amount of _token to pay the Gelato Executor.
|
||||
/// @param _getId The InstaMemory slot at which the payment amount was stored.
|
||||
/// @param _setId The InstaMemory slot to save the executor payout amound in.
|
||||
function payExecutor(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) external payable override {
|
||||
uint256 amt = _getUint(_getId, _amt);
|
||||
_setUint(_setId, amt);
|
||||
if (_token == ETH) payable(tx.origin).sendValue(amt);
|
||||
else IERC20(_token).safeTransfer(tx.origin, amt);
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
import {
|
||||
IConnectGelatoProviderPayment
|
||||
} from "../../interfaces/InstaDapp/connectors/IConnectGelatoProviderPayment.sol";
|
||||
import {Ownable} from "../../vendor/Ownable.sol";
|
||||
import {Address} from "../../vendor/Address.sol";
|
||||
import {GelatoString} from "../../lib/GelatoString.sol";
|
||||
import {IERC20} from "../../vendor/IERC20.sol";
|
||||
import {SafeERC20} from "../../vendor/SafeERC20.sol";
|
||||
import {_getUint, _setUint} from "../../functions/InstaDapp/FInstaDapp.sol";
|
||||
import {ETH} from "../../constants/CInstaDapp.sol";
|
||||
import {
|
||||
IGelatoProviders
|
||||
} from "@gelatonetwork/core/contracts/gelato_core/interfaces/IGelatoProviders.sol";
|
||||
|
||||
/// @title ConnectGelatoProviderPayment
|
||||
/// @notice InstaDapp Connector to compensate Gelato automation-gas Providers.
|
||||
/// @author Gelato Team
|
||||
contract ConnectGelatoProviderPayment is
|
||||
IConnectGelatoProviderPayment,
|
||||
Ownable
|
||||
{
|
||||
using Address for address payable;
|
||||
using GelatoString for string;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
// solhint-disable-next-line const-name-snakecase
|
||||
string public constant override name = "ConnectGelatoProviderPayment-v1.0";
|
||||
|
||||
address public constant override GELATO_CORE =
|
||||
0x1d681d76ce96E4d70a88A00EBbcfc1E47808d0b8;
|
||||
|
||||
address public override gelatoProvider;
|
||||
|
||||
uint256 internal immutable _id;
|
||||
address internal immutable _this;
|
||||
|
||||
constructor(uint256 id, address _gelatoProvider)
|
||||
noAddressZeroProvider(_gelatoProvider)
|
||||
{
|
||||
_id = id;
|
||||
_this = address(this);
|
||||
gelatoProvider = _gelatoProvider;
|
||||
}
|
||||
|
||||
modifier noAddressZeroProvider(address _gelatoProvider) {
|
||||
require(
|
||||
_gelatoProvider != address(0x0),
|
||||
"ConnectGelatoProviderPayment.noAddressZeroProvider"
|
||||
);
|
||||
_;
|
||||
}
|
||||
|
||||
/// @dev Connector Details
|
||||
function connectorID()
|
||||
external
|
||||
view
|
||||
override
|
||||
returns (uint256 _type, uint256 id)
|
||||
{
|
||||
(_type, id) = (1, _id); // Should put specific value.
|
||||
}
|
||||
|
||||
/// @notice Set the gelatoProvider address that will be paid for executing a task
|
||||
function setProvider(address _gelatoProvider)
|
||||
external
|
||||
override
|
||||
onlyOwner
|
||||
noAddressZeroProvider(_gelatoProvider)
|
||||
{
|
||||
gelatoProvider = _gelatoProvider;
|
||||
}
|
||||
|
||||
/// @notice Transfers automation gas fees to Gelato Provider
|
||||
/// @dev Gelato Provider risks:
|
||||
/// - _getId does not match actual InstaMemory gelatoProvider payment slot
|
||||
/// - _token balance not in DSA
|
||||
/// - worthless _token risk
|
||||
/// payable to be compatible in conjunction with DSA.cast payable target
|
||||
/// @param _token The token used to pay the Provider.
|
||||
/// @param _amt The amount of _token to pay the Gelato Provider.
|
||||
/// @param _getId The InstaMemory slot at which the payment amount was stored.
|
||||
/// @param _setId The InstaMemory slot to save the gelatoProvider payout amound in.
|
||||
function payProvider(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) external payable override {
|
||||
address provider =
|
||||
IConnectGelatoProviderPayment(_this).gelatoProvider();
|
||||
|
||||
uint256 amt = _getUint(_getId, _amt);
|
||||
_setUint(_setId, amt);
|
||||
|
||||
if (_token == ETH) {
|
||||
// solhint-disable no-empty-blocks
|
||||
try
|
||||
IGelatoProviders(GELATO_CORE).provideFunds{value: amt}(provider)
|
||||
{} catch Error(string memory error) {
|
||||
error.revertWithInfo(
|
||||
"ConnectGelatoProviderPayment.payProvider.provideFunds:"
|
||||
);
|
||||
} catch {
|
||||
revert(
|
||||
"ConnectGelatoProviderPayment.payProvider.provideFunds:undefined"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
IERC20(_token).safeTransfer(provider, amt);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import {
|
|||
_getGasCostMakerToMaker,
|
||||
_getRealisedDebt
|
||||
} from "../../../functions/gelato/FGelatoDebtBridge.sol";
|
||||
import {_getGelatoProviderFees} from "../../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../../functions/gelato/FGelato.sol";
|
||||
import {DAI} from "../../../constants/CInstaDapp.sol";
|
||||
import {wdiv} from "../../../vendor/DSMath.sol";
|
||||
|
||||
|
@ -76,7 +76,7 @@ contract ConditionDebtBridgeIsAffordable is GelatoConditionsStandard {
|
|||
uint256 wColToWithdrawFromMaker =
|
||||
_getMakerVaultCollateralBalance(_vaultId);
|
||||
uint256 gasFeesPaidFromCol =
|
||||
_getGelatoProviderFees(
|
||||
_getGelatoExecutorFees(
|
||||
_getGasCostMakerToMaker(
|
||||
false,
|
||||
_getFlashLoanRoute(
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
_getGasCostMakerToMaker,
|
||||
_getRealisedDebt
|
||||
} from "../../../functions/gelato/FGelatoDebtBridge.sol";
|
||||
import {_getGelatoProviderFees} from "../../../functions/gelato/FGelato.sol";
|
||||
import {_getGelatoExecutorFees} from "../../../functions/gelato/FGelato.sol";
|
||||
import {GelatoBytes} from "../../../lib/GelatoBytes.sol";
|
||||
import {sub} from "../../../vendor/DSMath.sol";
|
||||
|
||||
|
@ -70,7 +70,7 @@ contract ConditionDestVaultWillBeSafe is GelatoConditionsStandard {
|
|||
uint256 wColToDeposit =
|
||||
sub(
|
||||
_getMakerVaultCollateralBalance(_fromVaultId),
|
||||
_getGelatoProviderFees(
|
||||
_getGelatoExecutorFees(
|
||||
_getGasCostMakerToMaker(
|
||||
_destVaultId == 0,
|
||||
_getFlashLoanRoute(DAI, wDaiToBorrow)
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
pragma solidity 0.7.4;
|
||||
|
||||
import {
|
||||
IConnectGelatoProviderPayment
|
||||
} from "../../../interfaces/InstaDapp/connectors/IConnectGelatoProviderPayment.sol";
|
||||
IConnectGelatoExecutorPayment
|
||||
} from "../../../interfaces/InstaDapp/connectors/IConnectGelatoExecutorPayment.sol";
|
||||
|
||||
function _encodePayGelatoProvider(
|
||||
function _encodePayExecutor(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
|
@ -13,7 +13,7 @@ function _encodePayGelatoProvider(
|
|||
) pure returns (bytes memory) {
|
||||
return
|
||||
abi.encodeWithSelector(
|
||||
IConnectGelatoProviderPayment.payProvider.selector,
|
||||
IConnectGelatoExecutorPayment.payExecutor.selector,
|
||||
_token,
|
||||
_amt,
|
||||
_getId,
|
|
@ -10,6 +10,6 @@ function _getGelatoGasPrice() view returns (uint256) {
|
|||
return uint256(oracleGasPrice);
|
||||
}
|
||||
|
||||
function _getGelatoProviderFees(uint256 _gas) view returns (uint256) {
|
||||
function _getGelatoExecutorFees(uint256 _gas) view returns (uint256) {
|
||||
return mul(_gas, _getGelatoGasPrice());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
import {ConnectorInterface} from "../IInstaDapp.sol";
|
||||
|
||||
interface IConnectGelatoExecutorPayment is ConnectorInterface {
|
||||
function payExecutor(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) external payable;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity 0.7.4;
|
||||
|
||||
import {ConnectorInterface} from "../IInstaDapp.sol";
|
||||
|
||||
interface IConnectGelatoProviderPayment is ConnectorInterface {
|
||||
function setProvider(address _provider) external;
|
||||
|
||||
function payProvider(
|
||||
address _token,
|
||||
uint256 _amt,
|
||||
uint256 _getId,
|
||||
uint256 _setId
|
||||
) external payable;
|
||||
|
||||
function gelatoProvider() external view returns (address);
|
||||
|
||||
// solhint-disable-next-line func-name-mixedcase
|
||||
function GELATO_CORE() external pure returns (address);
|
||||
}
|
|
@ -43,7 +43,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
connectorId,
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -65,7 +65,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
parseInt(process.env.ConnectGelatoDataFullRefinanceMakerId),
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
gasPrice: hre.network.config.gasPrice,
|
||||
log: true,
|
||||
|
@ -79,5 +79,5 @@ module.exports.skip = async (hre) => {
|
|||
return process.env.ConnectGelatoDataFullRefinanceMakerId === undefined;
|
||||
return false;
|
||||
};
|
||||
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
||||
module.exports.dependencies = ["ConnectGelatoExecutorPayment"];
|
||||
module.exports.tags = ["MockConnectGelatoDataFullRefinanceMaker"];
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
connectorId,
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
parseInt(process.env.ConnectGelatoDataPartialRefinanceMakerId),
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
gasPrice: hre.network.config.gasPrice,
|
||||
log: true,
|
||||
|
@ -83,4 +83,4 @@ module.exports.skip = async (hre) => {
|
|||
return false;
|
||||
};
|
||||
module.exports.tags = ["ConnectGelatoDataPartialRefinanceMaker"];
|
||||
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
||||
module.exports.dependencies = ["ConnectGelatoExecutorPayment"];
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
connectorId,
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -65,7 +65,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
parseInt(process.env.ConnectGelatoDataFullMakerToCompoundId),
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
gasPrice: hre.network.config.gasPrice,
|
||||
log: true,
|
||||
|
@ -79,5 +79,5 @@ module.exports.skip = async (hre) => {
|
|||
return process.env.ConnectGelatoDataFullMakerToCompoundId === undefined;
|
||||
return false;
|
||||
};
|
||||
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
||||
module.exports.dependencies = ["ConnectGelatoExecutorPayment"];
|
||||
module.exports.tags = ["ConnectGelatoDataFullMakerToCompound"];
|
||||
|
|
|
@ -42,7 +42,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
connectorId,
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -63,7 +63,7 @@ module.exports = async (hre) => {
|
|||
from: deployer,
|
||||
args: [
|
||||
parseInt(process.env.ConnectGelatoDataFullMakerToMakerId),
|
||||
(await deployments.get("ConnectGelatoProviderPayment")).address,
|
||||
(await deployments.get("ConnectGelatoExecutorPayment")).address,
|
||||
],
|
||||
gasPrice: hre.network.config.gasPrice,
|
||||
log: true,
|
||||
|
@ -77,5 +77,5 @@ module.exports.skip = async (hre) => {
|
|||
return process.env.ConnectGelatoDataFullMakerToMakerId === undefined;
|
||||
return false;
|
||||
};
|
||||
module.exports.dependencies = ["ConnectGelatoProviderPayment"];
|
||||
module.exports.dependencies = ["ConnectGelatoExecutorPayment"];
|
||||
module.exports.tags = ["ConnectGelatoDataFullMakerToMaker"];
|
||||
|
|
|
@ -5,14 +5,14 @@ const { sleep } = require("@gelatonetwork/core");
|
|||
module.exports = async (hre) => {
|
||||
if (hre.network.name === "mainnet") {
|
||||
console.log(
|
||||
"Deploying ConnectGelatoProviderPayment to mainnet. Hit ctrl + c to abort"
|
||||
"Deploying ConnectGelatoExecutorPayment to mainnet. Hit ctrl + c to abort"
|
||||
);
|
||||
console.log("❗ CONNECTOR DEPLOYMENT: VERIFY & HARDCODE CONNECTOR ID");
|
||||
await sleep(10000);
|
||||
}
|
||||
const { deployments } = hre;
|
||||
const { deploy } = deployments;
|
||||
const { deployer, gelatoProvider } = await hre.getNamedAccounts();
|
||||
const { deployer } = await hre.getNamedAccounts();
|
||||
|
||||
if (hre.network.name === "hardhat") {
|
||||
const deployerWallet = await ethers.provider.getSigner(deployer);
|
||||
|
@ -37,15 +37,15 @@ module.exports = async (hre) => {
|
|||
const connectorLength = await instaConnectors.connectorLength();
|
||||
const connectorId = connectorLength.add(1);
|
||||
|
||||
await deploy("ConnectGelatoProviderPayment", {
|
||||
await deploy("ConnectGelatoExecutorPayment", {
|
||||
from: deployer,
|
||||
args: [connectorId, gelatoProvider],
|
||||
args: [connectorId],
|
||||
});
|
||||
|
||||
await instaConnectors
|
||||
.connect(instaMaster)
|
||||
.enable(
|
||||
(await ethers.getContract("ConnectGelatoProviderPayment")).address
|
||||
(await ethers.getContract("ConnectGelatoExecutorPayment")).address
|
||||
);
|
||||
|
||||
await hre.network.provider.request({
|
||||
|
@ -53,14 +53,11 @@ module.exports = async (hre) => {
|
|||
params: [await instaMaster.getAddress()],
|
||||
});
|
||||
} else {
|
||||
// the following will only deploy "ConnectGelatoProviderPayment"
|
||||
// the following will only deploy "ConnectGelatoExecutorPayment"
|
||||
// if the contract was never deployed or if the code changed since last deployment
|
||||
await deploy("ConnectGelatoProviderPayment", {
|
||||
await deploy("ConnectGelatoExecutorPayment", {
|
||||
from: deployer,
|
||||
args: [
|
||||
parseInt(process.env.ConnectGelatoProviderPaymentId),
|
||||
gelatoProvider,
|
||||
],
|
||||
args: [parseInt(process.env.ConnectGelatoExecutorPaymentId)],
|
||||
gasPrice: hre.network.config.gasPrice,
|
||||
log: true,
|
||||
});
|
||||
|
@ -70,7 +67,7 @@ module.exports = async (hre) => {
|
|||
module.exports.skip = async (hre) => {
|
||||
if (hre.network.name === "mainnet") return true;
|
||||
if (hre.network.name !== "hardhat")
|
||||
return process.env.ConnectGelatoProviderPaymentId === undefined;
|
||||
return process.env.ConnectGelatoExecutorPaymentId === undefined;
|
||||
return false;
|
||||
};
|
||||
module.exports.tags = ["ConnectGelatoProviderPayment"];
|
||||
module.exports.tags = ["ConnectGelatoExecutorPayment"];
|
|
@ -41,12 +41,8 @@ module.exports = {
|
|||
user: {
|
||||
default: 0,
|
||||
},
|
||||
gelatoProvider: {
|
||||
executor: {
|
||||
default: 1,
|
||||
mainnet: DEPLOYER,
|
||||
},
|
||||
gelatoExecutor: {
|
||||
default: 2,
|
||||
},
|
||||
},
|
||||
networks: {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"eslint": "7.14.0",
|
||||
"eslint-config-prettier": "6.15.0",
|
||||
"ethereum-waffle": "3.2.1",
|
||||
"ethers": "5.0.22",
|
||||
"ethers": "5.0.23",
|
||||
"hardhat": "2.0.3",
|
||||
"hardhat-deploy": "0.7.0-beta.30",
|
||||
"hardhat-deploy-ethers": "0.3.0-beta.6",
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = async function (
|
|||
|
||||
expect(
|
||||
await contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -41,7 +41,7 @@ module.exports = async function (
|
|||
|
||||
expect(
|
||||
await contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -52,7 +52,7 @@ module.exports = async function (
|
|||
if (mockRoute === 0) {
|
||||
await expect(
|
||||
contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.execViaRoute0AndOpenVault(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -61,7 +61,7 @@ module.exports = async function (
|
|||
} else if (mockRoute === 1) {
|
||||
await expect(
|
||||
contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.execViaRoute1AndOpenVault(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -70,7 +70,7 @@ module.exports = async function (
|
|||
} else if (mockRoute === 2) {
|
||||
await expect(
|
||||
contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.execViaRoute2AndOpenVault(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -79,7 +79,7 @@ module.exports = async function (
|
|||
} else if (mockRoute === 3) {
|
||||
await expect(
|
||||
contracts.mockDebtBridgeETHBExecutor
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.execViaRoute3AndOpenVAult(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -91,7 +91,7 @@ module.exports = async function (
|
|||
|
||||
// 🚧 For Debugging:
|
||||
// const txResponse2 = await contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice,
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
|
|
@ -50,13 +50,13 @@ module.exports = async function (
|
|||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.isTaskSpecProvided(
|
||||
wallets.gelatoProviderAddress,
|
||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||
|
@ -65,11 +65,11 @@ module.exports = async function (
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.taskSpecGasPriceCeil(
|
||||
wallets.gelatoProviderAddress,
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||
)
|
||||
).to.be.equal(gasPriceCeil);
|
||||
|
|
|
@ -18,18 +18,18 @@ module.exports = async function (mockRoute) {
|
|||
|
||||
// Gelato Testing environment setup.
|
||||
await provideFunds(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
constants.GAS_LIMIT,
|
||||
constants.GAS_PRICE_CEIL
|
||||
);
|
||||
await providerAssignsExecutor(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.mockDebtBridgeETHBExecutor.address,
|
||||
contracts.gelatoCore
|
||||
);
|
||||
await addProviderModuleDSA(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
contracts.dsaProviderModule.address
|
||||
);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { expect } = require("chai");
|
||||
|
||||
module.exports = async function (
|
||||
gelatoProviderWallet,
|
||||
gelatoProvider,
|
||||
gelatoCore,
|
||||
dsaProviderModuleAddr
|
||||
) {
|
||||
|
@ -11,17 +11,17 @@ module.exports = async function (
|
|||
// payload by adding some specificity like his address to the
|
||||
// Payment connector for receiving payment of User.
|
||||
|
||||
const gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
const gelatoProviderAddress = await gelatoProvider.getAddress();
|
||||
|
||||
await expect(
|
||||
gelatoCore
|
||||
.connect(gelatoProviderWallet)
|
||||
.connect(gelatoProvider)
|
||||
.addProviderModules([dsaProviderModuleAddr])
|
||||
).to.emit(gelatoCore, "LogProviderModuleAdded");
|
||||
|
||||
expect(
|
||||
await gelatoCore
|
||||
.connect(gelatoProviderWallet)
|
||||
.connect(gelatoProvider)
|
||||
.isModuleProvided(gelatoProviderAddress, dsaProviderModuleAddr)
|
||||
).to.be.true;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { expect } = require("chai");
|
||||
|
||||
module.exports = async function (
|
||||
gelatoProviderWallet,
|
||||
gelatoProvider,
|
||||
gelatoCore,
|
||||
gasLimit,
|
||||
gasPriceCeil
|
||||
|
@ -13,7 +13,7 @@ module.exports = async function (
|
|||
// Provider. At each provider's task execution, some funds (approximatively
|
||||
// the gas cost value) will be transfered to the Executor stake.
|
||||
|
||||
let gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
let gelatoProviderAddress = await gelatoProvider.getAddress();
|
||||
|
||||
const TASK_AUTOMATION_FUNDS = await gelatoCore.minExecProviderFunds(
|
||||
gasLimit,
|
||||
|
@ -21,11 +21,9 @@ module.exports = async function (
|
|||
);
|
||||
|
||||
await expect(
|
||||
gelatoCore
|
||||
.connect(gelatoProviderWallet)
|
||||
.provideFunds(gelatoProviderAddress, {
|
||||
value: TASK_AUTOMATION_FUNDS,
|
||||
})
|
||||
gelatoCore.connect(gelatoProvider).provideFunds(gelatoProviderAddress, {
|
||||
value: TASK_AUTOMATION_FUNDS,
|
||||
})
|
||||
).to.emit(gelatoCore, "LogFundsProvided");
|
||||
|
||||
expect(await gelatoCore.providerFunds(gelatoProviderAddress)).to.be.equal(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { expect } = require("chai");
|
||||
|
||||
module.exports = async function (
|
||||
gelatoProviderWallet,
|
||||
gelatoProvider,
|
||||
gelatoExecutorAddress,
|
||||
gelatoCore
|
||||
) {
|
||||
|
@ -10,11 +10,11 @@ module.exports = async function (
|
|||
// Provider choose a executor who will execute futur task
|
||||
// for the provider, it will be compensated by the provider.
|
||||
|
||||
const gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
const gelatoProviderAddress = await gelatoProvider.getAddress();
|
||||
|
||||
await expect(
|
||||
gelatoCore
|
||||
.connect(gelatoProviderWallet)
|
||||
.connect(gelatoProvider)
|
||||
.providerAssignsExecutor(gelatoExecutorAddress)
|
||||
).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { expect } = require("chai");
|
||||
|
||||
module.exports = async function (gelatoExecutorWallet, gelatoCore) {
|
||||
module.exports = async function (executor, gelatoCore) {
|
||||
//#region Executor Stake on Gelato
|
||||
|
||||
// For task execution provider will ask a executor to watch the
|
||||
|
@ -10,9 +10,9 @@ module.exports = async function (gelatoExecutorWallet, gelatoCore) {
|
|||
// For safety measure Gelato ask the executor to stake a minimum
|
||||
// amount.
|
||||
|
||||
const gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||
const gelatoExecutorAddress = await executor.getAddress();
|
||||
|
||||
await gelatoCore.connect(gelatoExecutorWallet).stakeExecutor({
|
||||
await gelatoCore.connect(executor).stakeExecutor({
|
||||
value: await gelatoCore.minExecutorStake(),
|
||||
});
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ module.exports = async function () {
|
|||
const conditionDebtBridgeIsAffordable = await ethers.getContract(
|
||||
"ConditionDebtBridgeIsAffordable"
|
||||
);
|
||||
const connectGelatoProviderPayment = await ethers.getContract(
|
||||
"ConnectGelatoProviderPayment"
|
||||
const connectGelatoExecutorPayment = await ethers.getContract(
|
||||
"ConnectGelatoExecutorPayment"
|
||||
);
|
||||
const makerResolver = await ethers.getContract("MakerResolver");
|
||||
const connectGelatoDataFullMakerToMaker = await ethers.getContract(
|
||||
|
@ -140,7 +140,7 @@ module.exports = async function () {
|
|||
instaConnectors,
|
||||
compoundResolver,
|
||||
conditionMakerVaultUnsafe,
|
||||
connectGelatoProviderPayment,
|
||||
connectGelatoExecutorPayment,
|
||||
priceOracleResolver,
|
||||
dsa: ethers.constants.AddressZero,
|
||||
makerResolver,
|
||||
|
|
|
@ -5,19 +5,15 @@ const { ethers } = hre;
|
|||
module.exports = async function () {
|
||||
let userWallet;
|
||||
let userAddress;
|
||||
let gelatoProviderWallet;
|
||||
let gelatoProvider;
|
||||
let gelatoProviderAddress;
|
||||
let gelatoExecutorWallet;
|
||||
let executor;
|
||||
let gelatoExecutorAddress;
|
||||
|
||||
[
|
||||
userWallet,
|
||||
gelatoProviderWallet,
|
||||
gelatoExecutorWallet,
|
||||
] = await ethers.getSigners();
|
||||
[userWallet, gelatoProvider, executor] = await ethers.getSigners();
|
||||
userAddress = await userWallet.getAddress();
|
||||
gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||
gelatoProviderAddress = await gelatoProvider.getAddress();
|
||||
gelatoExecutorAddress = await executor.getAddress();
|
||||
|
||||
// Hardhat default wallets prefilled with 100 ETH
|
||||
expect(await userWallet.getBalance()).to.be.gt(ethers.utils.parseEther("10"));
|
||||
|
@ -25,9 +21,9 @@ module.exports = async function () {
|
|||
return {
|
||||
userWallet: userWallet,
|
||||
userAddress: userAddress,
|
||||
gelatoProviderWallet: gelatoProviderWallet,
|
||||
gelatoProvider: gelatoProvider,
|
||||
gelatoProviderAddress: gelatoProviderAddress,
|
||||
gelatoExecutorWallet: gelatoExecutorWallet,
|
||||
executor: executor,
|
||||
gelatoExecutorAddress: gelatoExecutorAddress,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -170,7 +170,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -181,7 +181,7 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -216,22 +216,18 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
|||
).sub(gasFeesPaidFromCol);
|
||||
|
||||
//#endregion
|
||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||
wallets.gelatoProviderAddress
|
||||
);
|
||||
const executorBalanceBeforeExecution = await wallets.executor.getBalance();
|
||||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
contracts.gelatoCore.connect(wallets.executor).exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||
|
||||
// 🚧 For Debugging:
|
||||
// const txResponse2 = await contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice,
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -244,14 +240,12 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function ()
|
|||
// }
|
||||
// await GelatoCoreLib.sleep(10000);
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||
).to.be.gt(
|
||||
providerBalanceBeforeExecution.sub(
|
||||
gasFeesPaidFromCol
|
||||
.mul(await contracts.gelatoCore.totalSuccessShare())
|
||||
.div(100)
|
||||
)
|
||||
expect(await wallets.executor.getBalance()).to.be.gt(
|
||||
executorBalanceBeforeExecution
|
||||
);
|
||||
|
||||
expect(await wallets.executor.getBalance()).to.be.gt(
|
||||
executorBalanceBeforeExecution
|
||||
);
|
||||
|
||||
// compound position of DSA on cDai and cEth
|
||||
|
|
|
@ -184,7 +184,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -195,7 +195,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -235,22 +235,18 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
|||
).sub(gasFeesPaidFromCol);
|
||||
|
||||
//#endregion
|
||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||
wallets.gelatoProviderAddress
|
||||
);
|
||||
const executorBalanceBeforeExecution = await wallets.executor.getBalance();
|
||||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
contracts.gelatoCore.connect(wallets.executor).exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||
|
||||
// 🚧 For Debugging:
|
||||
// const txResponse2 = await contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice,
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -285,14 +281,8 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
|||
vaultBId
|
||||
);
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||
).to.be.gt(
|
||||
providerBalanceBeforeExecution.sub(
|
||||
gasFeesPaidFromCol
|
||||
.mul(await contracts.gelatoCore.totalSuccessShare())
|
||||
.div(100)
|
||||
)
|
||||
expect(await wallets.executor.getBalance()).to.be.gt(
|
||||
executorBalanceBeforeExecution
|
||||
);
|
||||
|
||||
// Estimated amount to borrowed token should be equal to the actual one read on compound contracts
|
||||
|
|
|
@ -186,7 +186,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -197,7 +197,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -237,22 +237,18 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
|||
).sub(gasFeesPaidFromCol);
|
||||
|
||||
//#endregion
|
||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||
wallets.gelatoProviderAddress
|
||||
);
|
||||
const executorBalanceBeforeExecution = await wallets.executor.getBalance();
|
||||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
contracts.gelatoCore.connect(wallets.executor).exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||
|
||||
// 🚧 For Debugging:
|
||||
// const txResponse2 = await contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice,
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -287,14 +283,8 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
|||
vaultBId
|
||||
);
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||
).to.be.gt(
|
||||
providerBalanceBeforeExecution.sub(
|
||||
gasFeesPaidFromCol
|
||||
.mul(await contracts.gelatoCore.totalSuccessShare())
|
||||
.div(100)
|
||||
)
|
||||
expect(await wallets.executor.getBalance()).to.be.gt(
|
||||
executorBalanceBeforeExecution
|
||||
);
|
||||
|
||||
// Estimated amount to borrowed token should be equal to the actual one read on compound contracts
|
||||
|
|
|
@ -205,7 +205,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -216,7 +216,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -256,22 +256,18 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
|||
).sub(gasFeesPaidFromCol);
|
||||
|
||||
//#endregion
|
||||
const providerBalanceBeforeExecution = await contracts.gelatoCore.providerFunds(
|
||||
wallets.gelatoProviderAddress
|
||||
);
|
||||
const executorBalanceBeforeExecution = await wallets.executor.getBalance();
|
||||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
contracts.gelatoCore.connect(wallets.executor).exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
})
|
||||
).to.emit(contracts.gelatoCore, "LogExecSuccess");
|
||||
|
||||
// 🚧 For Debugging:
|
||||
// const txResponse2 = await contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice,
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -309,14 +305,8 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with Vault B cre
|
|||
vaultBId
|
||||
);
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore.providerFunds(wallets.gelatoProviderAddress)
|
||||
).to.be.gt(
|
||||
providerBalanceBeforeExecution.sub(
|
||||
gasFeesPaidFromCol
|
||||
.mul(await contracts.gelatoCore.totalSuccessShare())
|
||||
.div(100)
|
||||
)
|
||||
expect(await wallets.executor.getBalance()).to.be.gt(
|
||||
executorBalanceBeforeExecution
|
||||
);
|
||||
|
||||
// Estimated amount to borrowed token should be equal to the actual one read on compound contracts
|
||||
|
|
|
@ -50,13 +50,13 @@ module.exports = async function (
|
|||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.isTaskSpecProvided(
|
||||
wallets.gelatoProviderAddress,
|
||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||
|
@ -65,11 +65,11 @@ module.exports = async function (
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.taskSpecGasPriceCeil(
|
||||
wallets.gelatoProviderAddress,
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||
)
|
||||
).to.be.equal(gasPriceCeil);
|
||||
|
|
|
@ -43,13 +43,13 @@ module.exports = async function (wallets, contracts, constants, vaultId) {
|
|||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.isTaskSpecProvided(
|
||||
wallets.gelatoProviderAddress,
|
||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||
|
@ -58,11 +58,11 @@ module.exports = async function (wallets, contracts, constants, vaultId) {
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.taskSpecGasPriceCeil(
|
||||
wallets.gelatoProviderAddress,
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||
)
|
||||
).to.be.equal(gasPriceCeil);
|
||||
|
|
|
@ -44,13 +44,13 @@ module.exports = async function (wallets, contracts, constants, vaultId) {
|
|||
|
||||
await expect(
|
||||
contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||
).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
|
||||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.isTaskSpecProvided(
|
||||
wallets.gelatoProviderAddress,
|
||||
connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||
|
@ -59,11 +59,11 @@ module.exports = async function (wallets, contracts, constants, vaultId) {
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.taskSpecGasPriceCeil(
|
||||
wallets.gelatoProviderAddress,
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoProviderWallet)
|
||||
.connect(wallets.gelatoProvider)
|
||||
.hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||
)
|
||||
).to.be.equal(gasPriceCeil);
|
||||
|
|
|
@ -17,20 +17,20 @@ module.exports = async function () {
|
|||
const ABI = getABI();
|
||||
|
||||
// Gelato Testing environment setup.
|
||||
await stakeExecutor(wallets.gelatoExecutorWallet, contracts.gelatoCore);
|
||||
await stakeExecutor(wallets.executor, contracts.gelatoCore);
|
||||
await provideFunds(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
constants.GAS_LIMIT,
|
||||
constants.GAS_PRICE_CEIL
|
||||
);
|
||||
await providerAssignsExecutor(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
wallets.gelatoExecutorAddress,
|
||||
contracts.gelatoCore
|
||||
);
|
||||
await addProviderModuleDSA(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
contracts.dsaProviderModule.address
|
||||
);
|
||||
|
|
|
@ -18,20 +18,20 @@ module.exports = async function () {
|
|||
const ABI = getABI();
|
||||
|
||||
// Gelato Testing environment setup.
|
||||
await stakeExecutor(wallets.gelatoExecutorWallet, contracts.gelatoCore);
|
||||
await stakeExecutor(wallets.executor, contracts.gelatoCore);
|
||||
await provideFunds(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
constants.GAS_LIMIT,
|
||||
constants.GAS_PRICE_CEIL
|
||||
);
|
||||
await providerAssignsExecutor(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
wallets.gelatoExecutorAddress,
|
||||
contracts.gelatoCore
|
||||
);
|
||||
await addProviderModuleDSA(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
contracts.dsaProviderModule.address
|
||||
);
|
||||
|
|
|
@ -17,20 +17,20 @@ module.exports = async function () {
|
|||
const ABI = getABI();
|
||||
|
||||
// Gelato Testing environment setup.
|
||||
await stakeExecutor(wallets.gelatoExecutorWallet, contracts.gelatoCore);
|
||||
await stakeExecutor(wallets.executor, contracts.gelatoCore);
|
||||
await provideFunds(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
constants.GAS_LIMIT,
|
||||
constants.GAS_PRICE_CEIL
|
||||
);
|
||||
await providerAssignsExecutor(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
wallets.gelatoExecutorAddress,
|
||||
contracts.gelatoCore
|
||||
);
|
||||
await addProviderModuleDSA(
|
||||
wallets.gelatoProviderWallet,
|
||||
wallets.gelatoProvider,
|
||||
contracts.gelatoCore,
|
||||
contracts.dsaProviderModule.address
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@ const setupMakerToMaker = require("../helpers/setupMakerToMaker");
|
|||
|
||||
// This test showcases how to submit a task refinancing a Users debt position from
|
||||
// Maker to Compound using Gelato
|
||||
describe("Security: _cast function by example of ETHA-ETHB with disabled ConnectGelatoProviderPayment", function () {
|
||||
describe("Security: _cast function by example of ETHA-ETHB with disabled ConnectGelatoExecutorPayment", function () {
|
||||
this.timeout(0);
|
||||
if (hre.network.name !== "hardhat") {
|
||||
console.error("Test Suite is meant to be run on hardhat only");
|
||||
|
@ -184,7 +184,7 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -195,7 +195,7 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
|
||||
expect(
|
||||
await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.canExec(taskReceipt, constants.GAS_LIMIT, gelatoGasPrice)
|
||||
).to.be.equal("OK");
|
||||
|
||||
|
@ -206,11 +206,11 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
hre.network.config.InstaConnectors
|
||||
);
|
||||
|
||||
const { address: connectGelatoProviderPayment } = await ethers.getContract(
|
||||
"ConnectGelatoProviderPayment"
|
||||
const { address: connectGelatoExecutorPayment } = await ethers.getContract(
|
||||
"ConnectGelatoExecutorPayment"
|
||||
);
|
||||
|
||||
expect(await instaConnectors.isConnector([connectGelatoProviderPayment])).to
|
||||
expect(await instaConnectors.isConnector([connectGelatoExecutorPayment])).to
|
||||
.be.true;
|
||||
|
||||
const instaMaster = await ethers.provider.getSigner(
|
||||
|
@ -229,7 +229,7 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
|
||||
await instaConnectors
|
||||
.connect(instaMaster)
|
||||
.disable(connectGelatoProviderPayment);
|
||||
.disable(connectGelatoExecutorPayment);
|
||||
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_stopImpersonatingAccount",
|
||||
|
@ -238,7 +238,7 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
|
||||
// await expect(
|
||||
// contracts.gelatoCore
|
||||
// .connect(wallets.gelatoExecutorWallet)
|
||||
// .connect(wallets.executor)
|
||||
// .exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
// gasLimit: constants.GAS_LIMIT,
|
||||
|
@ -246,7 +246,7 @@ describe("Security: _cast function by example of ETHA-ETHB with disabled Connect
|
|||
// ).to.emit(contracts.gelatoCore, "LogExecReverted");
|
||||
|
||||
const txResponse = await contracts.gelatoCore
|
||||
.connect(wallets.gelatoExecutorWallet)
|
||||
.connect(wallets.executor)
|
||||
.exec(taskReceipt, {
|
||||
gasPrice: gelatoGasPrice,
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// const ConnectAuth = require("../../../../pre-compiles/ConnectAuth.json");
|
||||
// const ConnectGelatoFullDebtBridgeFromMakerABI = require("../artifacts/contracts/contracts/connectors/ConnectGelatoPartialDebtBridgeFromMaker.sol/ConnectGelatoPartialDebtBridgeFromMaker.json")
|
||||
// .abi;
|
||||
// const ConnectGelatoProviderPaymentABI = require("../../../../artifacts/contracts/contracts/connectors/ConnectGelatoProviderPayment.sol/ConnectGelatoProviderPayment.json")
|
||||
// const ConnectGelatoExecutorPaymentABI = require("../../../../artifacts/contracts/contracts/connectors/ConnectGelatoExecutorPayment.sol/ConnectGelatoExecutorPayment.json")
|
||||
// .abi;
|
||||
// const InstaConnector = require("../../../../pre-compiles/InstaConnectors.json");
|
||||
// const DssCdpManager = require("../../../../pre-compiles/DssCdpManager.json");
|
||||
|
@ -121,9 +121,9 @@
|
|||
// // Wallet to use for local testing
|
||||
// let userWallet;
|
||||
// let userAddress;
|
||||
// let gelatoProviderWallet;
|
||||
// let gelatoProvider;
|
||||
// let gelatoProviderAddress;
|
||||
// let gelatoExecutorWallet;
|
||||
// let executor;
|
||||
// let gelatoExecutorAddress;
|
||||
|
||||
// // Deployed instances
|
||||
|
@ -146,7 +146,7 @@
|
|||
// // Contracts to deploy and use for local testing
|
||||
// let conditionMakerVaultUnsafe;
|
||||
// let connectGelatoPartialDebtBridgeFromMaker;
|
||||
// let connectGelatoProviderPayment;
|
||||
// let connectGelatoExecutorPayment;
|
||||
// let priceOracleResolver;
|
||||
// let dsaProviderModule;
|
||||
|
||||
|
@ -163,12 +163,12 @@
|
|||
// // Get Test Wallet for local testnet
|
||||
// [
|
||||
// userWallet,
|
||||
// gelatoProviderWallet,
|
||||
// gelatoExecutorWallet,
|
||||
// gelatoProvider,
|
||||
// executor,
|
||||
// ] = await ethers.getSigners();
|
||||
// userAddress = await userWallet.getAddress();
|
||||
// gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
// gelatoExecutorAddress = await gelatoExecutorWallet.getAddress();
|
||||
// gelatoProviderAddress = await gelatoProvider.getAddress();
|
||||
// gelatoExecutorAddress = await executor.getAddress();
|
||||
|
||||
// instaMaster = await ethers.provider.getSigner(
|
||||
// hre.network.config.InstaMaster
|
||||
|
@ -260,20 +260,20 @@
|
|||
// );
|
||||
// await connectGelatoPartialDebtBridgeFromMaker.deployed();
|
||||
|
||||
// const ConnectGelatoProviderPayment = await ethers.getContractFactory(
|
||||
// "ConnectGelatoProviderPayment"
|
||||
// const ConnectGelatoExecutorPayment = await ethers.getContractFactory(
|
||||
// "ConnectGelatoExecutorPayment"
|
||||
// );
|
||||
// connectGelatoProviderPayment = await ConnectGelatoProviderPayment.deploy(
|
||||
// connectGelatoExecutorPayment = await ConnectGelatoExecutorPayment.deploy(
|
||||
// (await instaConnectors.connectorLength()).add(2)
|
||||
// );
|
||||
// await connectGelatoProviderPayment.deployed();
|
||||
// await connectGelatoExecutorPayment.deployed();
|
||||
|
||||
// const ProviderModuleDsa = await ethers.getContractFactory(
|
||||
// "ProviderModuleDsa"
|
||||
// );
|
||||
// dsaProviderModule = await ProviderModuleDsa.deploy(
|
||||
// hre.network.config.GelatoCore,
|
||||
// connectGelatoProviderPayment.address
|
||||
// connectGelatoExecutorPayment.address
|
||||
// );
|
||||
// await dsaProviderModule.deployed();
|
||||
|
||||
|
@ -337,7 +337,7 @@
|
|||
|
||||
// await instaConnectors
|
||||
// .connect(instaMaster)
|
||||
// .enable(connectGelatoProviderPayment.address);
|
||||
// .enable(connectGelatoExecutorPayment.address);
|
||||
|
||||
// await hre.network.provider.request({
|
||||
// method: "hardhat_stopImpersonatingAccount",
|
||||
|
@ -350,7 +350,7 @@
|
|||
// ])
|
||||
// ).to.be.true;
|
||||
// expect(
|
||||
// await instaConnectors.isConnector([connectGelatoProviderPayment.address])
|
||||
// await instaConnectors.isConnector([connectGelatoExecutorPayment.address])
|
||||
// ).to.be.true;
|
||||
|
||||
// //#endregion
|
||||
|
@ -364,7 +364,7 @@
|
|||
// // For safety measure Gelato ask the executor to stake a minimum
|
||||
// // amount.
|
||||
|
||||
// await gelatoCore.connect(gelatoExecutorWallet).stakeExecutor({
|
||||
// await gelatoCore.connect(executor).stakeExecutor({
|
||||
// value: await gelatoCore.minExecutorStake(),
|
||||
// });
|
||||
|
||||
|
@ -388,7 +388,7 @@
|
|||
|
||||
// await expect(
|
||||
// gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .provideFunds(gelatoProviderAddress, {
|
||||
// value: TASK_AUTOMATION_FUNDS,
|
||||
// })
|
||||
|
@ -407,7 +407,7 @@
|
|||
|
||||
// await expect(
|
||||
// gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .providerAssignsExecutor(gelatoExecutorAddress)
|
||||
// ).to.emit(gelatoCore, "LogProviderAssignedExecutor");
|
||||
|
||||
|
@ -425,13 +425,13 @@
|
|||
|
||||
// await expect(
|
||||
// gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .addProviderModules([dsaProviderModule.address])
|
||||
// ).to.emit(gelatoCore, "LogProviderModuleAdded");
|
||||
|
||||
// expect(
|
||||
// await gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .isModuleProvided(gelatoProviderAddress, dsaProviderModule.address)
|
||||
// ).to.be.true;
|
||||
|
||||
|
@ -636,17 +636,17 @@
|
|||
|
||||
// spells.push(flashPayBack);
|
||||
|
||||
// const payProvider = new GelatoCoreLib.Action({
|
||||
// addr: connectGelatoProviderPayment.address,
|
||||
// const payExecutor = new GelatoCoreLib.Action({
|
||||
// addr: connectGelatoExecutorPayment.address,
|
||||
// data: await hre.run("abi-encode-withselector", {
|
||||
// abi: ConnectGelatoProviderPaymentABI,
|
||||
// functionname: "payProvider",
|
||||
// abi: ConnectGelatoExecutorPaymentABI,
|
||||
// functionname: "payExecutor",
|
||||
// inputs: [gelatoProviderAddress, ETH, 0, "605", 0],
|
||||
// }),
|
||||
// operation: GelatoCoreLib.Operation.Delegatecall,
|
||||
// });
|
||||
|
||||
// spells.push(payProvider);
|
||||
// spells.push(payExecutor);
|
||||
|
||||
// const gasPriceCeil = ethers.constants.MaxUint256;
|
||||
|
||||
|
@ -660,13 +660,13 @@
|
|||
|
||||
// await expect(
|
||||
// gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
|
||||
// ).to.emit(gelatoCore, "LogTaskSpecProvided");
|
||||
|
||||
// expect(
|
||||
// await gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .isTaskSpecProvided(
|
||||
// gelatoProviderAddress,
|
||||
// connectGelatoFullDebtBridgeFromMakerTaskSpec
|
||||
|
@ -675,11 +675,11 @@
|
|||
|
||||
// expect(
|
||||
// await gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .taskSpecGasPriceCeil(
|
||||
// gelatoProviderAddress,
|
||||
// await gelatoCore
|
||||
// .connect(gelatoProviderWallet)
|
||||
// .connect(gelatoProvider)
|
||||
// .hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
|
||||
// )
|
||||
// ).to.be.equal(gasPriceCeil);
|
||||
|
@ -774,7 +774,7 @@
|
|||
|
||||
// expect(
|
||||
// await gelatoCore
|
||||
// .connect(gelatoExecutorWallet)
|
||||
// .connect(executor)
|
||||
// .canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
||||
// ).to.be.equal("ConditionNotOk:MakerVaultNotUnsafe");
|
||||
|
||||
|
@ -783,7 +783,7 @@
|
|||
|
||||
// expect(
|
||||
// await gelatoCore
|
||||
// .connect(gelatoExecutorWallet)
|
||||
// .connect(executor)
|
||||
// .canExec(taskReceipt, GAS_LIMIT, gelatoGasPrice)
|
||||
// ).to.be.equal("OK");
|
||||
|
||||
|
@ -831,10 +831,10 @@
|
|||
// //console.log(String(wdiv(pricedCollateral.sub(wmul(expectedColWithdrawAmount, latestPrice).add(gasFeesPaidFromCol)),debt.sub(expectedBorAmountToPayBack))));
|
||||
|
||||
// //#endregion
|
||||
// const providerBalanceBeforeExecution = await gelatoProviderWallet.getBalance();
|
||||
// const providerBalanceBeforeExecution = await gelatoProvider.getBalance();
|
||||
|
||||
// await expect(
|
||||
// gelatoCore.connect(gelatoExecutorWallet).exec(taskReceipt, {
|
||||
// gelatoCore.connect(executor).exec(taskReceipt, {
|
||||
// gasPrice: gelatoGasPrice, // Exectutor must use gelatoGasPrice (Chainlink fast gwei)
|
||||
// gasLimit: GAS_LIMIT,
|
||||
// })
|
||||
|
@ -842,7 +842,7 @@
|
|||
|
||||
// // 🚧 For Debugging:
|
||||
// // const txResponse2 = await gelatoCore
|
||||
// // .connect(gelatoProviderWallet)
|
||||
// // .connect(gelatoProvider)
|
||||
// // .exec(taskReceipt, {
|
||||
// // gasPrice: gelatoGasPrice,
|
||||
// // gasLimit: GAS_LIMIT,
|
||||
|
@ -855,7 +855,7 @@
|
|||
// // }
|
||||
// // await GelatoCoreLib.sleep(10000);
|
||||
|
||||
// expect(await gelatoProviderWallet.getBalance()).to.be.gt(
|
||||
// expect(await gelatoProvider.getBalance()).to.be.gt(
|
||||
// providerBalanceBeforeExecution
|
||||
// );
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ const { ethers } = hre;
|
|||
|
||||
module.exports = async function (
|
||||
userWallet,
|
||||
connectGelatoProviderPaymentAddr,
|
||||
connectGelatoExecutorPaymentAddr,
|
||||
connectGelatoDataAddr,
|
||||
instaMaster,
|
||||
instaConnectors
|
||||
|
@ -34,7 +34,7 @@ module.exports = async function (
|
|||
|
||||
await instaConnectors
|
||||
.connect(instaMaster)
|
||||
.enable(connectGelatoProviderPaymentAddr);
|
||||
.enable(connectGelatoExecutorPaymentAddr);
|
||||
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_stopImpersonatingAccount",
|
||||
|
@ -42,7 +42,7 @@ module.exports = async function (
|
|||
});
|
||||
|
||||
expect(await instaConnectors.isConnector([connectGelatoDataAddr])).to.be.true;
|
||||
expect(await instaConnectors.isConnector([connectGelatoProviderPaymentAddr]))
|
||||
expect(await instaConnectors.isConnector([connectGelatoExecutorPaymentAddr]))
|
||||
.to.be.true;
|
||||
|
||||
//#endregion
|
||||
|
|
|
@ -2,10 +2,6 @@ const { expect } = require("chai");
|
|||
const hre = require("hardhat");
|
||||
const { ethers, deployments } = hre;
|
||||
|
||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||
|
||||
// #region Contracts ABI
|
||||
|
||||
const ConnectMaker = require("../../../pre-compiles/ConnectMaker.json");
|
||||
const GetCdps = require("../../../pre-compiles/GetCdps.json");
|
||||
const DssCdpManager = require("../../../pre-compiles/DssCdpManager.json");
|
||||
|
@ -15,9 +11,7 @@ const InstaAccount = require("../../../pre-compiles/InstaAccount.json");
|
|||
const InstaIndex = require("../../../pre-compiles/InstaIndex.json");
|
||||
const IERC20 = require("../../../pre-compiles/IERC20.json");
|
||||
|
||||
// #endregion
|
||||
|
||||
describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||
describe("ConnectGelatoExecutorPayment Unit Test", function () {
|
||||
this.timeout(0);
|
||||
if (hre.network.name !== "hardhat") {
|
||||
console.error("Test Suite is meant to be run on hardhat only");
|
||||
|
@ -26,19 +20,15 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
|
||||
let userWallet;
|
||||
let userAddress;
|
||||
let gelatoProviderWallet;
|
||||
let gelatoProviderAddress;
|
||||
|
||||
let gelatoCore;
|
||||
|
||||
let instaList;
|
||||
let instaIndex;
|
||||
let DAI;
|
||||
let dai;
|
||||
let connectBasic;
|
||||
let getCdps;
|
||||
let dssCdpManager;
|
||||
|
||||
let connectGelatoProviderPayment;
|
||||
let connectGelatoExecutorPayment;
|
||||
|
||||
let dsa;
|
||||
let cdpId;
|
||||
|
@ -48,14 +38,8 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
await deployments.fixture();
|
||||
|
||||
// Get Test Wallet for local testnet
|
||||
[userWallet, gelatoProviderWallet] = await ethers.getSigners();
|
||||
[userWallet] = await ethers.getSigners();
|
||||
userAddress = await userWallet.getAddress();
|
||||
gelatoProviderAddress = await gelatoProviderWallet.getAddress();
|
||||
|
||||
gelatoCore = await ethers.getContractAt(
|
||||
GelatoCoreLib.GelatoCore.abi,
|
||||
hre.network.config.GelatoCore
|
||||
);
|
||||
|
||||
// Hardhat default accounts prefilled with 100 ETH
|
||||
expect(await userWallet.getBalance()).to.be.gt(
|
||||
|
@ -82,11 +66,11 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
DssCdpManager.abi,
|
||||
hre.network.config.DssCdpManager
|
||||
);
|
||||
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||
dai = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||
|
||||
// ========== Test Setup ============
|
||||
connectGelatoProviderPayment = await ethers.getContract(
|
||||
"ConnectGelatoProviderPayment"
|
||||
connectGelatoExecutorPayment = await ethers.getContract(
|
||||
"ConnectGelatoExecutorPayment"
|
||||
);
|
||||
|
||||
// ========== Create DeFi Smart Account for User account ============
|
||||
|
@ -107,29 +91,7 @@ describe("ConnectGelatoProviderPayment Unit Test", 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(
|
||||
connectGelatoProviderPayment.setProvider(ethers.constants.AddressZero)
|
||||
).to.be.revertedWith("ConnectGelatoProviderPayment.noAddressZeroProvider");
|
||||
});
|
||||
|
||||
it("#3: setProvider should change the provider address", async function () {
|
||||
await connectGelatoProviderPayment.setProvider(userAddress);
|
||||
|
||||
expect(await connectGelatoProviderPayment.gelatoProvider()).to.be.equal(
|
||||
userAddress
|
||||
);
|
||||
});
|
||||
|
||||
it("#4: payProvider should pay to Provider 300 Dai", async function () {
|
||||
const providerDAIBalanceBefore = await DAI.balanceOf(gelatoProviderAddress);
|
||||
|
||||
it("#1: payExecutor should pay to Executor 300 dai", async function () {
|
||||
await dsa.cast(
|
||||
[hre.network.config.ConnectMaker],
|
||||
[
|
||||
|
@ -173,36 +135,36 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
userAddress
|
||||
);
|
||||
|
||||
expect(await DAI.balanceOf(dsa.address)).to.be.equal(
|
||||
expect(await dai.balanceOf(dsa.address)).to.be.equal(
|
||||
ethers.utils.parseEther("1000")
|
||||
);
|
||||
|
||||
const executorDaiBalanceBefore = await dai.balanceOf(userAddress);
|
||||
|
||||
await dsa.cast(
|
||||
[connectGelatoProviderPayment.address],
|
||||
[connectGelatoExecutorPayment.address],
|
||||
[
|
||||
await hre.run("abi-encode-withselector", {
|
||||
abi: (
|
||||
await hre.artifacts.readArtifact("ConnectGelatoProviderPayment")
|
||||
await hre.artifacts.readArtifact("ConnectGelatoExecutorPayment")
|
||||
).abi,
|
||||
functionname: "payProvider",
|
||||
inputs: [DAI.address, ethers.utils.parseUnits("300", 18), 0, 0],
|
||||
functionname: "payExecutor",
|
||||
inputs: [dai.address, ethers.utils.parseUnits("300", 18), 0, 0],
|
||||
}),
|
||||
],
|
||||
userAddress
|
||||
);
|
||||
|
||||
expect(await DAI.balanceOf(gelatoProviderAddress)).to.be.equal(
|
||||
providerDAIBalanceBefore.add(ethers.utils.parseUnits("300", 18))
|
||||
expect(await dai.balanceOf(userAddress)).to.be.equal(
|
||||
executorDaiBalanceBefore.add(ethers.utils.parseUnits("300", 18))
|
||||
);
|
||||
});
|
||||
|
||||
it("#5: payProvider should pay to Provider 1 ether", async function () {
|
||||
const providerBalanceOnGelatoCoreBefore = await gelatoCore.providerFunds(
|
||||
gelatoProviderAddress
|
||||
);
|
||||
it("#2: payExecutor should pay to Executor 1 ether", async function () {
|
||||
const executorBalanceBefore = await userWallet.getBalance();
|
||||
|
||||
await dsa.cast(
|
||||
[connectBasic.address, connectGelatoProviderPayment.address],
|
||||
const { gasPrice, wait } = await dsa.cast(
|
||||
[connectBasic.address, connectGelatoExecutorPayment.address],
|
||||
[
|
||||
await hre.run("abi-encode-withselector", {
|
||||
abi: ConnectBasic.abi,
|
||||
|
@ -216,9 +178,9 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
}),
|
||||
await hre.run("abi-encode-withselector", {
|
||||
abi: (
|
||||
await hre.artifacts.readArtifact("ConnectGelatoProviderPayment")
|
||||
await hre.artifacts.readArtifact("ConnectGelatoExecutorPayment")
|
||||
).abi,
|
||||
functionname: "payProvider",
|
||||
functionname: "payExecutor",
|
||||
inputs: ["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 0, "105", 0],
|
||||
}),
|
||||
],
|
||||
|
@ -228,8 +190,10 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
|||
}
|
||||
);
|
||||
|
||||
expect(await gelatoCore.providerFunds(gelatoProviderAddress)).to.be.equal(
|
||||
providerBalanceOnGelatoCoreBefore.add(ethers.utils.parseEther("1"))
|
||||
const { gasUsed } = await wait();
|
||||
|
||||
expect(await userWallet.getBalance()).to.be.eq(
|
||||
executorBalanceBefore.sub(gasUsed.mul(gasPrice))
|
||||
);
|
||||
});
|
||||
});
|
49
yarn.lock
49
yarn.lock
|
@ -288,12 +288,12 @@
|
|||
"@ethersproject/bytes" "^5.0.4"
|
||||
"@ethersproject/properties" "^5.0.3"
|
||||
|
||||
"@ethersproject/bignumber@5.0.11", "@ethersproject/bignumber@^5.0.10":
|
||||
version "5.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.11.tgz#0d89c1c42439e04ab85013e6d437e428914fcbb2"
|
||||
integrity sha512-6mS55WZDceEFZHaWKlRTKwOUmw8sU51Ar1Tbdt3qfk1HNf7i60d6MQVAWJswzCfKWx+E2gCBob8ywajgTZ7zMw==
|
||||
"@ethersproject/bignumber@5.0.12":
|
||||
version "5.0.12"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.12.tgz#fe4a78667d7cb01790f75131147e82d6ea7e7cba"
|
||||
integrity sha512-mbFZjwthx6vFlHG9owXP/C5QkNvsA+xHpDCkPPPdG2n1dS9AmZAL5DI0InNLid60rQWL3MXpEl19tFmtL7Q9jw==
|
||||
dependencies:
|
||||
"@ethersproject/bytes" "^5.0.4"
|
||||
"@ethersproject/bytes" "^5.0.8"
|
||||
"@ethersproject/logger" "^5.0.5"
|
||||
bn.js "^4.4.0"
|
||||
|
||||
|
@ -306,6 +306,15 @@
|
|||
"@ethersproject/logger" "^5.0.5"
|
||||
bn.js "^4.4.0"
|
||||
|
||||
"@ethersproject/bignumber@^5.0.10":
|
||||
version "5.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.11.tgz#0d89c1c42439e04ab85013e6d437e428914fcbb2"
|
||||
integrity sha512-6mS55WZDceEFZHaWKlRTKwOUmw8sU51Ar1Tbdt3qfk1HNf7i60d6MQVAWJswzCfKWx+E2gCBob8ywajgTZ7zMw==
|
||||
dependencies:
|
||||
"@ethersproject/bytes" "^5.0.4"
|
||||
"@ethersproject/logger" "^5.0.5"
|
||||
bn.js "^4.4.0"
|
||||
|
||||
"@ethersproject/bytes@5.0.5", "@ethersproject/bytes@>=5.0.0-beta.129", "@ethersproject/bytes@^5.0.2", "@ethersproject/bytes@^5.0.4":
|
||||
version "5.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.5.tgz#688b70000e550de0c97a151a21f15b87d7f97d7c"
|
||||
|
@ -313,10 +322,10 @@
|
|||
dependencies:
|
||||
"@ethersproject/logger" "^5.0.5"
|
||||
|
||||
"@ethersproject/bytes@5.0.7":
|
||||
version "5.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.7.tgz#a3e23281ea05b4bfaa769894a18ce5cfc6842dd6"
|
||||
integrity sha512-AxTEe6ucwifQiauelO/cpbm14coJTFPl/1uXTXclUO7zBy1HHpNRzspUZlJmozZ/vE6/yNsNq82vy+UmoTDF7g==
|
||||
"@ethersproject/bytes@5.0.8", "@ethersproject/bytes@^5.0.8":
|
||||
version "5.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.8.tgz#cf1246a6a386086e590063a4602b1ffb6cc43db1"
|
||||
integrity sha512-O+sJNVGzzuy51g+EMK8BegomqNIg+C2RO6vOt0XP6ac4o4saiq69FnjlsrNslaiMFVO7qcEHBsWJ9hx1tj1lMw==
|
||||
dependencies:
|
||||
"@ethersproject/logger" "^5.0.5"
|
||||
|
||||
|
@ -557,10 +566,10 @@
|
|||
bech32 "1.1.4"
|
||||
ws "7.2.3"
|
||||
|
||||
"@ethersproject/providers@5.0.16":
|
||||
version "5.0.16"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.0.16.tgz#23892ea140180f22051801b1a2177ee9c1cc3f75"
|
||||
integrity sha512-OCo0NH7VC8hfr7ESuZDMQl2Jdz2jpWulNGsWgnxXZT0tuPrrKHO+5BADS5s1W+YsovL3mKFkQjwGcOP2arvhzw==
|
||||
"@ethersproject/providers@5.0.17":
|
||||
version "5.0.17"
|
||||
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.0.17.tgz#f380e7831149e24e7a1c6c9b5fb1d6dfc729d024"
|
||||
integrity sha512-bJnvs5X7ttU5x2ekGJYG7R3Z+spZawLFfR0IDsbaMDLiCwZOyrgk+VTBU7amSFLT0WUhWFv8WwSUB+AryCQG1Q==
|
||||
dependencies:
|
||||
"@ethersproject/abstract-provider" "^5.0.4"
|
||||
"@ethersproject/abstract-signer" "^5.0.4"
|
||||
|
@ -3970,10 +3979,10 @@ ethereumjs-wallet@0.6.5:
|
|||
utf8 "^3.0.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
ethers@5.0.22:
|
||||
version "5.0.22"
|
||||
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.0.22.tgz#0d7d9b195a6818494ee75f6b2db88b060664cb3a"
|
||||
integrity sha512-hfpsfQf9b6JITeMULOCJDhWAowS9e6fxCBJfDuFDE3yYZlW0q/U2k3xfSK/q+g8twkRM01uZvUHJN/9zXwrrzQ==
|
||||
ethers@5.0.23:
|
||||
version "5.0.23"
|
||||
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.0.23.tgz#461a6e63c4906d5ea64126d53975ddf2ca81a979"
|
||||
integrity sha512-f3pTcgYpMhtmMTMG9KO6pWHYjrCiGz7yVnvMsTQgAYfAVAeUxKy2H1cxQJyqyghRjtAvgVYJlnXQo8mMCD63BA==
|
||||
dependencies:
|
||||
"@ethersproject/abi" "5.0.9"
|
||||
"@ethersproject/abstract-provider" "5.0.7"
|
||||
|
@ -3981,8 +3990,8 @@ ethers@5.0.22:
|
|||
"@ethersproject/address" "5.0.8"
|
||||
"@ethersproject/base64" "5.0.6"
|
||||
"@ethersproject/basex" "5.0.6"
|
||||
"@ethersproject/bignumber" "5.0.11"
|
||||
"@ethersproject/bytes" "5.0.7"
|
||||
"@ethersproject/bignumber" "5.0.12"
|
||||
"@ethersproject/bytes" "5.0.8"
|
||||
"@ethersproject/constants" "5.0.7"
|
||||
"@ethersproject/contracts" "5.0.8"
|
||||
"@ethersproject/hash" "5.0.8"
|
||||
|
@ -3993,7 +4002,7 @@ ethers@5.0.22:
|
|||
"@ethersproject/networks" "5.0.6"
|
||||
"@ethersproject/pbkdf2" "5.0.6"
|
||||
"@ethersproject/properties" "5.0.6"
|
||||
"@ethersproject/providers" "5.0.16"
|
||||
"@ethersproject/providers" "5.0.17"
|
||||
"@ethersproject/random" "5.0.6"
|
||||
"@ethersproject/rlp" "5.0.6"
|
||||
"@ethersproject/sha2" "5.0.6"
|
||||
|
|
Loading…
Reference in New Issue
Block a user