Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serp dinar #537

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 64 additions & 27 deletions README.md

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions lib-serml/serp/serp-ocw/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,14 @@ impl SerpTreasury<AccountId> for MockSerpTreasury {
unimplemented!()
}

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(
_amount: Balance,
_currency_id: CurrencyId
) -> DispatchResult {
unimplemented!()
}

/// Reward SETR cashdrop to vault
fn setter_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// Reward SETUSD cashdrop to vault
fn setusd_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// issue serpup surplus(stable currencies) to their destinations according to the serpup_ratio.
fn on_serpup(
_currency_id: CurrencyId,
Expand Down
41 changes: 8 additions & 33 deletions lib-serml/serp/serp-treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,8 @@ pub mod module {
pub struct Pallet<T>(_);

#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
//
// NOTE: This function is called BEFORE ANY extrinsic in a block is applied,
// including inherent extrinsics. Hence for instance, if you runtime includes
// `pallet_timestamp`, the `timestamp` is not yet up to date at this point.
//
// Triggers Serping for all system stablecoins at every block.
// fn on_initialize(now: T::BlockNumber) -> Weight {
// CashDrop period for transferring cashdrop.
// The ideal period is after every `24 hours`.

// if now % T::CashDropPeriod::get() == Zero::zero() {
// Release CashDrop to vault.
// let mut count: u32 = 0;
// if Self::setter_cashdrop_to_vault().is_ok() {
// count += 1;
// };
// if Self::setusd_cashdrop_to_vault().is_ok() {
// count += 1;
// };

// T::WeightInfo::on_initialize(count)
// } else {
// 0
// }
// }
}
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}

