You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/build-your-staking-dapp/polygon/methods.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,8 +50,11 @@ To build a staking transaction, you will need to specify:
50
50
-**delegatorAddress**: The delegator's Ethereum address
51
51
-**validatorShareAddress**: The validator's ValidatorShare contract address
52
52
-**amount**: The amount to stake in POL
53
-
-**slippageBps**: (Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint automatically.
54
-
-**minSharesToMint**: (Optional) Minimum validator shares to receive for slippage protection. Use this OR slippageBps, not both.
53
+
-**slippageBps**: Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint automatically. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default).
54
+
-**minSharesToMint**: Minimum validator shares to receive for slippage protection. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default).
55
+
56
+
> **Why is slippage required?** Polygon uses a share-based delegation model where the exchange rate between POL and validator shares fluctuates. The slippage parameter protects against unfavorable rate changes between transaction submission and execution. This is a requirement of the ValidatorShare contract itself.
57
+
55
58
-**referrer**: (Optional) Custom referrer string for tracking. Defaults to `'sdk-chorusone-staking'`.
56
59
57
60
### Example
@@ -99,8 +102,11 @@ To build an unstaking transaction, you need to specify:
99
102
-**delegatorAddress**: The address of the delegator
100
103
-**validatorShareAddress**: The validator's ValidatorShare contract address
101
104
-**amount**: The amount of POL to unstake
102
-
-**slippageBps**: (Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn automatically.
103
-
-**maximumSharesToBurn**: (Optional) Maximum validator shares willing to burn for slippage protection. Use this OR slippageBps, not both.
105
+
-**slippageBps**: Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn automatically. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default).
106
+
-**maximumSharesToBurn**: Maximum validator shares willing to burn for slippage protection. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default).
107
+
108
+
> **Why is slippage required?** Polygon uses a share-based delegation model where the exchange rate between POL and validator shares fluctuates. The slippage parameter protects against unfavorable rate changes between transaction submission and execution. This is a requirement of the ValidatorShare contract itself.
109
+
104
110
-**referrer**: (Optional) Custom referrer string for tracking. Defaults to `'sdk-chorusone-staking'`.
Copy file name to clipboardExpand all lines: book/docs/classes/polygon_src.PolygonStaker.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,6 +124,9 @@ Builds a staking (delegation) transaction
124
124
Delegates POL tokens to a validator via their ValidatorShare contract.
125
125
Requires prior token approval to the StakeManager contract.
126
126
127
+
**Slippage requirement:** Exactly one of `slippageBps` or `minSharesToMint` must be provided.
128
+
There is no default value. Providing neither or both will throw an error.
129
+
127
130
### Parameters
128
131
129
132
| Name | Type | Description |
@@ -132,8 +135,8 @@ Requires prior token approval to the StakeManager contract.
132
135
|`params.delegatorAddress`|\`0x$\{string}\`| The delegator's Ethereum address |
133
136
|`params.validatorShareAddress`|\`0x$\{string}\`| The validator's ValidatorShare contract address |
134
137
|`params.amount`|`string`| The amount to stake in POL |
135
-
|`params.slippageBps?`|`number`|(Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint. |
136
-
|`params.minSharesToMint?`|`bigint`|(Optional) Minimum validator shares to receive. Use this OR slippageBps, not both. |
138
+
|`params.slippageBps?`|`number`| Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default). |
139
+
|`params.minSharesToMint?`|`bigint`| Minimum validator shares to receive. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default). |
137
140
|`params.referrer?`|`string`| (Optional) Custom referrer string for tracking. If not provided, uses 'sdk-chorusone-staking'. |
138
141
139
142
### Returns
@@ -153,6 +156,9 @@ Builds an unstaking transaction
153
156
Creates an unbond request to unstake POL tokens from a validator.
154
157
After the unbonding period (~80 checkpoints, approximately 3-4 days), call buildWithdrawTx() to claim funds.
155
158
159
+
**Slippage requirement:** Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided.
160
+
There is no default value. Providing neither or both will throw an error.
161
+
156
162
### Parameters
157
163
158
164
| Name | Type | Description |
@@ -161,8 +167,8 @@ After the unbonding period (~80 checkpoints, approximately 3-4 days), call build
161
167
|`params.delegatorAddress`|\`0x$\{string}\`| The delegator's address |
162
168
|`params.validatorShareAddress`|\`0x$\{string}\`| The validator's ValidatorShare contract address |
163
169
|`params.amount`|`string`| The amount to unstake in POL (will be converted to wei internally) |
164
-
|`params.slippageBps?`|`number`|(Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn. |
165
-
|`params.maximumSharesToBurn?`|`bigint`|(Optional) Maximum validator shares willing to burn. Use this OR slippageBps, not both. |
170
+
|`params.slippageBps?`|`number`| Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default). |
171
+
|`params.maximumSharesToBurn?`|`bigint`| Maximum validator shares willing to burn. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default). |
166
172
|`params.referrer?`|`string`| (Optional) Custom referrer string for tracking. If not provided, uses 'sdk-chorusone-staking'. |
Create an unbond request to unstake POL tokens. After the unbonding period (~80 epochs, approximately 3-4 days), call withdraw to claim funds:
126
+
Create an unbond request to unstake POL tokens. After the unbonding period (~80 epochs, approximately 3-4 days), call withdraw to claim funds.
127
+
128
+
You must provide exactly one of `slippageBps` or `maximumSharesToBurn` (not both). There is no default — omitting both will throw an error.
125
129
126
130
```javascript
127
131
const { tx } =awaitstaker.buildUnstakeTx({
@@ -215,7 +219,7 @@ console.log(status) // 'success', 'failure', or 'unknown'
215
219
-**Ethereum L1 Based**: Polygon PoS staking operates via ValidatorShare contracts deployed on Ethereum mainnet (or Sepolia for testnet)
216
220
-**POL Token Staking**: Stake the native POL token (formerly MATIC) to validators
217
221
-**Human-Readable Amounts**: Pass token amounts as strings (e.g., '1.5'), conversion to wei is handled automatically
218
-
-**Slippage Protection**: Stake and unstake operations support `slippageBps` (basis points) for automatic slippage calculation, or manual `minSharesToMint`/`maximumSharesToBurn` parameters
222
+
-**Slippage Protection**: Stake and unstake operations require either `slippageBps` (basis points) for automatic slippage calculation, or manual `minSharesToMint`/`maximumSharesToBurn` parameters. Exactly one must be provided — there is no default.
219
223
-**Query Methods**: Read stake balances, rewards, allowances, unbond status (with POL amount and withdrawability), and epoch information
220
224
-**Rewards Management**: Claim rewards to wallet or compound them back into your delegation
Copy file name to clipboardExpand all lines: packages/polygon/src/staker.ts
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -140,12 +140,15 @@ export class PolygonStaker {
140
140
* Delegates POL tokens to a validator via their ValidatorShare contract.
141
141
* Requires prior token approval to the StakeManager contract.
142
142
*
143
+
* **Slippage requirement:** Exactly one of `slippageBps` or `minSharesToMint` must be provided.
144
+
* There is no default value. Providing neither or both will throw an error.
145
+
*
143
146
* @param params - Parameters for building the transaction
144
147
* @param params.delegatorAddress - The delegator's Ethereum address
145
148
* @param params.validatorShareAddress - The validator's ValidatorShare contract address
146
149
* @param params.amount - The amount to stake in POL
147
-
* @param params.slippageBps - (Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint.
148
-
* @param params.minSharesToMint - (Optional) Minimum validator shares to receive. Use this OR slippageBps, not both.
150
+
* @param params.slippageBps - Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate minSharesToMint. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default).
151
+
* @param params.minSharesToMint - Minimum validator shares to receive. Exactly one of `slippageBps` or `minSharesToMint` must be provided (not both, no default).
149
152
* @param params.referrer - (Optional) Custom referrer string for tracking. If not provided, uses 'sdk-chorusone-staking'.
150
153
*
151
154
* @returns Returns a promise that resolves to a Polygon staking transaction
@@ -214,12 +217,15 @@ export class PolygonStaker {
214
217
* Creates an unbond request to unstake POL tokens from a validator.
215
218
* After the unbonding period (~80 checkpoints, approximately 3-4 days), call buildWithdrawTx() to claim funds.
216
219
*
220
+
* **Slippage requirement:** Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided.
221
+
* There is no default value. Providing neither or both will throw an error.
222
+
*
217
223
* @param params - Parameters for building the transaction
218
224
* @param params.delegatorAddress - The delegator's address
219
225
* @param params.validatorShareAddress - The validator's ValidatorShare contract address
220
226
* @param params.amount - The amount to unstake in POL (will be converted to wei internally)
221
-
* @param params.slippageBps - (Optional) Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn.
222
-
* @param params.maximumSharesToBurn - (Optional) Maximum validator shares willing to burn. Use this OR slippageBps, not both.
227
+
* @param params.slippageBps - Slippage tolerance in basis points (e.g., 50 = 0.5%). Used to calculate maximumSharesToBurn. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default).
228
+
* @param params.maximumSharesToBurn - Maximum validator shares willing to burn. Exactly one of `slippageBps` or `maximumSharesToBurn` must be provided (not both, no default).
223
229
* @param params.referrer - (Optional) Custom referrer string for tracking. If not provided, uses 'sdk-chorusone-staking'.
224
230
*
225
231
* @returns Returns a promise that resolves to a Polygon unstaking transaction
0 commit comments