From 89b62642e688d13b02decacabbfcceeda1164492 Mon Sep 17 00:00:00 2001 From: gianfra-t <96739519+gianfra-t@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:15:52 -0300 Subject: [PATCH 01/15] fix for try-runtime features (#386) * fix for try-runtime features * point to the latest spacewalk commit * add enhancement for Relative value type * update missing spacewalk dependencies, rename adjust_amount function * fixing indentation --- Cargo.lock | 182 +++++++----------- node/Cargo.toml | 12 +- .../Cargo.toml | 5 + .../Cargo.toml | 9 +- pallets/parachain-staking/rpc/Cargo.toml | 2 +- .../rpc/runtime-api/Cargo.toml | 2 +- pallets/parachain-staking/src/try_state.rs | 2 +- runtime/amplitude/Cargo.toml | 107 +++++++--- runtime/amplitude/src/lib.rs | 17 +- runtime/amplitude/src/xcm_config.rs | 31 +-- runtime/common/Cargo.toml | 2 +- runtime/common/src/lib.rs | 25 ++- runtime/development/Cargo.toml | 22 ++- runtime/development/src/lib.rs | 3 - runtime/foucoco/Cargo.toml | 106 +++++++--- runtime/foucoco/src/lib.rs | 19 +- runtime/integration-tests/Cargo.toml | 2 +- runtime/pendulum/Cargo.toml | 54 +++++- runtime/pendulum/src/lib.rs | 18 +- runtime/pendulum/src/xcm_config.rs | 42 ++-- 20 files changed, 419 insertions(+), 243 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eba0e2641..db0c69a73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", "stellar-relay", "substrate-wasm-builder", @@ -1194,8 +1194,8 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "clients-info" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "frame-system", @@ -2065,8 +2065,8 @@ dependencies = [ [[package]] name = "currency" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "frame-system", @@ -2080,7 +2080,7 @@ dependencies = [ "serde", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] @@ -2853,8 +2853,8 @@ dependencies = [ [[package]] name = "fee" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "frame-benchmarking", @@ -2873,7 +2873,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", ] @@ -3099,7 +3099,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", "stellar-relay", "substrate-wasm-builder", @@ -4158,8 +4158,8 @@ dependencies = [ [[package]] name = "issue" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "base64 0.13.1", "currency", @@ -4186,7 +4186,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "stellar-relay", "vault-registry", ] @@ -5437,8 +5437,8 @@ dependencies = [ [[package]] name = "module-issue-rpc" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "jsonrpsee", "module-issue-rpc-runtime-api", @@ -5450,8 +5450,8 @@ dependencies = [ [[package]] name = "module-issue-rpc-runtime-api" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "parity-scale-codec", @@ -5461,8 +5461,8 @@ dependencies = [ [[package]] name = "module-oracle-rpc" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "jsonrpsee", "module-oracle-rpc-runtime-api", @@ -5470,20 +5470,20 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-runtime", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] name = "module-oracle-rpc-runtime-api" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "parity-scale-codec", "serde", "sp-api", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] @@ -5514,8 +5514,8 @@ dependencies = [ [[package]] name = "module-redeem-rpc" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "jsonrpsee", "module-redeem-rpc-runtime-api", @@ -5527,8 +5527,8 @@ dependencies = [ [[package]] name = "module-redeem-rpc-runtime-api" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "parity-scale-codec", @@ -5538,8 +5538,8 @@ dependencies = [ [[package]] name = "module-replace-rpc" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "jsonrpsee", "module-replace-rpc-runtime-api", @@ -5551,8 +5551,8 @@ dependencies = [ [[package]] name = "module-replace-rpc-runtime-api" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "parity-scale-codec", @@ -5562,8 +5562,8 @@ dependencies = [ [[package]] name = "module-vault-registry-rpc" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "jsonrpsee", "module-oracle-rpc-runtime-api", @@ -5576,8 +5576,8 @@ dependencies = [ [[package]] name = "module-vault-registry-rpc-runtime-api" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "module-oracle-rpc-runtime-api", @@ -5851,8 +5851,8 @@ dependencies = [ [[package]] name = "nomination" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "fee", @@ -5876,7 +5876,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", "vault-registry", ] @@ -6023,8 +6023,8 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "oracle" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "dia-oracle", @@ -6043,7 +6043,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "spin 0.9.8", "staking", ] @@ -6201,7 +6201,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=d05b0015d15ca39cc780889bcc095335e9862a36)", + "spacewalk-primitives", ] [[package]] @@ -7747,7 +7747,7 @@ dependencies = [ "sp-session", "sp-timestamp", "sp-transaction-pool", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", @@ -7838,7 +7838,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "substrate-wasm-builder", "vesting-manager", "xcm", @@ -9169,8 +9169,8 @@ dependencies = [ [[package]] name = "pooled-rewards" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "frame-benchmarking", @@ -9185,7 +9185,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] @@ -9614,8 +9614,8 @@ dependencies = [ [[package]] name = "redeem" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "fee", @@ -9639,7 +9639,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "stellar-relay", "vault-registry", ] @@ -9776,8 +9776,8 @@ dependencies = [ [[package]] name = "replace" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "fee", @@ -9803,7 +9803,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "stellar-relay", "vault-registry", ] @@ -9820,8 +9820,8 @@ dependencies = [ [[package]] name = "reward" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -9834,13 +9834,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] name = "reward-distribution" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "frame-benchmarking", @@ -9862,7 +9862,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", ] @@ -10081,7 +10081,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "xcm", "xcm-executor", "zenlink-protocol", @@ -10126,7 +10126,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-tracing", - "spacewalk-primitives 1.2.0", + "spacewalk-primitives", "statemine-runtime", "statemint-runtime", "xcm", @@ -11609,8 +11609,8 @@ dependencies = [ [[package]] name = "security" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-support", "frame-system", @@ -12651,26 +12651,8 @@ dependencies = [ [[package]] name = "spacewalk-primitives" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" -dependencies = [ - "base58", - "bstringify", - "frame-support", - "hex", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-runtime", - "sp-std", - "substrate-stellar-sdk", -] - -[[package]] -name = "spacewalk-primitives" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=d05b0015d15ca39cc780889bcc095335e9862a36#d05b0015d15ca39cc780889bcc095335e9862a36" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "base58", "bstringify", @@ -12685,22 +12667,6 @@ dependencies = [ "substrate-stellar-sdk", ] -[[package]] -name = "spacewalk-primitives" -version = "1.2.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=58983d2695c309665c9c017a022436aaee088f3d#58983d2695c309665c9c017a022436aaee088f3d" -dependencies = [ - "base58", - "bstringify", - "frame-support", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", - "substrate-stellar-sdk", -] - [[package]] name = "spin" version = "0.5.2" @@ -12749,8 +12715,8 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -12765,7 +12731,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] @@ -12955,8 +12921,8 @@ dependencies = [ [[package]] name = "stellar-relay" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "base64 0.13.1", "currency", @@ -12969,7 +12935,7 @@ dependencies = [ "sha2 0.10.7", "sp-core", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", ] [[package]] @@ -13934,8 +13900,8 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" -version = "1.0.0" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85#20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" +version = "1.0.3" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" dependencies = [ "currency", "fee", @@ -13962,7 +13928,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.0 (git+https://github.com/pendulum-chain/spacewalk?rev=20a3dd191dc352f989f90a1a48eacb8ff6d9ac85)", + "spacewalk-primitives", "staking", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index d7bbc4528..61ea197eb 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -15,13 +15,13 @@ codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.145", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } -module-issue-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-oracle-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-redeem-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-replace-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-vault-registry-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +module-issue-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +module-oracle-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +module-redeem-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +module-replace-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +module-vault-registry-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} module-pallet-staking-rpc = { path = "../pallets/parachain-staking/rpc" } -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} # Local amplitude-runtime = {path = "../runtime/amplitude"} diff --git a/pallets/orml-currencies-allowance-extension/Cargo.toml b/pallets/orml-currencies-allowance-extension/Cargo.toml index 2439e4c24..7153dcb19 100644 --- a/pallets/orml-currencies-allowance-extension/Cargo.toml +++ b/pallets/orml-currencies-allowance-extension/Cargo.toml @@ -55,3 +55,8 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances" ] + +try-runtime = [ + "frame-system/try-runtime", + "pallet-balances/try-runtime" +] \ No newline at end of file diff --git a/pallets/orml-tokens-management-extension/Cargo.toml b/pallets/orml-tokens-management-extension/Cargo.toml index d2ca15d7d..6b7aa40b7 100644 --- a/pallets/orml-tokens-management-extension/Cargo.toml +++ b/pallets/orml-tokens-management-extension/Cargo.toml @@ -33,7 +33,7 @@ sp-io = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0. pallet-balances = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} # Spacewalk libraries -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "d05b0015d15ca39cc780889bcc095335e9862a36"} +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} [features] @@ -59,3 +59,10 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] + +try-runtime = [ + "frame-system/try-runtime", + "frame-support/try-runtime", + "orml-currencies/try-runtime", + "orml-tokens/try-runtime", +] \ No newline at end of file diff --git a/pallets/parachain-staking/rpc/Cargo.toml b/pallets/parachain-staking/rpc/Cargo.toml index cafbca161..13187aaa1 100644 --- a/pallets/parachain-staking/rpc/Cargo.toml +++ b/pallets/parachain-staking/rpc/Cargo.toml @@ -7,7 +7,7 @@ version = "1.0.0" [dependencies] codec = {package = "parity-scale-codec", version = "3.0.0"} jsonrpsee = {version = "0.16.0", features = ["server", "macros"]} -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} module-pallet-staking-rpc-runtime-api = {path = "runtime-api"} sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} diff --git a/pallets/parachain-staking/rpc/runtime-api/Cargo.toml b/pallets/parachain-staking/rpc/runtime-api/Cargo.toml index 9ce8f015a..7e0bd4b08 100644 --- a/pallets/parachain-staking/rpc/runtime-api/Cargo.toml +++ b/pallets/parachain-staking/rpc/runtime-api/Cargo.toml @@ -10,7 +10,7 @@ sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0 sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} parity-scale-codec = {version = "3.1.5", default-features = false, features = ["derive"]} scale-info = {version = "2.1.1", default-features = false, features = ["derive"]} -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} serde = {version = "1.0.142", default-features = false, optional = true, features = ["derive"]} [features] diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index c2e58bb85..899b7bb9e 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::{ensure, traits::Get}; -use scale_info::prelude::format; +use scale_info::prelude::{format, string::String}; use sp_runtime::{ traits::{CheckedAdd, Zero}, SaturatedConversion, Saturating, diff --git a/runtime/amplitude/Cargo.toml b/runtime/amplitude/Cargo.toml index fb52cc741..a3d04da20 100644 --- a/runtime/amplitude/Cargo.toml +++ b/runtime/amplitude/Cargo.toml @@ -27,27 +27,27 @@ smallvec = "1.9.0" runtime-common = { path = "../common", default-features = false } # Custom libraries for Spacewalk -clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -module-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } -module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } +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 = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +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 @@ -164,6 +164,7 @@ std = [ "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "orml-asset-registry/std", "orml-currencies/std", "orml-traits/std", @@ -217,7 +218,8 @@ std = [ "zenlink-protocol-runtime-api/std", "bifrost-farming/std", "bifrost-farming-rpc-runtime-api/std", - # custom libraries from spacewalk + + #custom libraries from spacewalk "security/std", "staking/std", "oracle/std", @@ -274,5 +276,64 @@ runtime-benchmarks = [ try-runtime = [ "frame-executive/try-runtime", - "frame-try-runtime/try-runtime", -] + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-democracy/try-runtime", + "pallet-identity/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", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/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", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + + "orml-asset-registry/try-runtime", + "orml-currencies/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", +] \ No newline at end of file diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 67ffe6514..a40a4b8e5 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -778,7 +778,7 @@ impl pallet_child_bounties::Config for Runtime { parameter_type_with_key! { pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { // Since the xcm trader uses Tokens to get the minimum - // balance of both it's assets and native, we need to + // balance of both it's assets and native, we need to // handle native here match currency_id{ CurrencyId::Native => EXISTENTIAL_DEPOSIT, @@ -1638,14 +1638,21 @@ impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { + fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { log::info!("try-runtime::on_runtime_upgrade amplitude."); - let weight = Executive::try_runtime_upgrade().unwrap(); + let weight = Executive::try_runtime_upgrade(checks).unwrap(); (weight, RuntimeBlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) + fn execute_block( + block: Block, + state_root_check: bool, + signature_check: bool, + select: frame_try_runtime::TryStateSelect + ) -> Weight { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. + Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } diff --git a/runtime/amplitude/src/xcm_config.rs b/runtime/amplitude/src/xcm_config.rs index 46d7ea5bb..98fcad2ce 100644 --- a/runtime/amplitude/src/xcm_config.rs +++ b/runtime/amplitude/src/xcm_config.rs @@ -26,7 +26,7 @@ use xcm_executor::{ XcmExecutor, }; -use runtime_common::parachains::kusama::asset_hub; +use runtime_common::{parachains::kusama::asset_hub, RelativeValue}; use cumulus_primitives_utility::{ ChargeWeightInFungibles, TakeFirstAssetTrader, XcmFeesTo32ByteAccount, @@ -113,34 +113,19 @@ impl Convert> for CurrencyIdConvert { } } -pub struct RelativeValue { - num: Balance, - denominator: Balance, -} - -impl RelativeValue { - fn adjust_amount_by_relative_value(amount: Balance, relative_value: RelativeValue) -> Balance { - if relative_value.denominator == 0 { - // Or probably error - return amount - } - // Calculate the adjusted amount - let adjusted_amount = amount * relative_value.denominator / relative_value.num; - adjusted_amount - } -} +type RelativeValueOf = RelativeValue; pub struct RelayRelativeValue; impl RelayRelativeValue { - fn get_relative_value(id: CurrencyId) -> Option { + fn get_relative_value(id: CurrencyId) -> Option { match id { CurrencyId::XCM(index) => match index { - xcm_assets::RELAY_KSM => Some(RelativeValue { num: 100, denominator: 1 }), - xcm_assets::ASSETHUB_USDT => Some(RelativeValue { num: 20, denominator: 4 }), + xcm_assets::RELAY_KSM => Some(RelativeValueOf { num: 100, denominator: 1 }), + xcm_assets::ASSETHUB_USDT => Some(RelativeValueOf { num: 20, denominator: 4 }), _ => None, }, - CurrencyId::Native => Some(RelativeValue { num: 1, denominator: 1 }), - _ => Some(RelativeValue { num: 1, denominator: 1 }), + CurrencyId::Native => Some(RelativeValueOf { num: 1, denominator: 1 }), + _ => Some(RelativeValueOf { num: 1, denominator: 1 }), } } } @@ -313,7 +298,7 @@ impl ChargeWeightInFungibles for ChargeWeightInFungiblesImple if let Some(relative_value) = RelayRelativeValue::get_relative_value(asset_id) { let adjusted_amount = - RelativeValue::adjust_amount_by_relative_value(amount, relative_value); + RelativeValue::::divide_by_relative_value(amount, relative_value); log::info!("amount to be charged: {:?} in asset: {:?}", adjusted_amount, asset_id); return Ok(adjusted_amount) } else { diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 7bc227474..6eda0545e 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -33,7 +33,7 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } zenlink-protocol = { git = "https://github.com/pendulum-chain/Zenlink-DEX-Module", default-features = false, branch = "polkadot-v0.9.40-protocol" } -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85" } +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" } [features] default = [ diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 375a919a5..092e86c28 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -2,7 +2,7 @@ #![allow(non_snake_case)] use sp_runtime::{ - traits::{IdentifyAccount, Verify}, + traits::{CheckedDiv, IdentifyAccount, Saturating, Verify}, DispatchError, MultiSignature, }; @@ -70,6 +70,29 @@ pub mod opaque { pub type BlockId = generic::BlockId; } +pub struct RelativeValue { + pub num: Amount, + pub denominator: Amount, +} + +impl + Saturating + Clone> RelativeValue { + pub fn divide_by_relative_value( + amount: Amount, + relative_value: RelativeValue, + ) -> Amount { + // Calculate the adjusted amount + if let Some(adjusted_amount) = amount + .clone() + .saturating_mul(relative_value.denominator) + .checked_div(&relative_value.num) + { + return adjusted_amount + } + // We should never specify a numerator of 0, but just to be safe + return amount + } +} + #[macro_use] pub mod parachains { diff --git a/runtime/development/Cargo.toml b/runtime/development/Cargo.toml index eecde2b60..73b25db47 100644 --- a/runtime/development/Cargo.toml +++ b/runtime/development/Cargo.toml @@ -96,6 +96,7 @@ std = [ "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", @@ -144,6 +145,23 @@ runtime-benchmarks = [ ] try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime/try-runtime", + "frame-executive/try-runtime", + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-xcm/try-runtime", + + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + ] diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index bdbe2b7ef..6807e45b5 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -583,9 +583,6 @@ impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { - // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to - // have a backtrace here. If any of the pre/post migration checks fail, we shall stop - // right here and right now. let weight = Executive::try_runtime_upgrade(checks).unwrap(); (weight, RuntimeBlockWeights::get().max_block) } diff --git a/runtime/foucoco/Cargo.toml b/runtime/foucoco/Cargo.toml index 9e288e986..2574993f0 100644 --- a/runtime/foucoco/Cargo.toml +++ b/runtime/foucoco/Cargo.toml @@ -27,27 +27,27 @@ smallvec = "1.9.0" runtime-common = { path = "../common", default-features = false } # custom libraries from spacewalk -clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -pooled-rewards = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +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"} +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"} -module-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} -module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +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 } # Substrate @@ -163,6 +163,7 @@ std = [ "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "orml-asset-registry/std", "orml-currencies/std", "orml-traits/std", @@ -218,7 +219,8 @@ std = [ "xcm/std", "zenlink-protocol/std", "zenlink-protocol-runtime-api/std", - # custom libraries from spacewalk + + #custom libraries from spacewalk "currency/std", "security/std", "staking/std", @@ -274,5 +276,65 @@ runtime-benchmarks = [ try-runtime = [ "frame-executive/try-runtime", - "frame-try-runtime/try-runtime", + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-identity/try-runtime", + "pallet-democracy/try-runtime", + "pallet-multisig/try-runtime", + "pallet-preimage/try-runtime", + "pallet-insecure-randomness-collective-flip/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-proxy/try-runtime", + "pallet-sudo/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/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", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + + "orml-asset-registry/try-runtime", + "orml-currencies/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", + "orml-tokens-management-extension/try-runtime", + + "bifrost-farming/try-runtime", + + "zenlink-protocol/try-runtime", ] diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 0c9d2b440..52e716aaf 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -783,7 +783,7 @@ impl pallet_child_bounties::Config for Runtime { parameter_type_with_key! { pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { // Since the xcm trader uses Tokens to get the minimum - // balance of both it's assets and native, we need to + // balance of both it's assets and native, we need to // handle native here match currency_id{ CurrencyId::Native => EXISTENTIAL_DEPOSIT, @@ -2063,17 +2063,24 @@ impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { - log::info!("try-runtime::on_runtime_upgrade foucoco."); - let weight = Executive::try_runtime_upgrade().unwrap(); + fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { + let weight = Executive::try_runtime_upgrade(checks).unwrap(); (weight, RuntimeBlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) + fn execute_block( + block: Block, + state_root_check: bool, + signature_check: bool, + select: frame_try_runtime::TryStateSelect + ) -> Weight { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. + Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index 96eae61ec..d9874accb 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -11,7 +11,7 @@ scale-info = { version = "2.1.2", features = ["derive"] } serde = { version = "1.0.144", features = ["derive"] } # Spacewalk libraries -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "58983d2695c309665c9c017a022436aaee088f3d"} +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } diff --git a/runtime/pendulum/Cargo.toml b/runtime/pendulum/Cargo.toml index d575d0af6..2523cea68 100644 --- a/runtime/pendulum/Cargo.toml +++ b/runtime/pendulum/Cargo.toml @@ -27,7 +27,7 @@ smallvec = "1.9.0" runtime-common = {path = "../common", default-features = false} # Spacewalk libraries -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +spacewalk-primitives = { 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"} @@ -37,7 +37,7 @@ 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 = "20a3dd191dc352f989f90a1a48eacb8ff6d9ac85"} +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"} @@ -145,6 +145,7 @@ std = [ "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", + "frame-try-runtime/std", "module-pallet-staking-rpc-runtime-api/std", "module-oracle-rpc-runtime-api/std", "orml-asset-registry/std", @@ -224,6 +225,51 @@ runtime-benchmarks = [ ] try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime/try-runtime", + "frame-executive/try-runtime", + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-democracy/try-runtime", + "pallet-identity/try-runtime", + "pallet-multisig/try-runtime", + "pallet-proxy/try-runtime", + "pallet-preimage/try-runtime", + "pallet-insecure-randomness-collective-flip/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", + + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + + "orml-asset-registry/try-runtime", + "orml-currencies/try-runtime", + "orml-tokens/try-runtime", + "orml-xtokens/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", ] diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index d3a54e779..5d0802599 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -685,7 +685,7 @@ impl pallet_child_bounties::Config for Runtime { parameter_type_with_key! { pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { // Since the xcm trader uses Tokens to get the minimum - // balance of both it's assets and native, we need to + // balance of both it's assets and native, we need to // handle native here match currency_id{ CurrencyId::Native => EXISTENTIAL_DEPOSIT, @@ -1342,14 +1342,20 @@ impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (Weight, Weight) { - log::info!("try-runtime::on_runtime_upgrade pendulum."); - let weight = Executive::try_runtime_upgrade().unwrap(); + fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { + let weight = Executive::try_runtime_upgrade(checks).unwrap(); (weight, RuntimeBlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) + fn execute_block( + block: Block, + state_root_check: bool, + signature_check: bool, + select: frame_try_runtime::TryStateSelect + ) -> Weight { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. + Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } diff --git a/runtime/pendulum/src/xcm_config.rs b/runtime/pendulum/src/xcm_config.rs index 0d470aca7..47faf7202 100644 --- a/runtime/pendulum/src/xcm_config.rs +++ b/runtime/pendulum/src/xcm_config.rs @@ -32,6 +32,7 @@ use xcm_executor::{ use runtime_common::{ custom_transactor::{AssetData, AutomationPalletConfig, CustomTransactorInterceptor}, parachains::polkadot::{asset_hub, equilibrium, moonbeam, polkadex}, + RelativeValue, }; use crate::{ @@ -100,41 +101,26 @@ impl Convert> for CurrencyIdConvert { } } -pub struct RelativeValue { - num: Balance, - denominator: Balance, -} - -impl RelativeValue { - fn adjust_amount_by_relative_value(amount: Balance, relative_value: RelativeValue) -> Balance { - if relative_value.denominator == 0 { - // Or probably error - return amount - } - // Calculate the adjusted amount - let adjusted_amount = amount * relative_value.denominator / relative_value.num; - adjusted_amount - } -} +type RelativeValueOf = RelativeValue; pub struct RelayRelativeValue; impl RelayRelativeValue { - fn get_relative_value(id: CurrencyId) -> Option { + fn get_relative_value(id: CurrencyId) -> Option { match id { CurrencyId::XCM(f) => match f { - xcm_assets::RELAY_DOT => Some(RelativeValue { num: 98, denominator: 1 }), - xcm_assets::ASSETHUB_USDT => Some(RelativeValue { num: 12, denominator: 1 }), - xcm_assets::ASSETHUB_USDC => Some(RelativeValue { num: 12, denominator: 1 }), - xcm_assets::EQUILIBRIUM_EQD => Some(RelativeValue { num: 12, denominator: 1 }), - xcm_assets::MOONBEAM_BRZ => Some(RelativeValue { num: 23, denominator: 10 }), - xcm_assets::POLKADEX_PDEX => Some(RelativeValue { num: 14, denominator: 1 }), - xcm_assets::MOONBEAM_GLMR => Some(RelativeValue { num: 55, denominator: 10 }), + xcm_assets::RELAY_DOT => Some(RelativeValueOf { num: 98, denominator: 1 }), + xcm_assets::ASSETHUB_USDT => Some(RelativeValueOf { num: 12, denominator: 1 }), + xcm_assets::ASSETHUB_USDC => Some(RelativeValueOf { num: 12, denominator: 1 }), + xcm_assets::EQUILIBRIUM_EQD => Some(RelativeValueOf { num: 12, denominator: 1 }), + xcm_assets::MOONBEAM_BRZ => Some(RelativeValueOf { num: 23, denominator: 10 }), + xcm_assets::POLKADEX_PDEX => Some(RelativeValueOf { num: 14, denominator: 1 }), + xcm_assets::MOONBEAM_GLMR => Some(RelativeValueOf { num: 55, denominator: 10 }), _ => None, }, - CurrencyId::Native => Some(RelativeValue { num: 1, denominator: 1 }), - assets::tokens::EURC_ID => Some(RelativeValue { num: 13, denominator: 1 }), - _ => Some(RelativeValue { num: 10, denominator: 1 }), + CurrencyId::Native => Some(RelativeValueOf { num: 1, denominator: 1 }), + assets::tokens::EURC_ID => Some(RelativeValueOf { num: 13, denominator: 1 }), + _ => Some(RelativeValueOf { num: 10, denominator: 1 }), } } } @@ -331,7 +317,7 @@ impl ChargeWeightInFungibles for ChargeWeightInFungiblesImple // and adjust the amount inversily proportional to the value if let Some(relative_value) = RelayRelativeValue::get_relative_value(asset_id) { let adjusted_amount = - RelativeValue::adjust_amount_by_relative_value(amount, relative_value); + RelativeValue::::divide_by_relative_value(amount, relative_value); log::info!("amount to be charged: {:?} in asset: {:?}", adjusted_amount, asset_id); return Ok(adjusted_amount) } else { From 2be0703b0c818bdd43fd32e2438eb4927d7f603c Mon Sep 17 00:00:00 2001 From: gianfra-t <96739519+gianfra-t@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:13:19 -0300 Subject: [PATCH 02/15] 394 bump versions for pendulum runtime upgrade 11 (#397) bump spec version --- runtime/pendulum/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 5d0802599..ff7640fd6 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("pendulum"), impl_name: create_runtime_str!("pendulum"), authoring_version: 1, - spec_version: 10, + spec_version: 11, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 10, From b7865600bbe5d4470de28e96540044f8900fe693 Mon Sep 17 00:00:00 2001 From: Bogdan Sandu Date: Thu, 18 Jan 2024 11:36:08 +0200 Subject: [PATCH 03/15] Add custom metadata and parameters for asset registry (#398) * Modify CustomMetadata struct to hold blockchain and symbol info for assets in asset registry * Fmt --- runtime/amplitude/src/lib.rs | 5 ++++- runtime/common/src/asset_registry.rs | 28 ++++++++++++++++++++++------ runtime/foucoco/src/lib.rs | 4 +++- runtime/pendulum/src/lib.rs | 5 ++++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index a40a4b8e5..3a2dfcb43 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -21,6 +21,7 @@ use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo}; pub use parachain_staking::InflationInfo; use codec::Encode; +use scale_info::TypeInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; @@ -830,6 +831,8 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; + #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] + pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -841,7 +844,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; diff --git a/runtime/common/src/asset_registry.rs b/runtime/common/src/asset_registry.rs index e61bbe924..b6e206a99 100644 --- a/runtime/common/src/asset_registry.rs +++ b/runtime/common/src/asset_registry.rs @@ -4,21 +4,37 @@ use frame_system::EnsureRoot; use orml_traits::asset_registry::{AssetMetadata, AssetProcessor}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_runtime::DispatchError; +use sp_core::Get; +use sp_runtime::{BoundedVec, DispatchError}; +use sp_std::fmt::Debug; use spacewalk_primitives::CurrencyId; -pub use spacewalk_primitives::CustomMetadata; +#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +pub struct CustomMetadata + TypeInfo + Clone + Eq + Debug + Send + Sync> { + pub dia_keys: DiaKeys, + pub fee_per_second: u128, +} + +#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +pub struct DiaKeys + TypeInfo + Clone + Eq + Debug + Send + Sync> { + pub blockchain: BoundedVec, + pub symbol: BoundedVec, +} #[derive( Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, )] pub struct CustomAssetProcessor; -impl AssetProcessor> for CustomAssetProcessor { +impl AssetProcessor>> + for CustomAssetProcessor +where + T: Get + TypeInfo + Clone + Eq + Debug + Send + Sync + 'static, +{ fn pre_register( id: Option, - metadata: AssetMetadata, - ) -> Result<(CurrencyId, AssetMetadata), DispatchError> { + metadata: AssetMetadata>, + ) -> Result<(CurrencyId, AssetMetadata>), DispatchError> { match id { Some(id) => Ok((id, metadata)), None => Err(DispatchError::Other("asset-registry: AssetId is required")), @@ -27,7 +43,7 @@ impl AssetProcessor> for Cust fn post_register( _id: CurrencyId, - _asset_metadata: AssetMetadata, + _asset_metadata: AssetMetadata>, ) -> Result<(), DispatchError> { Ok(()) } diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 52e716aaf..1b819a7e0 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -833,6 +833,8 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; + #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] + pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -844,7 +846,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index ff7640fd6..eb3e8171d 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -19,6 +19,7 @@ use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo}; pub use parachain_staking::InflationInfo; use codec::Encode; +use scale_info::TypeInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; @@ -735,6 +736,8 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; + #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] + pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -746,7 +749,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; From cbe46145223c9c660304ebc1ea2306d27fe45501 Mon Sep 17 00:00:00 2001 From: Bogdan Sandu Date: Fri, 19 Jan 2024 12:23:41 +0200 Subject: [PATCH 04/15] Bump spec and transaction version for Foucoco (#370) * Bump spec and transaction version for Foucoco * Bump spec and transaction version to 7 --- runtime/foucoco/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 1b819a7e0..f48fbef00 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -256,10 +256,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("foucoco"), impl_name: create_runtime_str!("foucoco"), authoring_version: 1, - spec_version: 4, + spec_version: 7, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 4, + transaction_version: 7, state_version: 1, }; From 67e39a0f36cae8bf2afd8876067a2563f5986830 Mon Sep 17 00:00:00 2001 From: gianfra-t <96739519+gianfra-t@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:54:59 -0300 Subject: [PATCH 05/15] addition of spwacewalk pallets to pendulum (#401) * addition of spwacewalk pallets to pendulum * Update node/src/chain_spec.rs Co-authored-by: Marcel Ebert * fix incorrect field in genesis function * indentation * try to fix strange indentation issue * indentation 2 --------- Co-authored-by: Marcel Ebert --- Cargo.lock | 18 ++ node/src/chain_spec.rs | 79 ++++++- node/src/rpc.rs | 5 + runtime/pendulum/Cargo.toml | 166 ++++++++++----- runtime/pendulum/src/lib.rs | 411 +++++++++++++++++++++++++++++++++++- 5 files changed, 613 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db0c69a73..c829b2038 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7764,6 +7764,7 @@ version = "0.1.0" dependencies = [ "bifrost-farming", "bifrost-farming-rpc-runtime-api", + "clients-info", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -7773,8 +7774,10 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", + "currency", "dia-oracle", "dia-oracle-runtime-api", + "fee", "frame-benchmarking", "frame-executive", "frame-support", @@ -7783,9 +7786,16 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", + "issue", "log", + "module-issue-rpc-runtime-api", "module-oracle-rpc-runtime-api", "module-pallet-staking-rpc-runtime-api", + "module-redeem-rpc-runtime-api", + "module-replace-rpc-runtime-api", + "module-vault-registry-rpc-runtime-api", + "nomination", + "oracle", "orml-asset-registry", "orml-currencies", "orml-currencies-allowance-extension", @@ -7822,8 +7832,13 @@ dependencies = [ "paste", "polkadot-parachain", "polkadot-runtime-common", + "pooled-rewards", + "redeem", + "replace", + "reward-distribution", "runtime-common", "scale-info", + "security", "serde", "smallvec", "sp-api", @@ -7839,7 +7854,10 @@ dependencies = [ "sp-transaction-pool", "sp-version", "spacewalk-primitives", + "staking", + "stellar-relay", "substrate-wasm-builder", + "vault-registry", "vesting-manager", "xcm", "xcm-builder", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 96c671e86..b3d629874 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -331,6 +331,7 @@ pub fn pendulum_config() -> PendulumChainSpec { vesting_schedules.clone(), multisig_genesis.clone(), pendulum::PARACHAIN_ID.into(), + false, ) }, // Bootnodes @@ -412,6 +413,10 @@ pub fn development_config() -> DevelopmentChainSpec { ) } +fn default_pair(currency_id: CurrencyId) -> VaultCurrencyPair { + VaultCurrencyPair { collateral: currency_id, wrapped: MAINNET_USDC_CURRENCY_ID } +} + fn amplitude_genesis( invulnerables: Vec, signatories: Vec, @@ -420,10 +425,6 @@ fn amplitude_genesis( id: ParaId, start_shutdown: bool, ) -> amplitude_runtime::GenesisConfig { - fn default_pair(currency_id: CurrencyId) -> VaultCurrencyPair { - VaultCurrencyPair { collateral: currency_id, wrapped: MAINNET_USDC_CURRENCY_ID } - } - let mut balances: Vec<_> = signatories .iter() .cloned() @@ -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() { @@ -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 }, } } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 3316ab826..1af41d0fd 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -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) diff --git a/runtime/pendulum/Cargo.toml b/runtime/pendulum/Cargo.toml index 2523cea68..a94628e13 100644 --- a/runtime/pendulum/Cargo.toml +++ b/runtime/pendulum/Cargo.toml @@ -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"} @@ -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"} @@ -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", @@ -194,7 +211,6 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", - "vesting-manager/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", @@ -202,7 +218,31 @@ 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 = [ @@ -213,6 +253,16 @@ 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", @@ -221,55 +271,69 @@ runtime-benchmarks = [ "pallet-collective/runtime-benchmarks", "runtime-common/runtime-benchmarks", - "orml-currencies-allowance-extension/runtime-benchmarks" + "orml-currencies-allowance-extension/runtime-benchmarks" ] try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime", - "frame-system/try-runtime", - "parachain-info/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-balances/try-runtime", - "pallet-bounties/try-runtime", - "pallet-child-bounties/try-runtime", - "pallet-collective/try-runtime", - "pallet-contracts/try-runtime", - "pallet-democracy/try-runtime", - "pallet-identity/try-runtime", - "pallet-multisig/try-runtime", - "pallet-proxy/try-runtime", - "pallet-preimage/try-runtime", - "pallet-insecure-randomness-collective-flip/try-runtime", - "pallet-scheduler/try-runtime", - "pallet-session/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-treasury/try-runtime", - "pallet-utility/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm/try-runtime", + "frame-executive/try-runtime", + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-democracy/try-runtime", + "pallet-identity/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", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/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", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", - "orml-currencies/try-runtime", - "orml-tokens/try-runtime", - "orml-xtokens/try-runtime", + "orml-asset-registry/try-runtime", + "orml-currencies/try-runtime", + "orml-tokens/try-runtime", + "orml-xtokens/try-runtime", - "dia-oracle/try-runtime", - "orml-currencies-allowance-extension/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", - "vesting-manager/try-runtime", + "dia-oracle/try-runtime", + "orml-currencies-allowance-extension/try-runtime", + "vesting-manager/try-runtime", + + "bifrost-farming/try-runtime", - "bifrost-farming/try-runtime", - - "zenlink-protocol/try-runtime", - - "parachain-staking/try-runtime", -] + "zenlink-protocol/try-runtime", +] \ No newline at end of file diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index eb3e8171d..625063a4e 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -23,18 +23,28 @@ use scale_info::TypeInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto}, + traits::{ + AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, + }, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, SaturatedConversion, + ApplyExtrinsicResult, DispatchError, FixedPointNumber, MultiAddress, Perbill, Permill, + Perquintill, SaturatedConversion, }; use bifrost_farming as farming; use bifrost_farming_rpc_runtime_api as farming_rpc_runtime_api; pub use spacewalk_primitives::CurrencyId; +use spacewalk_primitives::{ + self as primitives, CurrencyId::XCM, Moment, SignedFixedPoint, SignedInner, UnsignedFixedPoint, + UnsignedInner, +}; + +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-utils"))] +use oracle::testing_utils::MockDataFeeder; use sp_std::{marker::PhantomData, prelude::*}; #[cfg(feature = "std")] @@ -46,8 +56,8 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, traits::{ - ConstBool, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Imbalance, - InstanceFilter, OnUnbalanced, WithdrawReasons, + ConstBool, ConstU32, Contains, Currency as FrameCurrency, EitherOfDiverse, + EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, WithdrawReasons, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -59,7 +69,6 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -pub use sp_runtime::{traits::AccountIdConversion, MultiAddress, Perbill, Permill, Perquintill}; use runtime_common::{ asset_registry, opaque, AccountId, Amount, AuraId, Balance, BlockNumber, Hash, Index, PoolId, @@ -69,6 +78,16 @@ use runtime_common::{ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use dia_oracle::DiaOracle; +pub use issue::{Event as IssueEvent, IssueRequest}; +pub use nomination::Event as NominationEvent; +use oracle::{ + dia, + dia::{DiaOracleAdapter, NativeCurrencyKey, XCMCurrencyConversion}, +}; +pub use redeem::{Event as RedeemEvent, RedeemRequest}; +pub use replace::{Event as ReplaceEvent, ReplaceRequest}; +pub use security::StatusCode; +pub use stellar_relay::traits::{FieldLength, Organization, Validator}; use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; @@ -89,6 +108,9 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use crate::chain_ext::Psp22Extension; use xcm_executor::XcmExecutor; +/// Spacewalk vault id type +pub type VaultId = primitives::VaultId; + /// The address format for describing accounts. pub type Address = MultiAddress; @@ -134,6 +156,60 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +pub struct PendulumDiaOracleKeyConverter; + +impl NativeCurrencyKey for PendulumDiaOracleKeyConverter { + fn native_symbol() -> Vec { + b"PEN".to_vec() + } + + fn native_chain() -> Vec { + b"Pendulum".to_vec() + } +} + +impl XCMCurrencyConversion for PendulumDiaOracleKeyConverter { + fn convert_to_dia_currency_id(token_symbol: u8) -> Option<(Vec, Vec)> { + match token_symbol { + 0 => Some((b"Polkadot".to_vec(), b"DOT".to_vec())), + _ => None, + } + } + + fn convert_from_dia_currency_id(blockchain: Vec, symbol: Vec) -> Option { + match (blockchain.as_slice(), symbol.as_slice()) { + (b"Polkadot", b"DOT") => Some(0), + _ => None, + } + } +} + +type DataProviderImpl = DiaOracleAdapter< + DiaOracleModule, + UnsignedFixedPoint, + Moment, + dia::DiaOracleKeyConvertor, + ConvertPrice, + ConvertMoment, +>; + +pub struct ConvertPrice; + +impl Convert> for ConvertPrice { + fn convert(price: u128) -> Option { + Some(UnsignedFixedPoint::from_inner(price)) + } +} + +pub struct ConvertMoment; + +impl Convert> for ConvertMoment { + fn convert(moment: u64) -> Option { + // The provided moment is in seconds, but we need milliseconds + Some(moment.saturating_mul(1000)) + } +} + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// @@ -251,6 +327,7 @@ impl Contains for BaseFilter { // These modules are all allowed to be called by transactions: RuntimeCall::Bounties(_) | RuntimeCall::ChildBounties(_) | + RuntimeCall::ClientsInfo(_) | RuntimeCall::Treasury(_) | RuntimeCall::Tokens(_) | RuntimeCall::Currencies(_) | @@ -279,6 +356,17 @@ impl Contains for BaseFilter { RuntimeCall::VestingManager(_) | RuntimeCall::TokenAllowance(_) | RuntimeCall::AssetRegistry(_) | + RuntimeCall::Fee(_) | + RuntimeCall::Issue(_) | + RuntimeCall::Nomination(_) | + RuntimeCall::Oracle(_) | + RuntimeCall::Redeem(_) | + RuntimeCall::Replace(_) | + RuntimeCall::Security(_) | + RuntimeCall::StellarRelay(_) | + RuntimeCall::VaultRegistry(_) | + RuntimeCall::PooledVaultRewards(_) | + RuntimeCall::RewardDistribution(_) | RuntimeCall::Farming(_) | RuntimeCall::Proxy(_) => true, // All pallets are allowed, but exhaustive match is defensive @@ -385,7 +473,7 @@ parameter_types! { pub const OperationalFeeMultiplier: u8 = 5; } -type NegativeImbalance = >::NegativeImbalance; +type NegativeImbalance = >::NegativeImbalance; pub struct DealWithFees; impl OnUnbalanced for DealWithFees { @@ -989,6 +1077,183 @@ where } } +pub struct CurrencyConvert; + +impl currency::CurrencyConversion, CurrencyId> for CurrencyConvert { + fn convert( + amount: ¤cy::Amount, + to: CurrencyId, + ) -> Result, DispatchError> { + Oracle::convert(amount, to) + } +} +parameter_types! { + pub const RelayChainCurrencyId: CurrencyId = XCM(0); // 0 is the index of the relay chain in our XCM mapping +} +impl currency::Config for Runtime { + type UnsignedFixedPoint = UnsignedFixedPoint; + type SignedInner = SignedInner; + type SignedFixedPoint = SignedFixedPoint; + type Balance = Balance; + type GetRelayChainCurrencyId = RelayChainCurrencyId; + type AssetConversion = primitives::AssetConversion; + type BalanceConversion = primitives::BalanceConversion; + type CurrencyConversion = CurrencyConvert; + type AmountCompatibility = primitives::StellarCompatibility; +} + +impl security::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = security::SubstrateWeight; +} + +parameter_types! { + pub const MaxRewardCurrencies: u32= 10; +} + +impl staking::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type SignedInner = SignedInner; + type SignedFixedPoint = SignedFixedPoint; + type GetNativeCurrencyId = NativeCurrencyId; + type CurrencyId = CurrencyId; + type MaxRewardCurrencies = MaxRewardCurrencies; +} + +#[cfg(feature = "runtime-benchmarks")] +pub struct DataFeederBenchmark(PhantomData<(K, V, A)>); + +#[cfg(feature = "runtime-benchmarks")] +impl orml_traits::DataFeeder for DataFeederBenchmark { + fn feed_value(_who: A, _key: K, _value: V) -> sp_runtime::DispatchResult { + Ok(()) + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl orml_traits::DataProvider for DataFeederBenchmark { + fn get(_key: &K) -> Option { + None + } +} + +impl oracle::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = oracle::SubstrateWeight; + type DataProvider = DataProviderImpl; + #[cfg(feature = "runtime-benchmarks")] + type DataFeeder = MockDataFeeder; +} + +parameter_types! { + pub const OrganizationLimit: u32 = 255; + pub const ValidatorLimit: u32 = 255; + pub const IsPublicNetwork: bool = true; +} + +impl stellar_relay::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OrganizationId = u128; + type OrganizationLimit = OrganizationLimit; + type ValidatorLimit = ValidatorLimit; + type IsPublicNetwork = IsPublicNetwork; + type WeightInfo = stellar_relay::SubstrateWeight; +} + +parameter_types! { + pub const FeePalletId: PalletId = PalletId(*b"mod/fees"); + pub const VaultRegistryPalletId: PalletId = PalletId(*b"mod/vreg"); + pub const MaxExpectedValue: UnsignedFixedPoint = UnsignedFixedPoint::from_inner(::DIV); + pub FeeAccount: AccountId = FeePalletId::get().into_account_truncating(); +} +impl fee::Config for Runtime { + type FeePalletId = FeePalletId; + type WeightInfo = fee::SubstrateWeight; + type SignedFixedPoint = SignedFixedPoint; + type SignedInner = SignedInner; + type UnsignedFixedPoint = UnsignedFixedPoint; + type UnsignedInner = UnsignedInner; + type VaultRewards = PooledVaultRewards; + type VaultStaking = VaultStaking; + type OnSweep = currency::SweepFunds; + type MaxExpectedValue = MaxExpectedValue; + type RewardDistribution = RewardDistribution; +} + +impl vault_registry::Config for Runtime { + type PalletId = VaultRegistryPalletId; + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type WeightInfo = vault_registry::SubstrateWeight; + type GetGriefingCollateralCurrencyId = NativeCurrencyId; +} + +impl redeem::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = redeem::SubstrateWeight; +} + +pub struct BlockNumberToBalance; + +impl sp_runtime::traits::Convert for BlockNumberToBalance { + fn convert(a: BlockNumber) -> Balance { + a.into() + } +} + +impl issue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type BlockNumberToBalance = BlockNumberToBalance; + type WeightInfo = issue::SubstrateWeight; +} + +impl nomination::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = nomination::SubstrateWeight; +} + +impl replace::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = replace::SubstrateWeight; +} + +impl clients_info::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = clients_info::SubstrateWeight; + type MaxNameLength = ConstU32<255>; + type MaxUriLength = ConstU32<255>; +} +// Choice of parameters: Perquintill::from_parts(36600800000000000u64) represents a value of +// 0.0366008 = 36600800000000000 / 1×10¹⁸ +// The decay interval 216000 equates to a month when considering 1 block every 12 seconds +parameter_types! { + pub const DecayRate: Perquintill = Perquintill::from_parts(36600800000000000); + pub const MaxCurrencies: u32 = 10; +} + +impl reward_distribution::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = reward_distribution::SubstrateWeight; + type Balance = Balance; + type DecayInterval = ConstU32<216_000>; + type DecayRate = DecayRate; + type VaultRewards = PooledVaultRewards; + type MaxCurrencies = MaxCurrencies; + type OracleApi = Oracle; + type Balances = Balances; + type VaultStaking = VaultStaking; + type FeePalletId = FeePalletId; +} + +impl pooled_rewards::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type SignedFixedPoint = SignedFixedPoint; + type PoolId = CurrencyId; + type PoolRewardsCurrencyId = CurrencyId; + type StakeId = VaultId; + type MaxRewardCurrencies = MaxRewardCurrencies; +} + impl InstanceFilter for ProxyType { fn filter(&self, c: &RuntimeCall) -> bool { match self { @@ -1100,17 +1365,32 @@ construct_runtime!( RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage} = 57, DiaOracleModule: dia_oracle::{Pallet, Storage, Call, Event} = 58, - TokenAllowance: orml_currencies_allowance_extension::{Pallet, Storage, Call, Event} = 80, - + // Zenlink ZenlinkProtocol: zenlink_protocol::{Pallet, Call, Storage, Event} = 59, + // Spacewalk pallets + Currency: currency::{Pallet} = 60, + Fee: fee::{Pallet, Call, Config, Storage} = 61, + Issue: issue::{Pallet, Call, Config, Storage, Event} = 62, + Nomination: nomination::{Pallet, Call, Config, Storage, Event} = 63, + Oracle: oracle::{Pallet, Call, Config, Storage, Event} = 64, + Redeem: redeem::{Pallet, Call, Config, Storage, Event} = 65, + Replace: replace::{Pallet, Call, Config, Storage, Event} = 66, + Security: security::{Pallet, Call, Config, Storage, Event} = 67, + StellarRelay: stellar_relay::{Pallet, Call, Config, Storage, Event} = 68, + VaultRegistry: vault_registry::{Pallet, Call, Config, Storage, Event, ValidateUnsigned} = 69, + PooledVaultRewards: pooled_rewards::{Pallet, Call, Storage, Event} = 70, + VaultStaking: staking::{Pallet, Storage, Event} = 71, + ClientsInfo: clients_info::{Pallet, Call, Storage, Event} = 72, + RewardDistribution: reward_distribution::{Pallet, Call, Storage, Event} = 73, + + TokenAllowance: orml_currencies_allowance_extension::{Pallet, Storage, Call, Event} = 80, + //Farming Farming: farming::{Pallet, Call, Storage, Event} = 90, // Asset Metadata AssetRegistry: orml_asset_registry::{Pallet, Storage, Call, Event, Config} = 91, - - VestingManager: vesting_manager::{Pallet, Call, Event} = 100 } ); @@ -1419,6 +1699,98 @@ impl_runtime_apis! { } } + impl module_issue_rpc_runtime_api::IssueApi< + Block, + AccountId, + H256, + IssueRequest + > for Runtime { + fn get_issue_requests(account_id: AccountId) -> Vec { + Issue::get_issue_requests_for_account(account_id) + } + fn get_vault_issue_requests(vault_id: AccountId) -> Vec { + Issue::get_issue_requests_for_vault(vault_id) + } + } + impl module_vault_registry_rpc_runtime_api::VaultRegistryApi< + Block, + VaultId, + Balance, + UnsignedFixedPoint, + CurrencyId, + AccountId, + > for Runtime { + fn get_vault_collateral(vault_id: VaultId) -> Result, DispatchError> { + let result = VaultRegistry::compute_collateral(&vault_id)?; + Ok(BalanceWrapper{amount:result.amount()}) + } + fn get_vaults_by_account_id(account_id: AccountId) -> Result, DispatchError> { + VaultRegistry::get_vaults_by_account_id(account_id) + } + fn get_vault_total_collateral(vault_id: VaultId) -> Result, DispatchError> { + let result = VaultRegistry::get_backing_collateral(&vault_id)?; + Ok(BalanceWrapper{amount:result.amount()}) + } + fn get_premium_redeem_vaults() -> Result)>, DispatchError> { + let result = VaultRegistry::get_premium_redeem_vaults()?; + Ok(result.iter().map(|v| (v.0.clone(), BalanceWrapper{amount:v.1.amount()})).collect()) + } + fn get_vaults_with_issuable_tokens() -> Result)>, DispatchError> { + let result = VaultRegistry::get_vaults_with_issuable_tokens()?; + Ok(result.into_iter().map(|v| (v.0, BalanceWrapper{amount:v.1.amount()})).collect()) + } + fn get_vaults_with_redeemable_tokens() -> Result)>, DispatchError> { + let result = VaultRegistry::get_vaults_with_redeemable_tokens()?; + Ok(result.into_iter().map(|v| (v.0, BalanceWrapper{amount:v.1.amount()})).collect()) + } + fn get_issuable_tokens_from_vault(vault: VaultId) -> Result, DispatchError> { + let result = VaultRegistry::get_issuable_tokens_from_vault(&vault)?; + Ok(BalanceWrapper{amount:result.amount()}) + } + fn get_collateralization_from_vault(vault: VaultId, only_issued: bool) -> Result { + VaultRegistry::get_collateralization_from_vault(vault, only_issued) + } + fn get_collateralization_from_vault_and_collateral(vault: VaultId, collateral: BalanceWrapper, only_issued: bool) -> Result { + let amount = currency::Amount::new(collateral.amount, vault.collateral_currency()); + VaultRegistry::get_collateralization_from_vault_and_collateral(vault, &amount, only_issued) + } + fn get_required_collateral_for_wrapped(amount_wrapped: BalanceWrapper, wrapped_currency_id: CurrencyId, collateral_currency_id: CurrencyId) -> Result, DispatchError> { + let amount_wrapped = currency::Amount::new(amount_wrapped.amount, wrapped_currency_id); + let result = VaultRegistry::get_required_collateral_for_wrapped(&amount_wrapped, collateral_currency_id)?; + Ok(BalanceWrapper{amount:result.amount()}) + } + fn get_required_collateral_for_vault(vault_id: VaultId) -> Result, DispatchError> { + let result = VaultRegistry::get_required_collateral_for_vault(vault_id)?; + Ok(BalanceWrapper{amount:result.amount()}) + } + } + impl module_redeem_rpc_runtime_api::RedeemApi< + Block, + AccountId, + H256, + RedeemRequest + > for Runtime { + fn get_redeem_requests(account_id: AccountId) -> Vec { + Redeem::get_redeem_requests_for_account(account_id) + } + fn get_vault_redeem_requests(vault_account_id: AccountId) -> Vec { + Redeem::get_redeem_requests_for_vault(vault_account_id) + } + } + impl module_replace_rpc_runtime_api::ReplaceApi< + Block, + AccountId, + H256, + ReplaceRequest + > for Runtime { + fn get_old_vault_replace_requests(vault_id: AccountId) -> Vec { + Replace::get_replace_requests_for_old_vault(vault_id) + } + fn get_new_vault_replace_requests(vault_id: AccountId) -> Vec { + Replace::get_replace_requests_for_new_vault(vault_id) + } + } + impl pallet_contracts::ContractsApi for Runtime { @@ -1484,6 +1856,23 @@ impl_runtime_apis! { } } + impl module_oracle_rpc_runtime_api::OracleApi for Runtime { + fn currency_to_usd(amount:BalanceWrapper, currency_id: CurrencyId) -> Result, DispatchError> { + let result = Oracle::currency_to_usd(amount.amount, currency_id)?; + Ok(BalanceWrapper{amount:result}) + } + + fn usd_to_currency(amount:BalanceWrapper, currency_id: CurrencyId) -> Result, DispatchError> { + let result = Oracle::usd_to_currency(amount.amount, currency_id)?; + Ok(BalanceWrapper{amount:result}) + } + + fn get_exchange_rate(currency_id: CurrencyId) -> Result { + let result = Oracle::get_exchange_rate(currency_id)?; + Ok(result) + } + } + } struct CheckInherents; From 28eccfba21dd5a6a1abc593bf2c0e855844b5938 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Fri, 26 Jan 2024 17:02:13 +0100 Subject: [PATCH 06/15] Change BRZ token address (#403) --- runtime/common/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 092e86c28..e42946c29 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -187,11 +187,9 @@ pub mod parachains { pub const ASSET_PALLET_INDEX: u8 = 110; pub const BALANCES_PALLET_INDEX: u8 = 10; - // 0xD65A1872f2E2E26092A443CB86bb5d8572027E6E - // extracted using `H160::from_str("...")` then `as_bytes()` + // The address of the BRZ token on Moonbeam `0x3225edCe8aD30Ae282e62fa32e7418E4b9cf197b` as byte array pub const BRZ_ASSET_ACCOUNT_IN_BYTES: [u8; 20] = [ - 214, 90, 24, 114, 242, 226, 226, 96, 146, 164, 67, 203, 134, 187, 93, 133, 114, 2, - 126, 110, + 50, 37, 237, 206, 138, 211, 10, 226, 130, 230, 47, 163, 46, 116, 24, 228, 185, 207, 25, 123 ]; parachain_asset_location!( From 4ea070519ce59df4bce3d316c8ef2e6533da41b6 Mon Sep 17 00:00:00 2001 From: gianfra-t <96739519+gianfra-t@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:59:29 -0300 Subject: [PATCH 07/15] bump spec version (#405) * bump spec version * bump transaction version * revert bump transaction version --- runtime/pendulum/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 625063a4e..40d53ced3 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -246,7 +246,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("pendulum"), impl_name: create_runtime_str!("pendulum"), authoring_version: 1, - spec_version: 11, + spec_version: 12, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 10, From aab59d93b7a974f5c4fb4967477e0eb3b63d33aa Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Tue, 6 Feb 2024 12:49:18 +0100 Subject: [PATCH 08/15] 406 change native currency identifier in foucoco runtime (#407) * Change `native_chain` identifier in foucoco * Bump `spec_version` to `8` --- runtime/foucoco/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index f48fbef00..8fd869675 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -176,7 +176,7 @@ impl oracle::dia::NativeCurrencyKey for SpacewalkNativeCurrency { } fn native_chain() -> Vec { - "AMPLITUDE".as_bytes().to_vec() + "Amplitude".as_bytes().to_vec() } } @@ -256,7 +256,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("foucoco"), impl_name: create_runtime_str!("foucoco"), authoring_version: 1, - spec_version: 7, + spec_version: 8, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 7, From 97be1d6a18f7286b8db26d56740abf9efaa5196c Mon Sep 17 00:00:00 2001 From: Bogdan Sandu Date: Wed, 7 Feb 2024 17:51:03 +0200 Subject: [PATCH 09/15] 408 fix GitHub workflows failing because they run out of space (#409) * Modify workflow to free up more space * Sudo * Remove sudo * Test workflow * Test workflow --- .github/workflows/test-code.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index e2af28c60..91ed89150 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -15,12 +15,17 @@ jobs: steps: - name: Freeing up more disk space run: | + sudo swapoff -a + sudo rm -f /swapfile + docker rmi $(docker image ls -aq) sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET sudo rm -rf /opt/ghc sudo rm -rf /usr/local/share/boost sudo rm -rf /opt/hostedtoolcache/CodeQL sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo apt clean + df -h - name: Install package run: | From eb45880e002e4750f7e616618ff82db33c9ffc5f Mon Sep 17 00:00:00 2001 From: Bogdan Sandu Date: Tue, 13 Feb 2024 19:45:15 +0200 Subject: [PATCH 10/15] Implement pallet that extends our current treasury pallet with buyout feature (#396) * WIP * Fmt * Add comment * Still wip * Fmt * Add doc comments * Address change requests * Fmt * Add comment * Add fee for basic asset * Fmt * Return NoPrice error when price fetching fails * Add signed extension * Add first iteration of mock * Allow only XCM assets for buyout * Update mock to only allow specific XCM assets * Add tests and benchmarks - still wip * Fmt * Handle currency id in benchmarks * Update comments * Remove benchmark comment * Fix benchmarks and tests, add pallet to Foucoco, switch from UnixTime to blocks, generate weights * Fmt * Refactor dot currency id in tests * Small refactor for test attempt_buyout_after_buyout_limit_exceeded_fails * Update comments * Small refactor * Add comment in Foucoco runtime * Add comment in Foucoco runtime * Update comment * Update comment * Add signed extension to runtime * Add comment * Fix indentation in tests * Fix indentation in tests * Fix indentation in tests * Fix indentation in tests * Update comment Co-authored-by: Marcel Ebert * Fix building project with runtime benchmarks flag * Address change requests * Small refactor for asset registry benchmarks * Fix compiler warning * Address change requests * Update comment Co-authored-by: Marcel Ebert * Optimise fetching oracle price for benchmarks and regenerate weights * Fmt * Add change requests + fmt * Add try-runtime feature * Update Github workflow * Update Github workflow * Update Github workflow * Add extrinsic and storage item for updating allowed assets for buyout * Fmt * Refactor update_allowed_assets extrinsic, tests * Fmt * Address request for change * Fmt * Move comment * Address comments + regenerate weights * Fmt * Update extrinsic weight --------- Co-authored-by: Marcel Ebert --- .github/workflows/test-code.yml | 14 +- Cargo.lock | 89 ++- Cargo.toml | 1 + pallets/treasury-buyout-extension/Cargo.toml | 70 ++ .../src/benchmarking.rs | 74 ++ .../src/default_weights.rs | 151 ++++ pallets/treasury-buyout-extension/src/lib.rs | 621 +++++++++++++++++ pallets/treasury-buyout-extension/src/mock.rs | 242 +++++++ .../treasury-buyout-extension/src/tests.rs | 653 ++++++++++++++++++ .../treasury-buyout-extension/src/types.rs | 26 + runtime/amplitude/src/lib.rs | 5 +- runtime/common/src/asset_registry.rs | 24 +- .../src/benchmarking/orml_asset_registry.rs | 20 +- runtime/foucoco/Cargo.toml | 9 +- runtime/foucoco/src/lib.rs | 121 +++- runtime/pendulum/src/lib.rs | 5 +- 16 files changed, 2065 insertions(+), 60 deletions(-) create mode 100644 pallets/treasury-buyout-extension/Cargo.toml create mode 100644 pallets/treasury-buyout-extension/src/benchmarking.rs create mode 100644 pallets/treasury-buyout-extension/src/default_weights.rs create mode 100644 pallets/treasury-buyout-extension/src/lib.rs create mode 100644 pallets/treasury-buyout-extension/src/mock.rs create mode 100644 pallets/treasury-buyout-extension/src/tests.rs create mode 100644 pallets/treasury-buyout-extension/src/types.rs diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 91ed89150..a609c3c14 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -16,15 +16,23 @@ jobs: - name: Freeing up more disk space run: | sudo swapoff -a - sudo rm -f /swapfile + sudo rm -f /mnt/swapfile + free -h docker rmi $(docker image ls -aq) sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET sudo rm -rf /opt/ghc sudo rm -rf /usr/local/share/boost - sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo rm -rf /opt/hostedtoolcache sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo apt clean + sudo apt-get remove -y 'php.*' --fix-missing + sudo apt-get remove -y '^mongodb-.*' --fix-missing + sudo apt-get remove -y '^mysql-.*' --fix-missing + sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing + sudo apt-get remove -y google-cloud-sdk --fix-missing + sudo apt-get remove -y google-cloud-cli --fix-missing + sudo apt-get autoremove -y + sudo apt-get clean df -h - name: Install package diff --git a/Cargo.lock b/Cargo.lock index c829b2038..c485ba09b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", "stellar-relay", "substrate-wasm-builder", @@ -2080,7 +2080,7 @@ dependencies = [ "serde", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -2873,7 +2873,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", ] @@ -3008,6 +3008,7 @@ version = "0.1.0" dependencies = [ "bifrost-farming", "bifrost-farming-rpc-runtime-api", + "cfg-if", "clients-info", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -3099,10 +3100,11 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", "stellar-relay", "substrate-wasm-builder", + "treasury-buyout-extension", "vault-registry", "xcm", "xcm-builder", @@ -4186,7 +4188,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "stellar-relay", "vault-registry", ] @@ -5470,7 +5472,7 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-runtime", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -5483,7 +5485,7 @@ dependencies = [ "serde", "sp-api", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -5876,7 +5878,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", "vault-registry", ] @@ -6043,7 +6045,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "spin 0.9.8", "staking", ] @@ -6201,7 +6203,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -7747,7 +7749,7 @@ dependencies = [ "sp-session", "sp-timestamp", "sp-transaction-pool", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", @@ -7853,7 +7855,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", "stellar-relay", "substrate-wasm-builder", @@ -9203,7 +9205,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -9657,7 +9659,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "stellar-relay", "vault-registry", ] @@ -9821,7 +9823,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "stellar-relay", "vault-registry", ] @@ -9852,7 +9854,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -9880,7 +9882,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", ] @@ -10099,7 +10101,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "xcm", "xcm-executor", "zenlink-protocol", @@ -10144,7 +10146,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-tracing", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "statemine-runtime", "statemint-runtime", "xcm", @@ -12667,6 +12669,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "spacewalk-primitives" +version = "1.0.0" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=d05b0015d15ca39cc780889bcc095335e9862a36#d05b0015d15ca39cc780889bcc095335e9862a36" +dependencies = [ + "base58", + "bstringify", + "frame-support", + "hex", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", + "substrate-stellar-sdk", +] + [[package]] name = "spacewalk-primitives" version = "1.0.3" @@ -12749,7 +12769,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -12953,7 +12973,7 @@ dependencies = [ "sha2 0.10.7", "sp-core", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", ] [[package]] @@ -13641,6 +13661,31 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "treasury-buyout-extension" +version = "1.0.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "mocktopus", + "orml-currencies", + "orml-tokens", + "orml-traits", + "pallet-balances", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "serde", + "sha2 0.8.2", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "spacewalk-primitives 1.0.0", +] + [[package]] name = "trie-db" version = "0.27.1" @@ -13946,7 +13991,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives", + "spacewalk-primitives 1.0.3", "staking", ] diff --git a/Cargo.toml b/Cargo.toml index 5900a4897..b8bf0bac1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "pallets/vesting-manager", "pallets/orml-currencies-allowance-extension", "pallets/orml-tokens-management-extension", + "pallets/treasury-buyout-extension", "runtime/common", "runtime/amplitude", "runtime/foucoco", diff --git a/pallets/treasury-buyout-extension/Cargo.toml b/pallets/treasury-buyout-extension/Cargo.toml new file mode 100644 index 000000000..d377f6c9a --- /dev/null +++ b/pallets/treasury-buyout-extension/Cargo.toml @@ -0,0 +1,70 @@ +[package] +authors = ["Pendulum Chain"] +edition = "2021" +name = "treasury-buyout-extension" +version = "1.0.0" + +[dependencies] +codec = {package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"]} +scale-info = {version = "2.2.0", default-features = false, features = ["derive"]} +serde = {version = "1.0.130", default-features = false, features = ["derive"], optional = true} +sha2 = {version = "0.8.2", default-features = false} + +# Substrate dependencies +frame-support = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +frame-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +sp-core = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +sp-runtime = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +sp-arithmetic = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} + +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false, optional = true } + +orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40", default-features = false } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40", default-features = false } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40", default-features = false } + +[dev-dependencies] +mocktopus = "0.8.0" +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-io = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} + +pallet-balances = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} + +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "d05b0015d15ca39cc780889bcc095335e9862a36"} + +[features] +default = ["std"] +std = [ + "serde", + "codec/std", + "sha2/std", + "sp-core/std", + "sp-std/std", + "sp-arithmetic/std", + "sp-runtime/std", + "frame-support/std", + "frame-system/std", + "orml-currencies/std", + "orml-tokens/std", + "orml-traits/std", + "frame-benchmarking/std", + "pallet-balances/std", + "spacewalk-primitives/std" +] + +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks" +] + +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "orml-currencies/try-runtime", + "orml-tokens/try-runtime", + "pallet-balances/try-runtime" +] \ No newline at end of file diff --git a/pallets/treasury-buyout-extension/src/benchmarking.rs b/pallets/treasury-buyout-extension/src/benchmarking.rs new file mode 100644 index 000000000..49a4f221c --- /dev/null +++ b/pallets/treasury-buyout-extension/src/benchmarking.rs @@ -0,0 +1,74 @@ +#![allow(warnings)] +#![cfg(feature = "runtime-benchmarks")] + +use super::{Pallet as TreasuryBuyoutExtension, *}; +use crate::types::{AccountIdOf, BalanceOf, CurrencyIdOf}; +use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, Vec}; +use frame_support::assert_ok; +use frame_system::RawOrigin; +use sp_std::prelude::*; + +// Mint some tokens to caller and treasury accounts +fn set_up_accounts(caller_account: &AccountIdOf, treasury_account: &AccountIdOf) { + let token_currency_id = T::RelayChainCurrencyId::get(); + let native_currency_id = ::GetNativeCurrencyId::get(); + + let amount: BalanceOf = 1_000_000_000_000_000u128.try_into().unwrap_or_default(); + + assert_ok!(<::Currency as MultiCurrency::>>::deposit( + token_currency_id, + &caller_account, + amount + )); + + assert_ok!(<::Currency as MultiCurrency::>>::deposit( + native_currency_id, + &treasury_account, + amount + )); +} + +benchmarks! { + buyout { + let token_currency_id = T::RelayChainCurrencyId::get(); + let native_currency_id = ::GetNativeCurrencyId::get(); + let caller_account = account("Caller", 0, 0); + let treasury_account = ::TreasuryAccount::get(); + set_up_accounts::(&caller_account, &treasury_account); + let origin = RawOrigin::Signed(caller_account.clone()); + let limit: BalanceOf = 100_000_000_000_000u128.try_into().unwrap_or_default(); + // Add token to allowed currencies for buyout + AllowedCurrencies::::insert(token_currency_id, ()); + BuyoutLimit::::put(limit); + // Set previous buyout limit to 0 + Buyouts::::insert(caller_account.clone(), (BalanceOf::::default(), 0)); + + }: buyout(origin, token_currency_id, Amount::Buyout(100_000_000_000_000u128.try_into().unwrap_or_default())) + verify{ + assert_eq!( + as MultiCurrency::>>::free_balance(native_currency_id, &caller_account), + 100_000_000_000_000u128.try_into().unwrap_or_default() + ); + } + + update_buyout_limit { + }: update_buyout_limit(RawOrigin::Root, Some(100_000_000_000_000u128.try_into().unwrap_or_default())) + + update_allowed_assets { + // This has to come first. Ranges are inclusive on both sides so we start from 1, see + // [here](https://tidelabs.github.io/tidechain/frame_benchmarking/v1/macro.benchmarks.html) + let n in 1..T::MaxAllowedBuyoutCurrencies::get(); + + let token_currency_id = T::RelayChainCurrencyId::get(); + + // It does not really matter that it's the same currency as the loop of the extrinsic + // will iterate over it the same amount of times. + let allowed_currencies = vec![token_currency_id; n as usize]; + }: update_allowed_assets(RawOrigin::Root, allowed_currencies) +} + +impl_benchmark_test_suite!( + TreasuryBuyoutExtension, + crate::mock::ExtBuilder::build(), + crate::mock::Test +); diff --git a/pallets/treasury-buyout-extension/src/default_weights.rs b/pallets/treasury-buyout-extension/src/default_weights.rs new file mode 100644 index 000000000..cfddf0368 --- /dev/null +++ b/pallets/treasury-buyout-extension/src/default_weights.rs @@ -0,0 +1,151 @@ + +//! Autogenerated weights for treasury_buyout_extension +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-02-13, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Bogdans-M2-MacBook-Pro.local`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("foucoco"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/pendulum-node +// benchmark +// pallet +// --chain +// foucoco +// --execution=wasm +// --wasm-execution=compiled +// --pallet +// treasury-buyout-extension +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --output +// pallets/treasury-buyout-extension/src/default_weights.rs +// --template +// .maintain/frame-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weight functions needed for treasury_buyout_extension. +pub trait WeightInfo { + fn buyout() -> Weight; + fn update_buyout_limit() -> Weight; + fn update_allowed_assets(n: u32, ) -> Weight; +} + +/// Weights for treasury_buyout_extension using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: TreasuryBuyoutExtension AllowedCurrencies (r:1 w:0) + /// Proof: TreasuryBuyoutExtension AllowedCurrencies (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen) + /// Storage: TreasuryBuyoutExtension BuyoutLimit (r:1 w:0) + /// Proof: TreasuryBuyoutExtension BuyoutLimit (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TreasuryBuyoutExtension Buyouts (r:1 w:1) + /// Proof: TreasuryBuyoutExtension Buyouts (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(150), added: 2625, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Security ParachainStatus (r:0 w:1) + /// Proof Skipped: Security ParachainStatus (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Oracle OracleKeys (r:1 w:1) + /// Proof Skipped: Oracle OracleKeys (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + fn buyout() -> Weight { + // Proof Size summary in bytes: + // Measured: `863` + // Estimated: `26038` + // Minimum execution time: 81_000_000 picoseconds. + Weight::from_parts(83_000_000, 26038) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: TreasuryBuyoutExtension BuyoutLimit (r:0 w:1) + /// Proof: TreasuryBuyoutExtension BuyoutLimit (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn update_buyout_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: TreasuryBuyoutExtension AllowedCurrencies (r:1 w:1) + /// Proof: TreasuryBuyoutExtension AllowedCurrencies (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 20]`. + fn update_allowed_assets(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `3527` + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(15_935_593, 3527) + // Standard Error: 3_669 + .saturating_add(Weight::from_parts(1_123_793, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: TreasuryBuyoutExtension AllowedCurrencies (r:1 w:0) + /// Proof: TreasuryBuyoutExtension AllowedCurrencies (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen) + /// Storage: TreasuryBuyoutExtension BuyoutLimit (r:1 w:0) + /// Proof: TreasuryBuyoutExtension BuyoutLimit (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TreasuryBuyoutExtension Buyouts (r:1 w:1) + /// Proof: TreasuryBuyoutExtension Buyouts (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(150), added: 2625, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Security ParachainStatus (r:0 w:1) + /// Proof Skipped: Security ParachainStatus (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Oracle OracleKeys (r:1 w:1) + /// Proof Skipped: Oracle OracleKeys (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + fn buyout() -> Weight { + // Proof Size summary in bytes: + // Measured: `863` + // Estimated: `26038` + // Minimum execution time: 81_000_000 picoseconds. + Weight::from_parts(83_000_000, 26038) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: TreasuryBuyoutExtension BuyoutLimit (r:0 w:1) + /// Proof: TreasuryBuyoutExtension BuyoutLimit (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn update_buyout_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(8_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: TreasuryBuyoutExtension AllowedCurrencies (r:1 w:1) + /// Proof: TreasuryBuyoutExtension AllowedCurrencies (max_values: None, max_size: Some(62), added: 2537, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 20]`. + fn update_allowed_assets(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `3527` + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(15_935_593, 3527) + // Standard Error: 3_669 + .saturating_add(Weight::from_parts(1_123_793, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} \ No newline at end of file diff --git a/pallets/treasury-buyout-extension/src/lib.rs b/pallets/treasury-buyout-extension/src/lib.rs new file mode 100644 index 000000000..1e76cc700 --- /dev/null +++ b/pallets/treasury-buyout-extension/src/lib.rs @@ -0,0 +1,621 @@ +#![deny(warnings)] +#![cfg_attr(test, feature(proc_macro_hygiene))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +#[cfg(test)] +mod mock; + +pub mod default_weights; + +#[cfg(test)] +mod tests; + +mod types; + +use crate::{ + default_weights::WeightInfo, + types::{AccountIdOf, Amount, BalanceOf, CurrencyIdOf}, +}; +use codec::{Decode, Encode}; +use frame_support::{ + dispatch::{DispatchError, DispatchResult}, + ensure, + sp_runtime::SaturatedConversion, + traits::{Get, IsSubType}, + transactional, +}; +use orml_traits::MultiCurrency; +pub use pallet::*; +use sp_arithmetic::{ + per_things::Rounding, + traits::{CheckedAdd, Saturating}, +}; +use sp_runtime::{ + traits::{DispatchInfoOf, One, SignedExtension, Zero}, + transaction_validity::{ + InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, + }, + ArithmeticError, FixedPointNumber, FixedU128, +}; +use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; + +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::{pallet_prelude::*, sp_runtime::Permill}; + use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; + + #[pallet::config] + pub trait Config: frame_system::Config + orml_currencies::Config { + /// The overarching event type. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + /// Used for currency-related operations + type Currency: MultiCurrency, CurrencyId = CurrencyIdOf>; + + /// Used for getting the treasury account + #[pallet::constant] + type TreasuryAccount: Get>; + + /// Buyout period in blocks in which a caller can buyout up to the amount limit stored in `BuyoutLimit` + /// When attempting to buyout after this period, the buyout limit is reset for the caller + #[pallet::constant] + type BuyoutPeriod: Get; + + /// Fee from the native asset buyouts + #[pallet::constant] + type SellFee: Get; + + /// Used for fetching prices of currencies from oracle + type PriceGetter: PriceGetter>; + + /// Min amount of native token to buyout + #[pallet::constant] + type MinAmountToBuyout: Get>; + + /// Maximum number of allowed currencies for buyout + #[pallet::constant] + type MaxAllowedBuyoutCurrencies: Get; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + + /// Currency id of the relay chain, only used in benchmarks + #[cfg(feature = "runtime-benchmarks")] + type RelayChainCurrencyId: Get>; + } + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::error] + pub enum Error { + /// Storage clearing of `AllowedCurrencies` failed + StorageClearingFailure, + /// Attempt to add native token to allowed assets + NativeTokenNotAllowed, + /// Exceeds number of allowed currencies for buyout + ExceedsNumberOfAllowedCurrencies, + /// Attempt to exchange native token to native token + WrongAssetToBuyout, + /// Buyout limit exceeded for the current period + BuyoutLimitExceeded, + /// One of transacted currencies is missing price information + NoPrice, + /// The treasury balance is too low for an operation + InsufficientTreasuryBalance, + /// The account balance is too low for an operation + InsufficientAccountBalance, + /// Less than minimum amoount allowed for buyout + LessThanMinBuyoutAmount, + /// Attempt to use treasury account for buyout + BuyoutWithTreasuryAccount, + /// Exchange failed + ExchangeFailure, + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Buyout event + Buyout { + who: AccountIdOf, + buyout_amount: BalanceOf, + asset: CurrencyIdOf, + exchange_amount: BalanceOf, + }, + /// Buyout limit updated event + BuyoutLimitUpdated { limit: Option> }, + + /// Updated allowed assets for buyout event + AllowedAssetsForBuyoutUpdated { allowed_assets: Vec> }, + } + + /// Stores buyout limit amount user could buy for a period of `BuyoutPeriod` blocks. + /// Each user can buyout up to this amount in a period. After each period passes, buyout limit is reset + /// When `None` - buyouts are not limited + #[pallet::storage] + pub type BuyoutLimit = StorageValue<_, BalanceOf, OptionQuery>; + + /// Stores amount of buyouts (amount, block number of last buyout) + #[pallet::storage] + pub type Buyouts = + StorageMap<_, Blake2_128Concat, AccountIdOf, (BalanceOf, u32), ValueQuery>; + + /// Stores allowed currencies for buyout + #[pallet::storage] + pub(super) type AllowedCurrencies = + StorageMap<_, Blake2_128Concat, CurrencyIdOf, (), OptionQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub allowed_currencies: Vec>, + } + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self { allowed_currencies: vec![] } + } + } + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + for i in &self.allowed_currencies.clone() { + AllowedCurrencies::::insert(i, ()); + } + } + } + + #[pallet::call] + impl Pallet { + /// Allows caller to buyout a given amount of native token. + /// When denoting the `amount` as `Buyout` the caller will receive this exact amount of the native token in exchange for a corresponding amount of an allowed asset. + /// When denoting the `amount` as `Exchange`, the caller will spend this exact amount of an allowed asset in exchange for a corresponding amount of the native token. + /// + /// Parameters + /// + /// - `origin`: Caller's origin. + /// - `asset`: Exchange asset used for buyout of basic asset. + /// - `amount`: Amount of basic asset to buyout or amount of asset to exchange. + /// + /// Emits `Buyout` event when successful. + #[pallet::call_index(0)] + #[pallet::weight((::WeightInfo::buyout(), Pays::No))] + pub fn buyout( + origin: OriginFor, + asset: CurrencyIdOf, + amount: Amount>, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + Self::do_buyout(who, asset, amount)?; + Ok(().into()) + } + + /// Allows root to update the buyout limit. + /// + /// Parameters + /// + /// - `origin`: Origin must be root. + /// - `limit`: New buyout limit. If None, then buyouts are not limited. + /// + /// Emits `BuyoutLimitUpdated` event when successful. + #[pallet::call_index(1)] + #[pallet::weight(::WeightInfo::update_buyout_limit())] + pub fn update_buyout_limit( + origin: OriginFor, + limit: Option>, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + match limit { + Some(limit) => BuyoutLimit::::put(limit), + None => BuyoutLimit::::kill(), + } + Self::deposit_event(Event::::BuyoutLimitUpdated { limit }); + Ok(().into()) + } + + /// Allows root to update the allowed currencies for buyout. + /// `AllowedCurrencies` storage will be reset and updated with provided `assets`. + /// + /// Parameters + /// + /// - `origin`: Origin must be root. + /// - `assets`: List of assets to be inserted into `AllowedCurrencies` storage. + /// + /// Emits `AllowedAssetsForBuyoutUpdated` event when successful. + #[pallet::call_index(2)] + #[pallet::weight(::WeightInfo::update_allowed_assets(T::MaxAllowedBuyoutCurrencies::get()))] + #[transactional] + pub fn update_allowed_assets( + origin: OriginFor, + assets: Vec>, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + + // Ensure number of currencies doesn't exceed the maximum allowed + let max_allowed_currencies_for_buyout = T::MaxAllowedBuyoutCurrencies::get(); + ensure!( + assets.len() <= max_allowed_currencies_for_buyout as usize, + Error::::ExceedsNumberOfAllowedCurrencies + ); + + // Ensure that native token is not allowed for buyout + let basic_asset = ::GetNativeCurrencyId::get(); + ensure!( + !assets.iter().any(|asset| *asset == basic_asset), + Error::::NativeTokenNotAllowed + ); + + // Clear `AllowedCurrencies` storage + // `AllowedCurrencies` should have at most `max_allowed_currencies_for_buyout` entries + let result = AllowedCurrencies::::clear(max_allowed_currencies_for_buyout, None); + // If storage clearing returns cursor which is `Some`, then clearing was not entirely successful + ensure!(result.maybe_cursor.is_none(), Error::::StorageClearingFailure); + + // Used for event data + let mut allowed_assets = Vec::new(); + + // Update `AllowedCurrencies` storage with provided `assets` + for asset in assets.clone() { + // Check for duplicates + if !AllowedCurrencies::::contains_key(&asset) { + AllowedCurrencies::::insert(asset, ()); + allowed_assets.push(asset); + } + } + + Self::deposit_event(Event::::AllowedAssetsForBuyoutUpdated { allowed_assets }); + Ok(().into()) + } + } +} + +impl Pallet { + /// Ensures that buyout limit is not exceeded for the current buyout period + fn ensure_buyout_limit_not_exceeded( + account_id: &AccountIdOf, + buyout_amount: BalanceOf, + ) -> DispatchResult { + if let Some(buyout_limit) = BuyoutLimit::::get() { + let buyout_period = T::BuyoutPeriod::get(); + // Get current block number + let current_block_number = + >::block_number().saturated_into::(); + let current_period_start_number = current_block_number + .checked_div(buyout_period) + .and_then(|n| Some(n.saturating_mul(buyout_period))) + .unwrap_or_default(); + let (mut buyouts, last_buyout) = Buyouts::::get(account_id); + + // Check if caller's last buyout was in the previous period + // If true, reset buyout amount limit for the caller since this is the first buyout in the current period + if !buyouts.is_zero() && last_buyout < current_period_start_number { + buyouts = Default::default(); + Buyouts::::insert(account_id, (buyouts, current_block_number)); + }; + + ensure!( + buyouts.saturating_add(buyout_amount) <= buyout_limit, + Error::::BuyoutLimitExceeded + ); + } + + Ok(()) + } + + /// Ensures that asset is allowed for buyout + fn ensure_asset_allowed_for_buyout(asset: &CurrencyIdOf) -> DispatchResult { + ensure!(AllowedCurrencies::::get(asset) == Some(()), Error::::WrongAssetToBuyout); + + Ok(()) + } + + /// Updates buyouts storage for the account + fn update_buyouts(account_id: &AccountIdOf, buyout_amount: BalanceOf) { + if BuyoutLimit::::get().is_some() { + Buyouts::::mutate(account_id, |(prev_buyouts, last)| { + *prev_buyouts = prev_buyouts.saturating_add(buyout_amount); + *last = >::block_number().saturated_into::(); + }); + } + } + + /// Used for calculating amount of exchange asset user will get for buyout_amount of basic asset + fn calc_amount_to_exchange( + asset: CurrencyIdOf, + buyout_amount: BalanceOf, + ) -> Result, DispatchError> { + let basic_asset = ::GetNativeCurrencyId::get(); + ensure!(asset != basic_asset, Error::::WrongAssetToBuyout); + + let (basic_asset_price, exchange_asset_price) = Self::fetch_prices((&basic_asset, &asset))?; + + // Add fee to the basic asset price + let fee_plus_one = FixedU128::from(T::SellFee::get()) + .checked_add(&FixedU128::one()) + .ok_or::(ArithmeticError::Overflow.into())?; + let basic_asset_price_with_fee = basic_asset_price.saturating_mul(fee_plus_one); + + let exchange_amount = Self::multiply_by_rational( + buyout_amount.saturated_into::(), + basic_asset_price_with_fee.into_inner(), + exchange_asset_price.into_inner(), + ) + .map(|n| n.try_into().ok()) + .flatten() + .ok_or(ArithmeticError::Overflow.into()); + + exchange_amount + } + + /// Used for calculating buyout amount of basic asset user will get for exchange_amount of exchange asset + fn calc_buyout_amount( + asset: CurrencyIdOf, + exchange_amount: BalanceOf, + ) -> Result, DispatchError> { + let basic_asset = ::GetNativeCurrencyId::get(); + + ensure!(asset != basic_asset, Error::::WrongAssetToBuyout); + + let (basic_asset_price, exchange_asset_price) = Self::fetch_prices((&basic_asset, &asset))?; + + // Add fee to the basic asset price + let fee_plus_one = FixedU128::from(T::SellFee::get()) + .checked_add(&FixedU128::one()) + .ok_or::(ArithmeticError::Overflow.into())?; + let basic_asset_price_with_fee = basic_asset_price.saturating_mul(fee_plus_one); + + let buyout_amount = Self::multiply_by_rational( + exchange_amount.saturated_into::(), + exchange_asset_price.into_inner(), + basic_asset_price_with_fee.into_inner(), + ) + .map(|b| b.try_into().ok()) + .flatten() + .ok_or(ArithmeticError::Overflow.into()); + + buyout_amount + } + + /// Used for splitting calculations of amount based on the input given + /// If user's call contains buyout amount, then exchange amount is calculated and viceversa + fn split_to_buyout_and_exchange( + asset: CurrencyIdOf, + amount: Amount>, + ) -> Result<(BalanceOf, BalanceOf), DispatchError> { + match amount { + Amount::Buyout(buyout_amount) => { + let exchange_amount = Self::calc_amount_to_exchange(asset, buyout_amount)?; + Ok((buyout_amount, exchange_amount)) + }, + Amount::Exchange(exchange_amount) => { + let buyout_amount = Self::calc_buyout_amount(asset, exchange_amount)?; + Ok((buyout_amount, exchange_amount)) + }, + } + } + + fn do_buyout( + who: AccountIdOf, + asset: CurrencyIdOf, + amount: Amount>, + ) -> DispatchResult { + Self::ensure_asset_allowed_for_buyout(&asset)?; + + let basic_asset = ::GetNativeCurrencyId::get(); + let (buyout_amount, exchange_amount) = Self::split_to_buyout_and_exchange(asset, amount)?; + + Self::ensure_buyout_limit_not_exceeded(&who, buyout_amount)?; + let treasury_account_id = T::TreasuryAccount::get(); + + // Start exchanging + // Check for same accounts + if who == treasury_account_id { + return Err(Error::::BuyoutWithTreasuryAccount.into()) + } + // Check for exchanging zero values + if exchange_amount.is_zero() && buyout_amount.is_zero() { + return Err(Error::::LessThanMinBuyoutAmount.into()) + } + + // Check both balances before transfer + let user_balance = T::Currency::free_balance(asset, &who); + let treasury_balance = T::Currency::free_balance(basic_asset, &treasury_account_id); + + if user_balance < exchange_amount { + return Err(Error::::InsufficientAccountBalance.into()) + } + if treasury_balance < buyout_amount { + return Err(Error::::InsufficientTreasuryBalance.into()) + } + + // Transfer from user account to treasury then viceversa + T::Currency::transfer(asset, &who, &treasury_account_id, exchange_amount) + .map_err(|_| Error::::ExchangeFailure)?; + T::Currency::transfer(basic_asset, &treasury_account_id, &who, buyout_amount) + .map_err(|_| Error::::ExchangeFailure)?; + + Self::update_buyouts(&who, buyout_amount); + Self::deposit_event(Event::::Buyout { who, buyout_amount, asset, exchange_amount }); + + Ok(()) + } + + /// Used for calculating exchange amount based on buyout amount(a), price of basic asset with fee(b) and price of exchange asset(c) + /// or buyout amount based on exchange amount(a), price of exchange asset(b) and price of basic asset with fee(c) + fn multiply_by_rational( + a: impl Into, + b: impl Into, + c: impl Into, + ) -> Option { + // return a * b / c + sp_runtime::helpers_128bit::multiply_by_rational_with_rounding( + a.into(), + b.into(), + c.into(), + Rounding::NearestPrefDown, + ) + } + + /// Used for fetching asset prices + /// The concrete implementation of PriceGetter trait must be provided by the runtime e.g. oracle pallet + fn fetch_prices( + assets: (&CurrencyIdOf, &CurrencyIdOf), + ) -> Result<(FixedU128, FixedU128), DispatchError> { + let basic_asset_price: FixedU128 = T::PriceGetter::get_price::(*assets.0) + .map_err(|_| Error::::NoPrice)? + .into(); + let exchange_asset_price: FixedU128 = T::PriceGetter::get_price::(*assets.1) + .map_err(|_| Error::::NoPrice)? + .into(); + Ok((basic_asset_price, exchange_asset_price)) + } +} + +/// Used for fetching prices of assets +/// This trait must be implemented by the runtime e.g. oracle pallet +pub trait PriceGetter +where + CurrencyId: Clone + PartialEq + Eq + Debug, +{ + /// Gets a current price for a given currency + fn get_price>( + currency_id: CurrencyId, + ) -> Result; +} + +/// Buyout validity errors +#[repr(u8)] +pub enum ValidityError { + /// Account balance is too low to make buyout + NotEnoughToBuyout = 0, + /// Math error + Math = 1, + /// Buyout limit exceeded + BuyoutLimitExceeded = 2, + /// Amount to buyout less than min amount + LessThanMinBuyoutAmount = 3, + /// Wrong asset + WrongAssetToBuyout = 4, +} + +impl From for u8 { + fn from(err: ValidityError) -> Self { + err as u8 + } +} + +#[derive(Encode, Decode, Clone, Eq, PartialEq, scale_info::TypeInfo)] +pub struct CheckBuyout(PhantomData) +where + ::RuntimeCall: IsSubType>; + +impl Debug for CheckBuyout +where + ::RuntimeCall: IsSubType>, +{ + #[cfg(feature = "std")] + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + write!(f, "CheckBuyout") + } + + #[cfg(not(feature = "std"))] + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + Ok(()) + } +} + +impl Default for CheckBuyout +where + ::RuntimeCall: IsSubType>, +{ + fn default() -> Self { + Self(PhantomData) + } +} + +impl CheckBuyout +where + ::RuntimeCall: IsSubType>, +{ + pub fn new() -> Self { + Self(PhantomData) + } +} + +impl SignedExtension for CheckBuyout +where + ::RuntimeCall: IsSubType>, +{ + const IDENTIFIER: &'static str = "CheckBuyout"; + type AccountId = AccountIdOf; + type Call = T::RuntimeCall; + type AdditionalSigned = (); + type Pre = (); + + fn additional_signed(&self) -> Result { + Ok(()) + } + + fn pre_dispatch( + self, + who: &Self::AccountId, + call: &Self::Call, + info: &DispatchInfoOf, + len: usize, + ) -> Result { + self.validate(who, call, info, len) + .map(|_| Self::Pre::default()) + .map_err(Into::into) + } + + /// Checks: + /// - asset is allowed for buyout + /// - buyout amount is greater or equal `MinAmountToBuyout` + /// - `who` has enough balance to make buyout + /// - buyout limit is not exceeded for `who` + fn validate( + &self, + who: &Self::AccountId, + call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, + ) -> TransactionValidity { + if let Some(local_call) = call.is_sub_type() { + if let Call::buyout { asset, amount } = local_call { + Pallet::::ensure_asset_allowed_for_buyout(asset).map_err(|_| { + InvalidTransaction::Custom(ValidityError::WrongAssetToBuyout.into()) + })?; + + let (buyout_amount, exchange_amount) = + Pallet::::split_to_buyout_and_exchange(*asset, *amount) + .map_err(|_| InvalidTransaction::Custom(ValidityError::Math.into()))?; + + ensure!( + buyout_amount >= T::MinAmountToBuyout::get(), + InvalidTransaction::Custom(ValidityError::LessThanMinBuyoutAmount.into()) + ); + + let free_balance = T::Currency::free_balance(*asset, who); + + ensure!( + free_balance >= exchange_amount, + InvalidTransaction::Custom(ValidityError::NotEnoughToBuyout.into()) + ); + + Pallet::::ensure_buyout_limit_not_exceeded(who, buyout_amount).map_err( + |_| InvalidTransaction::Custom(ValidityError::BuyoutLimitExceeded.into()), + )?; + } + } + + Ok(ValidTransaction::default()) + } +} diff --git a/pallets/treasury-buyout-extension/src/mock.rs b/pallets/treasury-buyout-extension/src/mock.rs new file mode 100644 index 000000000..5b2cadba0 --- /dev/null +++ b/pallets/treasury-buyout-extension/src/mock.rs @@ -0,0 +1,242 @@ +use crate::{ + self as treasury_buyout_extension, default_weights::SubstrateWeight, Config, PriceGetter, +}; +use frame_support::{ + pallet_prelude::GenesisBuild, + parameter_types, + traits::{ConstU32, Everything}, +}; +use orml_currencies::BasicCurrencyAdapter; +use orml_traits::parameter_type_with_key; +use sp_arithmetic::{FixedPointNumber, FixedU128, Permill}; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup, One, Zero}, + DispatchError, +}; +use sp_std::fmt::Debug; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +pub const UNIT: Balance = 1_000_000_000_000; + +// Configure a mock runtime to test the pallet. +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Tokens: orml_tokens::{Pallet, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Event}, + Currencies: orml_currencies::{Pallet, Call}, + TreasuryBuyoutExtension: treasury_buyout_extension::{Pallet, Storage, Call, Event}, + } +); + +pub type AccountId = u64; +pub type Balance = u128; +pub type BlockNumber = u64; +pub type Index = u64; +pub type Amount = i64; +pub type CurrencyId = u64; + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const SS58Prefix: u8 = 42; +} +impl frame_system::Config for Test { + type BaseCallFilter = Everything; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type Index = Index; + type BlockNumber = BlockNumber; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = TestEvent; + type BlockHashCount = BlockHashCount; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = SS58Prefix; + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +pub type TestEvent = RuntimeEvent; + +parameter_types! { + pub const MaxLocks: u32 = 50; + pub const GetNativeCurrencyId: CurrencyId = u64::MAX; + pub const RelayChainCurrencyId: CurrencyId = 0u64; +} + +parameter_type_with_key! { + pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance { + 0 + }; +} + +pub struct CurrencyHooks(sp_std::marker::PhantomData); +impl + orml_traits::currency::MutationHooks for CurrencyHooks +{ + type OnDust = orml_tokens::BurnDust; + type OnSlash = (); + type PreDeposit = (); + type PostDeposit = (); + type PreTransfer = (); + type PostTransfer = (); + type OnNewTokenAccount = (); + type OnKilledTokenAccount = (); +} + +impl orml_tokens::Config for Test { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = CurrencyId; + type WeightInfo = (); + type ExistentialDeposits = ExistentialDeposits; + type CurrencyHooks = CurrencyHooks; + type MaxLocks = MaxLocks; + type MaxReserves = ConstU32<0>; + type ReserveIdentifier = (); + type DustRemovalWhitelist = Everything; +} + +parameter_types! { + pub const ExistentialDeposit: Balance = 1000; + pub const MaxReserves: u32 = 50; + pub const TreasuryAccount: AccountId = u64::MAX; + pub const SellFee: Permill = Permill::from_percent(1); + pub const MinAmountToBuyout: Balance = 100 * UNIT; + // 24 hours in blocks (where average block time is 12 seconds) + pub const BuyoutPeriod: u32 = 7200; + // Maximum number of allowed currencies for buyout + pub const MaxAllowedBuyoutCurrencies: u32 = 20; +} + +impl pallet_balances::Config for Test { + type MaxLocks = MaxLocks; + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight; + type MaxReserves = MaxReserves; + type ReserveIdentifier = (); +} + +impl orml_currencies::Config for Test { + type MultiCurrency = Tokens; + type NativeCurrency = BasicCurrencyAdapter; + type GetNativeCurrencyId = GetNativeCurrencyId; + type WeightInfo = (); +} + +pub struct OracleMock; +impl PriceGetter for OracleMock { + fn get_price(currency_id: CurrencyId) -> Result + where + FixedNumber: FixedPointNumber + One + Zero + Debug + TryFrom, + { + // This simulates price fetching error for testing pre_dispatch validation but only for one specific supported asset + if currency_id == 2u64 { + return Err(DispatchError::Other("No price")) + } + + let price: FixedNumber = FixedNumber::one() + .try_into() + .map_err(|_| DispatchError::Other("FixedU128 convert"))?; + Ok(price) + } +} + +impl Config for Test { + /// The overarching event type. + type RuntimeEvent = RuntimeEvent; + /// Used for currency-related operations + type Currency = Currencies; + /// Used for getting the treasury account + type TreasuryAccount = TreasuryAccount; + /// Buyout period in blocks + type BuyoutPeriod = BuyoutPeriod; + /// Fee from the native asset buyouts + type SellFee = SellFee; + /// Used for fetching prices of currencies from oracle + type PriceGetter = OracleMock; + /// Min amount of native token to buyout + type MinAmountToBuyout = MinAmountToBuyout; + /// Maximum number of storage updates for allowed currencies in one extrinsic call + type MaxAllowedBuyoutCurrencies = MaxAllowedBuyoutCurrencies; + /// Weight information for extrinsics in this pallet. + type WeightInfo = SubstrateWeight; + /// Currency id of relay chain + #[cfg(feature = "runtime-benchmarks")] + type RelayChainCurrencyId = RelayChainCurrencyId; +} + +// ------- Constants and Genesis Config ------ // + +pub const USER: u64 = 0; +pub const TREASURY_ACCOUNT: u64 = TreasuryAccount::get(); + +pub const USERS_INITIAL_BALANCE: u128 = 200 * UNIT; +pub const TREASURY_INITIAL_BALANCE: u128 = 1000 * UNIT; + +pub struct ExtBuilder; + +impl ExtBuilder { + pub fn build() -> sp_io::TestExternalities { + let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + + let dot_currency_id = RelayChainCurrencyId::get(); + + orml_tokens::GenesisConfig:: { + balances: vec![(USER, dot_currency_id, USERS_INITIAL_BALANCE)], + } + .assimilate_storage(&mut storage) + .unwrap(); + + pallet_balances::GenesisConfig:: { + balances: vec![ + (USER, USERS_INITIAL_BALANCE), + (TREASURY_ACCOUNT, TREASURY_INITIAL_BALANCE), + ], + } + .assimilate_storage(&mut storage) + .unwrap(); + + treasury_buyout_extension::GenesisConfig:: { + allowed_currencies: vec![dot_currency_id, 1, 2, 6], + } + .assimilate_storage(&mut storage) + .unwrap(); + + sp_io::TestExternalities::from(storage) + } +} + +pub fn run_test(test: T) +where + T: FnOnce(), +{ + ExtBuilder::build().execute_with(|| { + System::set_block_number(1); + test(); + }); +} diff --git a/pallets/treasury-buyout-extension/src/tests.rs b/pallets/treasury-buyout-extension/src/tests.rs new file mode 100644 index 000000000..d3a0957b6 --- /dev/null +++ b/pallets/treasury-buyout-extension/src/tests.rs @@ -0,0 +1,653 @@ +#![cfg(test)] +use crate::{ + mock::*, + types::{Amount, CurrencyIdOf}, + BuyoutLimit, Buyouts, Config, Error, PriceGetter, ValidityError, +}; +use frame_support::{assert_err, assert_noop, assert_ok}; +use orml_traits::MultiCurrency; +use sp_arithmetic::{traits::One, FixedU128}; +use sp_runtime::{ + traits::BadOrigin, + transaction_validity::{InvalidTransaction, TransactionValidityError}, + SaturatedConversion, +}; + +fn get_free_balance(currency_id: CurrencyIdOf, account: &AccountId) -> Balance { + as MultiCurrency>::free_balance(currency_id, account) +} + +fn run_to_block(new_block: ::BlockNumber) { + frame_system::Pallet::::set_block_number(new_block); +} + +#[test] +fn buyout_using_dot_given_exchange_amount_in_dot_succeeds() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let initial_user_dot_balance = get_free_balance(dot_currency_id, &user); + let initial_treasury_dot_balance = + get_free_balance(dot_currency_id, &TreasuryAccount::get()); + + let initial_user_native_balance = get_free_balance(GetNativeCurrencyId::get(), &user); + let initial_treasury_native_balance = + get_free_balance(GetNativeCurrencyId::get(), &TreasuryAccount::get()); + + assert_eq!(initial_user_native_balance, USERS_INITIAL_BALANCE); + assert_eq!(initial_treasury_native_balance, TREASURY_INITIAL_BALANCE); + + let exchange_amount = 100 * UNIT; + assert_ok!(crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Exchange(exchange_amount), + )); + + // Fetch prices from Oracle mock + let basic_asset_price = >>::get_price::< + FixedU128, + >(GetNativeCurrencyId::get()) + .expect("This is mocked so it should not fail"); + let exchange_asset_price = >>::get_price::< + FixedU128, + >(dot_currency_id) + .expect("This is mocked so it should not fail"); + + // Add fee to basic asset price + let basic_asset_price_with_fee = + basic_asset_price * (FixedU128::from(SellFee::get()) + FixedU128::one()); + + // Calculate Native buyout amount + let buyout_amount = crate::Pallet::::multiply_by_rational( + exchange_amount, + exchange_asset_price.into_inner(), + basic_asset_price_with_fee.into_inner(), + ) + .expect("This is mocked so it should not fail"); + + let final_user_dot_balance = get_free_balance(dot_currency_id, &user); + let final_user_native_balance = get_free_balance(GetNativeCurrencyId::get(), &user); + + let final_treasury_dot_balance = get_free_balance(dot_currency_id, &TreasuryAccount::get()); + let final_treasury_native_balance = + get_free_balance(GetNativeCurrencyId::get(), &TreasuryAccount::get()); + + assert_eq!(final_user_dot_balance, initial_user_dot_balance - exchange_amount); + assert_eq!(final_treasury_dot_balance, initial_treasury_dot_balance + exchange_amount); + + assert_eq!(final_user_native_balance, initial_user_native_balance + buyout_amount); + assert_eq!(final_treasury_native_balance, initial_treasury_native_balance - buyout_amount); + + // Verify Buyout event was emitted + assert!(System::events().iter().any(|record| matches!( + record.event, + TestEvent::TreasuryBuyoutExtension(crate::Event::Buyout { who, buyout_amount: amount, .. }) + if who == user && amount == buyout_amount + ))); + }); +} + +#[test] +fn buyout_using_dot_given_buyout_amount_in_native_succeeds() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let initial_user_dot_balance = get_free_balance(dot_currency_id, &user); + let initial_treasury_dot_balance = + get_free_balance(dot_currency_id, &TreasuryAccount::get()); + + let initial_user_native_balance = get_free_balance(GetNativeCurrencyId::get(), &user); + let initial_treasury_native_balance = + get_free_balance(GetNativeCurrencyId::get(), &TreasuryAccount::get()); + + assert_eq!(initial_user_native_balance, USERS_INITIAL_BALANCE); + assert_eq!(initial_treasury_native_balance, TREASURY_INITIAL_BALANCE); + + let buyout_amount = 100 * UNIT; + assert_ok!(crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Buyout(buyout_amount), + )); + + // Fetch prices from Oracle mock + let basic_asset_price = >>::get_price::< + FixedU128, + >(GetNativeCurrencyId::get()) + .expect("This is mocked so it should not fail"); + let exchange_asset_price = >>::get_price::< + FixedU128, + >(dot_currency_id) + .expect("This is mocked so it should not fail"); + + // Add fee to basic asset price + let basic_asset_price_with_fee = + basic_asset_price * (FixedU128::from(SellFee::get()) + FixedU128::one()); + + // Calculate DOT exchange amount + let exchange_amount = crate::Pallet::::multiply_by_rational( + buyout_amount, + basic_asset_price_with_fee.into_inner(), + exchange_asset_price.into_inner(), + ) + .expect("This is mocked so it should not fail"); + + let final_user_dot_balance = get_free_balance(dot_currency_id, &user); + let final_user_native_balance = get_free_balance(GetNativeCurrencyId::get(), &user); + + let final_treasury_dot_balance = get_free_balance(dot_currency_id, &TreasuryAccount::get()); + let final_treasury_native_balance = + get_free_balance(GetNativeCurrencyId::get(), &TreasuryAccount::get()); + + assert_eq!(final_user_dot_balance, initial_user_dot_balance - exchange_amount); + assert_eq!(final_treasury_dot_balance, initial_treasury_dot_balance + exchange_amount); + + assert_eq!(final_user_native_balance, initial_user_native_balance + buyout_amount); + assert_eq!(final_treasury_native_balance, initial_treasury_native_balance - buyout_amount); + + // Verify Buyout event was emitted + assert!(System::events().iter().any(|record| matches!( + record.event, + TestEvent::TreasuryBuyoutExtension(crate::Event::Buyout { who, buyout_amount: amount, .. }) + if who == user && amount == buyout_amount + ))); + }); +} + +#[test] +fn root_update_buyout_amount_limit_succeeds() { + run_test(|| { + let buyout_amount_limit = 200 * UNIT; + assert_ok!(crate::Pallet::::update_buyout_limit( + RuntimeOrigin::root(), + Some(buyout_amount_limit.into()), + )); + + assert_eq!(BuyoutLimit::::get(), buyout_amount_limit.into()); + + let buyout_amount_limit = None; + assert_ok!(crate::Pallet::::update_buyout_limit( + RuntimeOrigin::root(), + buyout_amount_limit, + )); + + assert_eq!(BuyoutLimit::::get(), buyout_amount_limit); + }); +} + +#[test] +fn user_update_buyout_amount_limit_fails() { + run_test(|| { + let user = USER; + + let buyout_amount_limit = 200 * UNIT; + assert_noop!( + crate::Pallet::::update_buyout_limit( + RuntimeOrigin::signed(user), + Some(buyout_amount_limit.into()), + ), + BadOrigin + ); + }); +} + +#[test] +fn root_update_allowed_currencies_succeeds() { + run_test(|| { + let dot_currency_id = RelayChainCurrencyId::get(); + + // Since dot is already added to allowed currencies in the genesis, provide some other allowed currencies that will overwrite the storage + let allowed_currencies = vec![1u64, 2u64, 3u64]; + + assert_ok!(crate::Pallet::::update_allowed_assets( + RuntimeOrigin::root(), + allowed_currencies + )); + + // Test user buyout after allowed currencies update + // It should fail because dot is not allowed for buyout + let user = USER; + let exchange_amount = 100 * UNIT; + + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Exchange(exchange_amount), + ), + Error::::WrongAssetToBuyout + ); + + // Add dot back to allowed currencies among some others + // Order of insertion is the order of the currencies in the input vector + let allowed_currencies = vec![ + 3u64, + // Duplicating the same currency should not fail + 3u64, + 2u64, + dot_currency_id, + 6u64, + ]; + + assert_ok!(crate::Pallet::::update_allowed_assets( + RuntimeOrigin::root(), + allowed_currencies + )); + + // Expected allowed currencies after update + // Order of insertion in the storage respects the order of the currencies in the input vector + // The order of the currencies in the event vector is the order of insertion + // Duplicates are skipped + let expected_allowed_currencies = vec![3u64, 2u64, dot_currency_id, 6u64]; + + assert!(System::events().iter().any(|r| matches!( + r.event, + RuntimeEvent::TreasuryBuyoutExtension(crate::Event::AllowedAssetsForBuyoutUpdated { allowed_assets: ref a }) if a == &expected_allowed_currencies + ))); + + // Test user buyout after allowed currencies update + // It should succeed because dot is now allowed for buyout + assert_ok!(crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Exchange(exchange_amount), + )); + }); +} + +#[test] +fn user_update_allowed_currencies_fails() { + run_test(|| { + let user = USER; + + let allowed_currencies = vec![1u64, 2u64, 3u64, 4u64, 6u64]; + + assert_noop!( + crate::Pallet::::update_allowed_assets( + RuntimeOrigin::signed(user), + allowed_currencies + ), + BadOrigin + ); + }); +} + +#[test] +fn root_update_allowed_currencies_with_native_fails() { + run_test(|| { + let native_currency_id = GetNativeCurrencyId::get(); + + let allowed_currencies = vec![1u64, 3u64, 6u64, native_currency_id]; + + assert_noop!( + crate::Pallet::::update_allowed_assets(RuntimeOrigin::root(), allowed_currencies), + Error::::NativeTokenNotAllowed + ); + }); +} + +#[test] +fn root_attempt_update_allowed_currencies_exceeds_limit_fails() { + run_test(|| { + let max_allowed_currencies_for_buyout = MaxAllowedBuyoutCurrencies::get() as usize; + let exceeding_currencies_number = max_allowed_currencies_for_buyout + 1; + + // Create vector with currencies that exceeds the maximum number of allowed currencies for buyout + let mut allowed_currencies = Vec::with_capacity(max_allowed_currencies_for_buyout); + for i in 0..exceeding_currencies_number { + allowed_currencies.push(i as u64); + } + + assert_noop!( + crate::Pallet::::update_allowed_assets(RuntimeOrigin::root(), allowed_currencies), + Error::::ExceedsNumberOfAllowedCurrencies + ); + }); +} + +#[test] +fn attempt_buyout_with_wrong_currency_fails() { + run_test(|| { + let user = USER; + let native_currency_id = GetNativeCurrencyId::get(); + let initial_user_native_balance = get_free_balance(native_currency_id, &user); + let initial_treasury_native_balance = + get_free_balance(native_currency_id, &TreasuryAccount::get()); + + assert_eq!(initial_user_native_balance, USERS_INITIAL_BALANCE); + assert_eq!(initial_treasury_native_balance, TREASURY_INITIAL_BALANCE); + + let buyout_amount = 100 * UNIT; + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + native_currency_id, + Amount::Buyout(buyout_amount), + ), + Error::::WrongAssetToBuyout + ); + + assert_eq!(initial_user_native_balance, USERS_INITIAL_BALANCE); + assert_eq!(initial_treasury_native_balance, TREASURY_INITIAL_BALANCE); + + let exchange_amount = 100 * UNIT; + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + native_currency_id, + Amount::Exchange(exchange_amount), + ), + Error::::WrongAssetToBuyout + ); + + assert_eq!(initial_user_native_balance, USERS_INITIAL_BALANCE); + assert_eq!(initial_treasury_native_balance, TREASURY_INITIAL_BALANCE); + }); +} + +#[test] +fn buyout_with_previous_existing_buyouts_succeeds() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let exchange_amount = 100 * UNIT; + + // With buyout limit and buyouts of previous periods + BuyoutLimit::::put(200 * UNIT); + Buyouts::::insert(user, (100 * UNIT, 0)); + + assert_ok!(crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Exchange(exchange_amount), + )); + }); +} + +#[test] +fn attempt_buyout_after_buyout_limit_exceeded_fails() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let exchange_amount = 100 * UNIT; + + let current_block = frame_system::Pallet::::block_number().saturated_into::(); + + // With buyout limit + BuyoutLimit::::put(150 * UNIT); + // Buyout at current_block + Buyouts::::insert(user, (100 * UNIT, current_block)); + + assert_eq!(Buyouts::::get(user), (100 * UNIT, current_block)); + + // Skip to exactly the last block before the buyout period ends + let buyout_period: u32 = BuyoutPeriod::get(); + let new_current_block = buyout_period - 1; + run_to_block((new_current_block).into()); + + // This buyout attempt for 100 * UNIT should fail because the limit is exceeded for the current period + // Buyout limit is 150 * UNIT and the previous buyout was 100 * UNIT + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Exchange(exchange_amount), + ), + Error::::BuyoutLimitExceeded + ); + }); +} + +#[test] +fn buyout_after_buyout_limit_reset_succeeds() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let buyout_amount = 100 * UNIT; + + let current_block = frame_system::Pallet::::block_number().saturated_into::(); + + // With buyout limit + BuyoutLimit::::put(200 * UNIT); + // Previous buyout at current_block + Buyouts::::insert(user, (150 * UNIT, current_block)); + + assert_eq!(Buyouts::::get(user), (150 * UNIT, current_block)); + + let buyout_period: u32 = BuyoutPeriod::get(); + // Skip buyout_period + 1 blocks, when the initial buyout period has already passed + run_to_block((current_block + buyout_period + 1).into()); + + assert_ok!(crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Buyout(buyout_amount), + )); + + let new_current_block = + frame_system::Pallet::::block_number().saturated_into::(); + // Buyouts should be reset and the total buyout amount should be equal to the last buyout amount + assert_eq!(Buyouts::::get(user), (100 * UNIT, new_current_block)); + }); +} + +#[test] +fn attempt_buyout_with_insufficient_user_balance_fails() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let buyout_amount = 10000 * UNIT; + + // This buyout attempt should fail because the user balance is insufficient + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Buyout(buyout_amount), + ), + Error::::InsufficientAccountBalance + ); + }); +} + +#[test] +fn attempt_buyout_with_insufficient_treasury_balance_fails() { + run_test(|| { + let user = USER; + let native_currency_id = GetNativeCurrencyId::get(); + let dot_currency_id = RelayChainCurrencyId::get(); + let buyout_amount = 100 * UNIT; + + // Transfer all treasury balance to user just for testing purposes + // Makes treasury balance insufficient + assert_ok!(<::Currency>::transfer( + RuntimeOrigin::signed(TREASURY_ACCOUNT), + user, + native_currency_id, + TREASURY_INITIAL_BALANCE + )); + + // This buyout attempt should fail because the treasury balance is insufficient + assert_noop!( + crate::Pallet::::buyout( + RuntimeOrigin::signed(user), + dot_currency_id, + Amount::Buyout(buyout_amount), + ), + Error::::InsufficientTreasuryBalance + ); + }); +} + +mod signed_extension { + use frame_support::{dispatch::DispatchInfo, weights::Weight}; + use sp_runtime::traits::SignedExtension; + + use crate::CheckBuyout; + + use super::*; + + pub fn info_from_weight(w: Weight) -> DispatchInfo { + DispatchInfo { weight: w, ..Default::default() } + } + + #[test] + fn validate_skip_other_calls_succeeds() { + run_test(|| { + let buyout_call = + RuntimeCall::TreasuryBuyoutExtension(crate::Call::update_buyout_limit { + limit: None, + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + assert_ok!(check.validate(&1, &buyout_call, &info, 0)); + }); + } + + #[test] + fn validate_when_wrong_asset_fails() { + run_test(|| { + let user = USER; + + // Some unsupported assets for buyout + let native_currency_id = GetNativeCurrencyId::get(); + let brz_currency_id = 4u64; + + // Call with unsupported asset + for asset in [native_currency_id, brz_currency_id] { + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset, + amount: Amount::Buyout(100 * UNIT), + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_err!( + check.validate(&user, &buyout_call, &info, 1), + TransactionValidityError::Invalid(InvalidTransaction::Custom( + ValidityError::WrongAssetToBuyout.into() + )) + ); + } + }); + } + + #[test] + fn validate_when_no_price_found_fails() { + run_test(|| { + let user = USER; + // For currency id 2u64 there is no price defined in the mock in order to test this case + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset: 2u64, + amount: Amount::Buyout(100 * UNIT), + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_err!( + check.validate(&user, &buyout_call, &info, 1), + TransactionValidityError::Invalid(InvalidTransaction::Custom( + ValidityError::Math.into() + )) + ); + }); + } + + #[test] + fn validate_when_not_enough_to_buyout_fails() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset: dot_currency_id, + amount: Amount::Buyout(1000 * UNIT), + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_err!( + check.validate(&user, &buyout_call, &info, 1), + TransactionValidityError::Invalid(InvalidTransaction::Custom( + ValidityError::NotEnoughToBuyout.into() + )) + ); + }); + } + + #[test] + fn validate_when_buyout_limit_exceeded_fails() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset: dot_currency_id, + amount: Amount::Buyout(100 * UNIT), + }); + + let current_block = + frame_system::Pallet::::block_number().saturated_into::(); + + // With buyout limit + BuyoutLimit::::put(100 * UNIT); + // Previous buyout at current_block + Buyouts::::insert(&user, (80 * UNIT, current_block)); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_err!( + check.validate(&user, &buyout_call, &info, 1), + TransactionValidityError::Invalid(InvalidTransaction::Custom( + ValidityError::BuyoutLimitExceeded.into() + )) + ); + }); + } + + #[test] + fn validate_when_less_than_min_amount_to_buyout_fails() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset: dot_currency_id, + amount: Amount::Buyout(10 * UNIT), + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_err!( + check.validate(&user, &buyout_call, &info, 1), + TransactionValidityError::Invalid(InvalidTransaction::Custom( + ValidityError::LessThanMinBuyoutAmount.into() + )) + ); + }); + } + + #[test] + fn validate_succeeds() { + run_test(|| { + let user = USER; + let dot_currency_id = RelayChainCurrencyId::get(); + + let buyout_call = RuntimeCall::TreasuryBuyoutExtension(crate::Call::buyout { + asset: dot_currency_id, + amount: Amount::Buyout(100 * UNIT), + }); + + let check = CheckBuyout::::new(); + let info = info_from_weight(Weight::zero()); + + assert_ok!(check.validate(&user, &buyout_call, &info, 1)); + }); + } +} diff --git a/pallets/treasury-buyout-extension/src/types.rs b/pallets/treasury-buyout-extension/src/types.rs new file mode 100644 index 000000000..cbd15ade5 --- /dev/null +++ b/pallets/treasury-buyout-extension/src/types.rs @@ -0,0 +1,26 @@ +use crate::Config; +use codec::{Decode, Encode, MaxEncodedLen}; +use orml_traits::MultiCurrency; +use scale_info::TypeInfo; + +#[allow(type_alias_bounds)] +pub(crate) type AccountIdOf = ::AccountId; + +#[allow(type_alias_bounds)] +pub(crate) type CurrencyIdOf = + <::MultiCurrency as MultiCurrency< + ::AccountId, + >>::CurrencyId; + +#[allow(type_alias_bounds)] +pub(crate) type BalanceOf = + <::Currency as MultiCurrency>>::Balance; + +/// Type of amount +#[derive(Copy, Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub enum Amount { + /// Amount of native asset user get for buyout + Buyout(Balance), + /// Amount of exchange asset user give for buyout + Exchange(Balance), +} diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 3a2dfcb43..a40a4b8e5 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -21,7 +21,6 @@ use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo}; pub use parachain_staking::InflationInfo; use codec::Encode; -use scale_info::TypeInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; @@ -831,8 +830,6 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; - #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] - pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -844,7 +841,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; diff --git a/runtime/common/src/asset_registry.rs b/runtime/common/src/asset_registry.rs index b6e206a99..4ffd1dd94 100644 --- a/runtime/common/src/asset_registry.rs +++ b/runtime/common/src/asset_registry.rs @@ -10,8 +10,16 @@ use sp_std::fmt::Debug; use spacewalk_primitives::CurrencyId; #[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] -pub struct CustomMetadata + TypeInfo + Clone + Eq + Debug + Send + Sync> { - pub dia_keys: DiaKeys, +pub struct StringLimit; +impl Get for StringLimit { + fn get() -> u32 { + 50 + } +} + +#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +pub struct CustomMetadata { + pub dia_keys: DiaKeys, pub fee_per_second: u128, } @@ -26,15 +34,11 @@ pub struct DiaKeys + TypeInfo + Clone + Eq + Debug + Send + Sync> { )] pub struct CustomAssetProcessor; -impl AssetProcessor>> - for CustomAssetProcessor -where - T: Get + TypeInfo + Clone + Eq + Debug + Send + Sync + 'static, -{ +impl AssetProcessor> for CustomAssetProcessor { fn pre_register( id: Option, - metadata: AssetMetadata>, - ) -> Result<(CurrencyId, AssetMetadata>), DispatchError> { + metadata: AssetMetadata, + ) -> Result<(CurrencyId, AssetMetadata), DispatchError> { match id { Some(id) => Ok((id, metadata)), None => Err(DispatchError::Other("asset-registry: AssetId is required")), @@ -43,7 +47,7 @@ where fn post_register( _id: CurrencyId, - _asset_metadata: AssetMetadata>, + _asset_metadata: AssetMetadata, ) -> Result<(), DispatchError> { Ok(()) } diff --git a/runtime/common/src/benchmarking/orml_asset_registry.rs b/runtime/common/src/benchmarking/orml_asset_registry.rs index 0fabd64ed..2f18594a4 100644 --- a/runtime/common/src/benchmarking/orml_asset_registry.rs +++ b/runtime/common/src/benchmarking/orml_asset_registry.rs @@ -3,11 +3,13 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use orml_asset_registry::AssetMetadata; use sp_std::{vec, vec::Vec}; -use spacewalk_primitives::{CurrencyId, CustomMetadata}; +use crate::asset_registry::{CustomMetadata, DiaKeys}; +use spacewalk_primitives::CurrencyId; use xcm::{ latest::MultiLocation, opaque::lts::{Junction::*, Junctions::*}, }; +use sp_runtime::BoundedVec; pub struct Pallet(orml_asset_registry::Pallet); pub trait Config: @@ -37,7 +39,13 @@ pub mod benchmarks { symbol: longest_vec(), existential_deposit: 0, location: Some(longest_multilocation().into()), - additional: CustomMetadata, + additional: CustomMetadata { + dia_keys: DiaKeys { + blockchain: BoundedVec::truncate_from(longest_vec()), + symbol: BoundedVec::truncate_from(longest_vec()), + }, + fee_per_second: 123, + } } } @@ -72,7 +80,13 @@ pub mod benchmarks { Some(vec![b'b', 128]), Some(1234), Some(Some(location.into())), - Some(CustomMetadata), + Some(CustomMetadata { + dia_keys: DiaKeys { + blockchain: BoundedVec::truncate_from(longest_vec()), + symbol: BoundedVec::truncate_from(longest_vec()), + }, + fee_per_second: 123, + }), ); } diff --git a/runtime/foucoco/Cargo.toml b/runtime/foucoco/Cargo.toml index 2574993f0..8eb30eef5 100644 --- a/runtime/foucoco/Cargo.toml +++ b/runtime/foucoco/Cargo.toml @@ -22,6 +22,7 @@ paste = "1.0.14" scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.144", optional = true, features = ["derive"] } smallvec = "1.9.0" +cfg-if = "1.0.0" # Local runtime-common = { path = "../common", default-features = false } @@ -106,6 +107,7 @@ parachain-staking = { path = "../../pallets/parachain-staking", default-features orml-currencies-allowance-extension = {path = "../../pallets/orml-currencies-allowance-extension", default-features = false} orml-tokens-management-extension = {path = "../../pallets/orml-tokens-management-extension", default-features = false} +treasury-buyout-extension = {path = "../../pallets/treasury-buyout-extension", default-features = false} # DIA dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } @@ -240,7 +242,7 @@ std = [ "module-pallet-staking-rpc-runtime-api/std", "spacewalk-primitives/std", "orml-currencies-allowance-extension/std", - + "treasury-buyout-extension/std", "bifrost-farming/std", "bifrost-farming-rpc-runtime-api/std", ] @@ -271,7 +273,8 @@ runtime-benchmarks = [ "oracle/testing-utils", "runtime-common/runtime-benchmarks", "orml-currencies-allowance-extension/runtime-benchmarks", - "orml-tokens-management-extension/runtime-benchmarks" + "orml-tokens-management-extension/runtime-benchmarks", + "treasury-buyout-extension/runtime-benchmarks" ] try-runtime = [ @@ -333,6 +336,8 @@ try-runtime = [ "dia-oracle/try-runtime", "orml-currencies-allowance-extension/try-runtime", "orml-tokens-management-extension/try-runtime", + + "treasury-buyout-extension/try-runtime", "bifrost-farming/try-runtime", diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 8fd869675..5d6ee635c 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -29,10 +29,12 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, + One, Zero, }, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, DispatchError, FixedPointNumber, SaturatedConversion, + ApplyExtrinsicResult, DispatchError, FixedPointNumber, FixedU128, SaturatedConversion, }; +use sp_std::fmt::Debug; use sp_std::{marker::PhantomData, prelude::*}; #[cfg(feature = "std")] @@ -67,6 +69,8 @@ use runtime_common::{ #[cfg(any(feature = "runtime-benchmarks", feature = "testing-utils"))] use oracle::testing_utils::MockDataFeeder; +use oracle::OracleKey; + use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use dia_oracle::DiaOracle; @@ -149,6 +153,7 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + treasury_buyout_extension::CheckBuyout, ); /// Unchecked extrinsic type as expected by this runtime. @@ -196,14 +201,30 @@ impl XCMCurrencyConversion for SpacewalkNativeCurrency { } } -type DataProviderImpl = DiaOracleAdapter< - DiaOracleModule, - UnsignedFixedPoint, - Moment, - oracle::dia::DiaOracleKeyConvertor, - ConvertPrice, - ConvertMoment, ->; +cfg_if::cfg_if! { + if #[cfg(feature = "runtime-benchmarks")] { + use oracle::testing_utils::{ + MockConvertMoment, MockConvertPrice, MockDiaOracle, MockOracleKeyConvertor, + }; + type DataProviderImpl = DiaOracleAdapter< + MockDiaOracle, + UnsignedFixedPoint, + Moment, + MockOracleKeyConvertor, + MockConvertPrice, + MockConvertMoment, + >; + } else { + type DataProviderImpl = DiaOracleAdapter< + DiaOracleModule, + UnsignedFixedPoint, + Moment, + oracle::dia::DiaOracleKeyConvertor, + ConvertPrice, + ConvertMoment, + >; + } +} pub struct ConvertPrice; impl Convert> for ConvertPrice { @@ -379,6 +400,7 @@ impl Contains for BaseFilter { RuntimeCall::AssetRegistry(_) | RuntimeCall::Proxy(_) | RuntimeCall::OrmlExtension(_) | + RuntimeCall::TreasuryBuyoutExtension(_) | RuntimeCall::RewardDistribution(_) => true, // All pallets are allowed, but exhaustive match is defensive // in the case of adding new pallets. } @@ -833,8 +855,6 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; - #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] - pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -846,7 +866,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; @@ -972,6 +992,79 @@ impl orml_tokens_management_extension::Config for Runtime { type DepositCurrency = DepositCurrency; type AssetDeposit = AssetDeposit; } +pub struct OraclePriceGetter(Oracle); +impl treasury_buyout_extension::PriceGetter for OraclePriceGetter { + #[cfg(not(feature = "runtime-benchmarks"))] + fn get_price(currency_id: CurrencyId) -> Result + where + FixedNumber: FixedPointNumber + One + Zero + Debug + TryFrom, + { + let key = OracleKey::ExchangeRate(currency_id); + let asset_price = Oracle::get_price(key.clone())?; + + let converted_asset_price = FixedNumber::try_from(asset_price); + + match converted_asset_price { + Ok(price) => Ok(price), + Err(_) => Err(DispatchError::Other("Failed to convert price")), + } + } + #[cfg(feature = "runtime-benchmarks")] + fn get_price(currency_id: CurrencyId) -> Result + where + FixedNumber: FixedPointNumber + One + Zero + Debug + TryFrom, + { + // Forcefully set chain status to running when benchmarking so that the oracle doesn't fail + Security::set_status(StatusCode::Running); + + let key = OracleKey::ExchangeRate(currency_id); + + // Attempt to get the price once and use the result to decide if feeding a value is necessary + match Oracle::get_price(key.clone()) { + Ok(asset_price) => { + // If the price is successfully retrieved, use it directly + let converted_asset_price = FixedNumber::try_from(asset_price) + .map_err(|_| DispatchError::Other("Failed to convert price"))?; + Ok(converted_asset_price) + }, + Err(_) => { + // Price not found, feed the default value + let rate = FixedU128::checked_from_rational(100, 1).expect("This is a valid ratio"); + // Account used for feeding values + let account = AccountId::from([0u8; 32]); + Oracle::feed_values(account, vec![(key.clone(), rate)])?; + + // If feeding was successful, just use the feeded price to spare a read + let converted_asset_price = FixedNumber::try_from(rate) + .map_err(|_| DispatchError::Other("Failed to convert price"))?; + Ok(converted_asset_price) + }, + } + } +} + +parameter_types! { + pub const SellFee: Permill = Permill::from_percent(1); + pub const MinAmountToBuyout: Balance = 100 * UNIT; + // 24 hours in blocks (where average block time is 12 seconds) + pub const BuyoutPeriod: u32 = 7200; + // Maximum number of allowed currencies for buyout + pub const MaxAllowedBuyoutCurrencies: u32 = 20; +} + +impl treasury_buyout_extension::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Currencies; + type TreasuryAccount = FoucocoTreasuryAccount; + type BuyoutPeriod = BuyoutPeriod; + type SellFee = SellFee; + type PriceGetter = OraclePriceGetter; + type MinAmountToBuyout = MinAmountToBuyout; + type MaxAllowedBuyoutCurrencies = MaxAllowedBuyoutCurrencies; + type WeightInfo = treasury_buyout_extension::default_weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type RelayChainCurrencyId = RelayChainCurrencyId; +} const fn deposit(items: u32, bytes: u32) -> Balance { (items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 @@ -1492,6 +1585,7 @@ where frame_system::CheckNonce::::from(index), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(tip), + treasury_buyout_extension::CheckBuyout::::new(), ); let raw_payload = SignedPayload::new(call, extra).ok()?; @@ -1816,6 +1910,8 @@ construct_runtime!( TokenAllowance: orml_currencies_allowance_extension::{Pallet, Storage, Call, Event} = 80, OrmlExtension: orml_tokens_management_extension::{Pallet, Storage, Call, Event} = 81, + TreasuryBuyoutExtension: treasury_buyout_extension::{Pallet, Storage, Call, Event} = 82, + Farming: farming::{Pallet, Call, Storage, Event} = 90, // Asset Metadata @@ -1852,6 +1948,7 @@ mod benches { [orml_currencies_allowance_extension, TokenAllowance] [orml_tokens_management_extension, OrmlExtension] + [treasury_buyout_extension, TreasuryBuyoutExtension] ); } diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 40d53ced3..773d0c386 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -19,7 +19,6 @@ use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo}; pub use parachain_staking::InflationInfo; use codec::Encode; -use scale_info::TypeInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; @@ -824,8 +823,6 @@ impl orml_tokens::Config for Runtime { parameter_types! { pub const NativeCurrencyId: CurrencyId = CurrencyId::Native; - #[derive(Clone, Eq, PartialEq, Debug, TypeInfo)] - pub const StringLimit: u32 = 50; } impl orml_currencies::Config for Runtime { @@ -837,7 +834,7 @@ impl orml_currencies::Config for Runtime { impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type CustomMetadata = asset_registry::CustomMetadata; + type CustomMetadata = asset_registry::CustomMetadata; type AssetId = CurrencyId; type AuthorityOrigin = asset_registry::AssetAuthority; type AssetProcessor = asset_registry::CustomAssetProcessor; From 6fff8c7c598c0457501b81d10b9da504448689dd Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Tue, 20 Feb 2024 14:52:29 +0100 Subject: [PATCH 11/15] Fix `ConvertPrice` implementations (#413) --- runtime/amplitude/src/lib.rs | 4 +++- runtime/foucoco/src/lib.rs | 4 +++- runtime/pendulum/src/lib.rs | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index a40a4b8e5..11ea9c6cb 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -196,7 +196,9 @@ pub struct ConvertPrice; impl Convert> for ConvertPrice { fn convert(price: u128) -> Option { - Some(UnsignedFixedPoint::from_inner(price)) + // The DIA batching server returns the price in 1e12 format, see [here](https://github.com/pendulum-chain/oracle-pallet/blob/716073885de01f923a0fe44a05bd2a0bd45db555/dia-batching-server/src/price_updater.rs#L141) + // but our UnsignedFixedPoint implementation expects the price in 1e18 format. + Some(UnsignedFixedPoint::from_rational(price, 1_000_000_000_000)) } } diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 5d6ee635c..c107ca719 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -229,7 +229,9 @@ cfg_if::cfg_if! { pub struct ConvertPrice; impl Convert> for ConvertPrice { fn convert(price: u128) -> Option { - Some(UnsignedFixedPoint::from_inner(price)) + // The DIA batching server returns the price in 1e12 format, see [here](https://github.com/pendulum-chain/oracle-pallet/blob/716073885de01f923a0fe44a05bd2a0bd45db555/dia-batching-server/src/price_updater.rs#L141) + // but our UnsignedFixedPoint implementation expects the price in 1e18 format. + Some(UnsignedFixedPoint::from_rational(price, 1_000_000_000_000)) } } diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 773d0c386..b86e10369 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -196,7 +196,9 @@ pub struct ConvertPrice; impl Convert> for ConvertPrice { fn convert(price: u128) -> Option { - Some(UnsignedFixedPoint::from_inner(price)) + // The DIA batching server returns the price in 1e12 format, see [here](https://github.com/pendulum-chain/oracle-pallet/blob/716073885de01f923a0fe44a05bd2a0bd45db555/dia-batching-server/src/price_updater.rs#L141) + // but our UnsignedFixedPoint implementation expects the price in 1e18 format. + Some(UnsignedFixedPoint::from_rational(price, 1_000_000_000_000)) } } From 206cb7e91ac5a484d9727766fd4b4e186dfb71d3 Mon Sep 17 00:00:00 2001 From: Bogdan Sandu Date: Wed, 21 Feb 2024 11:46:48 +0200 Subject: [PATCH 12/15] Bump spec and transaction versions, change min buyout amount (#415) --- runtime/foucoco/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index c107ca719..b30f5c01e 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -279,10 +279,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("foucoco"), impl_name: create_runtime_str!("foucoco"), authoring_version: 1, - spec_version: 8, + spec_version: 9, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 7, + transaction_version: 8, state_version: 1, }; @@ -1047,7 +1047,7 @@ impl treasury_buyout_extension::PriceGetter for OraclePriceGetter { parameter_types! { pub const SellFee: Permill = Permill::from_percent(1); - pub const MinAmountToBuyout: Balance = 100 * UNIT; + pub const MinAmountToBuyout: Balance = NANOUNIT; // 24 hours in blocks (where average block time is 12 seconds) pub const BuyoutPeriod: u32 = 7200; // Maximum number of allowed currencies for buyout From e85eb59ed30188162d7a0172e170c5872a111172 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Wed, 21 Feb 2024 16:59:16 +0100 Subject: [PATCH 13/15] 417 update spacewalk dependencies and bump spec version on pendulum (#418) * Bump pendulum `spec_version` * Change `rev` of spacewalk dependencies to latest commit hash * Define `DecimalsLookup` for each runtime * Bump foucoco spec version * Move comments --- Cargo.lock | 148 ++--- node/Cargo.toml | 52 +- .../Cargo.toml | 50 +- pallets/parachain-staking/rpc/Cargo.toml | 14 +- .../rpc/runtime-api/Cargo.toml | 28 +- runtime/amplitude/Cargo.toml | 92 ++- runtime/amplitude/src/lib.rs | 3 +- runtime/common/Cargo.toml | 4 +- runtime/foucoco/Cargo.toml | 78 ++- runtime/foucoco/src/lib.rs | 22 +- runtime/integration-tests/Cargo.toml | 26 +- runtime/pendulum/Cargo.toml | 536 +++++++++--------- runtime/pendulum/src/lib.rs | 11 +- 13 files changed, 529 insertions(+), 535 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c485ba09b..34141777b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", "stellar-relay", "substrate-wasm-builder", @@ -1194,8 +1194,8 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "clients-info" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "frame-system", @@ -2065,8 +2065,8 @@ dependencies = [ [[package]] name = "currency" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "frame-system", @@ -2080,7 +2080,7 @@ dependencies = [ "serde", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -2853,8 +2853,8 @@ dependencies = [ [[package]] name = "fee" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "frame-benchmarking", @@ -2873,7 +2873,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", ] @@ -3100,7 +3100,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", "stellar-relay", "substrate-wasm-builder", @@ -4160,8 +4160,8 @@ dependencies = [ [[package]] name = "issue" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "base64 0.13.1", "currency", @@ -4188,7 +4188,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "stellar-relay", "vault-registry", ] @@ -5439,8 +5439,8 @@ dependencies = [ [[package]] name = "module-issue-rpc" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "jsonrpsee", "module-issue-rpc-runtime-api", @@ -5452,8 +5452,8 @@ dependencies = [ [[package]] name = "module-issue-rpc-runtime-api" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "parity-scale-codec", @@ -5463,8 +5463,8 @@ dependencies = [ [[package]] name = "module-oracle-rpc" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "jsonrpsee", "module-oracle-rpc-runtime-api", @@ -5472,20 +5472,20 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-runtime", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] name = "module-oracle-rpc-runtime-api" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "parity-scale-codec", "serde", "sp-api", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -5516,8 +5516,8 @@ dependencies = [ [[package]] name = "module-redeem-rpc" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "jsonrpsee", "module-redeem-rpc-runtime-api", @@ -5529,8 +5529,8 @@ dependencies = [ [[package]] name = "module-redeem-rpc-runtime-api" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "parity-scale-codec", @@ -5540,8 +5540,8 @@ dependencies = [ [[package]] name = "module-replace-rpc" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "jsonrpsee", "module-replace-rpc-runtime-api", @@ -5553,8 +5553,8 @@ dependencies = [ [[package]] name = "module-replace-rpc-runtime-api" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "parity-scale-codec", @@ -5564,8 +5564,8 @@ dependencies = [ [[package]] name = "module-vault-registry-rpc" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "jsonrpsee", "module-oracle-rpc-runtime-api", @@ -5578,8 +5578,8 @@ dependencies = [ [[package]] name = "module-vault-registry-rpc-runtime-api" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "module-oracle-rpc-runtime-api", @@ -5853,8 +5853,8 @@ dependencies = [ [[package]] name = "nomination" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "fee", @@ -5878,7 +5878,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", "vault-registry", ] @@ -6025,8 +6025,8 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "oracle" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "dia-oracle", @@ -6045,7 +6045,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "spin 0.9.8", "staking", ] @@ -6203,7 +6203,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -7749,7 +7749,7 @@ dependencies = [ "sp-session", "sp-timestamp", "sp-transaction-pool", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", @@ -7855,7 +7855,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", "stellar-relay", "substrate-wasm-builder", @@ -9189,8 +9189,8 @@ dependencies = [ [[package]] name = "pooled-rewards" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "frame-benchmarking", @@ -9205,7 +9205,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -9634,8 +9634,8 @@ dependencies = [ [[package]] name = "redeem" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "fee", @@ -9659,7 +9659,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "stellar-relay", "vault-registry", ] @@ -9796,8 +9796,8 @@ dependencies = [ [[package]] name = "replace" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "fee", @@ -9823,7 +9823,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "stellar-relay", "vault-registry", ] @@ -9840,8 +9840,8 @@ dependencies = [ [[package]] name = "reward" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-benchmarking", "frame-support", @@ -9854,13 +9854,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] name = "reward-distribution" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "frame-benchmarking", @@ -9882,7 +9882,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", ] @@ -10101,7 +10101,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "xcm", "xcm-executor", "zenlink-protocol", @@ -10146,7 +10146,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-tracing", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "statemine-runtime", "statemint-runtime", "xcm", @@ -11629,8 +11629,8 @@ dependencies = [ [[package]] name = "security" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-support", "frame-system", @@ -12689,8 +12689,8 @@ dependencies = [ [[package]] name = "spacewalk-primitives" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "base58", "bstringify", @@ -12753,8 +12753,8 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "frame-benchmarking", "frame-support", @@ -12769,7 +12769,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -12959,8 +12959,8 @@ dependencies = [ [[package]] name = "stellar-relay" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "base64 0.13.1", "currency", @@ -12973,7 +12973,7 @@ dependencies = [ "sha2 0.10.7", "sp-core", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", ] [[package]] @@ -13963,8 +13963,8 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" -version = "1.0.3" -source = "git+https://github.com/pendulum-chain/spacewalk?rev=22c52abbecda0c1cdaa4187678fe7bcc2d6868c8#22c52abbecda0c1cdaa4187678fe7bcc2d6868c8" +version = "1.0.4" +source = "git+https://github.com/pendulum-chain/spacewalk?rev=bda384bcc6db3da88198c714851a261dcdea1063#bda384bcc6db3da88198c714851a261dcdea1063" dependencies = [ "currency", "fee", @@ -13991,7 +13991,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "spacewalk-primitives 1.0.3", + "spacewalk-primitives 1.0.4", "staking", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index 61ea197eb..611267849 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -15,37 +15,37 @@ codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.145", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } -module-issue-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -module-oracle-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -module-redeem-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -module-replace-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -module-vault-registry-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +module-issue-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-oracle-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-redeem-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-replace-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-vault-registry-rpc = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } module-pallet-staking-rpc = { path = "../pallets/parachain-staking/rpc" } -spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", rev = "bda384bcc6db3da88198c714851a261dcdea1063" } # Local -amplitude-runtime = {path = "../runtime/amplitude"} -foucoco-runtime = {path = "../runtime/foucoco"} -pendulum-runtime = {path = "../runtime/pendulum"} -development-runtime = {path = "../runtime/development"} -runtime-common = {path = "../runtime/common"} +amplitude-runtime = { path = "../runtime/amplitude" } +foucoco-runtime = { path = "../runtime/foucoco" } +pendulum-runtime = { path = "../runtime/pendulum" } +development-runtime = { path = "../runtime/development" } +runtime-common = { path = "../runtime/common" } # Substrate frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -pallet-multisig = {git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40"} -pallet-treasury = {git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40"} +pallet-multisig = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +pallet-treasury = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } @@ -87,7 +87,7 @@ cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/cumul cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.40" } #bifrost -bifrost-farming-rpc-api = { git = "https://github.com/pendulum-chain/bifrost", branch = "polkadot-v0.9.40-farming-add-currencyid-generic" } +bifrost-farming-rpc-api = { git = "https://github.com/pendulum-chain/bifrost", branch = "polkadot-v0.9.40-farming-add-currencyid-generic" } bifrost-farming-rpc-runtime-api = { git = "https://github.com/pendulum-chain/bifrost", branch = "polkadot-v0.9.40-farming-add-currencyid-generic" } zenlink-protocol = { git = "https://github.com/pendulum-chain/Zenlink-DEX-Module", branch = "polkadot-v0.9.40-protocol" } @@ -100,16 +100,16 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate" [features] default = [] runtime-benchmarks = [ - "amplitude-runtime/runtime-benchmarks", - "foucoco-runtime/runtime-benchmarks", - "pendulum-runtime/runtime-benchmarks", - "development-runtime/runtime-benchmarks", - "runtime-common/runtime-benchmarks", - "polkadot-cli/runtime-benchmarks", + "amplitude-runtime/runtime-benchmarks", + "foucoco-runtime/runtime-benchmarks", + "pendulum-runtime/runtime-benchmarks", + "development-runtime/runtime-benchmarks", + "runtime-common/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks", ] try-runtime = [ - "amplitude-runtime/try-runtime", - "foucoco-runtime/try-runtime", - "pendulum-runtime/try-runtime", - "try-runtime-cli/try-runtime" + "amplitude-runtime/try-runtime", + "foucoco-runtime/try-runtime", + "pendulum-runtime/try-runtime", + "try-runtime-cli/try-runtime" ] diff --git a/pallets/orml-tokens-management-extension/Cargo.toml b/pallets/orml-tokens-management-extension/Cargo.toml index 6b7aa40b7..41f9cedeb 100644 --- a/pallets/orml-tokens-management-extension/Cargo.toml +++ b/pallets/orml-tokens-management-extension/Cargo.toml @@ -5,17 +5,17 @@ name = "orml-tokens-management-extension" version = "1.0.0" [dependencies] -codec = {package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"]} -scale-info = {version = "2.2.0", default-features = false, features = ["derive"]} -serde = {version = "1.0.130", default-features = false, features = ["derive"], optional = true} -sha2 = {version = "0.8.2", default-features = false} +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] } +scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.130", default-features = false, features = ["derive"], optional = true } +sha2 = { version = "0.8.2", default-features = false } # Substrate dependencies -frame-support = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -frame-system = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -sp-core = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -sp-runtime = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false, optional = true } @@ -28,30 +28,30 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li [dev-dependencies] mocktopus = "0.8.0" frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-io = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } -pallet-balances = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } # Spacewalk libraries -spacewalk-primitives = { 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 = "bda384bcc6db3da88198c714851a261dcdea1063" } [features] default = ["std"] std = [ - "serde", - "codec/std", - "sha2/std", - "sp-core/std", - "sp-std/std", - "sp-runtime/std", - "frame-support/std", - "frame-system/std", - "orml-currencies/std", - "orml-tokens/std", - "orml-traits/std", - "frame-benchmarking/std", - "spacewalk-primitives/std" + "serde", + "codec/std", + "sha2/std", + "sp-core/std", + "sp-std/std", + "sp-runtime/std", + "frame-support/std", + "frame-system/std", + "orml-currencies/std", + "orml-tokens/std", + "orml-traits/std", + "frame-benchmarking/std", + "spacewalk-primitives/std" ] runtime-benchmarks = [ diff --git a/pallets/parachain-staking/rpc/Cargo.toml b/pallets/parachain-staking/rpc/Cargo.toml index 13187aaa1..0853e5f5a 100644 --- a/pallets/parachain-staking/rpc/Cargo.toml +++ b/pallets/parachain-staking/rpc/Cargo.toml @@ -5,10 +5,10 @@ name = "module-pallet-staking-rpc" version = "1.0.0" [dependencies] -codec = {package = "parity-scale-codec", version = "3.0.0"} -jsonrpsee = {version = "0.16.0", features = ["server", "macros"]} -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -module-pallet-staking-rpc-runtime-api = {path = "runtime-api"} -sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} -sp-blockchain = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} -sp-runtime = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} +codec = { package = "parity-scale-codec", version = "3.0.0" } +jsonrpsee = { version = "0.16.0", features = ["server", "macros"] } +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-pallet-staking-rpc-runtime-api = { path = "runtime-api" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } diff --git a/pallets/parachain-staking/rpc/runtime-api/Cargo.toml b/pallets/parachain-staking/rpc/runtime-api/Cargo.toml index 7e0bd4b08..b815216b1 100644 --- a/pallets/parachain-staking/rpc/runtime-api/Cargo.toml +++ b/pallets/parachain-staking/rpc/runtime-api/Cargo.toml @@ -5,22 +5,22 @@ name = "module-pallet-staking-rpc-runtime-api" version = "1.0.0" [dependencies] -frame-support = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -sp-api = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -sp-std = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false} -parity-scale-codec = {version = "3.1.5", default-features = false, features = ["derive"]} -scale-info = {version = "2.1.1", default-features = false, features = ["derive"]} -module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "22c52abbecda0c1cdaa4187678fe7bcc2d6868c8"} -serde = {version = "1.0.142", default-features = false, optional = true, features = ["derive"]} +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +serde = { version = "1.0.142", default-features = false, optional = true, features = ["derive"] } [features] default = ["std"] std = [ - "serde", - "frame-support/std", - "scale-info/std", - "sp-api/std", - "sp-std/std", - "parity-scale-codec/std", - "module-oracle-rpc-runtime-api/std", + "serde", + "frame-support/std", + "scale-info/std", + "sp-api/std", + "sp-std/std", + "parity-scale-codec/std", + "module-oracle-rpc-runtime-api/std", ] diff --git a/runtime/amplitude/Cargo.toml b/runtime/amplitude/Cargo.toml index a3d04da20..cf776d086 100644 --- a/runtime/amplitude/Cargo.toml +++ b/runtime/amplitude/Cargo.toml @@ -27,27 +27,27 @@ smallvec = "1.9.0" runtime-common = { path = "../common", default-features = false } # 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" } +clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } 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"} +pooled-rewards = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } # Substrate @@ -104,11 +104,11 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu # KILT parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } -orml-currencies-allowance-extension = {path = "../../pallets/orml-currencies-allowance-extension", default-features = false} +orml-currencies-allowance-extension = { path = "../../pallets/orml-currencies-allowance-extension", default-features = false } # Pendulum Pallets -vesting-manager = {path = "../../pallets/vesting-manager", default-features = false} +vesting-manager = { path = "../../pallets/vesting-manager", default-features = false } # DIA dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } @@ -181,9 +181,9 @@ std = [ "pallet-contracts-primitives/std", "pallet-democracy/std", "pallet-identity/std", - "pallet-multisig/std", + "pallet-multisig/std", "pallet-preimage/std", - "pallet-proxy/std", + "pallet-proxy/std", "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", @@ -218,7 +218,6 @@ std = [ "zenlink-protocol-runtime-api/std", "bifrost-farming/std", "bifrost-farming-rpc-runtime-api/std", - #custom libraries from spacewalk "security/std", "staking/std", @@ -238,11 +237,10 @@ 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", - + # custom libraries from pendulum + "orml-currencies-allowance-extension/std", + "parachain-staking/std", + "vesting-manager/std", ] runtime-benchmarks = [ @@ -253,25 +251,22 @@ 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", - + "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", - + "pallet-collective/runtime-benchmarks", "runtime-common/runtime-benchmarks", - "orml-currencies-allowance-extension/runtime-benchmarks" + "orml-currencies-allowance-extension/runtime-benchmarks" ] try-runtime = [ @@ -289,9 +284,9 @@ try-runtime = [ "pallet-contracts/try-runtime", "pallet-democracy/try-runtime", "pallet-identity/try-runtime", - "pallet-multisig/try-runtime", + "pallet-multisig/try-runtime", "pallet-preimage/try-runtime", - "pallet-proxy/try-runtime", + "pallet-proxy/try-runtime", "pallet-insecure-randomness-collective-flip/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", @@ -300,20 +295,16 @@ 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", "cumulus-pallet-parachain-system/try-runtime", "cumulus-pallet-xcm/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", "orml-currencies/try-runtime", "orml-tokens/try-runtime", "orml-xtokens/try-runtime", - "stellar-relay/try-runtime", "issue/try-runtime", "currency/try-runtime", @@ -328,12 +319,9 @@ 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", ] \ No newline at end of file diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 11ea9c6cb..83fbd31d1 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -579,8 +579,8 @@ impl pallet_democracy::Config for Runtime { type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod + type VoteLockingPeriod = EnactmentPeriod; type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. type ExternalOrigin = @@ -1129,6 +1129,7 @@ impl orml_traits::DataProvider for DataFeederBenchmark { impl oracle::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = oracle::SubstrateWeight; + type DecimalsLookup = spacewalk_primitives::AmplitudeDecimalsLookup; type DataProvider = DataProviderImpl; #[cfg(feature = "runtime-benchmarks")] type DataFeeder = MockDataFeeder; diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 6eda0545e..2a5a78a9f 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -33,7 +33,7 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } zenlink-protocol = { git = "https://github.com/pendulum-chain/Zenlink-DEX-Module", default-features = false, branch = "polkadot-v0.9.40-protocol" } -spacewalk-primitives = { 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 = "bda384bcc6db3da88198c714851a261dcdea1063" } [features] default = [ @@ -56,7 +56,7 @@ std = [ "dia-oracle/std", "orml-asset-registry/std", "orml-xcm-support/std", - "zenlink-protocol/std", + "zenlink-protocol/std", "spacewalk-primitives/std", ] diff --git a/runtime/foucoco/Cargo.toml b/runtime/foucoco/Cargo.toml index 8eb30eef5..6c131dd16 100644 --- a/runtime/foucoco/Cargo.toml +++ b/runtime/foucoco/Cargo.toml @@ -28,27 +28,27 @@ cfg-if = "1.0.0" runtime-common = { path = "../common", default-features = false } # custom libraries from 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"} -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"} +clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +pooled-rewards = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } -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-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } module-pallet-staking-rpc-runtime-api = { path = "../../pallets/parachain-staking/rpc/runtime-api", default-features = false } # Substrate @@ -105,9 +105,9 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu # KILT parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } -orml-currencies-allowance-extension = {path = "../../pallets/orml-currencies-allowance-extension", default-features = false} -orml-tokens-management-extension = {path = "../../pallets/orml-tokens-management-extension", default-features = false} -treasury-buyout-extension = {path = "../../pallets/treasury-buyout-extension", default-features = false} +orml-currencies-allowance-extension = { path = "../../pallets/orml-currencies-allowance-extension", default-features = false } +orml-tokens-management-extension = { path = "../../pallets/orml-tokens-management-extension", default-features = false } +treasury-buyout-extension = { path = "../../pallets/treasury-buyout-extension", default-features = false } # DIA dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } @@ -182,9 +182,9 @@ std = [ "pallet-contracts-primitives/std", "pallet-democracy/std", "pallet-identity/std", - "pallet-multisig/std", + "pallet-multisig/std", "pallet-preimage/std", - "pallet-proxy/std", + "pallet-proxy/std", "pallet-insecure-randomness-collective-flip/std", "pallet-scheduler/std", "pallet-session/std", @@ -221,7 +221,6 @@ std = [ "xcm/std", "zenlink-protocol/std", "zenlink-protocol-runtime-api/std", - #custom libraries from spacewalk "currency/std", "security/std", @@ -260,16 +259,15 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "pallet-collective/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-collective/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", "oracle/testing-utils", "runtime-common/runtime-benchmarks", "orml-currencies-allowance-extension/runtime-benchmarks", @@ -304,20 +302,16 @@ 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", "cumulus-pallet-parachain-system/try-runtime", "cumulus-pallet-xcm/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime", - "orml-asset-registry/try-runtime", "orml-currencies/try-runtime", "orml-tokens/try-runtime", "orml-xtokens/try-runtime", - "stellar-relay/try-runtime", "issue/try-runtime", "currency/try-runtime", @@ -332,14 +326,10 @@ try-runtime = [ "pooled-rewards/try-runtime", "clients-info/try-runtime", "reward-distribution/try-runtime", - "dia-oracle/try-runtime", "orml-currencies-allowance-extension/try-runtime", "orml-tokens-management-extension/try-runtime", - "treasury-buyout-extension/try-runtime", - "bifrost-farming/try-runtime", - "zenlink-protocol/try-runtime", ] diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index b30f5c01e..3d07ec4ba 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -10,6 +10,7 @@ mod assets; mod weights; pub mod xcm_config; pub mod zenlink; + use crate::zenlink::*; use xcm::v3::MultiLocation; use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo}; @@ -175,6 +176,7 @@ pub type Executive = frame_executive::Executive< >; pub struct SpacewalkNativeCurrency; + impl oracle::dia::NativeCurrencyKey for SpacewalkNativeCurrency { fn native_symbol() -> Vec { "AMPE".as_bytes().to_vec() @@ -227,6 +229,7 @@ cfg_if::cfg_if! { } pub struct ConvertPrice; + impl Convert> for ConvertPrice { fn convert(price: u128) -> Option { // The DIA batching server returns the price in 1e12 format, see [here](https://github.com/pendulum-chain/oracle-pallet/blob/716073885de01f923a0fe44a05bd2a0bd45db555/dia-batching-server/src/price_updater.rs#L141) @@ -236,6 +239,7 @@ impl Convert> for ConvertPrice { } pub struct ConvertMoment; + impl Convert> for ConvertMoment { fn convert(moment: u64) -> Option { // The provided moment is in seconds, but we need milliseconds @@ -254,6 +258,7 @@ impl Convert> for ConvertMoment { /// - Setting it to `0` will essentially disable the weight fee. /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. pub struct WeightToFee; + impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { @@ -279,7 +284,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("foucoco"), impl_name: create_runtime_str!("foucoco"), authoring_version: 1, - spec_version: 9, + spec_version: 10, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 8, @@ -354,6 +359,7 @@ parameter_types! { } pub struct BaseFilter; + impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { match call { @@ -510,6 +516,7 @@ parameter_types! { type NegativeImbalance = >::NegativeImbalance; pub struct DealWithFees; + impl OnUnbalanced for DealWithFees { fn on_unbalanceds(mut fees_then_tips: impl Iterator) { if let Some(mut fees) = fees_then_tips.next() { @@ -609,7 +616,8 @@ impl pallet_democracy::Config for Runtime { type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod + // Same as EnactmentPeriod + type VoteLockingPeriod = EnactmentPeriod; type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. type ExternalOrigin = @@ -662,6 +670,7 @@ parameter_types! { } type CouncilCollective = pallet_collective::Instance1; + impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -681,6 +690,7 @@ parameter_types! { } type TechnicalCollective = pallet_collective::Instance2; + impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -821,6 +831,7 @@ pub fn get_all_module_accounts() -> Vec { } pub struct DustRemovalWhitelist; + impl Contains for DustRemovalWhitelist { fn contains(a: &AccountId) -> bool { get_all_module_accounts().contains(a) @@ -828,6 +839,7 @@ impl Contains for DustRemovalWhitelist { } pub struct CurrencyHooks(PhantomData); + impl MutationHooks for CurrencyHooks { @@ -965,7 +977,9 @@ impl pallet_vesting::Config for Runtime { type WeightInfo = pallet_vesting::weights::SubstrateWeight; const MAX_VESTING_SCHEDULES: u32 = 10; } + pub struct CurrencyIdCheckerImpl; + impl orml_tokens_management_extension::CurrencyIdCheck for CurrencyIdCheckerImpl { type CurrencyId = CurrencyId; @@ -994,7 +1008,9 @@ impl orml_tokens_management_extension::Config for Runtime { type DepositCurrency = DepositCurrency; type AssetDeposit = AssetDeposit; } + pub struct OraclePriceGetter(Oracle); + impl treasury_buyout_extension::PriceGetter for OraclePriceGetter { #[cfg(not(feature = "runtime-benchmarks"))] fn get_price(currency_id: CurrencyId) -> Result @@ -1599,6 +1615,7 @@ where } pub struct CurrencyConvert; + impl currency::CurrencyConversion, CurrencyId> for CurrencyConvert { fn convert( amount: ¤cy::Amount, @@ -1661,6 +1678,7 @@ impl staking::Config for Runtime { impl oracle::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = oracle::SubstrateWeight; + type DecimalsLookup = spacewalk_primitives::AmplitudeDecimalsLookup; type DataProvider = DataProviderImpl; #[cfg(feature = "runtime-benchmarks")] type DataFeeder = MockDataFeeder; diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml index d9874accb..d82c07f94 100644 --- a/runtime/integration-tests/Cargo.toml +++ b/runtime/integration-tests/Cargo.toml @@ -11,7 +11,7 @@ scale-info = { version = "2.1.2", features = ["derive"] } serde = { version = "1.0.144", features = ["derive"] } # Spacewalk libraries -spacewalk-primitives = { 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 = "bda384bcc6db3da88198c714851a261dcdea1063" } frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } @@ -38,27 +38,27 @@ polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", bran xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "bea35c799d725a4233db6b9108ee2ed5bbfc1aed" } -cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"} -cumulus-pallet-xcmp-queue = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"} -cumulus-pallet-xcm = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"} -cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"} -cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } statemint-runtime = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } statemine-runtime = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -orml-xcm = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } -orml-xcm-support = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } -orml-traits = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } -orml-tokens = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } -orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40" } +orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } +orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" } +orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40" } # Local -runtime-common = {path = "../common", default-features = false} +runtime-common = { path = "../common", default-features = false } pendulum-runtime = { path = "../pendulum" } -amplitude-runtime = {path = "../amplitude" } +amplitude-runtime = { path = "../amplitude" } [features] default = ["std"] diff --git a/runtime/pendulum/Cargo.toml b/runtime/pendulum/Cargo.toml index a94628e13..35f8936bc 100644 --- a/runtime/pendulum/Cargo.toml +++ b/runtime/pendulum/Cargo.toml @@ -12,7 +12,7 @@ version = "0.1.0" targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } @@ -24,113 +24,113 @@ serde = { version = "1.0.144", optional = true, features = ["derive"] } smallvec = "1.9.0" # Local -runtime-common = {path = "../common", default-features = false} +runtime-common = { path = "../common", default-features = false } # 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" } +clients-info = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +currency = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +security = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +staking = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +oracle = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +stellar-relay = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +fee = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +vault-registry = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +redeem = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +issue = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +nomination = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +replace = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-issue-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-oracle-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-redeem-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-replace-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +module-vault-registry-rpc-runtime-api = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } 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"} +pooled-rewards = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } +reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "bda384bcc6db3da88198c714851a261dcdea1063" } # Substrate -frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40"} -frame-executive = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -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"} -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"} -pallet-bounties = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-child-bounties = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-contracts = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-contracts-primitives = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-democracy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-identity = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-preimage = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-proxy = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-insecure-randomness-collective-flip = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-inherents = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-offchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-transaction-pool = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} -sp-version = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40"} +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +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" } +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" } +pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } # Open Runtime Module Library -orml-asset-registry = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } -orml-currencies = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } -orml-traits = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } -orml-tokens = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } +orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } +orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.40" } orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.40" } orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.40" } # KILT -parachain-staking = {path = "../../pallets/parachain-staking", default-features = false} +parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } -orml-currencies-allowance-extension = {path = "../../pallets/orml-currencies-allowance-extension", default-features = false} +orml-currencies-allowance-extension = { path = "../../pallets/orml-currencies-allowance-extension", default-features = false } # DIA -dia-oracle = {git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40"} -dia-oracle-runtime-api = {git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40"} +dia-oracle = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } +dia-oracle-runtime-api = { git = "https://github.com/pendulum-chain/oracle-pallet", default-features = false, branch = "polkadot-v0.9.40" } # Pendulum Pallets -vesting-manager = {path = "../../pallets/vesting-manager", default-features = false} +vesting-manager = { path = "../../pallets/vesting-manager", default-features = false } # Polkadot -pallet-xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} -polkadot-parachain = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} -polkadot-runtime-common = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} -xcm = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} -xcm-builder = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} -xcm-executor = {git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40"} +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } # Cumulus -cumulus-pallet-aura-ext = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-pallet-parachain-system = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-pallet-session-benchmarking = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-pallet-xcm = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-pallet-xcmp-queue = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-primitives-timestamp = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} -parachain-info = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"} +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } +parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40" } # Zenlink zenlink-protocol = { git = "https://github.com/pendulum-chain/Zenlink-DEX-Module", default-features = false, branch = "polkadot-v0.9.40-protocol" } @@ -142,198 +142,186 @@ bifrost-farming-rpc-runtime-api = { git = "https://github.com/pendulum-chain/bif [features] default = [ - "std", + "std", ] std = [ - "codec/std", - "log/std", - "scale-info/std", - "serde", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "cumulus-primitives-utility/std", - "dia-oracle/std", - "dia-oracle-runtime-api/std", - "frame-executive/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "frame-try-runtime/std", - "module-pallet-staking-rpc-runtime-api/std", - "module-oracle-rpc-runtime-api/std", - "orml-asset-registry/std", - "orml-currencies/std", - "orml-traits/std", - "orml-tokens/std", - "orml-xtokens/std", - "orml-xcm-support/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-bounties/std", - "pallet-child-bounties/std", - "pallet-collective/std", - "pallet-contracts/std", - "pallet-contracts-primitives/std", - "pallet-democracy/std", - "pallet-identity/std", - "pallet-multisig/std", - "pallet-preimage/std", - "pallet-proxy/std", - "pallet-insecure-randomness-collective-flip/std", - "pallet-scheduler/std", - "pallet-session/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-treasury/std", - "pallet-utility/std", - "pallet-vesting/std", - "pallet-xcm/std", - "parachain-info/std", - "polkadot-parachain/std", - "polkadot-runtime-common/std", - "runtime-common/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/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", - - #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", + "codec/std", + "log/std", + "scale-info/std", + "serde", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", + "dia-oracle/std", + "dia-oracle-runtime-api/std", + "frame-executive/std", + "frame-support/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "frame-try-runtime/std", + "module-pallet-staking-rpc-runtime-api/std", + "module-oracle-rpc-runtime-api/std", + "orml-asset-registry/std", + "orml-currencies/std", + "orml-traits/std", + "orml-tokens/std", + "orml-xtokens/std", + "orml-xcm-support/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-bounties/std", + "pallet-child-bounties/std", + "pallet-collective/std", + "pallet-contracts/std", + "pallet-contracts-primitives/std", + "pallet-democracy/std", + "pallet-identity/std", + "pallet-multisig/std", + "pallet-preimage/std", + "pallet-proxy/std", + "pallet-insecure-randomness-collective-flip/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-timestamp/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", + "pallet-treasury/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-xcm/std", + "parachain-info/std", + "polkadot-parachain/std", + "polkadot-runtime-common/std", + "runtime-common/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/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", + #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", - - "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" + "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" ] try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime", - "frame-system/try-runtime", - "parachain-info/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-aura/try-runtime", - "pallet-authorship/try-runtime", - "pallet-balances/try-runtime", - "pallet-bounties/try-runtime", - "pallet-child-bounties/try-runtime", - "pallet-collective/try-runtime", - "pallet-contracts/try-runtime", - "pallet-democracy/try-runtime", - "pallet-identity/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", - "pallet-transaction-payment/try-runtime", - "pallet-treasury/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", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - - "orml-asset-registry/try-runtime", - "orml-currencies/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", + "frame-executive/try-runtime", + "frame-try-runtime", + "frame-system/try-runtime", + "parachain-info/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-collective/try-runtime", + "pallet-contracts/try-runtime", + "pallet-democracy/try-runtime", + "pallet-identity/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", + "pallet-transaction-payment/try-runtime", + "pallet-treasury/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", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "orml-asset-registry/try-runtime", + "orml-currencies/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", ] \ No newline at end of file diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index b86e10369..12fcf51d1 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -93,6 +93,7 @@ use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; use module_oracle_rpc_runtime_api::BalanceWrapper; use orml_currencies::BasicCurrencyAdapter; use orml_traits::{currency::MutationHooks, parameter_type_with_key}; + const CONTRACTS_DEBUG_OUTPUT: bool = true; #[cfg(any(feature = "std", test))] @@ -222,6 +223,7 @@ impl Convert> for ConvertMoment { /// - Setting it to `0` will essentially disable the weight fee. /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. pub struct WeightToFee; + impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { @@ -247,7 +249,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("pendulum"), impl_name: create_runtime_str!("pendulum"), authoring_version: 1, - spec_version: 12, + spec_version: 13, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 10, @@ -322,6 +324,7 @@ parameter_types! { } pub struct BaseFilter; + impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { match call { @@ -477,6 +480,7 @@ parameter_types! { type NegativeImbalance = >::NegativeImbalance; pub struct DealWithFees; + impl OnUnbalanced for DealWithFees { fn on_unbalanceds(mut fees_then_tips: impl Iterator) { if let Some(mut fees) = fees_then_tips.next() { @@ -630,6 +634,7 @@ parameter_types! { } type CouncilCollective = pallet_collective::Instance1; + impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -649,6 +654,7 @@ parameter_types! { } type TechnicalCollective = pallet_collective::Instance2; + impl pallet_collective::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -789,6 +795,7 @@ pub fn get_all_module_accounts() -> Vec { } pub struct DustRemovalWhitelist; + impl Contains for DustRemovalWhitelist { fn contains(a: &AccountId) -> bool { get_all_module_accounts().contains(a) @@ -796,6 +803,7 @@ impl Contains for DustRemovalWhitelist { } pub struct CurrencyHooks(PhantomData); + impl MutationHooks for CurrencyHooks { @@ -1139,6 +1147,7 @@ impl orml_traits::DataProvider for DataFeederBenchmark { impl oracle::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = oracle::SubstrateWeight; + type DecimalsLookup = spacewalk_primitives::PendulumDecimalsLookup; type DataProvider = DataProviderImpl; #[cfg(feature = "runtime-benchmarks")] type DataFeeder = MockDataFeeder; From c9bae73f427accce3c23c68db2bb39f58aff023a Mon Sep 17 00:00:00 2001 From: "B. Yap" <2826165+b-yap@users.noreply.github.com> Date: Mon, 26 Feb 2024 21:55:05 +0800 Subject: [PATCH 14/15] 423 add treasury buyout extension pallet to amplitude runtime (#424) * add the treasury-buyout-extension pallet * set the minamounttobuyout https://github.com/pendulum-chain/tasks/issues/198#issue-2070193524 * add a mock `DataProviderImpl` * set sellfee to 5% * https://github.com/pendulum-chain/pendulum/actions/runs/8006791620/job/21869341911?pr=424#step:8:1983 --- runtime/amplitude/Cargo.toml | 21 +++--- runtime/amplitude/src/lib.rs | 120 ++++++++++++++++++++++++++++++++--- 2 files changed, 123 insertions(+), 18 deletions(-) diff --git a/runtime/amplitude/Cargo.toml b/runtime/amplitude/Cargo.toml index cf776d086..c2c96240c 100644 --- a/runtime/amplitude/Cargo.toml +++ b/runtime/amplitude/Cargo.toml @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } [dependencies] +cfg-if = "1.0.0" codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.3.4", optional = true } log = { version = "0.4.17", default-features = false } @@ -104,8 +105,8 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu # KILT parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } -orml-currencies-allowance-extension = { path = "../../pallets/orml-currencies-allowance-extension", default-features = false } - +orml-currencies-allowance-extension = {path = "../../pallets/orml-currencies-allowance-extension", default-features = false} +treasury-buyout-extension = {path = "../../pallets/treasury-buyout-extension", default-features = false} # Pendulum Pallets vesting-manager = { path = "../../pallets/vesting-manager", default-features = false } @@ -237,10 +238,12 @@ 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", + # custom libraries from pendulum + "orml-currencies-allowance-extension/std", + "treasury-buyout-extension/std", + "parachain-staking/std", + "vesting-manager/std", + ] runtime-benchmarks = [ @@ -266,7 +269,8 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "runtime-common/runtime-benchmarks", - "orml-currencies-allowance-extension/runtime-benchmarks" + "orml-currencies-allowance-extension/runtime-benchmarks", + "treasury-buyout-extension/runtime-benchmarks" ] try-runtime = [ @@ -321,7 +325,8 @@ try-runtime = [ "reward-distribution/try-runtime", "dia-oracle/try-runtime", "orml-currencies-allowance-extension/try-runtime", + "treasury-buyout-extension/try-runtime", "vesting-manager/try-runtime", "bifrost-farming/try-runtime", "zenlink-protocol/try-runtime", -] \ No newline at end of file +] diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index 83fbd31d1..eaf209655 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -29,14 +29,16 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, + One, Zero, }, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, DispatchError, FixedPointNumber, SaturatedConversion, + ApplyExtrinsicResult, DispatchError, FixedPointNumber, FixedU128, SaturatedConversion, }; const CONTRACTS_DEBUG_OUTPUT: bool = true; -use sp_std::{marker::PhantomData, prelude::*}; +use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; + #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -85,6 +87,7 @@ pub use nomination::Event as NominationEvent; use oracle::{ dia, dia::{DiaOracleAdapter, NativeCurrencyKey, XCMCurrencyConversion}, + OracleKey, }; pub use redeem::{Event as RedeemEvent, RedeemRequest}; pub use replace::{Event as ReplaceEvent, ReplaceRequest}; @@ -135,6 +138,7 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + treasury_buyout_extension::CheckBuyout, ); /// Unchecked extrinsic type as expected by this runtime. @@ -183,14 +187,30 @@ impl XCMCurrencyConversion for AmplitudeDiaOracleKeyConverter { } } -type DataProviderImpl = DiaOracleAdapter< - DiaOracleModule, - UnsignedFixedPoint, - Moment, - dia::DiaOracleKeyConvertor, - ConvertPrice, - ConvertMoment, ->; +cfg_if::cfg_if! { + if #[cfg(feature = "runtime-benchmarks")] { + use oracle::testing_utils::{ + MockConvertMoment, MockConvertPrice, MockDiaOracle, MockOracleKeyConvertor, + }; + type DataProviderImpl = DiaOracleAdapter< + MockDiaOracle, + UnsignedFixedPoint, + Moment, + MockOracleKeyConvertor, + MockConvertPrice, + MockConvertMoment, + >; + } else { + type DataProviderImpl = DiaOracleAdapter< + DiaOracleModule, + UnsignedFixedPoint, + Moment, + dia::DiaOracleKeyConvertor, + ConvertPrice, + ConvertMoment, + >; + } +} pub struct ConvertPrice; @@ -371,6 +391,7 @@ impl Contains for BaseFilter { RuntimeCall::TokenAllowance(_) | RuntimeCall::AssetRegistry(_) | RuntimeCall::Proxy(_) | + RuntimeCall::TreasuryBuyoutExtension(_) | RuntimeCall::RewardDistribution(_) => true, // All pallets are allowed, but exhaustive match is defensive // in the case of adding new pallets. @@ -1056,6 +1077,7 @@ where frame_system::CheckNonce::::from(index), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(tip), + treasury_buyout_extension::CheckBuyout::::new(), ); let raw_payload = SignedPayload::new(call, extra).ok()?; @@ -1315,6 +1337,82 @@ impl orml_currencies_allowance_extension::Config for Runtime { type MaxAllowedCurrencies = ConstU32<256>; } +pub struct OraclePriceGetter(Oracle); + +impl treasury_buyout_extension::PriceGetter for OraclePriceGetter { + #[cfg(not(feature = "runtime-benchmarks"))] + fn get_price(currency_id: CurrencyId) -> Result + where + FixedNumber: FixedPointNumber + One + Zero + Debug + TryFrom, + { + let key = OracleKey::ExchangeRate(currency_id); + let asset_price = Oracle::get_price(key.clone())?; + + let converted_asset_price = FixedNumber::try_from(asset_price); + + match converted_asset_price { + Ok(price) => Ok(price), + Err(_) => Err(DispatchError::Other("Failed to convert price")), + } + } + + #[cfg(feature = "runtime-benchmarks")] + fn get_price(currency_id: CurrencyId) -> Result + where + FixedNumber: FixedPointNumber + One + Zero + Debug + TryFrom, + { + // Forcefully set chain status to running when benchmarking so that the oracle doesn't fail + Security::set_status(StatusCode::Running); + + let key = OracleKey::ExchangeRate(currency_id); + + // Attempt to get the price once and use the result to decide if feeding a value is necessary + match Oracle::get_price(key.clone()) { + Ok(asset_price) => { + // If the price is successfully retrieved, use it directly + let converted_asset_price = FixedNumber::try_from(asset_price) + .map_err(|_| DispatchError::Other("Failed to convert price"))?; + Ok(converted_asset_price) + }, + Err(_) => { + // Price not found, feed the default value + let rate = FixedU128::checked_from_rational(100, 1).expect("This is a valid ratio"); + // Account used for feeding values + let account = AccountId::from([0u8; 32]); + Oracle::feed_values(account, vec![(key.clone(), rate)])?; + + // If feeding was successful, just use the feeded price to spare a read + let converted_asset_price = FixedNumber::try_from(rate) + .map_err(|_| DispatchError::Other("Failed to convert price"))?; + Ok(converted_asset_price) + }, + } + } +} + +parameter_types! { + pub const SellFee: Permill = Permill::from_percent(5); + pub const MinAmountToBuyout: Balance = 10 * MILLIUNIT; // 0.01 AMPE or 10_000_000_000 + // 24 hours in blocks (where average block time is 12 seconds) + pub const BuyoutPeriod: u32 = 7200; + // Maximum number of allowed currencies for buyout + pub const MaxAllowedBuyoutCurrencies: u32 = 20; +} + +impl treasury_buyout_extension::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Currencies; + type TreasuryAccount = AmplitudeTreasuryAccount; + type BuyoutPeriod = BuyoutPeriod; + type SellFee = SellFee; + type PriceGetter = OraclePriceGetter; + type MinAmountToBuyout = MinAmountToBuyout; + type MaxAllowedBuyoutCurrencies = MaxAllowedBuyoutCurrencies; + type WeightInfo = treasury_buyout_extension::default_weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type RelayChainCurrencyId = RelayChainCurrencyId; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -1391,6 +1489,7 @@ construct_runtime!( RewardDistribution: reward_distribution::{Pallet, Call, Storage, Event} = 73, TokenAllowance: orml_currencies_allowance_extension::{Pallet, Storage, Call, Event} = 80, + TreasuryBuyoutExtension: treasury_buyout_extension::{Pallet, Storage, Call, Event} = 82, Farming: farming::{Pallet, Call, Storage, Event} = 90, @@ -1429,6 +1528,7 @@ mod benches { [pallet_xcm, PolkadotXcm] [orml_currencies_allowance_extension, TokenAllowance] + [treasury_buyout_extension, TreasuryBuyoutExtension] ); } From 4dda8b62489b553ace5a4ae536d240c0f7f24fd0 Mon Sep 17 00:00:00 2001 From: Marcel Ebert Date: Wed, 28 Feb 2024 10:19:58 +0100 Subject: [PATCH 15/15] Bump Amplitude `spec_version` to 14 (#427) Bump `spec_version` to 14 --- runtime/amplitude/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index eaf209655..3814c754b 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -268,7 +268,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("amplitude"), impl_name: create_runtime_str!("amplitude"), authoring_version: 1, - spec_version: 13, + spec_version: 14, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 13,