-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fee for Gateway.sendToken
should cover all costs
#1015
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1015 +/- ##
==========================================
+ Coverage 80.97% 81.50% +0.52%
==========================================
Files 52 54 +2
Lines 2150 2233 +83
Branches 67 70 +3
==========================================
+ Hits 1741 1820 +79
- Misses 394 398 +4
Partials 15 15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Gateway.sendToken
should cover all costs
The estimation to double the cost may not be accurate, the xcm fee totally depends on respective xcm config/impl in a specific parachain and may not be same as(or even differs a lot from) assetHub. E.g. Like for acala the trader they use to calculate the fee are totally different from trader in assetHub and they don't even use the asset pallet for MultiCurrency support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion. But looks good!
contracts/src/Assets.sol
Outdated
@@ -75,12 +87,19 @@ library Assets { | |||
} else { | |||
revert Unsupported(); | |||
} | |||
// If the final destination chain is not AssetHub, then the fee needs to additionally | |||
// include the cost of executing an XCM on the final destination parachain. | |||
extraFee = 2 * $.sendTokenFee; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Why not call sendTokenFee(ParaID assetHubParaID, ParaID destinationChain)
here? Is it because we are worried about gas costs because its external
? I think we should have an internal
implementation and use it for both here and in sendTokenFee(ParaID assetHubParaID, ParaID destinationChain)
so that the fee can be tuned in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah mostly worried about gas costs.
Gonna have to redo this code though, see my latest comment further below.
That's a good point Ron. And we will have the same issue for Xcm::Transact. I understand now that we need to implement something like this:
I think we can reasonably expect that parachains should accept DOT as the fee currency. This simplifies things. No need for custom fee tokens. There are other changes to make if we go with this approach. For example, Channel.outboundFee should be in DOT, not ETH. Then we convert to ETH using the exchange rate when Potential issues: The currency conversion with a lagging & mostly static exchange rate would lead to either of the following scenarios: Scenario 1:
Scenario 2:
|
Or could be loaded from some map storage something like
Since we've already introduced the exchange rate configurable in
As you mentioned the main issue is the outdated price. So we may need to introduce some price oracle like Chainlink Data Feeds or remember as @musnit mentioned before with an on-chain swap. |
Well the idea is that indeed there need to be some mapping of parachain to fees. But its much simpler for clients to maintain that mapping offchain, and pass the required
Agree 👍 I'm implementing that in this PR.
I think a outdated exchange rate is OK for our bridge, for various reasons:
The issue with all Chainlink services is that they are all centralized. They are not actually decentralised and trustless, since they are governed and maintained by a single company. |
Actually this param can be removed now, should be exactly the same as(cover) the cost in
|
Both these scenarios apply to our conversion rate on the substrate side as well. So we may want one extrinsic so that governance can upgrade the conversion rates on both sides of the bridge, maybe from the control pallet? |
…k/snowbridge into remove-redundant-address
For token transfers from Ethereum, if the final destination of the transfer is not AssetHub, we need to charge double the sendToken fee to cover cost of the extra XCM message to the final destination.
I've also improved the API that allows users to query fees for registering and sending tokens. The APIs give more detailed fee info, and in the case of SendToken, accounts for special case above.
requires: Snowfork/polkadot-sdk#49
Fixes: SNO-761