Skip to content

Commit 07334be

Browse files
committed
Better error message in EVMTokenConnectors.Sink.depositCapacity() regarding insufficient bridging fees
1 parent 3798cb4 commit 07334be

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

cadence/contracts/connectors/evm/ERC4626SinkConnectors.cdc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ access(all) contract ERC4626SinkConnectors {
132132
// approve the ERC4626 vault to spend the assets on deposit
133133
let uintAmount = FlowEVMBridgeUtils.convertCadenceAmountToERC20Amount(amount, erc20Address: self.assetEVMAddress)
134134
let approveRes = self._call(
135-
to: self.assetEVMAddress,
136-
signature: "approve(address,uint256)",
137-
args: [self.vault, uintAmount],
138-
gasLimit: 500_000
139-
)!
135+
to: self.assetEVMAddress,
136+
signature: "approve(address,uint256)",
137+
args: [self.vault, uintAmount],
138+
gasLimit: 500_000
139+
)!
140140
if approveRes.status != EVM.Status.successful {
141141
// Cadence panic reverts all EVM state changes in this transaction, so no need to bridge token back.
142142
panic(self._approveErrorMessage(ufixAmount: amount, uintAmount: uintAmount, approveRes: approveRes))

cadence/contracts/connectors/evm/EVMTokenConnectors.cdc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ access(all) contract EVMTokenConnectors {
125125

126126
// collect VM bridge fees
127127
let feeAmount = FlowEVMBridgeConfig.baseFee
128-
if self.feeSource.minimumAvailable() < feeAmount {
129-
return // early return here instead of reverting in bridge scope on insufficient fees
130-
}
128+
let availableFees = self.feeSource.minimumAvailable()
129+
assert(
130+
availableFees >= feeAmount,
131+
message: "Fee source \(availableFees.toString()) cannot cover bridging base fee \(feeAmount.toString())"
132+
)
131133
let fees <- self.feeSource.withdrawAvailable(maxAmount: feeAmount)
132134

133135
// deposit tokens and handle remaining fees

0 commit comments

Comments
 (0)