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

addition of spacewalk pallets to pendulum #401

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 75 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ pub fn pendulum_config() -> PendulumChainSpec {
vesting_schedules.clone(),
multisig_genesis.clone(),
pendulum::PARACHAIN_ID.into(),
false,
)
},
// Bootnodes
Expand Down Expand Up @@ -412,6 +413,10 @@ pub fn development_config() -> DevelopmentChainSpec {
)
}

fn default_pair(currency_id: CurrencyId) -> VaultCurrencyPair<CurrencyId> {
VaultCurrencyPair { collateral: currency_id, wrapped: MAINNET_USDC_CURRENCY_ID }
}

fn amplitude_genesis(
invulnerables: Vec<AccountId>,
signatories: Vec<AccountId>,
Expand All @@ -420,10 +425,6 @@ fn amplitude_genesis(
id: ParaId,
start_shutdown: bool,
) -> amplitude_runtime::GenesisConfig {
fn default_pair(currency_id: CurrencyId) -> VaultCurrencyPair<CurrencyId> {
VaultCurrencyPair { collateral: currency_id, wrapped: MAINNET_USDC_CURRENCY_ID }
}

let mut balances: Vec<_> = signatories
.iter()
.cloned()
Expand Down Expand Up @@ -852,6 +853,7 @@ fn pendulum_genesis(
vesting_schedules: Vec<(AccountId, BlockNumber, BlockNumber, Balance)>,
sudo_account: AccountId,
id: ParaId,
start_shutdown: bool,
) -> pendulum_runtime::GenesisConfig {
let mut genesis_issuance = pendulum::TOTAL_INITIAL_ISSUANCE;
for balance in balances.clone() {
Expand Down Expand Up @@ -921,6 +923,75 @@ fn pendulum_genesis(
..Default::default()
},
vesting: pendulum_runtime::VestingConfig { vesting: vesting_schedules },
issue: pendulum_runtime::IssueConfig {
issue_period: amplitude_runtime::DAYS,
issue_minimum_transfer_amount: 1000,
limit_volume_amount: None,
limit_volume_currency_id: XCM(0),
current_volume_amount: 0u32.into(),
interval_length: (60u32 * 60 * 24),
last_interval_index: 0u32,
},
redeem: pendulum_runtime::RedeemConfig {
redeem_period: pendulum_runtime::DAYS,
redeem_minimum_transfer_amount: 1000,
limit_volume_amount: None,
limit_volume_currency_id: XCM(0),
current_volume_amount: 0u32.into(),
interval_length: (60u32 * 60 * 24),
last_interval_index: 0u32,
},
replace: pendulum_runtime::ReplaceConfig {
replace_period: pendulum_runtime::DAYS,
replace_minimum_transfer_amount: 1000,
},
security: pendulum_runtime::SecurityConfig {
initial_status: if start_shutdown {
pendulum_runtime::StatusCode::Shutdown
} else {
pendulum_runtime::StatusCode::Error
},
},
oracle: pendulum_runtime::OracleConfig {
max_delay: u32::MAX,
oracle_keys: vec![
Key::ExchangeRate(CurrencyId::XCM(0)),
Key::ExchangeRate(MAINNET_USDC_CURRENCY_ID),
],
},
vault_registry: pendulum_runtime::VaultRegistryConfig {
minimum_collateral_vault: vec![(XCM(0), 0)],
punishment_delay: pendulum_runtime::DAYS,
secure_collateral_threshold: vec![(
default_pair(XCM(0)),
FixedU128::checked_from_rational(150, 100).unwrap(),
)],
/* 150% */
premium_redeem_threshold: vec![(
default_pair(XCM(0)),
FixedU128::checked_from_rational(130, 100).unwrap(),
)],
/* 130% */
liquidation_collateral_threshold: vec![(
default_pair(XCM(0)),
FixedU128::checked_from_rational(120, 100).unwrap(),
)],
/* 120% */
system_collateral_ceiling: vec![(
default_pair(XCM(0)),
60_000 * 10u128.pow(pendulum::TOKEN_DECIMALS),
)],
},
stellar_relay: pendulum_runtime::StellarRelayConfig::default(),
fee: pendulum_runtime::FeeConfig {
issue_fee: FixedU128::checked_from_rational(15, 10000).unwrap(), // 0.15%
issue_griefing_collateral: FixedU128::checked_from_rational(5, 100000).unwrap(), // 0.005%
redeem_fee: FixedU128::checked_from_rational(5, 1000).unwrap(), // 0.5%
premium_redeem_fee: FixedU128::checked_from_rational(5, 100).unwrap(), // 5%
punishment_fee: FixedU128::checked_from_rational(1, 10).unwrap(), // 10%
replace_griefing_collateral: FixedU128::checked_from_rational(1, 10).unwrap(), // 10%
},
nomination: pendulum_runtime::NominationConfig { is_nomination_enabled: false },
}
}

Expand Down
5 changes: 5 additions & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ where
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(Staking::new(client.clone()).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(Issue::new(client.clone()).into_rpc())?;
module.merge(Redeem::new(client.clone()).into_rpc())?;
module.merge(Replace::new(client.clone()).into_rpc())?;
module.merge(VaultRegistry::new(client.clone()).into_rpc())?;
module.merge(Oracle::new(client.clone()).into_rpc())?;
module.merge(FarmingRpc::new(client.clone()).into_rpc())?;
module.merge(ZenlinkProtocol::new(client).into_rpc())?;
Ok(module)
Expand Down
122 changes: 93 additions & 29 deletions runtime/pendulum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,28 @@ smallvec = "1.9.0"
# Local
runtime-common = {path = "../common", default-features = false}

# Spacewalk libraries
spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"}
# Custom libraries for Spacewalk
clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" }
module-pallet-staking-rpc-runtime-api = { path = "../../pallets/parachain-staking/rpc/runtime-api", default-features = false }
pooled-rewards = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"}
reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"}

# Substrate
frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40"}
Expand All @@ -37,8 +57,6 @@ frame-system = {git = "https://github.com/paritytech/substrate", default-feature
frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40"}
frame-system-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"}
frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40"}
module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"}
module-pallet-staking-rpc-runtime-api = { path = "../../pallets/parachain-staking/rpc/runtime-api", default-features = false }
pallet-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"}
pallet-authorship = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"}
pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"}
Expand Down Expand Up @@ -178,7 +196,6 @@ std = [
"pallet-vesting/std",
"pallet-xcm/std",
"parachain-info/std",
"parachain-staking/std",
"polkadot-parachain/std",
"polkadot-runtime-common/std",
"runtime-common/std",
Expand All @@ -194,34 +211,67 @@ std = [
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"vesting-manager/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
"bifrost-farming/std",
"bifrost-farming-rpc-runtime-api/std",
"orml-currencies-allowance-extension/std"

#custom libraries from spacewalk
"security/std",
"staking/std",
"oracle/std",
"stellar-relay/std",
"fee/std",
"vault-registry/std",
"redeem/std",
"issue/std",
"currency/std",
"nomination/std",
"replace/std",
"module-issue-rpc-runtime-api/std",
"module-oracle-rpc-runtime-api/std",
"module-redeem-rpc-runtime-api/std",
"module-replace-rpc-runtime-api/std",
"module-pallet-staking-rpc-runtime-api/std",
"module-vault-registry-rpc-runtime-api/std",
"spacewalk-primitives/std",

# custom libraries from pendulum
"orml-currencies-allowance-extension/std",
"parachain-staking/std",
"vesting-manager/std",
]

runtime-benchmarks = [
"hex-literal",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"hex-literal",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",

"fee/runtime-benchmarks",
"issue/runtime-benchmarks",
"nomination/runtime-benchmarks",
"oracle/runtime-benchmarks",
"redeem/runtime-benchmarks",
"replace/runtime-benchmarks",
"stellar-relay/runtime-benchmarks",
"vault-registry/runtime-benchmarks",

"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",

"runtime-common/runtime-benchmarks",
"orml-currencies-allowance-extension/runtime-benchmarks"
"runtime-common/runtime-benchmarks",
"orml-currencies-allowance-extension/runtime-benchmarks"
]

try-runtime = [
Expand All @@ -239,9 +289,9 @@ try-runtime = [
"pallet-contracts/try-runtime",
"pallet-democracy/try-runtime",
"pallet-identity/try-runtime",
"pallet-multisig/try-runtime",
"pallet-proxy/try-runtime",
"pallet-multisig/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
Expand All @@ -250,6 +300,8 @@ try-runtime = [
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"pallet-xcm/try-runtime",

"parachain-staking/try-runtime",

"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
Expand All @@ -262,14 +314,26 @@ try-runtime = [
"orml-tokens/try-runtime",
"orml-xtokens/try-runtime",

"stellar-relay/try-runtime",
"issue/try-runtime",
"currency/try-runtime",
"security/try-runtime",
"staking/try-runtime",
"oracle/try-runtime",
"fee/try-runtime",
"vault-registry/try-runtime",
"redeem/try-runtime",
"nomination/try-runtime",
"replace/try-runtime",
"pooled-rewards/try-runtime",
"clients-info/try-runtime",
"reward-distribution/try-runtime",

"dia-oracle/try-runtime",
"orml-currencies-allowance-extension/try-runtime",

"vesting-manager/try-runtime",

"bifrost-farming/try-runtime",

"zenlink-protocol/try-runtime",

"parachain-staking/try-runtime",
]
]
Loading
Loading