Skip to content

Commit

Permalink
settmint remnence to setmint
Browse files Browse the repository at this point in the history
  • Loading branch information
balqaasem committed Sep 2, 2021
1 parent f283b53 commit 4764534
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 145 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib-serml/serp/serp-treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
14 changes: 7 additions & 7 deletions lib-serml/setmint/setmint-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! # 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)]
Expand All @@ -48,7 +48,7 @@ mod tests;
pub use standard_exchange_rate_convertor::StandardExchangeRateConvertor;
pub use module::*;

pub type SettmintOf<T> = setmint::Pallet<T>;
pub type SetmintOf<T> = setmint::Pallet<T>;

#[frame_support::pallet]
pub mod module {
Expand Down Expand Up @@ -78,7 +78,7 @@ pub mod module {
pub enum Error<T> {
/// 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,
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<T: Config> Pallet<T> {
reserve_adjustment: Amount,
standard_adjustment: Amount,
) -> DispatchResult {
<SettmintOf<T>>::adjust_position(who, currency_id, reserve_adjustment, standard_adjustment)?;
<SetmintOf<T>>::adjust_position(who, currency_id, reserve_adjustment, standard_adjustment)?;
Ok(())
}
}
8 changes: 4 additions & 4 deletions lib-serml/setmint/setmint-engine/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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! {
Expand Down Expand Up @@ -331,11 +331,11 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
SettmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event<T>},
SetmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event<T>},
SerpTreasuryModule: serp_treasury::{Pallet, Storage, Event<T>},
Currencies: orml_currencies::{Pallet, Call, Event<T>},
Tokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>},
SettmintManagerModule: setmint::{Pallet, Storage, Call, Event<T>},
SetmintManagerModule: setmint::{Pallet, Storage, Call, Event<T>},
PalletBalances: pallet_balances::{Pallet, Call, Storage, Event<T>},
SetheumDEX: setheum_dex::{Pallet, Storage, Call, Event<T>, Config<T>},
}
Expand Down
22 changes: 11 additions & 11 deletions lib-serml/setmint/setmint-engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
Expand All @@ -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)
);
});
Expand All @@ -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);
});
}
14 changes: 7 additions & 7 deletions lib-serml/setmint/setmint-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! # 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)]
Expand Down Expand Up @@ -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(<T as Config>::WeightInfo::adjust_position())]
#[transactional]
pub fn adjust_position(
Expand All @@ -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
///
Expand Down
10 changes: 5 additions & 5 deletions lib-serml/setmint/setmint-gateway/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<Runtime>;
Expand All @@ -331,13 +331,13 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
SettmintGateway: setmint_gateway::{Pallet, Storage, Call, Event<T>},
SetmintGateway: setmint_gateway::{Pallet, Storage, Call, Event<T>},
Tokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>},
PalletBalances: pallet_balances::{Pallet, Call, Storage, Event<T>},
Currencies: orml_currencies::{Pallet, Call, Event<T>},
SettmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event<T>},
SetmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event<T>},
SerpTreasuryModule: serp_treasury::{Pallet, Storage, Event<T>},
SettmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event<T>},
SetmintEngineModule: setmint_engine::{Pallet, Storage, Call, Event<T>},
SetheumDEX: setheum_dex::{Pallet, Storage, Call, Event<T>, Config<T>},
}
);
Expand Down
48 changes: 24 additions & 24 deletions lib-serml/setmint/setmint-gateway/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Unit tests for the SettmintGateway module.
//! Unit tests for the SetmintGateway module.
#![cfg(test)]

Expand All @@ -28,26 +28,26 @@ 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));
});
}

#[test]
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::<Runtime>::NoPermission
);
});
Expand All @@ -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::<Runtime>::NoPermission
);
assert_noop!(
SettmintGateway::check_authorization(&ALICE, &BOB, SETUSD),
SetmintGateway::check_authorization(&ALICE, &BOB, SETUSD),
Error::<Runtime>::NoPermission
);
});
Expand All @@ -77,19 +77,19 @@ 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);
});
}

#[test]
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::<Runtime>::NoPermission,
);
});
Expand All @@ -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);
});
}
6 changes: 3 additions & 3 deletions lib-serml/setmint/setmint-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! # 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)]
Expand Down Expand Up @@ -82,7 +82,7 @@ pub mod module {
/// adjustment
type SerpTreasury: SerpTreasury<Self::AccountId, Balance = Balance, CurrencyId = CurrencyId>;

/// 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<PalletId>;
}
Expand Down
6 changes: 3 additions & 3 deletions lib-serml/setmint/setmint-manager/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

}

Expand All @@ -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<Runtime>;
Expand All @@ -322,7 +322,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
SettmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event<T>},
SetmintManagerModule: setmint_manager::{Pallet, Storage, Call, Event<T>},
Tokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>},
PalletBalances: pallet_balances::{Pallet, Call, Storage, Event<T>},
Currencies: orml_currencies::{Pallet, Call, Event<T>},
Expand Down
Loading

0 comments on commit 4764534

Please sign in to comment.