Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review] MIP-69: Bridge Fees, MD-69: Bridge Fees #69

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

franck44
Copy link
Contributor

@franck44 franck44 commented Dec 12, 2024

MD-k

See #66

Summary

First-cut of the MD for the bridge fees.

@franck44 franck44 changed the title [Draft] First-cut MD for bridge fees. [draft] First-cut MD for bridge fees. Dec 12, 2024
@Primata
Copy link
Contributor

Primata commented Dec 12, 2024

On how fee would be charged:
On the Layer 2, Relayer is able to specify a fee.
For a dynamic fee, we rely on the following:
0. We do have an estimation of how much gas it costs to completeBridgeTransfer on Ethereum in terms of Units of Gas to be used. If we don't want to rely on a fixed value, we take the 1. approach.

  1. once the relayer runs a transaction, it receives the total Units of Gas Used. That sets the gas to be used.
  2. The formula to gas cost is Units of Gas Used * Base Fee + Priority Fee
  3. A fixed Priority Fee of 1.
  4. All that is left is the Base Fee, which can be take from a light node using alloy's calculate_next_block_base_fee. With that we have the gas cost on Ethereum.
  5. Take the exchange ratio between ETH and MOVE from a deep liquidity pool on Ethereum between ETH/MOVE. Ideally we fund this pool to assure that a liquidity provider that would own the majority of the pool cannot reduce its cost to bridge from L2->L1 by pulling liquidity and selling MOVE into it.
  6. With this, we have (Units of Gas Used * Base Fee + Priority Fee) * exchange ratio. We add a 25% buffer to it to account for price hikes or momentary failures and front run the 12.5% gas estimation caused by calculate_next_block_base_fee internal logic for if the next block is full.
  7. With this information, the Relayer can call setFee on L2 if following conditions are met:
    • Current fee in MOVE is 25% lower than the estimated cost.
    • Current fee in MOVE is 10% higher than the estimated cost.
  8. CompleteBridgeTransfer is called in the following format:
    bridge.completeBridgeTransfer{max_fee_per_gas: ${baseFee}, max_priority_fee: 1}(bridgeTransferId, sender, receiver, amount, nonce);
    This prevents us from over spending

1. initiate a transfer on source chain;
2. finalize the transfer on the target chain.

Step (1) is performed by the user on the network (Ethereum or Movement), and step (2) is performed by the bridge operator via a _relayer_ (**ADD link to relayer MIP here**).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link missing

@apenzk
Copy link
Contributor

apenzk commented Dec 12, 2024

Thx @Primata, following came from yesterdays discussion

On how fee would be charged: On the Layer 2, Relayer is able to specify a fee. For a dynamic fee, we rely on the following: 0. We do have an estimation of how much gas it costs to completeBridgeTransfer on Ethereum in terms of Units of Gas to be used. If we don't want to rely on a fixed value, we take the 1. approach.

  1. once the relayer runs a transaction, it receives the total Units of Gas Used. That sets the gas to be used.

The user limits the maximum L2MOVE amount that should be consumed. This is not in gas but an amount that is dedacted from the total amount transferred. This way the user knows how much maximially gets consumed.

  1. All that is left is the Base Fee, which can be take from a light node using alloy's calculate_next_block_base_fee. With that we have the gas cost on Ethereum.

For reasons of cost stability and operational stability the bridge fee is set in the L2bridge contract by an operator that is different to the relayer. This entity reads the fee value from L1 and we keep this value for a certain amount of L2blocks

  1. With this, we have (Units of Gas Used * Base Fee + Priority Fee) * exchange ratio. We add a 25% buffer to it to account for price hikes or momentary failures and front run the 12.5% gas estimation caused by calculate_next_block_base_fee internal logic for if the next block is full.

Since we update the value say every minute (i.e. 5 Eth blocks) we have to consider a maximal increase of 100%, not 25%

@apenzk apenzk self-requested a review December 12, 2024 23:41
@Primata
Copy link
Contributor

Primata commented Dec 12, 2024

@apenzk

  1. The user would be able to see the cost, it's a variable set on the contract and a view function would let the user know how much MOVE they would spend (X) to bridge Y amount with Z fees, X being the sum of Y + Z.

  2. Setting fee on L2 will be extremely cheap, the benefits of updating it as frequently as necessary overshadows setting it on a frequency basis. It also prevents us from over setting the fee.

  3. If we set the base fee too low, the only issue we will have is the bridge taking too long to complete. But we set the base fee based on the charged amount of MOVE, not just whatever fee the next block needs.

Updated comment above to reflect this information.

@franck44
Copy link
Contributor Author

@Primata @apenzk This is an MD which sets the requirements not the implementation.
We'll discuss the implementation and possible strategies in an MIP (not written yet).

So can we first agree on the MD (requirements), without considering solutions that will be part of the corresponding MIP?

@franck44 franck44 added Draft MD/MIP A new/draft MD/MIP bridge labels Dec 17, 2024
@franck44 franck44 marked this pull request as ready for review January 5, 2025 23:52
@franck44 franck44 removed the Draft MD/MIP A new/draft MD/MIP label Jan 5, 2025
@franck44 franck44 added the Ready to Review Needs reviewing label Jan 5, 2025
@franck44 franck44 changed the title [draft] First-cut MD for bridge fees. [Review] First-cut MD for bridge fees. Jan 5, 2025
@apenzk
Copy link
Contributor

apenzk commented Jan 7, 2025

@franck44 MIP-58 contained a section on bridge fee that did not belong there. i have added it as appendix with a note/task to please incorporate it into this MIP

@franck44 franck44 added the MD Contains an MD label Jan 13, 2025
@apenzk apenzk changed the title [Review] First-cut MD for bridge fees. [Review] MIP-69: Bridge Fees, MD-69: Bridge Fees Jan 13, 2025
@apenzk apenzk added the MIP Contains an MIP label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bridge MD Contains an MD MIP Contains an MIP Ready to Review Needs reviewing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants