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

Introduce real exchange rate in the FPC #10805

Open
benesjan opened this issue Dec 17, 2024 · 0 comments
Open

Introduce real exchange rate in the FPC #10805

benesjan opened this issue Dec 17, 2024 · 0 comments

Comments

@benesjan
Copy link
Contributor

benesjan commented Dec 17, 2024

We need to introduce a real exchange rate when converting accepted asset (AA) to mana/fee juice in the FPC. Since we need protection against reverts it is necessary to check in private that the amount of provided asset is enough to cover the fee.

Since during the setup we don't yet have an info of how much mana was consumed we need to ensure that enough funds was provided to cover a full max_mana_cost_of_a_tx.

So we need to check:
max_fee_in_accepted_asset * exchange_rate_to_mana <= max_mana_cost_of_a_tx

What's important is that this is happening in private. This means that we are not able to obtain the exchange_rate_to_mana from a public function.

After discussing with Mike on slack regarding how to tackle this we've agreed that the best way would be to go with a timestamped signature of a price.

This is how it would work:

  • An FPC would select a trusted oracle and it would store its public key in storage.
  • A user would pass a message signed by the oracle to the FPC when setting up the flow.
  • The message would contain an exchange rate and a max_block_number.
  • The FPC would then verify the signature (using the pub key from storage and the sig) and it would call context.set_tx_max_block_number(max_block_number) where max_block_number was passed in the message --> this way it's guaranteed that the price stays fresh.
  • Then we would proceed with checking the condition from above.

On slippage

  • Slippage is not that big of a deal here and it can be set to a large value because unlike with DEX swaps this is just a payment of a small fee and not a swap of potentially a large amount of money.
  • Rahul made a good point on slack that large slippage is essentially a fee for the FPC. This is great as we would eventually need to introduce a fee anyway!
@benesjan benesjan added the S-needs-discussion Status: Still needs more discussion before work can start. label Dec 17, 2024
@benesjan benesjan removed the S-needs-discussion Status: Still needs more discussion before work can start. label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant