<!--
Parallel Documentation — this page, as markdown.
Index of every page: https://docs.parallel.best/llms.txt
The whole documentation in one file: https://docs.parallel.best/llms-full.txt
-->

# Key Operations Flows

## 1. Key Operation Flows

### 1.1 Staking Flow

This section contains the flows related to the staking part of the protocol.

#### **1.1.1 sPRL1 Flow**

**1.1.1.1 sPRL1 Deposit**

* Transfer PRL tokens to the sPRL1 contract
* Mint sPRL1 tokens to the user equivalent to the amount of PRL tokens transferred

**1.1.1.2 sPRL1 Request Withdraw**

* Burn the amount of sPRL1 tokens that the user wants to withdraw
* Set the unlocking time for this request

**1.1.1.3 sPRL1 Withdraw**

* Calculate the penalty based on the time left before the unlocking time.
* Send the PRL tokens to the user
* Send the PRL slashed by the penalty to the fee receiver.

**1.1.1.4 sPRL1 EmergencyWithdraw**

* Burn the amount of sPRL1 tokens that the user wants to withdraw
* Send the PRL tokens to the user without penalties.

#### **1.1.2 sPRL2 Flow**

This section contains the flows related to the sPRL2 v2 contract (sPRL2V2), on Ethereum and Base. Unlike the first sPRL2 vault, it keeps the BPT and does not stake it on Aura.

**1.1.2.1 sPRL2 Deposit PRL/WETH or PRL/ETH**

* Transfer PRL/WETH or PRL/ETH to the sPRL2V2 contract
* Deposit ETH to WETH if needed
* Add PRL/WETH liquidity into the Balancer V3 pool (80PRL/20WETH)
* Receive BPT tokens, held by the contract
* Return the PRL and WETH (or ETH) the pool did not take
* Mint sPRL2V2 tokens to the user equivalent to the amount of BPT received

**1.1.2.2 sPRL2 Deposit BPT 80PRL/20WETH**

* Transfer BPT to the sPRL2V2 contract
* Mint sPRL2V2 tokens to the user equivalent to the amount of BPT transferred

**1.1.2.3 sPRL2 Request Withdraw**

* Burn the amount of sPRL2V2 tokens that the user wants to withdraw
* Set the unlocking time for this request

**1.1.2.4 sPRL2 Withdraw PRL/WETH**

* Calculate the penalty based on the time left before the unlocking time.
* Send the BPT penalty to the fee receiver
* Withdraw the amount of PRL/WETH from the Balancer pool
* Send the PRL/WETH to the user

**1.1.2.5 sPRL2 Withdraw BPT 80PRL/20WETH**

* Calculate the penalty based on the time left before the unlocking time.
* Send the BPT penalty to the fee receiver
* Send the BPT lp tokens to the user

**1.1.2.6 sPRL2 EmergencyWithdraw**

* Only when the contract is paused
* Burn the amount of sPRL2V2 tokens that the user wants to withdraw
* Send the BPT tokens to the user without penalties.

**1.1.2.7 sPRL2 v1 to v2 Migration**

* The user approves the sPRL2Migrator to spend their sPRL2 (v1)
* The migrator transfers the sPRL2 (v1) to itself
* It calls `emergencyWithdraw` on the paused v1 contract and receives the BPT, without penalty
* It deposits the BPT into sPRL2V2
* It sends the sPRL2V2 tokens to the user, equal to the amount migrated

### **1**.2 Reward Distribution Flow

* RewardMerkleDistributor will receive the fees from the MainFeeDistributor at any time. Since Tokenomics v2.1 (PIP-68), both are on Base and the fees are in USDp.
* Using off-chain events and calculations, the protocol retrieve the total amount received during a specific period.
* Protocol will generate a merkle root based on the total amount received and the amount of rewards that will be distributed to the users.
* The merkle root will be updated in the RewardMerkleDistributor contract.
* Users will be able to claim their rewards using the merkle proof.
