You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
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:
max_block_number
.context.set_tx_max_block_number(max_block_number)
wheremax_block_number
was passed in the message --> this way it's guaranteed that the price stays fresh.On slippage
The text was updated successfully, but these errors were encountered: