Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
c3434eb1
Unverified
Commit
c3434eb1
authored
11 months ago
by
Liam Aharon
Browse files
Options
Downloads
Patches
Plain Diff
reduce scaling factor
parent
ed9e0dc8
Branches
Branches containing commit
No related merge requests found
Pipeline
#466445
failed with stages
in 2 minutes and 49 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/frame/asset-rewards/src/lib.rs
+1
-1
1 addition, 1 deletion
substrate/frame/asset-rewards/src/lib.rs
substrate/frame/asset-rewards/src/tests.rs
+11
-11
11 additions, 11 deletions
substrate/frame/asset-rewards/src/tests.rs
with
12 additions
and
12 deletions
substrate/frame/asset-rewards/src/lib.rs
+
1
−
1
View file @
c3434eb1
...
...
@@ -107,7 +107,7 @@ pub use weights::WeightInfo;
pub
type
PoolId
=
u32
;
/// Multiplier to maintain precision when calculating rewards.
pub
(
crate
)
const
PRECISION_SCALING_FACTOR
:
u
32
=
u32
::
MAX
;
pub
(
crate
)
const
PRECISION_SCALING_FACTOR
:
u
16
=
4096
;
/// Convenience alias for `PoolInfo`.
pub
type
PoolInfoFor
<
T
>
=
PoolInfo
<
...
...
This diff is collapsed.
Click to expand it.
substrate/frame/asset-rewards/src/tests.rs
+
11
−
11
View file @
c3434eb1
...
...
@@ -921,7 +921,7 @@ mod set_pool_reward_rate_per_block {
// Check that rewards are calculated correctly with the updated rate
assert_hypothetically_earned
(
staker
,
10
*
100
+
10
*
new_reward_rate
-
1
,
// -1 due to rounding
10
*
100
+
10
*
new_reward_rate
,
pool_id
,
NativeOrWithId
::
<
u32
>
::
Native
,
);
...
...
@@ -1227,8 +1227,8 @@ fn integration() {
// - Staker 2 is earning 33.33 tokens per block.
// Check that Staker 1 has earned 350 tokens and Staker 2 has earned 150 tokens.
assert_hypothetically_earned
(
staker1
,
3
49
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
1
49
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
3
50
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
1
50
,
pool_id
,
reward_asset_id
.clone
());
// Block 22: Staker 1 unstakes 100 tokens.
System
::
set_block_number
(
22
);
...
...
@@ -1237,7 +1237,7 @@ fn integration() {
// - Staker 2 has earned 483 (150 + 33.33 * 10) tokens.
// - Staker 1 is earning 50 tokens per block.
// - Staker 2 is earning 50 tokens per block.
assert_hypothetically_earned
(
staker1
,
101
5
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
101
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
483
,
pool_id
,
reward_asset_id
.clone
());
// Block 23: Staker 1 unstakes 100 tokens.
...
...
@@ -1247,7 +1247,7 @@ fn integration() {
// - Staker 2 has earned 533 (483 + 50) tokens.
// - Staker 1 is earning 0 tokens per block.
// - Staker 2 is earning 100 tokens per block.
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
533
,
pool_id
,
reward_asset_id
.clone
());
// Block 50: Stakers should only have earned 2 blocks worth of tokens (expiry is 25).
...
...
@@ -1256,7 +1256,7 @@ fn integration() {
// - Staker 2 has earned 733 (533 + 2 * 100) tokens.
// - Staker 1 is earning 0 tokens per block.
// - Staker 2 is earning 0 tokens per block.
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
733
,
pool_id
,
reward_asset_id
.clone
());
// Block 51: Extend the pool expiry block to 60.
...
...
@@ -1268,7 +1268,7 @@ fn integration() {
pool_id
,
60u64
));
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
733
,
pool_id
,
reward_asset_id
.clone
());
// Block 53: Check rewards are resumed.
...
...
@@ -1276,7 +1276,7 @@ fn integration() {
// - Staker 2 has earned 933 (733 + 2 * 100) tokens.
// - Staker 2 is earning 100 tokens per block.
System
::
set_block_number
(
53
);
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
933
,
pool_id
,
reward_asset_id
.clone
());
// Block 55: Halve the block reward.
...
...
@@ -1289,7 +1289,7 @@ fn integration() {
pool_id
,
50
));
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
1133
,
pool_id
,
reward_asset_id
.clone
());
// Block 57: Staker2 harvests their rewards.
...
...
@@ -1308,8 +1308,8 @@ fn integration() {
// - Staker 1 has earned 1065 tokens.
// - Staker 2 has earned 149 (3 * 50) tokens.
System
::
set_block_number
(
60
);
assert_hypothetically_earned
(
staker1
,
106
4
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
1
49
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker1
,
106
6
,
pool_id
,
reward_asset_id
.clone
());
assert_hypothetically_earned
(
staker2
,
1
50
,
pool_id
,
reward_asset_id
.clone
());
// Finally, check events.
assert_eq!
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment