# SinglePool

이 컨트랙트는 단일풀 컨트랙트로써 유동성 제공자는 자산을 예치/출금하고 플러스풀 사용자는 활용자산을 단일풀에서 가져오거나 반환하게 됩니다. &#x20;

## Address

* Contract adress after production is deployed (scope link)&#x20;

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

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

## Events

**GiveReward**

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

* KSP 보상 지급시 발생하는 이벤트&#x20;

**Deposit**

```solidity
event Deposit(address user, uint depositAmount, uint depositTokens, uint totalAmount, uint totalSupply);
```

* 단일풀 예치시 발생하는 이벤트
* Parameters
  * user : 예치한 지갑 주소
  * depositAmount : 예치한 Token 수량
  * depositTokens : 생성된 SP Token 수량
  * totalAmount : 풀에 예치된 총 Token 수량
  * totalSupply : 풀에 생성된 총 SP Token 수량

**Withdraw**

```solidity
event Withdraw(address user, uint withdrawAmount, uint withdrawTokens, uint totalAmount, uint totalSupply);
```

* 단일풀 출금시 발생하는 이벤트
* Parameters
  * user : 사용자 주소&#x20;
  * withdrawAmount : 출금한 Token 수량
  * withdrawTokens : 출금한 SP Token 수량
  * totalAmount : 풀에 예치된 총 Token 수량
  * totalSupply : 풀에 생성된 총 SP Token 수량

**Borrow**

```solidity
event Borrow(address user, address plusPoolAddress, uint borrowAmount, uint accountBorrows, uint totalBorrows);
```

* 플러스 예치시 활용자산 이용시 발생하는 이벤트
* Parameters
  * user : 사용자 주소&#x20;
  * plusPoolAddress : 플러스풀 주소&#x20;
  * borrowAmount : 활용자산으로 사용된 token 수량
  * accountBorrows : 사용자 총 활용자산 수량
  * totalBorrows : 단일풀 총 활용자산 수량   &#x20;

**Repay**

```solidity
event Repay(address user, address plusPoolAddress, uint repayAmount, uint accountBorrows, uint totalBorrows);
```

* 활용자산 반환시 발생하는 이벤트
* Parameters
  * user : 사용자 주소&#x20;
  * plusPoolAddress : 플러스풀 주소&#x20;
  * repayAmount : 반환된 활용자산 token 수량
  * accountBorrows : 사용자 총 활용자산 수량
  * totalBorrows : 단일풀 총 활용자산 수량
    {% endtab %}

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

## Read-Only Functions

#### name

* "I" + token name

#### symbol

* "i" + token symbol

**decimals**

* 18

**token**

* KIP7 기반 token address&#x20;

#### totalSupply

* 유동성 추가 제거에 따른 총 유동성 Token 수량

#### balanceOf

* 각 지갑 주소가 보유한 유동성 Token 수량

#### allowance

* 각 지갑 주소의 allowance 상태

#### getCash

* 예치된 Token 수량

#### reserveFactor

* 활용수수료 중 KSP 바이백 & 소각 배정 비율&#x20;
* 1 \~ 10^18, 단위 0.000000000000000001
* 기본 - 200000000000000000

#### totalBorrow

* 총 활용자산 수량

#### mining

* 단일풀에 분배되는 KSP 중 해당 풀이 채굴하는 비율
* 1 \~ 10000, 단위 0.0001

#### lastMined

* 마지막으로 수정된 SinglePoolFactory.mined() 값

#### withdrawActive

```solidity
function withdrawActive() public view returns (bool)
```

* 단일풀 출금 가능 여부

#### depositActive

```solidity
function depostiActive() public view returns (bool)
```

* 단일풀 예치 가능 여부&#x20;

####

{% endtab %}

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

## State-Changing Functions

#### transfer

```solidity
function transfer(address _to, uint _value) public returns (bool)
```

* KIP7 Standard
* 토큰 전송 함수&#x20;

#### transferFrom

```solidity
function transferFrom(address _from, address _to, uint _value) public returns (bool)
```

* KIP7 Standard
* 승인받은 지갑 토큰 전송 함수

#### approve

```solidity
function approve(address _spender, uint _value) public returns (bool)
```

* KIP7 Standard
* 전송 승인 요청 함수

#### depositKlay

```solidity
function depositKlay() public payable
```

* KLAY 단일풀 예치 함수
* `msg.value` 값 사용

#### depositKct

```solidity
function depositKct(uint depositAmount) public
```

* KIP7 기반 단일풀 예치입금 함수
* `depositAmount` : 토큰 수량

#### withdraw

```solidity
function withdraw(uint withdrawAmount)
```

* 단일풀 출금 함수
* withdrawAmount : 출금할 토큰 수량

#### withdrawByAmount

```solidity
function withdrawByAmount(uint withdrawTokens)
```

* 단일풀 유동성 토큰 출금 함수
* withdrawTokens : 출금할 단일풀 유동성 토큰(iToken) 수량

#### addReserves

```solidity
function addReserves(uint addAmount) external payable
```

* Buyback 대기금 충전 함수
* addAmount : 토큰 수량

#### claimReward

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

* 보상 청구 함수
* 호출시 누적된 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.klayswap.com/kr/developer/contract/singlepool.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.
