Ensure Signer bond is sufficient for fee refund
Given a situation where the signer bond must be used to refund
the cost of opening a keep, there should be sufficient funds to do so.
If funds are insufficient, the contract should revert
on deposit creation.
@@ -64,6 +64,7 @@ library DepositFunding {
uint256 _bondRequirementWei = _d.fetchBitcoinPrice().mul(_bondRequirementSatoshi);
_d.keepSetupFee = _d.tbtcSystem.getNewDepositFeeEstimate();
+
/* solium-disable-next-line value-in-payable */
_d.keepAddress = _d.tbtcSystem.requestNewKeep.value(msg.value)(
_m,
@@ -72,6 +73,8 @@ library DepositFunding {
TBTCConstants.getDepositTerm()
);
+ require(_d.fetchBondAmount() >= _d.keepSetupFee, "Insufficient signer bonds to cover setup fee");
+
_d.signerFeeDivisor = _d.tbtcSystem.getSignerFeeDivisor();
_d.undercollateralizedThresholdPercent = _d.tbtcSystem.getUndercollateralizedThresholdPercent();
_d.severelyUndercollateralizedThresholdPercent = _d.tbtcSystem.getSeverelyUndercollateralizedThresholdPercent();
