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

Flexible fee with extra fee #1032

Merged
merged 12 commits into from
Sep 6, 2023
Prev Previous commit
format
herryho committed Sep 6, 2023
commit 6c1acd3092e6fbf4bed5949af8c0433dcfc2acde
12 changes: 5 additions & 7 deletions integration-tests/bifrost-kusama/src/statemine.rs
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@
use crate::{kusama_integration_tests::*, kusama_test_net::*};
use bifrost_asset_registry::AssetMetadata;
use frame_support::assert_ok;
use node_primitives::XcmInterfaceOperation as XcmOperation;
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::AccountIdConversion;
use xcm::{
v3::{prelude::*, Weight},
VersionedMultiAssets, VersionedMultiLocation,
};
use xcm_emulator::TestExt;
use node_primitives::{XcmInterfaceOperation as XcmOperation};

const USDT: u128 = 1_000_000;

@@ -132,14 +132,12 @@ fn cross_usdt() {
10 * USDT
));

assert_ok!(
XcmInterface::set_xcm_dest_weight_and_fee(
RelayCurrencyId::get(),
XcmOperation::StatemineTransfer,
Some((Weight::from_parts(10000000000, 1000000), 10_000_000_000)),
assert_ok!(XcmInterface::set_xcm_dest_weight_and_fee(
RelayCurrencyId::get(),
XcmOperation::StatemineTransfer,
Some((Weight::from_parts(10000000000, 1000000), 10_000_000_000)),
));


assert_ok!(XcmInterface::transfer_statemine_assets(
RuntimeOrigin::signed(ALICE.into()),
5 * USDT,
19 changes: 10 additions & 9 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
@@ -89,7 +89,10 @@ use frame_support::{
use frame_system::{EnsureRoot, EnsureSigned};
use hex_literal::hex;
pub use node_primitives::{
traits::{CheckSubAccount, FarmingInfo, VtokenMintingInterface, VtokenMintingOperator, FeeGetter,XcmDestWeightAndFeeHandler},
traits::{
CheckSubAccount, FarmingInfo, FeeGetter, VtokenMintingInterface, VtokenMintingOperator,
XcmDestWeightAndFeeHandler,
},
AccountId, Amount, AssetIds, Balance, BlockNumber, CurrencyId, CurrencyIdMapping,
DistributionId, ExtraFeeInfo, ExtraFeeName, Moment, Nonce, ParaId, PoolId,
RpcContributionStatus, TimeUnit, TokenSymbol,
@@ -107,10 +110,7 @@ use governance::{custom_origins, CoreAdmin, TechAdmin};

// xcm config
mod xcm_config;
use bifrost_vtoken_voting::{
traits::{DerivativeAccountHandler},
DerivativeIndex,
};
use bifrost_vtoken_voting::{traits::DerivativeAccountHandler, DerivativeIndex};
use pallet_xcm::{EnsureResponse, QueryStatus};
use xcm::v3::prelude::*;
pub use xcm_config::{
@@ -1105,10 +1105,11 @@ impl FeeGetter<RuntimeCall> for ExtraFeeMatcher {
extra_fee_name: ExtraFeeName::StatemineTransfer,
extra_fee_currency: RelayCurrencyId::get(),
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) => ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken,
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) =>
ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken,
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::remove_delegator_vote {
vtoken,
..
23 changes: 12 additions & 11 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -90,10 +90,13 @@ use frame_support::{
use frame_system::{EnsureRoot, EnsureSigned};
use hex_literal::hex;
pub use node_primitives::{
traits::{CheckSubAccount, FarmingInfo, VtokenMintingInterface, VtokenMintingOperator, FeeGetter,XcmDestWeightAndFeeHandler},
traits::{
CheckSubAccount, FarmingInfo, FeeGetter, VtokenMintingInterface, VtokenMintingOperator,
XcmDestWeightAndFeeHandler,
},
AccountId, Amount, AssetIds, Balance, BlockNumber, CurrencyId, CurrencyIdMapping,
DistributionId, ExtraFeeName, ExtraFeeInfo, Moment, Nonce, ParaId, PoolId, RpcContributionStatus, TimeUnit,
TokenSymbol, DOT_TOKEN_ID, GLMR_TOKEN_ID,
DistributionId, ExtraFeeInfo, ExtraFeeName, Moment, Nonce, ParaId, PoolId,
RpcContributionStatus, TimeUnit, TokenSymbol, DOT_TOKEN_ID, GLMR_TOKEN_ID,
};
// zenlink imports
use bifrost_salp::remove_storage::RemoveUnusedQueryIdContributionInfo;
@@ -103,10 +106,7 @@ use zenlink_protocol::{
};
// xcm config
mod xcm_config;
use bifrost_vtoken_voting::{
traits::{DerivativeAccountHandler},
DerivativeIndex,
};
use bifrost_vtoken_voting::{traits::DerivativeAccountHandler, DerivativeIndex};
use orml_traits::{currency::MutationHooks, location::RelativeReserveProvider};
use pallet_xcm::{EnsureResponse, QueryStatus};
use static_assertions::const_assert;
@@ -963,10 +963,11 @@ impl FeeGetter<RuntimeCall> for ExtraFeeMatcher {
extra_fee_name: ExtraFeeName::StatemineTransfer,
extra_fee_currency: RelayCurrencyId::get(),
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) => ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken,
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::vote { vtoken, .. }) =>
ExtraFeeInfo {
extra_fee_name: ExtraFeeName::VoteVtoken,
extra_fee_currency: vtoken,
},
RuntimeCall::VtokenVoting(bifrost_vtoken_voting::Call::remove_delegator_vote {
vtoken,
..