Use encode with selector in condition

This commit is contained in:
Shivva 2020-11-25 11:20:44 +01:00 committed by Luis Schliesske
parent 1a58721543
commit 8c7ac0ed3c
3 changed files with 24 additions and 6 deletions

View File

@ -38,7 +38,12 @@ contract ConditionDebtBridgeIsAffordable is GelatoConditionsStandard {
virtual
returns (bytes memory)
{
return abi.encode(_vaultId, _ratioLimit);
return
abi.encodeWithSelector(
this.isAffordable.selector,
_vaultId,
_ratioLimit
);
}
/// @notice Standard GelatoCore system function
@ -51,7 +56,7 @@ contract ConditionDebtBridgeIsAffordable is GelatoConditionsStandard {
uint256
) public view virtual override returns (string memory) {
(uint256 _vaultID, uint256 _ratioLimit) =
abi.decode(_conditionData, (uint256, uint256));
abi.decode(_conditionData[4:], (uint256, uint256));
return isAffordable(_vaultID, _ratioLimit);
}

View File

@ -25,7 +25,13 @@ contract ConditionDestVaultWillBeSafe is GelatoConditionsStandard {
uint256 _destVaultId,
string calldata _destColType
) public pure virtual returns (bytes memory) {
return abi.encode(_fromVaultId, _destVaultId, _destColType);
return
abi.encodeWithSelector(
this.destVaultWillBeSafe.selector,
_fromVaultId,
_destVaultId,
_destColType
);
}
function ok(
@ -37,7 +43,7 @@ contract ConditionDestVaultWillBeSafe is GelatoConditionsStandard {
uint256 _fromVaultId,
uint256 _destVaultId,
string memory _destColType
) = abi.decode(_conditionData, (uint256, uint256, string));
) = abi.decode(_conditionData[4:], (uint256, uint256, string));
return destVaultWillBeSafe(_fromVaultId, _destVaultId, _destColType);
}

View File

@ -26,7 +26,14 @@ contract ConditionMakerVaultUnsafe is GelatoConditionsStandard {
bytes calldata _oraclePayload,
uint256 _minColRatio
) public pure virtual returns (bytes memory) {
return abi.encode(_vaultId, _priceOracle, _oraclePayload, _minColRatio);
return
abi.encodeWithSelector(
this.isVaultUnsafe.selector,
_vaultId,
_priceOracle,
_oraclePayload,
_minColRatio
);
}
/// @notice Standard GelatoCore system function
@ -43,7 +50,7 @@ contract ConditionMakerVaultUnsafe is GelatoConditionsStandard {
address _priceOracle,
bytes memory _oraclePayload,
uint256 _minColRatio
) = abi.decode(_conditionData, (uint256, address, bytes, uint256));
) = abi.decode(_conditionData[4:], (uint256, address, bytes, uint256));
return
isVaultUnsafe(_vaultID, _priceOracle, _oraclePayload, _minColRatio);