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

New timegraph tokenomics #1161

Merged
merged 39 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
38a3cde
init solution
juniuszhou Oct 2, 2024
109bcf8
initial parameter value
juniuszhou Oct 2, 2024
b042994
add saturating
juniuszhou Oct 2, 2024
c2e3660
all extrinsics done
juniuszhou Oct 3, 2024
9343485
document for all
juniuszhou Oct 3, 2024
a4b3807
fmt code
juniuszhou Oct 3, 2024
6a3b6c1
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
juniuszhou Oct 3, 2024
525088e
update benchmarks
juniuszhou Oct 3, 2024
83638e8
fix unit tests
juniuszhou Oct 4, 2024
6682ef9
more unit tests
juniuszhou Oct 4, 2024
d699a99
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 6, 2024
48fbf6f
update runtime
juniuszhou Oct 7, 2024
dd12a84
more test cases
juniuszhou Oct 7, 2024
ac48dc6
fix clippy
juniuszhou Oct 7, 2024
9068911
fix clippy
juniuszhou Oct 7, 2024
b143ebb
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 7, 2024
c6608b4
update benchmarks
juniuszhou Oct 7, 2024
7c6bf72
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 7, 2024
66d927b
update benchmarks
juniuszhou Oct 7, 2024
e0a1e77
update benchmarks
juniuszhou Oct 8, 2024
aa0627e
fix clippy
juniuszhou Oct 8, 2024
b351c9e
fix function in benchmarks
juniuszhou Oct 8, 2024
62e0ced
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 8, 2024
54fe4d9
update benchmarks
juniuszhou Oct 9, 2024
da20a93
fix clippy
juniuszhou Oct 9, 2024
7e9bfef
runtimes: update pallet weights
github-actions[bot] Oct 9, 2024
36b2704
merge with development
juniuszhou Oct 10, 2024
ae60c02
Mainnet Tokenomics parameters update (#1057)
taniasaleem123 Oct 9, 2024
ef33f3b
merge development
juniuszhou Oct 10, 2024
a32947c
runtimes: update pallet weights
github-actions[bot] Oct 10, 2024
8472ffc
update Cargo file
ana-junius Oct 10, 2024
714be86
runtimes: update pallet weights
github-actions[bot] Oct 10, 2024
ef3fdb2
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 14, 2024
01393d5
runtimes: update pallet weights
github-actions[bot] Oct 14, 2024
d686fde
runtimes: update pallet weights
github-actions[bot] Oct 14, 2024
224f750
Merge branch 'development' into junius/feat-new-timegraph-tokenomics
ana-junius Oct 15, 2024
92de181
runtimes: update pallet weights
github-actions[bot] Oct 15, 2024
eb0b43a
remove default value method
ana-junius Oct 17, 2024
e2a7728
runtimes: update pallet weights
github-actions[bot] Oct 17, 2024
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
5 changes: 3 additions & 2 deletions pallets/timegraph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ scale-codec = { workspace = true, features = [ "max-encoded-len" ] }
scale-info.workspace = true
simple-mermaid.workspace = true

polkadot-sdk = { workspace = true, features = [ "frame-support", "frame-system" ] }
polkadot-sdk = { workspace = true, features = [ "frame-support", "frame-system", "sp-runtime" ] }

[dev-dependencies]
polkadot-sdk = { workspace = true, features = [ "pallet-balances", "sp-core", "sp-io", "sp-runtime" ] }
polkadot-sdk = { workspace = true, features = [ "pallet-balances", "sp-core", "sp-io", "sp-tracing" ] }


[features]
default = [ "std" ]
Expand Down
68 changes: 62 additions & 6 deletions pallets/timegraph/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,85 @@ use frame_system::RawOrigin;
#[benchmarks]
mod benchmarks {
use super::*;
use frame_support::traits::Currency;
use frame_support::traits::{Currency, ReservableCurrency};

#[benchmark]
fn deposit() {
let caller = whitelisted_caller();
let recipient = account("recipient", 0, 1);
let amount: BalanceOf<T> = 5_000_000u32.into();
let amount_be: BalanceOf<T> = amount * 100u32.into();
T::Currency::resolve_creating(&caller, T::Currency::issue(amount_be));
#[extrinsic_call]
deposit(RawOrigin::Signed(caller), recipient, amount);
deposit(RawOrigin::Signed(caller), amount);
}

#[benchmark]
fn withdraw() {
let caller = whitelisted_caller();
let recipient = account("recipient", 0, 1);
let amount: BalanceOf<T> = 5_000_000u32.into();
let amount_be: BalanceOf<T> = amount * 100u32.into();
let sequence = 1;
T::Currency::resolve_creating(&caller, T::Currency::issue(amount_be));
let _ = T::Currency::reserve(&caller, Threshold::<T>::get() + amount);

#[extrinsic_call]
withdraw(RawOrigin::Signed(caller), amount);
}

#[benchmark]
fn transfer_to_pool() {
let caller: T::AccountId = whitelisted_caller();
let account: T::AccountId = account("name", 0, 0);
let amount: BalanceOf<T> = 5_000_000_u32.into();
T::Currency::resolve_creating(
&account,
T::Currency::issue(amount * 100u32.into() + Threshold::<T>::get()),
);
TimegraphAccount::<T>::set(caller.clone());
let _ = T::Currency::reserve(&account, Threshold::<T>::get() + amount);

#[extrinsic_call]
transfer_to_pool(RawOrigin::Signed(caller), account, amount);
}

#[benchmark]
fn transfer_award_to_user() {
let caller: T::AccountId = whitelisted_caller();
let account: T::AccountId = account("name", 0, 0);
let amount: BalanceOf<T> = 5_000_000_u32.into();

T::Currency::resolve_creating(&caller, T::Currency::issue(amount * 200u32.into()));

T::Currency::resolve_creating(&account, T::Currency::issue(amount * 100u32.into()));

TimegraphAccount::<T>::set(caller.clone());
RewardPoolAccount::<T>::set(caller.clone());

#[extrinsic_call]
transfer_award_to_user(RawOrigin::Signed(caller), account, amount);
}

#[benchmark]
fn set_timegraph_account() {
let new_account: T::AccountId = account("name", 0, 0);
#[extrinsic_call]
// Example new account
set_timegraph_account(RawOrigin::Root, new_account);
}

#[benchmark]
fn set_reward_pool_account() {
let new_account: T::AccountId = account("name", 0, 0);

#[extrinsic_call]
set_reward_pool_account(RawOrigin::Root, new_account);
}

#[benchmark]
fn set_threshold() {
let amount: BalanceOf<T> = 5_000_000_u32.into();

#[extrinsic_call]
withdraw(RawOrigin::Signed(caller), recipient, amount, sequence);
set_threshold(RawOrigin::Root, amount);
}

impl_benchmark_test_suite!(Timegraph, crate::mock::new_test_ext(), crate::mock::Test);
Expand Down
Loading