diff --git a/cadence/contracts/bridge/FlowEVMBridge.cdc b/cadence/contracts/bridge/FlowEVMBridge.cdc index a8c1071d..b1a572c6 100644 --- a/cadence/contracts/bridge/FlowEVMBridge.cdc +++ b/cadence/contracts/bridge/FlowEVMBridge.cdc @@ -213,7 +213,7 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { // Lock the NFT & calculate the storage used by the NFT let storageUsed = FlowEVMBridgeNFTEscrow.lockNFT(<-token) // Calculate the bridge fee on current rates - let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(used: storageUsed, includeBase: true) + let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(bytes: storageUsed) assert( feeProvider.isAvailableToWithdraw(amount: feeAmount), message: "Fee provider does not have balance to cover the bridge fee of ".concat(feeAmount.toString()) @@ -308,13 +308,13 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { protectedTransferCall: fun (): EVM.Result ): @{NonFungibleToken.NFT} { pre { - feeProvider.isAvailableToWithdraw(amount: FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true)): + feeProvider.isAvailableToWithdraw(amount: FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0)): "Insufficient fee paid" !type.isSubtype(of: Type<@{FungibleToken.Vault}>()): "Mixed asset types are not yet supported" self.typeRequiresOnboarding(type) == false: "NFT must first be onboarded" } // Withdraw from feeProvider and deposit to self - let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true) + let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0) let feeVault <-feeProvider.withdraw(amount: feeAmount) as! @FlowToken.Vault FlowEVMBridgeUtils.deposit(<-feeVault) @@ -401,10 +401,10 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { // Lock the FT balance & calculate the extra used by the FT if any let storageUsed = FlowEVMBridgeTokenEscrow.lockTokens(<-vault) // Calculate the bridge fee on current rates - feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(used: storageUsed, includeBase: true) + feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(bytes: storageUsed) } else { Burner.burn(<-vault) - feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true) + feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0) } // Withdraw from feeProvider and deposit to self @@ -469,14 +469,14 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { protectedTransferCall: fun (): EVM.Result ): @{FungibleToken.Vault} { pre { - feeProvider.isAvailableToWithdraw(amount: FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true)): + feeProvider.isAvailableToWithdraw(amount: FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0)): "Insufficient fee paid" !type.isSubtype(of: Type<@{NonFungibleToken.Collection}>()): "Mixed asset types are not yet supported" !type.isInstance(Type<@FlowToken.Vault>()): "Must use the CadenceOwnedAccount interface to bridge $FLOW from EVM" self.typeRequiresOnboarding(type) == false: "NFT must first be onboarded" } // Withdraw from feeProvider and deposit to self - let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true) + let feeAmount = FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0) let feeVault <-feeProvider.withdraw(amount: feeAmount) as! @FlowToken.Vault FlowEVMBridgeUtils.deposit(<-feeVault) diff --git a/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc b/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc index ba5e06c5..718e2710 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc @@ -62,7 +62,7 @@ transaction(nftContractAddress: Address, nftContractName: String, id: UInt256) { /* --- Configure a ScopedFTProvider --- */ // // Calculate the bridge fee - bridging from EVM consumes no storage, so flat fee - let approxFee = FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true) + let approxFee = FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0) // Issue and store bridge-dedicated Provider Capability in storage if necessary if signer.storage.type(at: FlowEVMBridgeConfig.providerCapabilityStoragePath) == nil { let providerCap = signer.capabilities.storage.issue( diff --git a/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc b/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc index 23de65b4..284318c8 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc @@ -51,8 +51,7 @@ transaction(nftContractAddress: Address, nftContractName: String, id: UInt64) { self.nft <- collection.withdraw(withdrawID: id) let withdrawnStorageUsage = signer.storage.used let approxFee = FlowEVMBridgeUtils.calculateBridgeFee( - used: currentStorageUsage - withdrawnStorageUsage, - includeBase: true + bytes: currentStorageUsage - withdrawnStorageUsage ) * 1.10 /* --- Configure a ScopedFTProvider --- */ diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc index 0c63368d..a92bbced 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc @@ -71,7 +71,7 @@ transaction(tokenContractAddress: Address, tokenContractName: String, amount: UI /* --- Configure a ScopedFTProvider --- */ // // Calculate the bridge fee - bridging from EVM consumes no storage, so flat fee - let approxFee = FlowEVMBridgeUtils.calculateBridgeFee(used: 0, includeBase: true) + let approxFee = FlowEVMBridgeUtils.calculateBridgeFee(bytes: 0) // Issue and store bridge-dedicated Provider Capability in storage if necessary if signer.storage.type(at: FlowEVMBridgeConfig.providerCapabilityStoragePath) == nil { let providerCap = signer.capabilities.storage.issue( diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc index 8f75b2f5..2e7f8c51 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc @@ -52,8 +52,7 @@ transaction(tokenContractAddress: Address, tokenContractName: String, amount: UF let withdrawnStorageUsage = signer.storage.used // Approximate the bridge fee based on the difference in storage usage with some buffer let approxFee = FlowEVMBridgeUtils.calculateBridgeFee( - used: currentStorageUsage - withdrawnStorageUsage, - includeBase: true + bytes: currentStorageUsage - withdrawnStorageUsage ) * 1.10 /* --- Configure a ScopedFTProvider --- */