mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
chore: cleanup
This commit is contained in:
parent
b8e1aef64f
commit
3bff63707d
|
@ -57,7 +57,7 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface {
|
||||||
|
|
||||||
/// @dev Connector Details
|
/// @dev Connector Details
|
||||||
function connectorID()
|
function connectorID()
|
||||||
public
|
external
|
||||||
view
|
view
|
||||||
override
|
override
|
||||||
returns (uint256 _type, uint256 id)
|
returns (uint256 _type, uint256 id)
|
||||||
|
@ -65,11 +65,16 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface {
|
||||||
(_type, id) = (1, _id); // Should put specific value.
|
(_type, id) = (1, _id); // Should put specific value.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice Entry Point for DSA.cast DebtBridge from e.g ETH-A to ETH-B
|
||||||
|
/// @dev payable to be compatible in conjunction with DSA.cast payable target
|
||||||
|
/// @param _vaultId Id of the unsafe vault of the client.
|
||||||
|
/// @param _token vault's col token address .
|
||||||
|
/// @param _colType colType of the new vault. example : ETH-B, ETH-A.
|
||||||
function getDataAndCastForFromMakerToMaker(
|
function getDataAndCastForFromMakerToMaker(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
address _token,
|
address _token,
|
||||||
string calldata _colType
|
string calldata _colType
|
||||||
) public payable {
|
) external payable {
|
||||||
(
|
(
|
||||||
address[] memory targets,
|
address[] memory targets,
|
||||||
bytes[] memory datas
|
bytes[] memory datas
|
||||||
|
@ -82,10 +87,14 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface {
|
||||||
_cast(targets, datas);
|
_cast(targets, datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice Entry Point for DSA.cast DebtBridge from Maker to Compound
|
||||||
|
/// @dev payable to be compatible in conjunction with DSA.cast payable target
|
||||||
|
/// @param _vaultId Id of the unsafe vault of the client.
|
||||||
|
/// @param _token vault's col token address .
|
||||||
function getDataAndCastForFromMakerToCompound(
|
function getDataAndCastForFromMakerToCompound(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
address _token
|
address _token
|
||||||
) public payable {
|
) external payable {
|
||||||
(
|
(
|
||||||
address[] memory targets,
|
address[] memory targets,
|
||||||
bytes[] memory datas
|
bytes[] memory datas
|
||||||
|
@ -114,61 +123,6 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface {
|
||||||
|
|
||||||
/* solhint-disable function-max-lines */
|
/* 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 .
|
|
||||||
/// @return targets : flashloan contract address
|
|
||||||
/// @return datas : calldata for flashloan
|
|
||||||
function _execPayloadForFullRefinanceFromMakerToCompound(
|
|
||||||
uint256 _vaultId,
|
|
||||||
address _token
|
|
||||||
) internal view returns (address[] memory targets, bytes[] memory datas) {
|
|
||||||
targets = new address[](1);
|
|
||||||
targets[0] = INSTA_POOL_V2;
|
|
||||||
|
|
||||||
uint256 wDaiDebtToMove = _getMakerVaultDebt(_vaultId);
|
|
||||||
uint256 wColToWithdrawFromMaker = _getMakerVaultCollateralBalance(
|
|
||||||
_vaultId
|
|
||||||
);
|
|
||||||
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(GAS_COST);
|
|
||||||
|
|
||||||
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;
|
|
||||||
_targets[5] = INSTA_POOL_V2;
|
|
||||||
|
|
||||||
bytes[] memory _datas = new bytes[](6);
|
|
||||||
_datas[0] = _encodePaybackMakerVault(_vaultId, uint256(-1), 0, 0);
|
|
||||||
_datas[1] = _encodedWithdrawMakerVault(_vaultId, uint256(-1), 0, 0);
|
|
||||||
_datas[2] = _encodeDepositCompound(
|
|
||||||
_token,
|
|
||||||
sub(wColToWithdrawFromMaker, gasFeesPaidFromCol),
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
_datas[3] = _encodeBorrowCompound(DAI, wDaiDebtToMove, 0, 0);
|
|
||||||
_datas[4] = _encodePayGelatoProvider(_token, gasFeesPaidFromCol, 0, 0);
|
|
||||||
_datas[5] = _encodeFlashPayback(DAI, wDaiDebtToMove, 0, 0);
|
|
||||||
|
|
||||||
datas = new bytes[](1);
|
|
||||||
datas[0] = abi.encodeWithSelector(
|
|
||||||
IConnectInstaPoolV2.flashBorrowAndCast.selector,
|
|
||||||
DAI,
|
|
||||||
wDaiDebtToMove,
|
|
||||||
0,
|
|
||||||
abi.encode(_targets, _datas)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @notice Generate Task for a full refinancing between Maker e.g. ETH-A to ETH-B.
|
|
||||||
/// @param _vaultId Id of the unsafe vault of the client.
|
|
||||||
/// @param _token vault's col token address .
|
|
||||||
/// @param _colType colType of the new vault, exemple : ETH-B, ETH-A.
|
|
||||||
/// @return targets : flashloan contract address
|
|
||||||
/// @return datas : calldata for flashloan
|
|
||||||
function _execPayloadForFullRefinanceFromMakerToMaker(
|
function _execPayloadForFullRefinanceFromMakerToMaker(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
address _token,
|
address _token,
|
||||||
|
@ -216,5 +170,49 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _execPayloadForFullRefinanceFromMakerToCompound(
|
||||||
|
uint256 _vaultId,
|
||||||
|
address _token
|
||||||
|
) internal view returns (address[] memory targets, bytes[] memory datas) {
|
||||||
|
targets = new address[](1);
|
||||||
|
targets[0] = INSTA_POOL_V2;
|
||||||
|
|
||||||
|
uint256 wDaiDebtToMove = _getMakerVaultDebt(_vaultId);
|
||||||
|
uint256 wColToWithdrawFromMaker = _getMakerVaultCollateralBalance(
|
||||||
|
_vaultId
|
||||||
|
);
|
||||||
|
uint256 gasFeesPaidFromCol = _getGelatoProviderFees(GAS_COST);
|
||||||
|
|
||||||
|
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;
|
||||||
|
_targets[5] = INSTA_POOL_V2;
|
||||||
|
|
||||||
|
bytes[] memory _datas = new bytes[](6);
|
||||||
|
_datas[0] = _encodePaybackMakerVault(_vaultId, uint256(-1), 0, 0);
|
||||||
|
_datas[1] = _encodedWithdrawMakerVault(_vaultId, uint256(-1), 0, 0);
|
||||||
|
_datas[2] = _encodeDepositCompound(
|
||||||
|
_token,
|
||||||
|
sub(wColToWithdrawFromMaker, gasFeesPaidFromCol),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
_datas[3] = _encodeBorrowCompound(DAI, wDaiDebtToMove, 0, 0);
|
||||||
|
_datas[4] = _encodePayGelatoProvider(_token, gasFeesPaidFromCol, 0, 0);
|
||||||
|
_datas[5] = _encodeFlashPayback(DAI, wDaiDebtToMove, 0, 0);
|
||||||
|
|
||||||
|
datas = new bytes[](1);
|
||||||
|
datas[0] = abi.encodeWithSelector(
|
||||||
|
IConnectInstaPoolV2.flashBorrowAndCast.selector,
|
||||||
|
DAI,
|
||||||
|
wDaiDebtToMove,
|
||||||
|
0,
|
||||||
|
abi.encode(_targets, _datas)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* solhint-enable function-max-lines */
|
/* solhint-enable function-max-lines */
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,16 @@ import {
|
||||||
} from "../../functions/gelato/FGelatoDebtBridge.sol";
|
} from "../../functions/gelato/FGelatoDebtBridge.sol";
|
||||||
|
|
||||||
contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
|
using GelatoBytes for bytes;
|
||||||
|
|
||||||
|
// vaultId: Id of the unsafe vault of the client.
|
||||||
|
// token: vault's col token address .
|
||||||
|
// wMinColRatioMaker: Min col ratio (wad) on Maker debt position
|
||||||
|
// wMinColRatioB: Min col ratio (wad) on debt position B (e.g. Compound, Maker, ...)
|
||||||
|
// priceOracle: The price oracle contract to supply the collateral price
|
||||||
|
// e.g. Maker's ETH/USD oracle for ETH collateral pricing.
|
||||||
|
// oraclePayload: The data for making the staticcall to the oracle's read
|
||||||
|
// method e.g. the function selector of MakerOracle's read function.
|
||||||
struct PartialDebtBridgePayload {
|
struct PartialDebtBridgePayload {
|
||||||
uint256 vaultId;
|
uint256 vaultId;
|
||||||
address token;
|
address token;
|
||||||
|
@ -54,8 +64,6 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
bytes oraclePayload;
|
bytes oraclePayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
using GelatoBytes for bytes;
|
|
||||||
|
|
||||||
// solhint-disable-next-line const-name-snakecase
|
// solhint-disable-next-line const-name-snakecase
|
||||||
string public constant override name = "ConnectGelatoData-v1.0";
|
string public constant override name = "ConnectGelatoData-v1.0";
|
||||||
uint256 internal immutable _id;
|
uint256 internal immutable _id;
|
||||||
|
@ -70,7 +78,7 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
|
|
||||||
/// @dev Connector Details
|
/// @dev Connector Details
|
||||||
function connectorID()
|
function connectorID()
|
||||||
public
|
external
|
||||||
view
|
view
|
||||||
override
|
override
|
||||||
returns (uint256 _type, uint256 id)
|
returns (uint256 _type, uint256 id)
|
||||||
|
@ -78,10 +86,14 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
(_type, id) = (1, _id); // Should put specific value.
|
(_type, id) = (1, _id); // Should put specific value.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice Entry Point for DSA.cast DebtBridge from e.g ETH-A to ETH-B
|
||||||
|
/// @dev payable to be compatible in conjunction with DSA.cast payable target
|
||||||
|
/// @param _payload See PartialDebtBridgePayload struct
|
||||||
|
/// @param _colType colType of the new vault. example : ETH-B, ETH-A.
|
||||||
function getDataAndCastForFromMakerToMaker(
|
function getDataAndCastForFromMakerToMaker(
|
||||||
PartialDebtBridgePayload calldata _payload,
|
PartialDebtBridgePayload calldata _payload,
|
||||||
string calldata _colType
|
string calldata _colType
|
||||||
) public payable {
|
) external payable {
|
||||||
(
|
(
|
||||||
address[] memory targets,
|
address[] memory targets,
|
||||||
bytes[] memory datas
|
bytes[] memory datas
|
||||||
|
@ -90,9 +102,12 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
_cast(targets, datas);
|
_cast(targets, datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice Entry Point for DSA.cast DebtBridge from Maker to Compound
|
||||||
|
/// @dev payable to be compatible in conjunction with DSA.cast payable target
|
||||||
|
/// @param _payload See PartialDebtBridgePayload struct
|
||||||
function getDataAndCastForFromMakerToCompound(
|
function getDataAndCastForFromMakerToCompound(
|
||||||
PartialDebtBridgePayload calldata _payload
|
PartialDebtBridgePayload calldata _payload
|
||||||
) public payable {
|
) external payable {
|
||||||
(
|
(
|
||||||
address[] memory targets,
|
address[] memory targets,
|
||||||
bytes[] memory datas
|
bytes[] memory datas
|
||||||
|
@ -121,97 +136,6 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
|
|
||||||
/* solhint-disable function-max-lines */
|
/* 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.
|
|
||||||
// @param _token vault's col token address .
|
|
||||||
// @param _wMinColRatioMaker Min col ratio (wad) on Maker debt position
|
|
||||||
// @param _wMinColRatioB Min col ratio (wad) on debt position B (e.g. Compound, Maker, ...)
|
|
||||||
// @param _priceOracle The price oracle contract to supply the collateral price
|
|
||||||
// e.g. Maker's ETH/USD oracle for ETH collateral pricing.
|
|
||||||
// @param _oraclePayload The data for making the staticcall to the oracle's read
|
|
||||||
// method e.g. the function selector of MakerOracle's read function.
|
|
||||||
// @param _provider address of the paying provider.
|
|
||||||
/// @return targets : flashloan contract address
|
|
||||||
/// @return datas : calldata for flashloan
|
|
||||||
function _execPayloadForPartialRefinanceFromMakerToCompound(
|
|
||||||
PartialDebtBridgePayload calldata _payload
|
|
||||||
) internal view returns (address[] memory targets, bytes[] memory datas) {
|
|
||||||
targets = new address[](1);
|
|
||||||
targets[0] = INSTA_POOL_V2;
|
|
||||||
|
|
||||||
(
|
|
||||||
uint256 wDaiDebtToMove,
|
|
||||||
uint256 wColToWithdrawFromMaker,
|
|
||||||
uint256 gasFeesPaidFromCol
|
|
||||||
) = computeDebtBridge(
|
|
||||||
_payload.vaultId,
|
|
||||||
_payload.wMinColRatioMaker,
|
|
||||||
_payload.wMinColRatioB,
|
|
||||||
_payload.priceOracle,
|
|
||||||
_payload.oraclePayload
|
|
||||||
);
|
|
||||||
|
|
||||||
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;
|
|
||||||
_targets[5] = INSTA_POOL_V2;
|
|
||||||
|
|
||||||
bytes[] memory _datas = new bytes[](6);
|
|
||||||
_datas[0] = _encodePaybackMakerVault(
|
|
||||||
_payload.vaultId,
|
|
||||||
uint256(-1),
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
_datas[1] = _encodedWithdrawMakerVault(
|
|
||||||
_payload.vaultId,
|
|
||||||
uint256(-1),
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
_datas[2] = _encodeDepositCompound(
|
|
||||||
_payload.token,
|
|
||||||
sub(wColToWithdrawFromMaker, gasFeesPaidFromCol),
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
_datas[3] = _encodeBorrowCompound(DAI, wDaiDebtToMove, 0, 0);
|
|
||||||
_datas[4] = _encodePayGelatoProvider(
|
|
||||||
_payload.token,
|
|
||||||
gasFeesPaidFromCol,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
_datas[5] = _encodeFlashPayback(DAI, wDaiDebtToMove, 0, 0);
|
|
||||||
|
|
||||||
datas = new bytes[](1);
|
|
||||||
datas[0] = abi.encodeWithSelector(
|
|
||||||
IConnectInstaPoolV2.flashBorrowAndCast.selector,
|
|
||||||
DAI,
|
|
||||||
wDaiDebtToMove,
|
|
||||||
0,
|
|
||||||
abi.encode(_targets, _datas)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @notice Generate Task for a full refinancing between Maker e.g. ETH-A and ETH-B.
|
|
||||||
/// @param _payload contain :
|
|
||||||
// @param _vaultId Id of the unsafe vault of the client.
|
|
||||||
// @param _token vault's col token address .
|
|
||||||
// @param _wMinColRatioMaker Min col ratio (wad) on Maker debt position
|
|
||||||
// @param _wMinColRatioB Min col ratio (wad) on debt position B (e.g. Compound, Maker, ...)
|
|
||||||
// @param _priceOracle The price oracle contract to supply the collateral price
|
|
||||||
// e.g. Maker's ETH/USD oracle for ETH collateral pricing.
|
|
||||||
// @param _oraclePayload The data for making the staticcall to the oracle's read
|
|
||||||
// method e.g. the function selector of MakerOracle's read function.
|
|
||||||
// @param _provider address of the paying provider.
|
|
||||||
/// @param _colType colType of the new vault, exemple : ETH-B, ETH-A.
|
|
||||||
/// @return targets : flashloan contract address
|
|
||||||
/// @return datas : calldata for flashloan
|
|
||||||
function _execPayloadForPartialRefinanceFromMakerToMaker(
|
function _execPayloadForPartialRefinanceFromMakerToMaker(
|
||||||
PartialDebtBridgePayload calldata _payload,
|
PartialDebtBridgePayload calldata _payload,
|
||||||
string calldata _colType
|
string calldata _colType
|
||||||
|
@ -279,6 +203,70 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _execPayloadForPartialRefinanceFromMakerToCompound(
|
||||||
|
PartialDebtBridgePayload calldata _payload
|
||||||
|
) internal view returns (address[] memory targets, bytes[] memory datas) {
|
||||||
|
targets = new address[](1);
|
||||||
|
targets[0] = INSTA_POOL_V2;
|
||||||
|
|
||||||
|
(
|
||||||
|
uint256 wDaiDebtToMove,
|
||||||
|
uint256 wColToWithdrawFromMaker,
|
||||||
|
uint256 gasFeesPaidFromCol
|
||||||
|
) = computeDebtBridge(
|
||||||
|
_payload.vaultId,
|
||||||
|
_payload.wMinColRatioMaker,
|
||||||
|
_payload.wMinColRatioB,
|
||||||
|
_payload.priceOracle,
|
||||||
|
_payload.oraclePayload
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
_targets[5] = INSTA_POOL_V2;
|
||||||
|
|
||||||
|
bytes[] memory _datas = new bytes[](6);
|
||||||
|
_datas[0] = _encodePaybackMakerVault(
|
||||||
|
_payload.vaultId,
|
||||||
|
uint256(-1),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
_datas[1] = _encodedWithdrawMakerVault(
|
||||||
|
_payload.vaultId,
|
||||||
|
uint256(-1),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
_datas[2] = _encodeDepositCompound(
|
||||||
|
_payload.token,
|
||||||
|
sub(wColToWithdrawFromMaker, gasFeesPaidFromCol),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
_datas[3] = _encodeBorrowCompound(DAI, wDaiDebtToMove, 0, 0);
|
||||||
|
_datas[4] = _encodePayGelatoProvider(
|
||||||
|
_payload.token,
|
||||||
|
gasFeesPaidFromCol,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
_datas[5] = _encodeFlashPayback(DAI, wDaiDebtToMove, 0, 0);
|
||||||
|
|
||||||
|
datas = new bytes[](1);
|
||||||
|
datas[0] = abi.encodeWithSelector(
|
||||||
|
IConnectInstaPoolV2.flashBorrowAndCast.selector,
|
||||||
|
DAI,
|
||||||
|
wDaiDebtToMove,
|
||||||
|
0,
|
||||||
|
abi.encode(_targets, _datas)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// @notice Computes values needed for DebtBridge Maker->ProtocolB
|
/// @notice Computes values needed for DebtBridge Maker->ProtocolB
|
||||||
/// @dev Use wad for colRatios.
|
/// @dev Use wad for colRatios.
|
||||||
/// @param _vaultId The id of the makerDAO vault.
|
/// @param _vaultId The id of the makerDAO vault.
|
||||||
|
@ -292,7 +280,6 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface {
|
||||||
/// flashBorrow->repay Maker->withdraw from B->flashPayback.
|
/// flashBorrow->repay Maker->withdraw from B->flashPayback.
|
||||||
/// @return wColToWithdrawFromMaker (wad) to: withdraw from Maker and deposit on B.
|
/// @return wColToWithdrawFromMaker (wad) to: withdraw from Maker and deposit on B.
|
||||||
/// @return gasFeesPaidFromCol Gelato automation-gas-fees paid from user's collateral
|
/// @return gasFeesPaidFromCol Gelato automation-gas-fees paid from user's collateral
|
||||||
// solhint-disable function-max-lines
|
|
||||||
function computeDebtBridge(
|
function computeDebtBridge(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
uint256 _wMinColRatioMaker,
|
uint256 _wMinColRatioMaker,
|
||||||
|
|
|
@ -31,8 +31,8 @@ contract ConnectGelatoProviderPayment is
|
||||||
|
|
||||||
constructor(uint256 id, address _gelatoProvider) {
|
constructor(uint256 id, address _gelatoProvider) {
|
||||||
_id = id;
|
_id = id;
|
||||||
gelatoProvider = _gelatoProvider;
|
|
||||||
_this = address(this);
|
_this = address(this);
|
||||||
|
gelatoProvider = _gelatoProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Connector Details
|
/// @dev Connector Details
|
||||||
|
@ -55,9 +55,6 @@ contract ConnectGelatoProviderPayment is
|
||||||
/// - _getId does not match actual InstaMemory gelatoProvider payment slot
|
/// - _getId does not match actual InstaMemory gelatoProvider payment slot
|
||||||
/// - _token balance not in DSA
|
/// - _token balance not in DSA
|
||||||
/// - worthless _token risk
|
/// - worthless _token risk
|
||||||
/// @param _gelatoProvider The Provider who pays the Gelato network for automation.
|
|
||||||
// This param should be verified / replaced by the ProviderModule in Gelato on-chain.
|
|
||||||
// In the latter case, it does not matter what address is passed off-chain.
|
|
||||||
/// @param _token The token used to pay the Provider.
|
/// @param _token The token used to pay the Provider.
|
||||||
/// @param _amt The amount of _token to pay the Gelato 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 _getId The InstaMemory slot at which the payment amount was stored.
|
||||||
|
@ -68,16 +65,16 @@ contract ConnectGelatoProviderPayment is
|
||||||
uint256 _getId,
|
uint256 _getId,
|
||||||
uint256 _setId
|
uint256 _setId
|
||||||
) external payable override {
|
) external payable override {
|
||||||
address _gelatoProvider = IConnectGelatoProviderPayment(_this)
|
address provider = IConnectGelatoProviderPayment(_this)
|
||||||
.gelatoProvider();
|
.gelatoProvider();
|
||||||
require(
|
require(
|
||||||
_gelatoProvider != address(0x0),
|
provider != address(0x0),
|
||||||
"ConnectGelatoProviderPayment.payProvider:!_gelatoProvider"
|
"ConnectGelatoProviderPayment.payProvider:!provider"
|
||||||
);
|
);
|
||||||
uint256 amt = _getUint(_getId, _amt);
|
uint256 amt = _getUint(_getId, _amt);
|
||||||
_setUint(_setId, amt);
|
_setUint(_setId, amt);
|
||||||
_token == ETH
|
_token == ETH
|
||||||
? payable(_gelatoProvider).sendValue(amt)
|
? payable(provider).sendValue(amt)
|
||||||
: IERC20(_token).safeTransfer(_gelatoProvider, amt);
|
: IERC20(_token).safeTransfer(provider, amt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,9 +168,7 @@ describe("ConnectGelatoProviderPayment Unit Test", function () {
|
||||||
value: ethers.utils.parseEther("1"),
|
value: ethers.utils.parseEther("1"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).to.be.revertedWith(
|
).to.be.revertedWith("ConnectGelatoProviderPayment.payProvider:!provider");
|
||||||
"ConnectGelatoProviderPayment.payProvider:!_gelatoProvider"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#2: setProvider should change the provider address", async function () {
|
it("#2: setProvider should change the provider address", async function () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user