From 4764534f9711ece825e640a852a4dd9f98963dd6 Mon Sep 17 00:00:00 2001 From: Muhammad-Jibril Date: Fri, 3 Sep 2021 04:08:18 +0800 Subject: [PATCH] settmint remnence to setmint --- README.md | 2 +- lib-serml/serp/serp-treasury/src/lib.rs | 2 +- lib-serml/setmint/setmint-engine/src/lib.rs | 14 +-- lib-serml/setmint/setmint-engine/src/mock.rs | 8 +- lib-serml/setmint/setmint-engine/src/tests.rs | 22 ++-- lib-serml/setmint/setmint-gateway/src/lib.rs | 14 +-- lib-serml/setmint/setmint-gateway/src/mock.rs | 10 +- .../setmint/setmint-gateway/src/tests.rs | 48 ++++---- lib-serml/setmint/setmint-manager/src/lib.rs | 6 +- lib-serml/setmint/setmint-manager/src/mock.rs | 6 +- .../setmint/setmint-manager/src/tests.rs | 110 +++++++++--------- node/service/src/chain_spec/newrome.rs | 2 +- .../src/benchmarking/setmint_manager.rs | 14 +-- runtime/newrome/src/lib.rs | 16 +-- runtime/setheum/src/lib.rs | 16 +-- 15 files changed, 145 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index f55c44c0a..727bed022 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ In The SERP and Setheum lingua, I coined these terms: * serpup: to increase the supply of a Setheum stablecurrency at its serping point. * serpdown: to decrease the supply of a Setheum stablecurrency at its serping point. -3. [The SetMint](./lib-serml/setmint) - The Settmint is partly inspired by the Maker Protocol (MakerDAO), except that SetMint is on a very different principle of Setheum that ought not to be violated. +3. [The SetMint](./lib-serml/setmint) - The Setmint is partly inspired by the Maker Protocol (MakerDAO), except that SetMint is on a very different principle of Setheum that ought not to be violated. SetMint is not a CDP but quite similar, as users can hold, authorize & transfer positions, users can reserve the Setter (SETR) to mint any SetCurrency of their choice without the need for over-collateralization, debt, interest rates, liquidation, or even stability fees. The stability of the Currencies is handles by the SERP, and the the Setter used as the reserve currency is also a SetCurrency (Setheum System Stablecoin) therefore eliminating position volatility and the risk of liquidation as all risk parameters have been eliminated with the Setter and Setheum's strong principle on the matters of the SetMint and Setheum's Monetary Policy. This is one of the reasons I see Setheum as one of the most Sophisticated Advanced Economic Systems yet so simple, easy to use and understand, and even easier to get started. diff --git a/lib-serml/serp/serp-treasury/src/lib.rs b/lib-serml/serp/serp-treasury/src/lib.rs index 7f9247253..e82fd821a 100644 --- a/lib-serml/serp/serp-treasury/src/lib.rs +++ b/lib-serml/serp/serp-treasury/src/lib.rs @@ -20,7 +20,7 @@ //! //! ## Overview //! -//! SERP Treasury manages the Settmint, and handle excess serplus +//! SERP Treasury manages the Setmint, and handle excess serplus //! and stabilize SetCurrencies standards timely in order to keep the //! system healthy. It manages the TES (Token Elasticity of Supply). diff --git a/lib-serml/setmint/setmint-engine/src/lib.rs b/lib-serml/setmint/setmint-engine/src/lib.rs index 90769ca2d..0906f6bac 100644 --- a/lib-serml/setmint/setmint-engine/src/lib.rs +++ b/lib-serml/setmint/setmint-engine/src/lib.rs @@ -16,13 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! # Settmint Engine Module +//! # Setmint Engine Module //! //! ## Overview //! -//! The core module of the Settmint protocol. -//! The Settmint engine is responsible for handling -//! internal processes of Settmint. +//! The core module of the Setmint protocol. +//! The Setmint engine is responsible for handling +//! internal processes of Setmint. #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] @@ -48,7 +48,7 @@ mod tests; pub use standard_exchange_rate_convertor::StandardExchangeRateConvertor; pub use module::*; -pub type SettmintOf = setmint::Pallet; +pub type SetmintOf = setmint::Pallet; #[frame_support::pallet] pub mod module { @@ -78,7 +78,7 @@ pub mod module { pub enum Error { /// Invalid reserve type. InvalidStandardType, - /// Remaining standard value in Settmint below the dust amount + /// Remaining standard value in Setmint below the dust amount RemainStandardValueTooSmall, /// Feed price is invalid InvalidFeedPrice, @@ -131,7 +131,7 @@ impl Pallet { reserve_adjustment: Amount, standard_adjustment: Amount, ) -> DispatchResult { - >::adjust_position(who, currency_id, reserve_adjustment, standard_adjustment)?; + >::adjust_position(who, currency_id, reserve_adjustment, standard_adjustment)?; Ok(()) } } diff --git a/lib-serml/setmint/setmint-engine/src/mock.rs b/lib-serml/setmint/setmint-engine/src/mock.rs index 3be304f35..5f4b957d2 100644 --- a/lib-serml/setmint/setmint-engine/src/mock.rs +++ b/lib-serml/setmint/setmint-engine/src/mock.rs @@ -138,7 +138,7 @@ impl orml_currencies::Config for Runtime { } parameter_types! { - pub const SettmintManagerPalletId: PalletId = PalletId(*b"set/mint"); + pub const SetmintManagerPalletId: PalletId = PalletId(*b"set/mint"); } impl setmint::Config for Runtime { @@ -148,7 +148,7 @@ impl setmint::Config for Runtime { type StandardCurrencyIds = StandardCurrencyIds; type GetReserveCurrencyId = GetReserveCurrencyId; type SerpTreasury = SerpTreasuryModule; - type PalletId = SettmintManagerPalletId; + type PalletId = SetmintManagerPalletId; } thread_local! { @@ -331,11 +331,11 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Storage, Config, Event}, - SettmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event}, + SetmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event}, SerpTreasuryModule: serp_treasury::{Pallet, Storage, Event}, Currencies: orml_currencies::{Pallet, Call, Event}, Tokens: orml_tokens::{Pallet, Storage, Event, Config}, - SettmintManagerModule: setmint::{Pallet, Storage, Call, Event}, + SetmintManagerModule: setmint::{Pallet, Storage, Call, Event}, PalletBalances: pallet_balances::{Pallet, Call, Storage, Event}, SetheumDEX: setheum_dex::{Pallet, Storage, Call, Event, Config}, } diff --git a/lib-serml/setmint/setmint-engine/src/tests.rs b/lib-serml/setmint/setmint-engine/src/tests.rs index e820219a4..9c52a40ef 100644 --- a/lib-serml/setmint/setmint-engine/src/tests.rs +++ b/lib-serml/setmint/setmint-engine/src/tests.rs @@ -29,7 +29,7 @@ use orml_traits::MultiCurrency; fn get_standard_exchange_rate_work() { ExtBuilder::default().build().execute_with(|| { assert_eq!( - SettmintEngineModule::get_standard_exchange_rate(SETR), + SetmintEngineModule::get_standard_exchange_rate(SETR), DefaultStandardExchangeRate::get() ); }); @@ -39,7 +39,7 @@ fn get_standard_exchange_rate_work() { fn calculate_reserve_ratio_work() { ExtBuilder::default().build().execute_with(|| { assert_eq!( - SettmintEngineModule::calculate_reserve_ratio(SETR, 100, 50, Price::saturating_from_rational(1, 1)), + SetmintEngineModule::calculate_reserve_ratio(SETR, 100, 50, Price::saturating_from_rational(1, 1)), Ratio::saturating_from_rational(100, 50) ); }); @@ -50,18 +50,18 @@ fn adjust_position_work() { ExtBuilder::default().build().execute_with(|| { assert_eq!(Currencies::free_balance(SETR, &ALICE), 1000); assert_eq!(Currencies::free_balance(SETUSD, &ALICE), 0); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).standard, 0); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).reserve, 0); - assert_ok!(SettmintEngineModule::adjust_position(&ALICE, SETUSD, 100, 50)); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).standard, 0); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).reserve, 0); + assert_ok!(SetmintEngineModule::adjust_position(&ALICE, SETUSD, 100, 50)); assert_eq!(Currencies::free_balance(SETR, &ALICE), 900); assert_eq!(Currencies::free_balance(SETUSD, &ALICE), 50); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).standard, 50); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).reserve, 100); - assert_eq!(SettmintEngineModule::adjust_position(&ALICE, SETUSD, 0, 20).is_ok(), true); - assert_ok!(SettmintEngineModule::adjust_position(&ALICE, SETUSD, 0, -20)); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).standard, 50); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).reserve, 100); + assert_eq!(SetmintEngineModule::adjust_position(&ALICE, SETUSD, 0, 20).is_ok(), true); + assert_ok!(SetmintEngineModule::adjust_position(&ALICE, SETUSD, 0, -20)); assert_eq!(Currencies::free_balance(SETR, &ALICE), 900); assert_eq!(Currencies::free_balance(SETUSD, &ALICE), 50); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).standard, 50); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).reserve, 100); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).standard, 50); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).reserve, 100); }); } diff --git a/lib-serml/setmint/setmint-gateway/src/lib.rs b/lib-serml/setmint/setmint-gateway/src/lib.rs index 9375442b5..f21e0bf2d 100644 --- a/lib-serml/setmint/setmint-gateway/src/lib.rs +++ b/lib-serml/setmint/setmint-gateway/src/lib.rs @@ -16,13 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! # SettmintGateway Module +//! # SetmintGateway Module //! //! ## Overview //! -//! The entry of the Settmint protocol for users, user can manipulate their Settmint +//! The entry of the Setmint protocol for users, user can manipulate their Setmint //! position to setter/payback, and can also authorize others to manage the their -//! Settmint under specific reserve type. +//! Setmint under specific reserve type. #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] @@ -116,12 +116,12 @@ pub mod module { /// /// - `currency_id`: standard currency id. /// - `reserve_adjustment`: signed amount, positive means to deposit - /// reserve currency into Settmint, negative means withdraw reserve - /// currency from Settmint. + /// reserve currency into Setmint, negative means withdraw reserve + /// currency from Setmint. /// - `standard_adjustment`: signed amount, positive means to issue some /// amount of `currency_id` to caller according to the standard adjustment, /// negative means caller will payback some amount of `currency_id` (standard setcurrency) to - /// Settmint according to to the standard adjustment. + /// Setmint according to to the standard adjustment. #[pallet::weight(::WeightInfo::adjust_position())] #[transactional] pub fn adjust_position( @@ -135,7 +135,7 @@ pub mod module { Ok(().into()) } - /// Transfer the whole Settmint of `from` under `currency_id` to caller's Settmint + /// Transfer the whole Setmint of `from` under `currency_id` to caller's Setmint /// under the same `currency_id`, caller must have the authorization of /// `from` for the specific STANDARD type /// diff --git a/lib-serml/setmint/setmint-gateway/src/mock.rs b/lib-serml/setmint/setmint-gateway/src/mock.rs index 80f9de609..edd4b4fe4 100644 --- a/lib-serml/setmint/setmint-gateway/src/mock.rs +++ b/lib-serml/setmint/setmint-gateway/src/mock.rs @@ -297,7 +297,7 @@ impl setmint_engine::Config for Runtime { } parameter_types! { - pub const SettmintManagerPalletId: PalletId = PalletId(*b"set/mint"); + pub const SetmintManagerPalletId: PalletId = PalletId(*b"set/mint"); } impl setmint_manager::Config for Runtime { @@ -307,7 +307,7 @@ impl setmint_manager::Config for Runtime { type StandardCurrencyIds = StandardCurrencyIds; type GetReserveCurrencyId = GetReserveCurrencyId; type SerpTreasury = SerpTreasuryModule; - type PalletId = SettmintManagerPalletId; + type PalletId = SetmintManagerPalletId; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -331,13 +331,13 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Storage, Config, Event}, - SettmintGateway: setmint_gateway::{Pallet, Storage, Call, Event}, + SetmintGateway: setmint_gateway::{Pallet, Storage, Call, Event}, Tokens: orml_tokens::{Pallet, Storage, Event, Config}, PalletBalances: pallet_balances::{Pallet, Call, Storage, Event}, Currencies: orml_currencies::{Pallet, Call, Event}, - SettmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event}, + SetmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event}, SerpTreasuryModule: serp_treasury::{Pallet, Storage, Event}, - SettmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event}, + SetmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event}, SetheumDEX: setheum_dex::{Pallet, Storage, Call, Event, Config}, } ); diff --git a/lib-serml/setmint/setmint-gateway/src/tests.rs b/lib-serml/setmint/setmint-gateway/src/tests.rs index 87bd69182..24073621c 100644 --- a/lib-serml/setmint/setmint-gateway/src/tests.rs +++ b/lib-serml/setmint/setmint-gateway/src/tests.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Unit tests for the SettmintGateway module. +//! Unit tests for the SetmintGateway module. #![cfg(test)] @@ -28,11 +28,11 @@ use mock::{Event, *}; fn authorize_should_work() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); - assert_ok!(SettmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); + assert_ok!(SetmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); - System::assert_last_event(Event::SettmintGateway(crate::Event::Authorization(ALICE, BOB, SETUSD))); + System::assert_last_event(Event::SetmintGateway(crate::Event::Authorization(ALICE, BOB, SETUSD))); - assert_ok!(SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD)); + assert_ok!(SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD)); }); } @@ -40,14 +40,14 @@ fn authorize_should_work() { fn unauthorize_should_work() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); - assert_ok!(SettmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); - assert_ok!(SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD)); - assert_ok!(SettmintGateway::unauthorize(Origin::signed(ALICE), SETUSD, BOB)); + assert_ok!(SetmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); + assert_ok!(SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD)); + assert_ok!(SetmintGateway::unauthorize(Origin::signed(ALICE), SETUSD, BOB)); - System::assert_last_event(Event::SettmintGateway(crate::Event::UnAuthorization(ALICE, BOB, SETUSD))); + System::assert_last_event(Event::SetmintGateway(crate::Event::UnAuthorization(ALICE, BOB, SETUSD))); assert_noop!( - SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD), + SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD), Error::::NoPermission ); }); @@ -57,18 +57,18 @@ fn unauthorize_should_work() { fn unauthorize_all_should_work() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); - assert_ok!(SettmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); - assert_ok!(SettmintGateway::authorize(Origin::signed(ALICE), SETUSD, CAROL)); - assert_ok!(SettmintGateway::unauthorize_all(Origin::signed(ALICE))); + assert_ok!(SetmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); + assert_ok!(SetmintGateway::authorize(Origin::signed(ALICE), SETUSD, CAROL)); + assert_ok!(SetmintGateway::unauthorize_all(Origin::signed(ALICE))); - System::assert_last_event(Event::SettmintGateway(crate::Event::UnAuthorizationAll(ALICE))); + System::assert_last_event(Event::SetmintGateway(crate::Event::UnAuthorizationAll(ALICE))); assert_noop!( - SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD), + SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD), Error::::NoPermission ); assert_noop!( - SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD), + SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD), Error::::NoPermission ); }); @@ -77,11 +77,11 @@ fn unauthorize_all_should_work() { #[test] fn transfer_position_from_should_work() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(SettmintGateway::adjust_position(Origin::signed(ALICE), SETUSD, 100, 50)); - assert_ok!(SettmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); - assert_ok!(SettmintGateway::transfer_position_from(Origin::signed(BOB), SETUSD, ALICE)); - assert_eq!(SettmintManagerModule::positions(SETUSD, BOB).reserve, 100); - assert_eq!(SettmintManagerModule::positions(SETUSD, BOB).standard, 50); + assert_ok!(SetmintGateway::adjust_position(Origin::signed(ALICE), SETUSD, 100, 50)); + assert_ok!(SetmintGateway::authorize(Origin::signed(ALICE), SETUSD, BOB)); + assert_ok!(SetmintGateway::transfer_position_from(Origin::signed(BOB), SETUSD, ALICE)); + assert_eq!(SetmintManagerModule::positions(SETUSD, BOB).reserve, 100); + assert_eq!(SetmintManagerModule::positions(SETUSD, BOB).standard, 50); }); } @@ -89,7 +89,7 @@ fn transfer_position_from_should_work() { fn transfer_unauthorization_setters_should_not_work() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - SettmintGateway::transfer_position_from(Origin::signed(ALICE), SETUSD, BOB), + SetmintGateway::transfer_position_from(Origin::signed(ALICE), SETUSD, BOB), Error::::NoPermission, ); }); @@ -98,8 +98,8 @@ fn transfer_unauthorization_setters_should_not_work() { #[test] fn adjust_position_should_work() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(SettmintGateway::adjust_position(Origin::signed(ALICE), SETUSD, 100, 50)); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).reserve, 100); - assert_eq!(SettmintManagerModule::positions(SETUSD, ALICE).standard, 50); + assert_ok!(SetmintGateway::adjust_position(Origin::signed(ALICE), SETUSD, 100, 50)); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).reserve, 100); + assert_eq!(SetmintManagerModule::positions(SETUSD, ALICE).standard, 50); }); } diff --git a/lib-serml/setmint/setmint-manager/src/lib.rs b/lib-serml/setmint/setmint-manager/src/lib.rs index faa6a3cf8..b3adc40ec 100644 --- a/lib-serml/setmint/setmint-manager/src/lib.rs +++ b/lib-serml/setmint/setmint-manager/src/lib.rs @@ -16,11 +16,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! # SettmintManager Module +//! # SetmintManager Module //! //! ## Overview //! -//! SettmintManager module manages Settmint's reserve asset (Setter) +//! SetmintManager module manages Setmint's reserve asset (Setter) //! and the standards backed by the asset (SetCurrencies). #![cfg_attr(not(feature = "std"), no_std)] @@ -82,7 +82,7 @@ pub mod module { /// adjustment type SerpTreasury: SerpTreasury; - /// The setter's module id, keep all reserves of Settmint. + /// The setter's module id, keep all reserves of Setmint. #[pallet::constant] type PalletId: Get; } diff --git a/lib-serml/setmint/setmint-manager/src/mock.rs b/lib-serml/setmint/setmint-manager/src/mock.rs index 01f492d0d..3453534d1 100644 --- a/lib-serml/setmint/setmint-manager/src/mock.rs +++ b/lib-serml/setmint/setmint-manager/src/mock.rs @@ -298,7 +298,7 @@ parameter_types! { SETUSD, ]; pub const GetReserveCurrencyId: CurrencyId = SETR; - pub const SettmintManagerPalletId: PalletId = PalletId(*b"set/mint"); + pub const SetmintManagerPalletId: PalletId = PalletId(*b"set/mint"); } @@ -309,7 +309,7 @@ impl Config for Runtime { type StandardCurrencyIds = StandardCurrencyIds; type GetReserveCurrencyId = GetReserveCurrencyId; type SerpTreasury = SerpTreasuryModule; - type PalletId = SettmintManagerPalletId; + type PalletId = SetmintManagerPalletId; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -322,7 +322,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Storage, Config, Event}, - SettmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event}, + SetmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event}, Tokens: orml_tokens::{Pallet, Storage, Event, Config}, PalletBalances: pallet_balances::{Pallet, Call, Storage, Event}, Currencies: orml_currencies::{Pallet, Call, Event}, diff --git a/lib-serml/setmint/setmint-manager/src/tests.rs b/lib-serml/setmint/setmint-manager/src/tests.rs index b23ebfdcc..899b76918 100644 --- a/lib-serml/setmint/setmint-manager/src/tests.rs +++ b/lib-serml/setmint/setmint-manager/src/tests.rs @@ -27,12 +27,12 @@ use mock::{Event, *}; #[test] fn standards_key() { ExtBuilder::default().build().execute_with(|| { - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 0); - assert_ok!(SettmintManagerModule::adjust_position(&ALICE, SETEUR, 200, 200)); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 200); - assert_eq!(Currencies::free_balance(SETR, &SettmintManagerModule::account_id()), 100); - assert_ok!(SettmintManagerModule::adjust_position(&ALICE, SETEUR, -100, -100)); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 100); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 0); + assert_ok!(SetmintManagerModule::adjust_position(&ALICE, SETEUR, 200, 200)); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 200); + assert_eq!(Currencies::free_balance(SETR, &SetmintManagerModule::account_id()), 100); + assert_ok!(SetmintManagerModule::adjust_position(&ALICE, SETEUR, -100, -100)); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 100); }); } @@ -41,13 +41,13 @@ fn check_update_position_underflow_work() { ExtBuilder::default().build().execute_with(|| { // reserve underflow assert_noop!( - SettmintManagerModule::update_position(&ALICE, SETEUR, -100, 0), + SetmintManagerModule::update_position(&ALICE, SETEUR, -100, 0), ArithmeticError::Underflow, ); // standard underflow assert_noop!( - SettmintManagerModule::update_position(&ALICE, SETEUR, 0, -100), + SetmintManagerModule::update_position(&ALICE, SETEUR, 0, -100), ArithmeticError::Underflow, ); }); @@ -60,31 +60,31 @@ fn adjust_position_should_work() { assert_eq!(Currencies::free_balance(SETR, &ALICE), 1000); assert_eq!(Currencies::free_balance(SETR, &ALICE), 1000); - assert_eq!(Currencies::free_balance(SETEUR, &SettmintManagerModule::account_id()), 0); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).standard, 0); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).reserve, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); + assert_eq!(Currencies::free_balance(SETEUR, &SetmintManagerModule::account_id()), 0); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).standard, 0); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).reserve, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); assert_eq!(Currencies::free_balance(SETEUR, &ALICE), 1000); // success - assert_ok!(SettmintManagerModule::adjust_position(&ALICE, SETEUR, 500, 300)); + assert_ok!(SetmintManagerModule::adjust_position(&ALICE, SETEUR, 500, 300)); assert_eq!(Currencies::free_balance(SETR, &ALICE), 750); - assert_eq!(Currencies::free_balance(SETR, &SettmintManagerModule::account_id()), 250); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).standard, 300); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).reserve, 500); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 300); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 500); + assert_eq!(Currencies::free_balance(SETR, &SetmintManagerModule::account_id()), 250); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).standard, 300); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).reserve, 500); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 300); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 500); assert_eq!(Currencies::free_balance(SETEUR, &ALICE), 1150); - System::assert_last_event(Event::SettmintManagerModule(crate::Event::PositionUpdated(ALICE, SETEUR, 500, 300))); + System::assert_last_event(Event::SetmintManagerModule(crate::Event::PositionUpdated(ALICE, SETEUR, 500, 300))); // reserve_adjustment is negatives // remove module account. - assert_eq!(Currencies::total_balance(SETEUR, &SettmintManagerModule::account_id()), 0); - assert_eq!(System::account_exists(&SettmintManagerModule::account_id()), true); - assert_ok!(SettmintManagerModule::adjust_position(&ALICE, SETEUR, -500, 0)); - assert_eq!(Currencies::free_balance(SETEUR, &SettmintManagerModule::account_id()), 0); - assert_eq!(System::account_exists(&SettmintManagerModule::account_id()), true); + assert_eq!(Currencies::total_balance(SETEUR, &SetmintManagerModule::account_id()), 0); + assert_eq!(System::account_exists(&SetmintManagerModule::account_id()), true); + assert_ok!(SetmintManagerModule::adjust_position(&ALICE, SETEUR, -500, 0)); + assert_eq!(Currencies::free_balance(SETEUR, &SetmintManagerModule::account_id()), 0); + assert_eq!(System::account_exists(&SetmintManagerModule::account_id()), true); }); } @@ -92,57 +92,57 @@ fn adjust_position_should_work() { fn transfer_position_should_work() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); - assert_ok!(SettmintManagerModule::update_position(&ALICE, SETEUR, 400, 500)); - assert_ok!(SettmintManagerModule::update_position(&BOB, SETEUR, 100, 600)); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 500); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 400); - assert_eq!(SettmintManagerModule::positions(SETEUR, &BOB).standard, 600); - assert_eq!(SettmintManagerModule::positions(SETEUR, &BOB).reserve, 100); - - assert_ok!(SettmintManagerModule::transfer_position(&ALICE, &BOB, SETEUR)); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &BOB).standard, 1100); - assert_eq!(SettmintManagerModule::positions(SETEUR, &BOB).reserve, 500); - - System::assert_last_event(Event::SettmintManagerModule(crate::Event::TransferPosition(ALICE, BOB, SETEUR))); + assert_ok!(SetmintManagerModule::update_position(&ALICE, SETEUR, 400, 500)); + assert_ok!(SetmintManagerModule::update_position(&BOB, SETEUR, 100, 600)); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 500); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 400); + assert_eq!(SetmintManagerModule::positions(SETEUR, &BOB).standard, 600); + assert_eq!(SetmintManagerModule::positions(SETEUR, &BOB).reserve, 100); + + assert_ok!(SetmintManagerModule::transfer_position(&ALICE, &BOB, SETEUR)); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &BOB).standard, 1100); + assert_eq!(SetmintManagerModule::positions(SETEUR, &BOB).reserve, 500); + + System::assert_last_event(Event::SetmintManagerModule(crate::Event::TransferPosition(ALICE, BOB, SETEUR))); }); } #[test] fn update_position_should_work() { ExtBuilder::default().build().execute_with(|| { - assert_eq!(Currencies::free_balance(SETR, &SettmintManagerModule::account_id()), 0); + assert_eq!(Currencies::free_balance(SETR, &SetmintManagerModule::account_id()), 0); assert_eq!(Currencies::free_balance(SETR, &ALICE), 1000); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).standard, 0); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).reserve, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).standard, 0); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).reserve, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); assert_eq!(>::contains_key(SETEUR, &ALICE), false); let alice_ref_count_0 = System::consumers(&ALICE); - assert_ok!(SettmintManagerModule::update_position(&ALICE, SETEUR, 3000, 2000)); + assert_ok!(SetmintManagerModule::update_position(&ALICE, SETEUR, 3000, 2000)); // just update records - assert_eq!(SettmintManagerModule::total_positions(SETEUR).standard, 2000); - assert_eq!(SettmintManagerModule::total_positions(SETEUR).reserve, 3000); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 2000); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 3000); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).standard, 2000); + assert_eq!(SetmintManagerModule::total_positions(SETEUR).reserve, 3000); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 2000); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 3000); // increase ref count when open new position let alice_ref_count_1 = System::consumers(&ALICE); assert_eq!(alice_ref_count_1, alice_ref_count_0 + 1); // dot not manipulate balance - assert_eq!(Currencies::free_balance(SETR, &SettmintManagerModule::account_id()), 0); + assert_eq!(Currencies::free_balance(SETR, &SetmintManagerModule::account_id()), 0); assert_eq!(Currencies::free_balance(SETR, &ALICE), 1000); // should remove position storage if zero assert_eq!(>::contains_key(SETEUR, &ALICE), true); - assert_ok!(SettmintManagerModule::update_position(&ALICE, SETEUR, -3000, -2000)); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).standard, 0); - assert_eq!(SettmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); + assert_ok!(SetmintManagerModule::update_position(&ALICE, SETEUR, -3000, -2000)); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).standard, 0); + assert_eq!(SetmintManagerModule::positions(SETEUR, &ALICE).reserve, 0); assert_eq!(>::contains_key(SETEUR, &ALICE), false); // decrease ref count after remove position @@ -154,7 +154,7 @@ fn update_position_should_work() { #[test] fn total_reserve_works() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(Currencies::deposit(SETR, &SettmintManagerModule::account_id(), 10)); - assert_eq!(SettmintManagerModule::total_reserve(), 10); + assert_ok!(Currencies::deposit(SETR, &SetmintManagerModule::account_id(), 10)); + assert_eq!(SetmintManagerModule::total_reserve(), 10); }); } diff --git a/node/service/src/chain_spec/newrome.rs b/node/service/src/chain_spec/newrome.rs index d2603ae20..7247bb05c 100644 --- a/node/service/src/chain_spec/newrome.rs +++ b/node/service/src/chain_spec/newrome.rs @@ -388,7 +388,7 @@ fn newrome_genesis( ) -> newrome_runtime::GenesisConfig { use newrome_runtime::{ cent, dollar, get_all_module_accounts, SetheumOracleConfig, BabeConfig, Balance, - BalancesConfig, SettmintEngineConfig, SerpTreasuryConfig, DexConfig, + BalancesConfig, SetmintEngineConfig, SerpTreasuryConfig, DexConfig, EnabledTradingPairs, GeneralCouncilMembershipConfig, SetheumJuryMembershipConfig, GrandpaConfig, FinancialCouncilMembershipConfig, ExchangeCouncilMembershipConfig, IndicesConfig, NativeTokenExistentialDeposit, OperatorMembershipSetheumConfig, diff --git a/runtime/newrome/src/benchmarking/setmint_manager.rs b/runtime/newrome/src/benchmarking/setmint_manager.rs index 593b90b21..f46b3a4dd 100644 --- a/runtime/newrome/src/benchmarking/setmint_manager.rs +++ b/runtime/newrome/src/benchmarking/setmint_manager.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::{ - dollar, SetheumOracle, AccountId, Amount, SettmintEngine, StandardCurrencyIds, CurrencyId, SettmintGateway, Indices, Price, Rate, + dollar, SetheumOracle, AccountId, Amount, SetmintEngine, StandardCurrencyIds, CurrencyId, SetmintGateway, Indices, Price, Rate, Ratio, Runtime, SETUSD, SETR, }; @@ -50,7 +50,7 @@ runtime_benchmarks! { let caller: AccountId = account("caller", 0, SEED); let to: AccountId = account("to", 0, SEED); let to_lookup = Indices::unlookup(to); - SettmintGateway::authorize( + SetmintGateway::authorize( RawOrigin::Signed(caller.clone()).into(), SETR, to_lookup.clone() @@ -66,7 +66,7 @@ runtime_benchmarks! { let to_lookup = Indices::unlookup(to); for i in 0 .. c { - SettmintGateway::authorize( + SetmintGateway::authorize( RawOrigin::Signed(caller.clone()).into(), currency_ids[i as usize], to_lookup.clone(), @@ -81,7 +81,7 @@ runtime_benchmarks! { let currency_id: CurrencyId = StandardCurrencyIds::get()[0]; let reserve_price = Price::one(); // 1 USD let standard_value = 100 * dollar(SETUSD); - let standard_exchange_rate = SettmintEngine::get_standard_exchange_rate(currency_id); + let standard_exchange_rate = SetmintEngine::get_standard_exchange_rate(currency_id); let standard_amount = standard_exchange_rate.reciprocal().unwrap().saturating_mul_int(standard_value); let standard_amount: Amount = standard_amount.unique_saturated_into(); let reserve_value = 10 * standard_value; @@ -103,7 +103,7 @@ runtime_benchmarks! { let standard_value = 100 * dollar(SETUSD); - let standard_exchange_rate = SettmintEngine::get_standard_exchange_rate(currency_id); + let standard_exchange_rate = SetmintEngine::get_standard_exchange_rate(currency_id); let standard_amount = standard_exchange_rate.reciprocal().unwrap().saturating_mul_int(standard_value); let standard_amount: Amount = standard_amount.unique_saturated_into(); let reserve_value = 10 * standard_value; @@ -116,7 +116,7 @@ runtime_benchmarks! { SetheumOracle::feed_values(RawOrigin::Root.into(), vec![(currency_id, Price::one())])?; // initialize sender's setter - SettmintGateway::adjust_position( + SetmintGateway::adjust_position( RawOrigin::Signed(sender.clone()).into(), currency_id, reserve_amount.try_into().unwrap(), @@ -124,7 +124,7 @@ runtime_benchmarks! { )?; // authorize receiver - SettmintGateway::authorize( + SetmintGateway::authorize( RawOrigin::Signed(sender.clone()).into(), currency_id, receiver_lookup, diff --git a/runtime/newrome/src/lib.rs b/runtime/newrome/src/lib.rs index 6d15653db..1236806f0 100644 --- a/runtime/newrome/src/lib.rs +++ b/runtime/newrome/src/lib.rs @@ -155,7 +155,7 @@ impl_opaque_keys! { // Module accounts of runtime parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"set/trsy"); - pub const SettmintManagerPalletId: PalletId = PalletId(*b"set/mint"); + pub const SetmintManagerPalletId: PalletId = PalletId(*b"set/mint"); pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); pub const NftPalletId: PalletId = PalletId(*b"set/sNFT"); @@ -164,7 +164,7 @@ parameter_types! { pub fn get_all_module_accounts() -> Vec { vec![ TreasuryPalletId::get().into_account(), - SettmintManagerPalletId::get().into_account(), + SetmintManagerPalletId::get().into_account(), DexPalletId::get().into_account(), SerpTreasuryPalletId::get().into_account(), ZeroAccountId::get(), @@ -213,7 +213,7 @@ impl Filter for BaseCallFilter { // Serp Call::Prices(_) | Call::SerpTreasury(_) | // Serttmint - Call::SettmintGateway(_)| Call::SettmintEngine(_) + Call::SetmintGateway(_)| Call::SetmintEngine(_) ) } } @@ -965,7 +965,7 @@ impl setmint_manager::Config for Runtime { type StandardCurrencyIds = StandardCurrencyIds; type GetReserveCurrencyId = GetReserveCurrencyId; type SerpTreasury = SerpTreasury; - type PalletId = SettmintManagerPalletId; + type PalletId = SetmintManagerPalletId; } impl frame_system::offchain::CreateSignedTransaction for Runtime @@ -1549,10 +1549,10 @@ construct_runtime!( // Dex Dex: setheum_dex::{Pallet, Storage, Call, Event, Config} = 40, - // Settmint - SettmintEngine: setmint_engine::{Pallet, Storage, Call, Event, Config, ValidateUnsigned} = 41, - SettmintGateway: setmint_gateway::{Pallet, Storage, Call, Event} = 42, - SettmintManager: setmint_manager::{Pallet, Storage, Call, Event} = 43, + // Setmint + SetmintEngine: setmint_engine::{Pallet, Storage, Call, Event, Config, ValidateUnsigned} = 41, + SetmintGateway: setmint_gateway::{Pallet, Storage, Call, Event} = 42, + SetmintManager: setmint_manager::{Pallet, Storage, Call, Event} = 43, // Smart contracts // Setheum EVM (SEVM) diff --git a/runtime/setheum/src/lib.rs b/runtime/setheum/src/lib.rs index 3419fc8cb..0af7729a9 100644 --- a/runtime/setheum/src/lib.rs +++ b/runtime/setheum/src/lib.rs @@ -155,7 +155,7 @@ impl_opaque_keys! { // Module accounts of runtime parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"set/trsy"); - pub const SettmintManagerPalletId: PalletId = PalletId(*b"set/mint"); + pub const SetmintManagerPalletId: PalletId = PalletId(*b"set/mint"); pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); pub const NftPalletId: PalletId = PalletId(*b"set/sNFT"); @@ -164,7 +164,7 @@ parameter_types! { pub fn get_all_module_accounts() -> Vec { vec![ TreasuryPalletId::get().into_account(), - SettmintManagerPalletId::get().into_account(), + SetmintManagerPalletId::get().into_account(), DexPalletId::get().into_account(), SerpTreasuryPalletId::get().into_account(), ZeroAccountId::get(), @@ -213,7 +213,7 @@ impl Filter for BaseCallFilter { // Serp Call::Prices(_) | Call::SerpTreasury(_) | // Serttmint - Call::SettmintGateway(_)| Call::SettmintEngine(_) + Call::SetmintGateway(_)| Call::SetmintEngine(_) ) } } @@ -981,7 +981,7 @@ impl setmint_manager::Config for Runtime { type StandardCurrencyIds = StandardCurrencyIds; type GetReserveCurrencyId = GetReserveCurrencyId; type SerpTreasury = SerpTreasury; - type PalletId = SettmintManagerPalletId; + type PalletId = SetmintManagerPalletId; } impl frame_system::offchain::CreateSignedTransaction for Runtime @@ -1503,10 +1503,10 @@ construct_runtime!( // Dex Dex: setheum_dex::{Pallet, Storage, Call, Event, Config} = 40, - // Settmint - SettmintEngine: setmint_engine::{Pallet, Storage, Call, Event, Config, ValidateUnsigned} = 41, - SettmintGateway: setmint_gateway::{Pallet, Storage, Call, Event} = 42, - SettmintManager: setmint_manager::{Pallet, Storage, Call, Event} = 43, + // Setmint + SetmintEngine: setmint_engine::{Pallet, Storage, Call, Event, Config, ValidateUnsigned} = 41, + SetmintGateway: setmint_gateway::{Pallet, Storage, Call, Event} = 42, + SetmintManager: setmint_manager::{Pallet, Storage, Call, Event} = 43, // Smart contracts // Setheum EVM (SEVM)