# VotingKSP

이 컨트랙트는 KSP를 스테이킹과 관련된 생태계 동작을 담당합니다. 스테이킹 수량과 기간에 따라 투표권(vKSP)을 발행하며, 스테이킹 참여자에게  1일 KSP 마이닝 수량의 40%를 분배합니다. \
(스테이킹 참여자 대상 KSP 분배율은 거버넌스 투표를 통해 변경될 수 있습니다)&#x20;

## Code

Github Link: (Will be updated after official launch)

## Address

* Cypress : [0x2F3713F388BC4b8b364a7A2d8D57c5Ff4E054830](https://scope.klaytn.com/account/0x2F3713F388BC4b8b364a7A2d8D57c5Ff4E054830?tabId=txList)

&#x20;

## Events, Read-Only Functions, and State-Changing Functions

{% tabs %}
{% tab title="Events" %}

## Events

**LockKSP**

```solidity
event LockKSP(address user, uint lockPeriod, uint KSPAmount, uint totalLockedKSP, uint unlockTime);
```

* KSP를 스테이킹시 발생되는 이벤트
* Parameters
  * `user` : 유저 지갑 주소
  * `lockPeriod` :&#x20;
    * 4개월 : 10,368,000
    * 8개월 : 20,736,000
    * 12개월 : 31,104,000
    * x8 : 1,555,200,000
  * `KSPAmount` : KSP 수량
  * `totalLockedKSP` : 총 스테이킹된 KSP 수량
  * `unlockTime` : 언스테이킹 가능한 시간 (timestamp)

**UnlockKSP**&#x20;

<pre class="language-solidity"><code class="lang-solidity"><strong>event UnlockKSP(address user, uint vKSPAmount, uint KSPAmount);
</strong></code></pre>

* vKSP를 언스테이킹 시 발생되는 이벤트
* Parameters
  * `user` : 유저 지갑 주소
  * `vKSPAmount` : 보유했던 vKSP 수량
  * `KSPAmount` : 언스테이킹 KSP 수량

**UnlockKSPUnlimited**

```solidity
event UnlockKSPUnlimited(address user, uint vKSPBefore, uint vKSPAfter, uint KSPAmount, uint unlockTime);
```

* vKSP x8 스테이킹을 해제할시 발생되는 이벤트
* Parameters
  * `user` : 유저 지갑 주소
  * `vKSPBefore` : 보유했던 vKSP 수량
  * `vKSPAfter` : 스테이킹 해제후 보유한 vKSP 수량
  * `KSPAmount` : 스테이킹한 KSP 수량
  * `unlockTime` : 언스테이킹 가능한 시간 (timestamp)

**RefixBoosting**

```solidity
event RefixBoosting(address user, uint lockPeriod, uint boostingAmount, uint unlockTime);
```

* 스테이킹 기간 변경 시 발생되는 이벤트
* Parameter
  * `user` : 유저 지갑 주소
  * `lockPeriod` : 변경 기간
  * `boostingAmount` : 변경 후 보유 vKSP
  * `unlockTime` : 언스테이킹 가능한 시간 (timestamp)

**ChangeMiningRate**

```solidity
event ChangeMiningRate(uint _mining);
```

* 일일 KSP 분배율 변경 시 발생되는 이벤트

**GiveReward**

```solidity
event GiveReward(address user, uint amount, uint lastIndex, uint rewardSum);
```

* KSP 보상 시 발생되는 이벤트
  {% endtab %}

{% tab title="Read-Only Functions" %}

## Read-Only Functions

**balanceOf**

* 지갑별 vKSP 보유 수량

**getCurrentBalance**

* 라운드 시작시 지갑별 vKSP 보유 수량

**getUserUnlockTime**

* 언스테이킹 가능 시점(스테이킹 기간 계산 포함)

**lockedKSP**

* 스테이킹 한 KSP 수량

**mining**

* 일일 KSP 분배
* 0 \~ 10000 값, 단위 0.01%

**snapShotBalance**

* 상위 풀 여부 스냅샷

**snapShotCount**

* 스냅샷 개

**unlockTime**

* 언스테이킹 가능 시

**getPriorBalance**

```solidity
function getPriorBalance(address user, uint blockNumber) public view returns (uint) 
```

* 블록 별 과거 vKSP 보유 수량
* Parameter
  * `user` : 지갑 주소
  * `blockNumber` : 과거 blockNumber

**getSnapBalance**

```solidity
function snapShotBalance(address user, uint index) public view returns (uint) 
```

* 지갑 별 과거 vKSP 보유 수량
* Parameter
  * `user` : 지갑 주소
  * `index` : 순차 별 인덱

**snapShotBlock**

```solidity
function snapShotBlock(address user, uint index) public view returns (uint) 
```

* 지갑 스냅샷 당시 BlockNumber
* Parameter
  * `user` : 지갑 주소
  * `index` : 순차 별 BlockNumber
    {% endtab %}

{% tab title="State-Changing Functions" %}

## **State-Changing Functions**

**lockKSP**

```solidity
function lockKSP(uint amount, uint lockPeriodRequested) public
```

* KSP 스테이킹 함수
* KSP 정수단위로 스테이킹 가능&#x20;

**unlockKSP**

```solidity
function unlockKSP() public
```

* KSP 언스테이킹 함수
* 언락 기간에만 언스테이킹 가능하다

**unlockKSPUnlimited**

```solidity
function unlockKSPUnlimited() public
```

* KSP x8 스테이킹을 해제하는 함수
* 해제 시점부터 x4 스테이킹으로 변경

**refixBoosting**

```solidity
function refixBoosting(uint lockPeriodRequested)
```

* KSP 스테이킹 기간 변경 함수

**claimReward**

```solidity
function claimReward() public
```

* KSP 보상 수령 함수

**compoundReward**

```solidity
function compoundReward() public
```

* KSP 보상 스테이킹 함수&#x20;
* 보상이 1 KSP 이상일때 호출 가능
* 정수 단위로 스테이킹 가능하며 나머지는 지갑 주소로 전
  {% endtab %}
  {% endtabs %}


---

# 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-new.klayswap.com/developers/contract/votingksp.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.
