Skip to content

Commit

Permalink
DIP-0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav authored Nov 28, 2023
1 parent f4da0e1 commit 58b379a
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions DIPs/dip-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
dip: 0
title: Staking Power Specification
description: This specification details the functioning of staking power.
authors: Darwinia Network (@AurevoirXavier, @hackfisher)
discussions-to: None
status: Final
type: Economic
created: 2023-11-28
---


## Abstract
This DIP explicates the staking power specification applicable to Darwinia and Crab.


## Rationale
Darwinia's initial design recognizes the existence of two tokens.
To incorporate these two tokens in staking, a unified measuring unit is indispensable.


## Specification
Power is a composite unit of RINGs and KTONs.

There is a constant total of `1` billion power, with `50%` allocated to RINGs and `50%` to KTONs.

A RING pool exists, where all staked RINGs are held to share the `50%` power. The same applies to the KTON pool.

```rs
const TOTAL_POWER: u32 = 1_000_000_000;
const HALF_POWER: u32 = TOTAL_POWER / 2;

// Initially, there are no stakers.
static mut ring_pool = 0;
static mut kton_pool = 0;

// The power of a staker is the sum of their RINGs' power and their KTONs' power.
fn power_of(staker) {
(staker.ring / ring_pool + staker.kton / kton_pool) * HALF_POWER
}

// Staker `S1` stakes `25` RINGs.
ring_pool += 25; // , which becomes `25`.
assert_eq!(power_of(S1), HALF_POWER);

// Staker `S1` stakes `25` KTONs.
kton_pool += 25; // , which becomes `25`;
assert_eq!(power_of(S1), TOTAL_POWER);

// Staker `S2` stakes `75` RINGs.
ring_pool += 75; // , which becomes `100`.
assert_eq!(power_of(S1), 25 / 100 * HALF_POWER + HALF_POWER);
assert_eq!(power_of(S2), 75 / 100 * HALF_POWER);

// Staker `S2` stakes `25` KTONs.
kton_pool += 25; // , which becomes `50`.
assert_eq!(power_of(S1), 25 / 100 * HALF_POWER + 25 / 50 * HALF_POWER);
assert_eq!(power_of(S2), 75 / 100 * HALF_POWER + 25 / 50 * HALF_POWER);
```


## Copyright
Copyright and related rights waived via [CC0](../LICENSE).

0 comments on commit 58b379a

Please sign in to comment.