Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
132 changes: 130 additions & 2 deletions docs/delegate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Delegate

Razor network is a proof of stake network. In order to participate in the network as a delegator, you will need to "Delegate" your RAZORs. RAZOR is (`ERC20` token standard) the native token in Razor Network.

In order to delegate, you will also need some RAZOR tokens on Europa Defi Hub. You can bridge RAZOR tokens from Ethereum to Europa Defi Hub using [SKALE Portal Bridge](https://portal.skale.space/bridge?from=mainnet&to=elated-tan-skat&token=razor&type=erc20). More info regarding RAZOR Token bridge can be found [here](/docs/token-bridge/europa-defi-hub#ethereum-to-europa-defi-hub). To pay transaction fees on Europa Defi Hub you will require sFUEL to pay for gas, you can get sFUEL from [Faucet](https://www.sfuelstation.com/).
In order to delegate, you will also need some RAZOR tokens on Europa Defi Hub. You can bridge RAZOR tokens from Ethereum to Europa Defi Hub using [SKALE Portal Bridge](https://portal.skale.space/bridge?from=mainnet&to=elated-tan-skat&token=razor&type=erc20). More info regarding RAZOR Token bridge can be found [here](/docs/token-bridge/europa-defi-hub#ethereum-to-europa-defi-hub). To pay transaction fees on Europa Defi Hub you will require sFUEL to pay for gas. Get sFUEL from [SKALE Portal](https://portal.skale.space/chains/europa) after connecting your wallet.

<!-- > Warning: Razor network is in alpha state and is deployed on Skale v2 Testnet. Please use Testnet tokens only. -->

Expand All @@ -17,7 +17,7 @@ In order to delegate, you will also need some RAZOR tokens on Europa Defi Hub. Y

**Note**: _You can get the stakers sRAZOR address by clicking on the `+` icon on that stakers delegate/unstake modal._

## Delegation on Razorscan {#delegation-on-razorscan}
## Using Razorscan (Recommended for beginners) {#delegation-on-razorscan}

### Step 1 {#step-1}

Expand Down Expand Up @@ -60,3 +60,131 @@ On the Metamask popup click on “Confirm”. There will be an update on the web
Click on your connected wallet address to get information on your actions.

![Screenshot](/img//delegate/delegation_step6.png)

## Using SKALE Block Explorer (Alternative method) {#delegation-block-explorer}

This method allows you to interact directly with the StakeManager smart contract through the SKALE Block Explorer. This is recommended for advanced users who are comfortable with direct contract interaction.

### Prerequisites {#block-explorer-prerequisites}

Before delegating via the block explorer, ensure you have:

1. **Metamask wallet** installed and configured
2. **Europa Defi Hub network** added to Metamask (see [network details](./razor-v2/mainnet.md))
3. **RAZOR tokens** on Europa Defi Hub (bridge from Ethereum via [SKALE Portal](https://portal.skale.space/bridge?from=mainnet&to=elated-tan-skat&token=razor&type=erc20))
4. **sFUEL tokens** for gas fees (get from [SKALE Portal](https://portal.skale.space/chains/europa) after connecting wallet)
5. **Staker ID** of the validator you want to delegate to

### Contract Addresses {#contract-addresses}

**Mainnet (Europa Defi Hub):**
- StakeManager: [`0xd492408e4901CF658c7874285984F6D5Db648D1E`](https://elated-tan-skat.explorer.mainnet.skalenodes.com/address/0xd492408e4901CF658c7874285984F6D5Db648D1E)
- RAZOR Token: [`0xCA46B70cA3c510Ce9D0c43D25817032e2F5354c0`](https://elated-tan-skat.explorer.mainnet.skalenodes.com/address/0xCA46B70cA3c510Ce9D0c43D25817032e2F5354c0)

**Testnet (Europa Defi Hub Testnet):**
- StakeManager: [`0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012`](https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/address/0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012)
- RAZOR Token: [`0x99Be5a5749bA2bccfC4Bb6584cA0E405A16586C4`](https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/address/0x99Be5a5749bA2bccfC4Bb6584cA0E405A16586C4)

### Step-by-Step Instructions {#block-explorer-steps}

#### Step 1: Find the Staker ID {#find-staker-id}

First, you need to know the Staker ID of the validator you want to delegate to. You can find this on [Razorscan](https://razorscan.io/staking) by looking at the staker list, or query it from the contract:

1. Visit the StakeManager contract on the block explorer (links above)
2. Go to the "Read Contract" tab
3. Find the `getStakerId` function
4. Enter the validator's wallet address
5. Click "Query" - the result is the Staker ID (note: returns 0 if the address is not a staker)

#### Step 2: Approve RAZOR Tokens {#approve-tokens}

Before delegating, you must approve the StakeManager contract to spend your RAZOR tokens:

1. Visit the **RAZOR Token contract** on the block explorer (use links above)
2. Click "Connect Wallet" and approve the Metamask connection
3. Verify your wallet is connected and you're on the correct network (Europa Defi Hub)
4. Navigate to the **"Write Contract"** tab
5. Find the **`approve`** function
6. Fill in the parameters:
- **spender (address)**: Enter the StakeManager contract address:
- Mainnet: `0xd492408e4901CF658c7874285984F6D5Db648D1E`
- Testnet: `0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012`
- **amount (uint256)**: Enter the amount in wei (e.g., for 1000 RAZOR, enter `1000000000000000000000`)
7. Click "Write" and confirm the transaction in Metamask
8. Wait for the transaction to be confirmed

**Note**: _1 RAZOR = 10^18 wei. To convert: multiply your RAZOR amount by 1000000000000000000_

#### Step 3: Navigate to StakeManager Contract {#navigate-stakemanager}

1. Visit the **StakeManager contract** on the block explorer:
- **Mainnet**: https://elated-tan-skat.explorer.mainnet.skalenodes.com/address/0xd492408e4901CF658c7874285984F6D5Db648D1E
- **Testnet**: https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/address/0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012

2. Ensure your wallet is still connected (if not, click "Connect Wallet" again)

#### Step 4: Execute Delegate Function {#execute-delegate}

1. Navigate to the **"Write Contract"** tab
2. Scroll down and find the **`delegate`** function
3. Fill in the parameters:
- **stakerId (uint32)**: Enter the Staker ID from Step 1 (e.g., `42`)
- **amount (uint256)**: Enter the delegation amount in wei (e.g., for 1000 RAZOR, enter `1000000000000000000000`)

4. Click "Write" to submit the transaction
5. Review the transaction details in the Metamask popup
6. Click "Confirm" in Metamask

**Important Notes:**
- The staker must have **delegation enabled** (`acceptDelegation = true`)
- You cannot delegate to yourself if you're already a staker
- The staker must not be slashed
- Ensure you've completed the token approval in Step 2

#### Step 5: Verify Transaction {#verify-transaction}

1. After confirming in Metamask, wait for the transaction to be processed
2. Once confirmed, you'll see a success message in the block explorer
3. Click on the transaction hash to view transaction details
4. You can verify your delegation by:
- Checking the transaction logs for a `Delegated` event
- Visiting your wallet on [Razorscan](https://razorscan.io/) to see your delegation

### Common Issues and Troubleshooting {#troubleshooting}

**Transaction fails with "Delegetion not accpected"**
- The staker has not enabled delegation acceptance
- Choose a different staker who accepts delegation

**Transaction fails with "ERC20: insufficient allowance"**
- You didn't complete Step 2 (token approval), or approved an insufficient amount
- Go back to Step 2 and approve the correct amount

**Transaction fails with "Staker cannot delegate themself"**
- You're trying to delegate to your own staker ID
- Stakers cannot delegate to themselves; they should use the `stake` function instead

**Transaction fails with "Staker is slashed"**
- The staker you're trying to delegate to has been slashed
- Choose a different staker

**Invalid Staker ID**
- Double-check the Staker ID is correct
- Ensure the staker exists by querying `getStaker` with the ID

### Wei Conversion Helper {#wei-conversion}

To convert RAZOR amounts to wei for the smart contract:

- 100 RAZOR = `100000000000000000000` wei
- 1000 RAZOR = `1000000000000000000000` wei
- 5000 RAZOR = `5000000000000000000000` wei

Formula: **RAZOR amount × 1,000,000,000,000,000,000**

### Related Operations {#related-operations}

After delegating, you may want to:
- [Unstake](./unstake.md) - Begin the unstaking process
- [Withdraw](./withdraw.md) - Complete withdrawal after unstaking period
192 changes: 192 additions & 0 deletions docs/initiate-withdraw.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: Initiate Withdraw

Before withdrawing, user needs to initiate withdraw to lock the RAZOR amount that needs to be withdraw.

## Using Razorscan (Recommended for beginners) {#initiate-withdraw-razorscan}

### Step 1 {#step-1}

Visit <https://razorscan.io/>
Expand Down Expand Up @@ -39,3 +41,193 @@ Once the transaction is successful, [Withdraw](./withdraw.md) will need to be ca
![Screenshot](/img/initiate-withdraw/Initiate_Withdraw_step5.png)

**Note**: _To get the exact values of the lock periods check Governance [here](https://razorscan.io/governance/values)_.

## Using SKALE Block Explorer (Alternative method) {#initiate-withdraw-block-explorer}

This method allows you to initiate withdrawal directly by interacting with the StakeManager smart contract through the SKALE Block Explorer. This is recommended for advanced users who are comfortable with direct contract interaction.

### Prerequisites {#block-explorer-prerequisites-initiate}

Before initiating withdrawal via the block explorer, ensure you have:

1. **Metamask wallet** installed and configured
2. **Europa Defi Hub network** added to Metamask (see [network details](./razor-v2/mainnet.md))
3. **sFUEL tokens** for gas fees (get from [SKALE Portal](https://portal.skale.space/chains/europa) after connecting wallet)
4. **Completed unstaking** - You must have called [unstake](./unstake.md) previously
5. **Unstake lock expired** - The `unstakeLockPeriod` must have passed
6. **Within initiation window** - You must be within the `withdrawInitiationPeriod`
7. **Correct state** - Current state must NOT be Propose or Dispute (must be Commit state)

### Contract Addresses {#contract-addresses-initiate}

**Mainnet (Europa Defi Hub):**
- StakeManager: [`0xd492408e4901CF658c7874285984F6D5Db648D1E`](https://elated-tan-skat.explorer.mainnet.skalenodes.com/address/0xd492408e4901CF658c7874285984F6D5Db648D1E)

**Testnet (Europa Defi Hub Testnet):**
- StakeManager: [`0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012`](https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/address/0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012)

### Step-by-Step Instructions {#block-explorer-steps-initiate}

#### Step 1: Verify Prerequisites {#verify-prerequisites}

Before calling initiate withdraw, verify:

**Check Unstake Lock Status:**
1. Visit the StakeManager contract on the block explorer (links above)
2. Go to the "Read Contract" tab
3. Find the `locks` function
4. Enter your parameters:
- **address**: Your wallet address
- **tokenAddress**: The sRZR token address for your staker
- **lockType**: `0` (for Unstake lock)
5. Click "Query" and check the result:
- `amount`: Should be greater than 0
- `unlockAfter`: Should be less than or equal to current epoch

**Check Current State:**
1. Find the `getState` function in the Read Contract tab
2. Enter `buffer` parameter (usually `5`)
3. Click "Query" - the result should be `0` (Commit state)
4. If it's `1` (Propose) or `2` (Dispute), wait a few minutes and try again

**Important**: Do NOT call initiate withdraw during Propose or Dispute states, as it will fail.

#### Step 2: Find Your Staker ID {#find-staker-id-initiate}

You need the Staker ID for your staker:

1. Visit the StakeManager contract on the block explorer (links above)
2. Go to the "Read Contract" tab
3. Find the `getStakerId` function
4. Enter your wallet address
5. Click "Query" - the result is your Staker ID

Alternatively, you can find your Staker ID on [Razorscan](https://razorscan.io/staking).

#### Step 3: Navigate to StakeManager Contract {#navigate-stakemanager-initiate}

1. Visit the **StakeManager contract** on the block explorer:
- **Mainnet**: https://elated-tan-skat.explorer.mainnet.skalenodes.com/address/0xd492408e4901CF658c7874285984F6D5Db648D1E
- **Testnet**: https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/address/0xbeCf5d1b74d0C2A6388c65491BBb4aD3880cD012

2. Click "Connect Wallet" and approve the Metamask connection
3. Verify your wallet is connected and you're on the correct network (Europa Defi Hub)

#### Step 4: Execute Initiate Withdraw Function {#execute-initiate-withdraw}

1. Navigate to the **"Write Contract"** tab
2. Scroll down and find the **`initiateWithdraw`** function
3. Fill in the parameters:
- **stakerId (uint32)**: Enter your Staker ID from Step 2 (e.g., `42`)

4. Click "Write" to submit the transaction
5. Review the transaction details in the Metamask popup
6. Click "Confirm" in Metamask

**Important Notes:**
- This function only requires the Staker ID parameter
- It will burn your locked sRZR tokens and lock equivalent RAZOR tokens
- The RAZOR tokens will be locked for `withdrawLockPeriod` (currently 300 epochs)
- Must be called during Commit state (not Propose or Dispute)

#### Step 5: Verify Transaction {#verify-transaction-initiate}

1. After confirming in Metamask, wait for the transaction to be processed
2. Once confirmed, you'll see a success message in the block explorer
3. Click on the transaction hash to view transaction details
4. You can verify your initiate withdraw by:
- Checking the transaction logs for a `WithdrawInitiated` event
- Visiting your wallet on [Razorscan](https://razorscan.io/) to see your withdraw lock status
- Querying the `locks` function with `lockType: 1` (Withdraw lock) to see your new lock

#### Step 6: Next Steps {#next-steps-initiate}

After successfully initiating withdrawal:

1. **Wait for withdrawLockPeriod** (currently 300 epochs) to pass
2. **Call [Withdraw](./withdraw.md)** to claim your RAZOR tokens
3. Track your lock status on [Razorscan](https://razorscan.io/)

### Common Issues and Troubleshooting {#troubleshooting-initiate}

**Transaction fails with "Unstake: NA Propose"**
- Current state is Propose
- Wait a few minutes for the state to change to Commit
- Check the current state using the method in Step 1

**Transaction fails with "Unstake: NA Dispute"**
- Current state is Dispute
- Wait a few minutes for the state to change to Commit
- Check the current state using the method in Step 1

**Transaction fails with "Did not unstake"**
- You don't have an active unstake lock
- You must call [unstake](./unstake.md) first

**Transaction fails with "Withdraw epoch not reached"**
- The unstake lock period hasn't expired yet
- Wait until the `unlockAfter` epoch has passed
- Check your lock status using the method in Step 1

**Transaction fails with "Initiation Period Passed"**
- You missed the withdrawal initiation window
- The unstake lock has expired beyond the `withdrawInitiationPeriod`
- You must call [Reset Lock](./reset-lock.md) (which incurs a penalty)

**Transaction fails with "Withdraw lock present"**
- You already have an active withdraw lock
- Complete the [Withdraw](./withdraw.md) process first

**Transaction fails with "staker doesnt exist"**
- Invalid Staker ID
- Double-check your Staker ID is correct

**Transaction fails with "No razor to withdraw"**
- The calculated RAZOR amount is 0
- This shouldn't happen if you followed the unstake process correctly

### Understanding the Withdrawal Process {#understanding-withdrawal}

The complete withdrawal process has 3 steps:

1. **[Unstake](./unstake.md)**: Lock sRZR tokens for `unstakeLockPeriod` (300 epochs)
2. **Initiate Withdraw** (this step): Burn sRZR and lock RAZOR for `withdrawLockPeriod` (300 epochs)
3. **[Withdraw](./withdraw.md)**: Claim locked RAZOR tokens

**Important Timing:**
- After unstaking at epoch `T`, you can initiate withdraw after epoch `T + 300`
- You must initiate withdraw before epoch `T + 450` (300 + 150 window)
- If you miss this window, you must call [Reset Lock](./reset-lock.md) with a penalty
- After initiating withdraw at epoch `T2`, you can withdraw after epoch `T2 + 300`

### State Requirements {#state-requirements}

**Why can't I call during Propose or Dispute?**
- During Propose and Dispute states, validators are actively participating in the consensus process
- Inactivity penalties are calculated during these states
- The initiate withdraw function calls `giveInactivityPenalties` which requires the state to be Commit
- This ensures all pending penalties are applied before withdrawal

**How to check current state:**
- Use Razorscan's state indicator on the homepage
- Query `getState` function on the StakeManager contract
- States cycle through: Commit → Propose → Dispute → Commit (approximately every few minutes)

### Lock Periods {#lock-periods-initiate}

Current network parameters (verify on [Razorscan Governance](https://razorscan.io/governance/values)):
- **unstakeLockPeriod**: 300 epochs (time after unstake before you can initiate withdraw)
- **withdrawInitiationPeriod**: 150 epochs (window to call initiate withdraw)
- **withdrawLockPeriod**: 300 epochs (time after initiate withdraw before you can withdraw)

### Related Operations {#related-operations-initiate}

**Before this operation:**
- [Unstake](./unstake.md) - Must be completed first

**After this operation:**
- Wait for withdrawLockPeriod to pass
- [Withdraw](./withdraw.md) - Claim your RAZOR tokens

**If you miss the window:**
- [Reset Lock](./reset-lock.md) - Extend the unstake lock (incurs penalty)
2 changes: 1 addition & 1 deletion docs/razor-v2/mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Razor Network is currently live on Mainnet. Details regarding mainnet is mention
| Chain name | Europa Defi Hub |
| ChainID | 2046399126 |
| Chain currency | sFUEL |
| Faucet | https://www.sfuelstation.com/ |
| Faucet | https://portal.skale.space/chains/europa |
| RPC Endpoint | https://mainnet.skalenodes.com/v1/elated-tan-skat |
| Chain Explorer | https://elated-tan-skat.explorer.mainnet.skalenodes.com/ |
| Token type | ERC-20 |
Expand Down
Loading