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

Feat/ban vbnc transfer #1487

Merged
merged 36 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
897528a
Bifrost v0.14.0
SunTiebing Sep 19, 2024
5a6927a
Merge branch 'develop' into v0.14.0
hqwangningbo Sep 20, 2024
ef3c9ed
Feat/optimize salp (#1433)
SunTiebing Sep 23, 2024
7d34b0f
Merge branch 'develop' into v0.14.0
ark930 Sep 23, 2024
394f729
Optimised calculation of evm fee (#1434)
hqwangningbo Sep 23, 2024
1a87eec
Moved PalletId and AccountId to primitives. (#1437)
MJLNSN Sep 25, 2024
0e8f755
Optimize xcm interface (#1439)
hqwangningbo Sep 25, 2024
c6e240c
remove unnecessary call method of cross-in-out (#1440)
SunTiebing Sep 25, 2024
9237c35
Update bb bnc (#1436)
yooml Sep 25, 2024
766e60f
Optimize slpx pallet (#1444)
hqwangningbo Sep 29, 2024
0aaf2cd
Moved palletId in runtime to primitives (#1443)
MJLNSN Sep 29, 2024
c081548
Optimize asset registry (#1445)
SunTiebing Sep 29, 2024
f372dfd
Removed getters in farming (#1446)
MJLNSN Sep 29, 2024
b03a194
Merge branch 'develop' into v0.14.0
ark930 Sep 29, 2024
55c9876
Merge branch 'develop' into v0.14.0
ark930 Sep 29, 2024
72b00f4
Removed getters in vesting. (#1447)
MJLNSN Sep 30, 2024
c97cdc2
Feat/vtoken voting vbnc (#1442)
SunTiebing Sep 30, 2024
8ba3c31
Fix try-runtime (#1451)
hqwangningbo Oct 8, 2024
81f5c6d
Slpx add evm create (#1454)
hqwangningbo Oct 10, 2024
b1542d2
Update farming (#1455)
yooml Oct 10, 2024
8d19729
Remove vsbond auction pallet (#1456)
SunTiebing Oct 11, 2024
9ac8443
This version of vtoken_voting does not support VBNC. (#1459)
SunTiebing Oct 11, 2024
c62e816
Update parachain staking (#1460)
hqwangningbo Oct 12, 2024
c6f72d5
Optimize system-staking pallet. (#1461)
SunTiebing Oct 15, 2024
3f0cf67
fix: 🐛 for review (#1462)
yooml Oct 15, 2024
f1bf1c4
fix: 🐛 for review (#1463)
yooml Oct 15, 2024
d980c23
Optimize stable pool (#1465)
SunTiebing Oct 15, 2024
4196c42
fix: 🐛 for review (#1467)
yooml Oct 15, 2024
87accfb
optimize lend-market pallet (#1468)
SunTiebing Oct 16, 2024
a7b8eda
Optimize vtoken minting (#1469)
hqwangningbo Oct 16, 2024
bcd1527
Replaced bifrost-finance with bifrost-io. (#1466)
MJLNSN Oct 16, 2024
8fe2c9c
fix: 🐛 pool ID for bbBNC (#1471)
yooml Oct 16, 2024
a742f74
test: 💍 add boost testing (#1470)
yooml Oct 17, 2024
2e5e114
Ban vbnc transfer
SunTiebing Oct 22, 2024
ade00b9
Merge branch 'refs/heads/v0.15.0' into feat/ban-vbnc-transfer
SunTiebing Oct 30, 2024
6f2cf00
Add restriction conditions for zenlink_protocol::Call::transfer
SunTiebing Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions primitives/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ pub const LDOT: CurrencyId = CurrencyId::Lend(0);
pub const LKSM: CurrencyId = CurrencyId::Lend(1);
pub const LUSDT: CurrencyId = CurrencyId::Lend(2);
pub const LVDOT: CurrencyId = CurrencyId::Lend(3);
pub const BLP_BNC_VBNC: CurrencyId = CurrencyId::BLP(2);
pub const LP_BNC_VBNC: CurrencyId = CurrencyId::LPToken(TokenSymbol::ASG, 0, TokenSymbol::BNC, 1);
pub const KUSAMA_VBNC_ASSET_INDEX: AssetId =
AssetId { chain_id: 2001, asset_type: 2, asset_index: 257 };
pub const KUSAMA_VBNC_LP_ASSET_INDEX: AssetId =
AssetId { chain_id: 2001, asset_type: 2, asset_index: 1103806596608 };
pub const KUSAMA_BNC_ASSET_INDEX: AssetId =
AssetId { chain_id: 2001, asset_type: 0, asset_index: 0 };

macro_rules! create_currency_id {
($(#[$meta:meta])*
Expand Down
136 changes: 135 additions & 1 deletion runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use bifrost_primitives::{
BLP_BNC_VBNC, KUSAMA_VBNC_ASSET_INDEX, KUSAMA_VBNC_LP_ASSET_INDEX, LP_BNC_VBNC, VBNC,
};
use bifrost_slp::{DerivativeAccountProvider, QueryResponseManager};
use core::convert::TryInto;
// A few exports that help ease life for downstream crates.
Expand Down Expand Up @@ -220,11 +223,142 @@ parameter_types! {
pub const StableAssetPalletId: PalletId = PalletId(*b"bf/stabl");
}

pub struct CallFilter;
impl Contains<RuntimeCall> for CallFilter {
fn contains(call: &RuntimeCall) -> bool {
let is_core_call = matches!(
call,
RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_)
);
if is_core_call {
// always allow core call
return true;
}

// disable transfer
let is_transfer = matches!(call, RuntimeCall::Tokens(_) | RuntimeCall::Balances(_));
if is_transfer {
let is_disabled = match call {
RuntimeCall::Tokens(orml_tokens::Call::transfer {
dest: _,
currency_id,
amount: _,
}) =>
VBNC == *currency_id ||
BLP_BNC_VBNC == *currency_id ||
LP_BNC_VBNC == *currency_id,
RuntimeCall::Tokens(orml_tokens::Call::transfer_all {
dest: _,
currency_id,
keep_alive: _,
}) =>
VBNC == *currency_id ||
BLP_BNC_VBNC == *currency_id ||
LP_BNC_VBNC == *currency_id,
RuntimeCall::Tokens(orml_tokens::Call::transfer_keep_alive {
dest: _,
currency_id,
amount: _,
}) =>
VBNC == *currency_id ||
BLP_BNC_VBNC == *currency_id ||
LP_BNC_VBNC == *currency_id,

RuntimeCall::StablePool(bifrost_stable_pool::Call::add_liquidity {
pool_id,
amounts: _,
min_mint_amount: _,
}) => *pool_id == 2,
RuntimeCall::StablePool(bifrost_stable_pool::Call::swap {
pool_id,
i: _,
j: _,
dx: _,
min_dy: _,
}) => *pool_id == 2,
RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_proportion {
pool_id,
amount: _,
min_redeem_amounts: _,
}) => *pool_id == 2,
RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_single {
pool_id,
amount: _,
i: _,
min_redeem_amount: _,
asset_length: _,
}) => *pool_id == 2,
RuntimeCall::StablePool(bifrost_stable_pool::Call::redeem_multi {
pool_id,
amounts: _,
max_redeem_amount: _,
}) => *pool_id == 2,

RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::transfer {
asset_id,
recipient: _,
amount: _,
}) => *asset_id == KUSAMA_VBNC_ASSET_INDEX || *asset_id == KUSAMA_VBNC_LP_ASSET_INDEX,
RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::add_liquidity {
asset_0,
asset_1,
amount_0_desired: _,
amount_1_desired: _,
amount_0_min: _,
amount_1_min: _,
deadline: _,
}) => *asset_0 == KUSAMA_VBNC_ASSET_INDEX || *asset_1 == KUSAMA_VBNC_ASSET_INDEX,
RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::remove_liquidity {
asset_0,
asset_1,
liquidity: _,
amount_0_min: _,
amount_1_min: _,
recipient: _,
deadline: _,
}) => *asset_0 == KUSAMA_VBNC_ASSET_INDEX || *asset_1 == KUSAMA_VBNC_ASSET_INDEX,
RuntimeCall::ZenlinkProtocol(
zenlink_protocol::Call::swap_exact_assets_for_assets {
amount_in: _,
amount_out_min: _,
path,
recipient: _,
deadline: _,
},
) => path.contains(&KUSAMA_VBNC_ASSET_INDEX),
RuntimeCall::ZenlinkProtocol(
zenlink_protocol::Call::swap_assets_for_exact_assets {
amount_out: _,
amount_in_max: _,
path,
recipient: _,
deadline: _,
},
) => path.contains(&KUSAMA_VBNC_ASSET_INDEX),
RuntimeCall::ZenlinkProtocol(zenlink_protocol::Call::bootstrap_claim {
recipient: _,
asset_0,
asset_1,
deadline: _,
}) => *asset_0 == KUSAMA_VBNC_ASSET_INDEX || *asset_1 == KUSAMA_VBNC_ASSET_INDEX,

_ => false,
};

if is_disabled {
// no switched off call
return false;
}
}
true
}
}

impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
type BaseCallFilter = InsideBoth<Everything, TxPause>;
type BaseCallFilter = InsideBoth<CallFilter, TxPause>;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
type BlockLength = RuntimeBlockLength;
Expand Down