/// set alternative swap path for SERP.
#[pallet::call]
impl<T: Config> Pallet<T> {
Expand Down Expand Up @@ -281,22 +256,22 @@ impl<T: Config> SerpTreasury<T::AccountId> for Pallet<T> {
let charity_fund_account = T::CharityFundAccountId::get();
// Charity Fund SerpUp Pool - 10%
let serping_amount: Balance = amount / 10;
// Issue the SerpUp propper to the SettPayVault
// Issue the SerpUp propper to the SetPayVault
Self::issue_standard(currency_id, &charity_fund_account, serping_amount)?;

<Pallet<T>>::deposit_event(Event::SerpUpDelivery(amount, currency_id));
Ok(())
}

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(amount: Balance, currency_id: Self::CurrencyId) -> DispatchResult {
let settpay_account = &T::CashDropPoolAccountId::get();
let setpay_account = &T::CashDropPoolAccountId::get();

// SettPay SerpUp Pool - 50%
// SetPay SerpUp Pool - 50%
let five: Balance = 5;
let serping_amount: Balance = five.saturating_mul(amount / 10);
// Issue the SerpUp propper to the SettPayVault
Self::issue_standard(currency_id, &settpay_account, serping_amount)?;
// Issue the SerpUp propper to the SetPayVault
Self::issue_standard(currency_id, &setpay_account, serping_amount)?;

<Pallet<T>>::deposit_event(Event::SerpUpDelivery(amount, currency_id));
Ok(())
Expand Down
26 changes: 13 additions & 13 deletions lib-serml/serp/serp-treasury/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ use sp_std::marker::PhantomData;

/// Weight functions needed for module_cdp_treasury.
pub trait WeightInfo {
fn on_initialize(c: u32) -> Weight;
// fn on_initialize(c: u32) -> Weight;
fn set_alternative_swap_path() -> Weight;
}

/// Weights for serp_treasury using the Setheum node and recommended hardware.
pub struct SetheumWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SetheumWeight<T> {
fn on_initialize(c: u32) -> Weight {
(33_360_000 as Weight)
.saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
}
// fn on_initialize(c: u32) -> Weight {
// (33_360_000 as Weight)
// .saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
// .saturating_add(T::DbWeight::get().reads(2 as Weight))
// .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
// }
fn set_alternative_swap_path() -> Weight {
(3_000_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Expand All @@ -68,12 +68,12 @@ impl<T: frame_system::Config> WeightInfo for SetheumWeight<T> {

// For backwards compatibility and tests
impl WeightInfo for () {
fn on_initialize(c: u32) -> Weight {
(33_360_000 as Weight)
.saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
}
// fn on_initialize(c: u32) -> Weight {
// (33_360_000 as Weight)
// .saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
// .saturating_add(RocksDbWeight::get().reads(2 as Weight))
// .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
// }
fn set_alternative_swap_path() -> Weight {
(3_000_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
Expand Down
2 changes: 1 addition & 1 deletion lib-serml/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub trait SerpTreasury<AccountId> {
/// SerpUp ratio for Setheum Foundation's Charity Fund
fn get_charity_fund_serpup(amount: Self::Balance, currency_id: Self::CurrencyId) -> DispatchResult;

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(amount: Self::Balance, currency_id: Self::CurrencyId) -> DispatchResult;

/// issue serpup surplus(stable currencies) to their destinations according to the serpup_ratio.
Expand Down
12 changes: 1 addition & 11 deletions lib-serml/tokens/nft/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,14 @@ impl SerpTreasury<AccountId> for MockSerpTreasury {
unimplemented!()
}

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(
_amount: Balance,
_currency_id: CurrencyId
) -> DispatchResult {
unimplemented!()
}

/// Reward SETR cashdrop to vault
fn setter_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// Reward SETUSD cashdrop to vault
fn setusd_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// issue serpup surplus(stable currencies) to their destinations according to the serpup_ratio.
fn on_serpup(
_currency_id: CurrencyId,
Expand Down
12 changes: 1 addition & 11 deletions lib-serml/transaction-payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,14 @@ impl SerpTreasury<AccountId> for MockSerpTreasury {
unimplemented!()
}

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(
_amount: Balance,
_currency_id: CurrencyId
) -> DispatchResult {
unimplemented!()
}

/// Reward SETR cashdrop to vault
fn setter_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// Reward SETUSD cashdrop to vault
fn setusd_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// issue serpup surplus(stable currencies) to their destinations according to the serpup_ratio.
fn on_serpup(
_currency_id: CurrencyId,
Expand Down
2 changes: 1 addition & 1 deletion predeploy-contracts
12 changes: 1 addition & 11 deletions runtime/common/src/precompile/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,14 @@ impl SerpTreasury<AccountId> for MockSerpTreasury {
unimplemented!()
}

/// SerpUp ratio for SettPay Cashdrops
/// SerpUp ratio for SetPay Cashdrops
fn get_cashdrop_serpup(
_amount: Balance,
_currency_id: CurrencyId
) -> DispatchResult {
unimplemented!()
}

/// Reward SETR cashdrop to vault
fn setter_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// Reward SETUSD cashdrop to vault
fn setusd_cashdrop_to_vault() -> DispatchResult {
unimplemented!()
}

/// issue serpup surplus(stable currencies) to their destinations according to the serpup_ratio.
fn on_serpup(
_currency_id: CurrencyId,
Expand Down
12 changes: 6 additions & 6 deletions runtime/newrome/src/weights/serp_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ use sp_std::marker::PhantomData;
/// Weight functions for serp_treasury.
pub struct WeightInfo<T>(_);
impl<T: frame_system::Config> serp_treasury::WeightInfo for WeightInfo<T> {
fn on_initialize(c: u32) -> Weight {
(33_360_000 as Weight)
.saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
}
// fn on_initialize(c: u32) -> Weight {
// (33_360_000 as Weight)
// .saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
// .saturating_add(T::DbWeight::get().reads(2 as Weight))
// .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
// }
fn set_alternative_swap_path() -> Weight {
(3_000_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Expand Down
12 changes: 6 additions & 6 deletions runtime/setheum/src/weights/serp_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ use sp_std::marker::PhantomData;
/// Weight functions for serp_treasury.
pub struct WeightInfo<T>(_);
impl<T: frame_system::Config> serp_treasury::WeightInfo for WeightInfo<T> {
fn on_initialize(c: u32) -> Weight {
(33_360_000 as Weight)
.saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
}
// fn on_initialize(c: u32) -> Weight {
// (33_360_000 as Weight)
// .saturating_add((23_139_000 as Weight).saturating_mul(c as Weight))
// .saturating_add(T::DbWeight::get().reads(2 as Weight))
// .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
// }
fn set_alternative_swap_path() -> Weight {
(3_000_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Expand Down