Skip to content

Commit 0c1bf19

Browse files
Staking branch (#1367)
* First staking draft * deleted some of the procedures outdated content * Refined and updated all staking and delegation-related docs. * Deleted unnecessary sentence in entering-staking.adoc * Deleted some of the prerequisites in the procedures * Update staking: Operator contract, allowance change, Sepolia addresses, and index update interval
1 parent 25d5320 commit 0c1bf19

File tree

9 files changed

+72
-32
lines changed

9 files changed

+72
-32
lines changed

components/Starknet/modules/cli/pages/starkli.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[WARNING]
55
====
6-
The Starknet CLI is deprecated. Instead, use xref:tools:devtools.adoc#starkli[StarkLi CLI].
6+
The Starknet CLI is deprecated. Instead, use link: https://docs.starknet.io/tools/devtools/overview/[StarkLi CLI].
77
====
88

99
[id="basic_command_line_syntax"]

components/Starknet/modules/staking/pages/architecture.adoc

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ Staking on Starknet is designed to enhance network security and decentralization
77

88
Staking is divided into several key components, each responsible for different aspects of the staking process.
99

10-
The following contracts handle the core functionalities of the staking system:
11-
1210
.Contracts of the Staking Architecture
1311
[cols='1,8']
1412
|===
1513
| Contract
1614
| Description
1715

16+
| Operator Contract
17+
| Acts as the access point for all interactions with the staking system, wrapping around the staking contract. It enforces access control and whitelisting, ensuring that only authorized users can perform staking operations.
18+
1819
| Staking Contract
19-
| The central contract that manages the staking process. It handles direct staking, rewards distribution, and interactions with delegation pools. Validators interact with this contract to stake their tokens, claim rewards, and initiate unstaking.
20+
| The central contract that manages the staking process. It handles direct staking, rewards distribution, and interactions with delegation pools. Validators interact with this contract through the Operator contract to stake their tokens, claim rewards, and initiate unstaking.
2021

2122
| Delegation Pooling Contract
2223
| This contract manages the delegation process, allowing delegators to assign their tokens to a validator for staking. The contract is responsible for tracking each delegator's share, calculating their rewards, and managing the delegation and unstaking processes.
@@ -45,36 +46,47 @@ The following data structures are stored within the contracts and play a crucial
4546

4647
For more technical details, you can refer to the full staking specification document available in: https://github.com/starkware-libs/starknet-staking/blob/main/docs/spec.md[Staking Repository Spec].
4748

48-
== Staking Contract
49+
== Operator Contract
4950

50-
The staking contract is the core of the staking system. It manages the lifecycle of validators, from the initial stake to claiming rewards and unstaking. The contract ensures that the validator's tokens are securely locked and that rewards are distributed according to the minting curve.
51+
The operator contract serves as the first point of interaction for all users. It manages access control, ensuring that only authorized users can stake, claim rewards, and interact with the staking system. The operator contract forwards user requests to the relevant contracts (e.g., staking contract) and includes features such as whitelisting, which restricts access to specific users if activated.
5152

5253
*Key Functions and Responsibilities*: +
53-
`stake`: Allows users to stake their STRK tokens directly into the contract. The function initializes the validator's information, locks the tokens, and optionally deploys a delegation pool if pooling is enabled. +
54-
`increase_stake`: Lets existing validators add more tokens to their stake. The contract recalculates rewards and updates the validator's information accordingly. +
55-
`unstake_intent`: Initiates the unstaking process by locking the validator's tokens for a specified exit period. No rewards are earned during this period. +
56-
`unstake_action`: Finalizes the unstaking process after the exit period has passed, releasing the staked tokens back to the validator. +
57-
`claim_rewards`: Calculates and transfers the validator's accumulated rewards to their designated reward address. +
54+
`stake`: Allows users to stake their STRK tokens, forwarding the request to the staking contract. +
55+
`increase_stake`: Lets existing stakers add more tokens to their stake. +
56+
`claim_rewards`: Facilitates the claiming of rewards for stakers and delegators. +
57+
`unstake_intent`: Initiates the unstaking process by signaling intent, which the staking contract processes. +
58+
`unstake_action`: Finalizes the unstaking process after the waiting period.
59+
60+
== Staking Contract
61+
62+
The staking contract is the core of the staking system. It manages the entire lifecycle of staking, from initial staking to claiming rewards and unstaking. The operator contract interacts with the staking contract to execute these functions.
63+
64+
*Key Functions and Responsibilities (accessed via the Operator contract)*: +
65+
`stake`: Allows users to stake their STRK tokens. This is facilitated by the Operator contract and forwarded to the Staking contract. +
66+
`increase_stake`: Lets existing validators increase their stake, accessed through the Operator. +
67+
`unstake_intent`: Initiates the unstaking process, managed by the Operator contract, which interacts with the Staking contract to initiate and finalize the unstaking process. +
68+
`unstake_action`: Finalizes the unstaking process after the waiting period, returning tokens to the user through the Operator. +
69+
`claim_rewards`: Allows users to claim rewards, facilitated through the Operator contract.
5870

5971
== Delegation Pooling Contract
6072

61-
The delegation pooling contract enables users to delegate their tokens to a validator without having to manage the staking process themselves. This contract tracks each delegator's contribution, calculates their rewards, and manages the delegation lifecycle.
73+
The delegation pooling contract enables users to delegate their tokens through the Operator contract. All interactions, such as entering or exiting the pool, are forwarded to the appropriate contracts via the Operator. This contract tracks each delegator's contribution, calculates their rewards, and manages the delegation lifecycle.
6274

6375
*Key Functions and Responsibilities*: +
6476
`enter_delegation_pool`: Allows users to delegate their tokens to the pool associated with a validator. This function transfers the tokens, updates the delegator's record, and integrates them into the validator's pool. +
6577
`add_to_delegation_pool`: Enables existing delegators to increase their delegation amount. The contract updates the pool's total and recalculates the member's rewards. +
6678
`exit_delegation_pool_intent`: Initiates the process for a delegator to exit the pool. Similar to validators, the delegator's funds are locked for a period before they can be withdrawn. +
6779
`exit_delegation_pool_action`: Finalizes the exit process for a delegator, returning their tokens and any unclaimed rewards. +
6880
`switch_delegation_pool`: Allows a delegator to transfer their delegated stake from one validator's pool to another, facilitating dynamic delegation strategies. +
69-
`claim_rewards`: Transfers the delegator's earned rewards to their specified reward address. +
81+
`claim_rewards`: Transfers the delegator's earned rewards to their specified reward address.
7082

7183
== Reward Supplier Contract
7284

7385
The reward supplier contract is responsible for calculating and supplying the staking rewards based on the minting curve. It ensures that the rewards are distributed fairly and in accordance with the protocol's economic parameters.
7486

7587
*Key Functions and Responsibilities*: +
7688
`calculate_staking_rewards`: Computes the rewards based on the current staking rate and the minting curve, updating the staking contract with the amount to be distributed. +
77-
`claim_rewards`: Handles the transfer of rewards to the staking contract, ensuring that the correct amount is distributed to validators and delegators. +
89+
`claim_rewards`: Handles the transfer of rewards to the staking contract, ensuring that the correct amount is distributed to validators and delegators.
7890

7991
== Minting Curve Contract
8092

@@ -86,4 +98,4 @@ The minting curve contract defines the economic model that governs reward distri
8698

8799
== Security and Upgradability
88100

89-
The staking architecture on Starknet is designed with security and upgradability in mind. Each contract is modular, allowing for targeted upgrades and improvements without affecting the entire system. Access control mechanisms are in place to ensure that only authorized parties can make critical changes, further enhancing the security of the staking process.
101+
The staking architecture on Starknet is designed with security and upgradability in mind. Each contract is modular, allowing for targeted upgrades and improvements without affecting the entire system. The introduction of the Operator contract adds an extra layer of access control, ensuring only authorized users can interact with the staking system. Access control mechanisms are in place to ensure that only authorized parties can make critical changes, further enhancing the security of the staking process.

components/Starknet/modules/staking/pages/claiming-rewards.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
:description: How to claim your staking rewards on Starknet by directly interacting with the staking or delegation pooling contracts.
55

6-
Staking rewards on Starknet accumulate over time as your staked STRK tokens contribute to network security. To claim these rewards, you need to interact with the staking contract (if you are a validator) or the specific delegation pooling contract associated with the validator you have staked with (if you are a delegator) and execute the appropriate functions.
6+
Staking rewards on Starknet accumulate over time as your staked STRK tokens contribute to network security. To claim these rewards, you need to interact with the operator contract (if you are a validator) or the specific delegation pooling contract associated with the validator you have staked with (if you are a delegator) and execute the appropriate functions.
77

88
.Prerequisites
99

@@ -14,7 +14,7 @@ Staking rewards on Starknet accumulate over time as your staked STRK tokens cont
1414

1515
. Using a Starknet block explorer, navigate to the appropriate contract:
1616
+
17-
* For validators: Navigate to the staking contract.
17+
* For validators: Navigate to the operator contract.
1818
* For delegators: Navigate to the delegation pooling contract associated with the validator you have staked with.
1919
. In the contract interface, locate and select the `claim_rewards` function.
2020
. Enter the following parameters:

components/Starknet/modules/staking/pages/delegating-stake.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The delegation process includes joining a validator's delegation pool by interac
99

1010
.Procedure
1111

12+
. Pre-approve the delegation pooling contract associated with the validator for the transfer of the requested amount of STRK tokens from your address.
1213
. Using a Starknet block explorer, navigate to the delegation pooling contract associated with the validator you want to delegate to.
1314
. In the contract interface, locate and select the `enter_delegation_pool` function.
1415
. Enter the following parameters:

components/Starknet/modules/staking/pages/entering-staking.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ For more information on what happens during the staking process, see xref:archit
1818
* Validators are expected to run full nodes in preparation for the following stages of the protocol. You can use any full node implementation you choose:
1919
** link:https://github.com/NethermindEth/juno[Juno] by Nethermind - link:https://juno.nethermind.io/hardware-requirements/#recommended-requirements[Spec].
2020
** link:https://github.com/eqlabs/pathfinder[Pathfinder] by EQLabs - https://github.com/eqlabs/pathfinder?tab=readme-ov-file#hardware-requirements[Spec].
21+
** link:https://github.com/madara-alliance/madara[Madara] by Madara Alliance - link:https://docs.madara.build/get-started/requirements[Spec].
2122
* A Starknet-compatible block explorer or CLI tool.
2223
* Sufficient STRK token balance in your wallet.
23-
* Pre-approval of the STRK ERC20 contract (link:https://starkscan.co/token/0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d[Starkscan], link:https://voyager.online/contract/0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d[Voyager])
24-
on Starknet for the transfer of tokens from your address to the staking contract.
2524

2625
.Procedure
2726

28-
. Using a Starknet block explorer, navigate to the staking contract.
27+
. Pre-approve the STRK ERC20 contract for the transfer of tokens from your address to the staking contract (and *not* the operator contract):
28+
+
29+
* Using a Starknet block explorer, navigate to the STRK ERC20 contract (link:https://starkscan.co/token/0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d[Starkscan], link:https://voyager.online/contract/0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d[Voyager]).
30+
* Approve the staking contract to transfer the specified amount of STRK tokens on your behalf.
31+
. Using a Starknet block explorer, navigate to the operator contract.
2932
. In the contract interface, locate and select the `stake` function.
3033
. Enter the following parameters:
3134
+

components/Starknet/modules/staking/pages/exiting-staking.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Validators can unstake their STRK tokens, which involves pausing rewards and exi
1616
.Procedure
1717

1818
1. **Signal Unstake Intent:**
19-
. Using a Starknet block explorer, navigate to the staking contract.
19+
. Using a Starknet block explorer, navigate to the operator contract.
2020
. In the contract interface, locate and select the `unstake_intent` function.
2121
. Submit the transaction to initiate the unstake process. This will record the unstake intent, pause rewards collection, and set a waiting period.
2222

2323
2. **Finalize Unstake:**
24-
. After the waiting period has passed, return to the staking contract.
24+
. After the waiting period has passed, return to the operator contract.
2525
. In the contract interface, locate and select the `unstake_action` function.
2626
. Enter the following parameters:
2727
+

components/Starknet/modules/staking/pages/increasing-staking.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33

44
:description: How to increase your stake on Starknet by interacting directly with the staking or delegation pooling contracts.
55

6-
The staking and pooling contracts allow validators and delegators to increase their existing stake. Validators use the `increase_stake` function, which is called from the staking contract, while delegators use the `add_to_delegation_pool` function, which is called from the delegation pooling contract. These functions add the specified amount of STRK tokens to the current stake, recalculate rewards before the staked amount is updated, and update the total staked amount.
6+
The staking and pooling contracts allow validators and delegators to increase their existing stake. Validators use the `increase_stake` function, which is called from the operator contract, while delegators use the `add_to_delegation_pool` function, which is called from the delegation pooling contract. These functions add the specified amount of STRK tokens to the current stake, recalculate rewards before the staked amount is updated, and update the total staked amount.
77

88
.Prerequisites
99

1010
* Sufficient STRK token balance in your Starknet wallet.
11-
* The validator/delegator must have pre-approved the relevant contract (staking contract for validators, delegation pooling contract for delegators) to transfer the specified STRK amount from their account.
1211
* The validator/delegator must not be in an unstake/undelegate process.
1312
* The caller must be either the validator/delegator or their respective reward address.
1413

1514
.Procedure
16-
17-
. Using a Starknet block explorer, navigate to the relevant contract (staking contract for validators, delegation pooling contract for delegators).
15+
. Pre-approve the STRK ERC20 contract for the transfer of tokens from your address to the relevant contract:
16+
+
17+
* Validators: Pre-approve the staking contract (and *not* the operator contract) for the transfer of tokens from your address.
18+
* Delegators: Pre-approve the delegation pooling contract for the transfer of tokens from your address.
19+
. Using a Starknet block explorer, navigate to the relevant contract (operator contract for validators, delegation pooling contract for delegators).
1820
. In the contract interface, locate and select the `increase_stake` function (for validators) or the `add_to_delegation_pool` function (for delegators).
1921
. Enter the following parameters:
2022
+

components/Starknet/modules/staking/pages/managing-staking-and-delegation-operations.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If a validator does not yet have a delegation pool, they can open one by calling
2020

2121
.Procedure
2222

23-
. Using a Starknet block explorer, navigate to the **staking contract**.
23+
. Using a Starknet block explorer, navigate to the operator contract.
2424
. In the contract interface, locate and select the `set_open_for_delegation` function.
2525
. Enter the following parameter:
2626
+
@@ -35,7 +35,7 @@ Validators can update the commission rate of their delegation pool using the `up
3535

3636
.Procedure
3737

38-
. Using a Starknet block explorer, navigate to the **staking contract**.
38+
. Using a Starknet block explorer, navigate to the operator contract.
3939
. In the contract interface, locate and select the `update_commission` function.
4040
. Enter the following parameter:
4141
+
@@ -52,7 +52,7 @@ Validators can change their operational address by interacting with the `change_
5252

5353
.Procedure
5454

55-
. Using a Starknet block explorer, navigate to the **staking contract**.
55+
. Using a Starknet block explorer, navigate to the operator contract.
5656
. In the contract interface, locate and select the `change_operational_address` function.
5757
. Enter the following parameter:
5858
+
@@ -67,8 +67,8 @@ Both validators and delegators can update their reward address using the `change
6767

6868
. Using a Starknet block explorer, navigate to the appropriate contract:
6969
+
70-
* For validators: Navigate to the **staking contract**.
71-
* For delegators: Navigate to the **delegation pooling contract**.
70+
* For validators: Navigate to the operator contract.
71+
* For delegators: Navigate to the delegation pooling contract.
7272
. In the contract interface, locate and select the `change_reward_address` function.
7373
. Enter the following parameter:
7474
+

components/Starknet/modules/staking/pages/overview.adoc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ STRK tokens never leave the Starknet protocol during these operations.
2929
** Staking Rewards.
3030
** Karnot.
3131

32-
3332
=== Overview
3433

3534
The staking protocol features two main options:
@@ -91,3 +90,26 @@ The proposed economic parameters are:
9190
* **Commission Policy Parameter (stem:[CP]):** Set by the validator (0 - 1), and can only be lowered once set.
9291

9392
These values are our proposed starting points for this version of the protocol. As part of the rationale behind this version, they are subject to change and may be adjusted to better suit the protocol’s needs under the proper governance procedures.
93+
94+
== Sepolia Testnet Parameters
95+
96+
Below are the relevant contract addresses and parameters for interacting with the staking protocol on Sepolia testnet:
97+
98+
=== Addresses
99+
100+
* **L1:**
101+
- Reward supplier address: 0xE58d25681B9d290D60e4d7f379a05d5BFD973fFB
102+
- Mint manager address: 0x648D1B35a932F5189e7ff97b2F795E03734DE4ce
103+
104+
* **L2:**
105+
- Staking address: 0x03745ab04a431fc02871a139be6b93d9260b0ff3e779ad9c8b377183b23109f1
106+
- Operator address: 0x04ce1719fd581433d59100cc3f00387c66866492253b4f3a08688828ed9f6832
107+
- Minting curve address: 0x0351c67dc2d4653cbe457be59a035f80ff1e6f6939118dad1b7a94317a51a454
108+
- Reward supplier address: 0x02ebbebb8ceb2e07f30a5088f5849afd4f908f04f3f9c97c694e5d83d2a7cc61
109+
110+
=== Economic Parameters
111+
112+
* **Minimum STRK for Staking:** 1 STRK
113+
* **Withdrawal Security Lockup:** 5 minutes
114+
* **Minting Curve Yearly Inflation Cap (stem:[C]):** 1.6
115+
* **Technical parameter for developers who want to deep dive:** The index update interval is set to a minimum of 1 minute on Sepolia, in contrast to the 24-hour interval used in production.

0 commit comments

Comments
 (0)