-
Notifications
You must be signed in to change notification settings - Fork 108
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
bb91e65
Gateway should provide detailed fee info
vgeddes 5d80c41
Fix tests
vgeddes ac5c8b1
Improve fee query API
vgeddes 0eb03f2
Add destinationChainFee parameter
vgeddes 26c9098
forge install: prb-math
vgeddes 2fcc415
Add exchage rate to gateway
vgeddes d88dfd5
Update gateway
vgeddes 2616424
rename Cost to Costs
vgeddes d0ad0e9
Fix compile error&tests
yrong 5a63319
Merge branch 'main' into remove-redundant-address
yrong 5df3d94
remove obsolete code
vgeddes 510880c
fix
vgeddes 5e88fd4
Fix contract tests
yrong 1817118
Merge branch 'remove-redundant-address' of https://github.com/Snowfor…
yrong 0fb8c7d
Test
yrong 7f403d7
SetPricingParameters
yrong ffa59e4
Fix breaking tests
yrong 6a4e9c0
Merge branch 'main' into remove-redundant-address
yrong c93468c
Merge main branch
yrong a6245fe
Merge branch 'main' into remove-redundant-address
yrong 3a99601
Update sdk
yrong 0b24172
Load InboundDeliveryCost from EthereumInboundQueue
yrong 1618e7e
Fix e2e setup & smoke tests
yrong 94e0949
Fix for compact scale
yrong 2c0110f
Increase SECONDS_PER_SLOT to 2
yrong dba9769
Merge main branch
yrong a4a62a5
Update sdk
yrong 59d3f20
merge main
yrong 5b65043
Update sdk
yrong 40d07ce
Simplify convert logic
yrong a396ad3
Format code
yrong 9e32156
Add smoke test for set pricing params
yrong 8d19ddb
Load fee params from env
yrong 8333be7
Add test for convert currency
yrong e08c279
Load price configs from env
yrong 7a68d89
Increase fee for test as enough
yrong edf418d
Remove createAssetExecutionFee
yrong b719ad1
Update sdk
yrong ab55e8f
Rename fee getter functions to include a `quote` prefix
vgeddes d26b6bd
improve setTokenTransferFees API, and add benchmarks
vgeddes 359784e
Bump polkadot-sdk
vgeddes c0b32ee
Refactor convertToNative logic
yrong 770c965
Update polkadot-sdk
vgeddes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
pragma solidity 0.8.22; | ||
|
||
import {OperatingMode, InboundMessage, ParaID, ChannelID, MultiAddress} from "../Types.sol"; | ||
import {OperatingMode, InboundMessage, ParaID, ChannelID, MultiAddress, Fee} from "../Types.sol"; | ||
import {Verification} from "../Verification.sol"; | ||
|
||
interface IGateway { | ||
|
@@ -75,13 +75,20 @@ interface IGateway { | |
/// @dev Emitted when a command is sent to register a new wrapped token on AssetHub | ||
event TokenRegistrationSent(address token); | ||
|
||
// @dev Fees in Ether for registering and sending tokens respectively | ||
function tokenTransferFees() external view returns (uint256, uint256); | ||
/// @dev Fee schedule in Ether for registering a token, covering | ||
/// 1. Delivery costs to BridgeHub | ||
/// 2. XCM Execution costs on AssetHub | ||
function registerTokenFee() external view returns (Fee memory); | ||
|
||
/// @dev Send a message to the AssetHub parachain to register a new fungible asset | ||
/// in the `ForeignAssets` pallet. | ||
function registerToken(address token) external payable; | ||
|
||
/// @dev Fees in Ether for sending a token | ||
/// 1. Delivery costs to BridgeHub | ||
/// 2. XCM execution costs on destinationChain | ||
function sendTokenFee(address token, ParaID destinationChain) external view returns (Fee memory); | ||
|
||
/// @dev Send ERC20 tokens to parachain `destinationChain` and deposit into account `destinationAddress` | ||
function sendToken(address token, ParaID destinationChain, MultiAddress calldata destinationAddress, uint128 amount) | ||
external | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
pragma solidity 0.8.22; | ||
|
||
import {Channel, InboundMessage, OperatingMode, ParaID, Command, ChannelID, MultiAddress} from "../../src/Types.sol"; | ||
import {Channel, InboundMessage, OperatingMode, ParaID, Command, ChannelID, MultiAddress, Fee} from "../../src/Types.sol"; | ||
import {IGateway} from "../../src/interfaces/IGateway.sol"; | ||
import {IInitializable} from "../../src/interfaces/IInitializable.sol"; | ||
import {Verification} from "../../src/Verification.sol"; | ||
|
@@ -32,17 +32,22 @@ contract GatewayUpgradeMock is IGateway, IInitializable { | |
return address(0); | ||
} | ||
|
||
function tokenTransferFees() external pure returns (uint256, uint256) { | ||
return (1, 1); | ||
} | ||
|
||
function implementation() external pure returns (address) { | ||
return address(0); | ||
} | ||
|
||
function submitInbound(InboundMessage calldata, bytes32[] calldata, Verification.Proof calldata) external {} | ||
|
||
function registerTokenFee() external pure returns (Fee memory) { | ||
return Fee(1, 1); | ||
} | ||
|
||
function registerToken(address) external payable {} | ||
|
||
function sendTokenFee(address, ParaID) external pure returns (Fee memory) { | ||
return Fee(1, 1); | ||
} | ||
|
||
function sendToken(address, ParaID, MultiAddress calldata, uint128) external payable {} | ||
|
||
event Initialized(uint256 d0, uint256 d1); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 itsexternal
? I think we should have aninternal
implementation and use it for both here and insendTokenFee(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.