Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Add a linear fee multiplier to ensure safety margins #127

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

vgeddes
Copy link

@vgeddes vgeddes commented Mar 20, 2024

Bridging fees are calculated using a static ETH/DOT exchange rate that can deviate significantly from the real-world exchange rate. We therefore need to add a safety margin to the fee so that users almost aways cover the cost of relaying.

FAQ

Why introduce a multiplier parameter instead of configuring an exchange rate which already has a safety factor applied?

When converting from ETH to DOT, we need to divide the multiplier by the exchange rate, and to convert from DOT to ETH we need to multiply the multiplier by the exchange rate.

Other input parameters to the fee calculation can also deviate from real-world values. These include substrate weights, gas prices, and so on. Why does the multiplier introduced here not adjust those?

A single scalar multiplier won't be able to accommodate the different volatilities efficiently. For example, gas prices are much more volatile than exchange rates, and substrate weights hardly ever change.

So the pricing config relating to weights and gas prices should already have some appropriate safety margin pre-applied.

Detailed Changes:

  • Added multiplier field to PricingParameters
  • Outbound-queue fee is multiplied by multiplier
  • This multiplier is synced to the Ethereum side
  • Improved Runtime API for calculating outbound-queue fees. This API makes it much easier to for configure parts of the system in preparation for launch.
  • Improve and clarify code documentation

Snowbridge Companion PR: Snowfork/snowbridge#1161

claravanstaden and others added 3 commits March 21, 2024 09:23
@vgeddes vgeddes changed the title Add a fee multiplier to ensure safety margins Add a linear fee multiplier to ensure safety margins Mar 21, 2024
@vgeddes vgeddes merged commit 5da7df7 into snowbridge Mar 21, 2024
7 checks passed
@vgeddes vgeddes deleted the fee-multiplier branch March 21, 2024 10:16
claravanstaden pushed a commit that referenced this pull request Mar 21, 2024
* Add fee multiplier

* fmt

* fmt

* Update test mock

* Swap order for parameters to calculate_fee

---------

Co-authored-by: claravanstaden <Cats 4 life!>
vgeddes added a commit that referenced this pull request Mar 22, 2024
* Add fee multiplier

* fmt

* fmt

* Update test mock

* Swap order for parameters to calculate_fee

---------

Co-authored-by: claravanstaden <Cats 4 life!>
github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Mar 22, 2024
Bridging fees are calculated using a static ETH/DOT exchange rate that
can deviate significantly from the real-world exchange rate. We
therefore need to add a safety margin to the fee so that users almost
aways cover the cost of relaying.

# FAQ

> Why introduce a `multiplier` parameter instead of configuring an
exchange rate which already has a safety factor applied?

When converting from ETH to DOT, we need to _divide_ the multiplier by
the exchange rate, and to convert from DOT to ETH we need to _multiply_
the multiplier by the exchange rate.

> Other input parameters to the fee calculation can also deviate from
real-world values. These include substrate weights, gas prices, and so
on. Why does the multiplier introduced here not adjust those?

A single scalar multiplier won't be able to accommodate the different
volatilities efficiently. For example, gas prices are much more volatile
than exchange rates, and substrate weights hardly ever change.

So the pricing config relating to weights and gas prices should already
have some appropriate safety margin pre-applied.

# Detailed Changes:

* Added `multiplier` field to `PricingParameters`
* Outbound-queue fee is multiplied by `multiplier`
* This `multiplier` is synced to the Ethereum side
* Improved Runtime API for calculating outbound-queue fees. This API
makes it much easier to for configure parts of the system in preparation
for launch.
* Improve and clarify code documentation

Upstreamed from Snowfork#127

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
claravanstaden pushed a commit that referenced this pull request Mar 22, 2024
* Add fee multiplier

* fmt

* fmt

* Update test mock

* Swap order for parameters to calculate_fee

---------

Co-authored-by: claravanstaden <Cats 4 life!>
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Mar 24, 2024
Bridging fees are calculated using a static ETH/DOT exchange rate that
can deviate significantly from the real-world exchange rate. We
therefore need to add a safety margin to the fee so that users almost
aways cover the cost of relaying.

# FAQ

> Why introduce a `multiplier` parameter instead of configuring an
exchange rate which already has a safety factor applied?

When converting from ETH to DOT, we need to _divide_ the multiplier by
the exchange rate, and to convert from DOT to ETH we need to _multiply_
the multiplier by the exchange rate.

> Other input parameters to the fee calculation can also deviate from
real-world values. These include substrate weights, gas prices, and so
on. Why does the multiplier introduced here not adjust those?

A single scalar multiplier won't be able to accommodate the different
volatilities efficiently. For example, gas prices are much more volatile
than exchange rates, and substrate weights hardly ever change.

So the pricing config relating to weights and gas prices should already
have some appropriate safety margin pre-applied.

# Detailed Changes:

* Added `multiplier` field to `PricingParameters`
* Outbound-queue fee is multiplied by `multiplier`
* This `multiplier` is synced to the Ethereum side
* Improved Runtime API for calculating outbound-queue fees. This API
makes it much easier to for configure parts of the system in preparation
for launch.
* Improve and clarify code documentation

Upstreamed from Snowfork#127

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants