# KyberStaking

{% hint style="warning" %}
You are referring to the **`Legacy`** version of KyberSwap docs.

For the most updated information, please refer to:

* [**`Classic`**](https://github.com/KyberNetwork/kyberswap-documentation/blob/main/reference/legacy/api-abi/core-smart-contracts/broken-reference/README.md)
* [**`Elastic`**](/reference/legacy/kyberswap-elastic.md)
* [**`Limit Order`**](/kyberswap-solutions/limit-order.md)
* [**`Aggregator`**](/kyberswap-solutions/kyberswap-aggregator.md)
  {% endhint %}

## constract KyberStaking

is IERC20, ReentrancyGuard, [IKyberStaking](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-ikyberstaking.md), [IKyberDao](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-ikyberdao.md), [EpochUtils](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-epochutils.md)\ imports [IKyberStaking](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-ikyberstaking.md), [EpochUtils](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-epochutils.md), ReentrancyGuard

*Source*: [KyberStaking.sol](https://github.com/KyberNetwork/smart-contracts/blob/master/contracts/sol6/Dao/KyberStaking.sol)

***

### INDEX[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#index) <a href="#index" id="index"></a>

\<AUTOGENERATED\_TABLE\_OF\_CONTENTS>

### REFERENCE[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#reference) <a href="#reference" id="reference"></a>

#### Events[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#events) <a href="#events" id="events"></a>

#### `WithdrawDataUpdateFailed`[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#withdrawdataupdatefailed) <a href="#withdrawdataupdatefailed" id="withdrawdataupdatefailed"></a>

Event for logging the failed withdrawal of KNC from the staking contract.

***

event **WithdrawDataUpdateFailed**(uint256 curEpoch, address staker, uint256 amount) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | `curEpoch` | uint256 | current epoch number where KNC was deposited | | `staker` | address | staker's address | | `amount` | uint256 | amount of KNC withdrawn in twei | Signature: 0xa412eef5316d3cbf9e2b4ba3d1cf3e482b40dc8946fd919b7f5053450fa621fb

\\

#### Functions[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#functions) <a href="#functions" id="functions"></a>

#### `delegate`[​](https://docs.kyberswap.com/Legacy/api-abi/core-smart-contracts/api_abi-kyberstaking#delegate) <a href="#delegate" id="delegate"></a>

Sets the delegation to a representative, and only takes effect on the next epoch

***

function **delegate**(address newRepresentative) external override | Parameter | Type | Description | | --------- |:-----:|:-----------:| | `dAddr` | address | representative's address to delegate to |

\
\### \`deposit\` Deposit and stake KNC. \_\_\_ function \_\_deposit\_\_(uint256 amount) external override | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`amount\` | uint256 | amount of KNC to deposit in twei |\
\### \`withdraw\` Unstakes and withdraws KNC from the staking contract. \_\_\_ function \_\_withdraw\_\_(uint256 amount) external override nonReentrant | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`amount\` | uint256 | amount of KNC to withdraw in twei |\
\### \`getStakerRawData\` Returns the raw staker data up to current epoch + 1. Returns 0 values if staker data is uninitialized. \_\_\_ function \_\_getStakerRawData\_\_(address staker, uint256 epoch) external view override returns (uint256 stake, uint256 delegatedStake, address representative) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | | \`epoch\` | uint256 | epoch number to get staker raw data |

**Returns:**\ stake - total amount of KNC staked in twei delegatedStake - amount of KNC delegated to the staker's address in twei representative - if the staker is delegating, this shows the address he is delegating to

\
\### \`getStake\` Get staked amount up to current epoch + 1. \_\_\_ function \_\_getStake\_\_(address staker, uint256 epoch) external view returns (uint256) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | | \`epoch\` | uint256 | epoch number to get the staked amount | \*\*Returns:\*\*\ Staked amount in KNC token wei at epoch\
\### \`getDelegatedStake\` Get delegated staked amount up to current epoch + 1. \_\_\_ function \_\_getDelegatedStake\_\_(address staker, uint256 epoch) external view returns (uint256) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | | \`epoch\` | uint256 | epoch number to get the delegated staked amount | \*\*Returns:\*\*\ Delegated staked amount in KNC token wei at epoch\
\### \`getRepresentative\` Get representative of a staker up to current epoch + 1. \_\_\_ function \_\_getRepresentative\_\_(address staker, uint256 epoch) external view returns (address) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | | \`epoch\` | uint256 | epoch number to get the representative | \*\*Returns:\*\*\ Representative's address at epoch\
\### \`getStakerData\` Iterates through all the epochs and returns the staker data up to current epoch + 1. \_\_\_ function \_\_getStakerData\_\_(address staker, uint256 epoch) external view override returns (uint256 stake, uint256 delegatedStake, address representative) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | | \`epoch\` | uint256 | epoch number to start iterating from to get staker data | \*\*Returns:\*\*\ stake - total amount of KNC staked in twei delegatedStake - amount of KNC delegated to the staker's address in twei representative - if the staker is delegating, this shows the address he is delegating to\
\### \`getLatestRepresentative\` Get representative of a staker up at the latest epoch. \_\_\_ function \_\_getLatestRepresentative\_\_(address staker) external view returns (address) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | \*\*Returns:\*\*\ Representative at the latest epoch\
\### \`getLatestDelegatedStake\` Get latest delegated staked amount. \_\_\_ function \_\_getLatestDelegatedStake\_\_(address staker) external view returns (uint256) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | \*\*Returns:\*\*\ Delegated staked amount in KNC token wei latest epoch\
\### \`getLatestStakeBalance\` Get staked amount at the latest epoch. \_\_\_ function \_\_getLatestStakeBalance\_\_(address staker) external view returns (uint256) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | \*\*Returns:\*\*\ Staked amount in KNC token wei at latest epoch\
\### \`getLatestStakerData\` Iterates through all the epochs until the latest epoch and returns the staker data. \_\_\_ function \_\_getLatestStakerData\_\_(address staker) external view override returns (uint256 stake, uint256 delegatedStake, address representative) | Parameter | Type | Description | | --------- |:-----:|:-----------:| | \`staker\` | address | staker's address | \*\*Returns:\*\*\ stake - total amount of KNC staked in twei delegatedStake - amount of KNC delegated to the staker's address in twei representative - if the staker is delegating, this shows the address he is delegating to


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kyberswap.com/reference/legacy/api-abi/core-smart-contracts/kyberstaking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
