# 로컬테스트 환경 내 명령어

Hardhat 프레임워크를 이용해 로컬 환경 내 배포된 컨트랙트와 상호작용하는 것을 CLI로 구현하였습니다. 모든 명령어는 `yarn hardhat <명령어>` 로 호출할 수 있습니다. 구현체는 **tasks/**&#xD3F4;더 아래에 있으므로, 작업에 참고하시길 바랍니다.

로컬 환경테스트를 진행하실 땐, 먼저 **yarn hardhat:deploy** 을 우선 실행하여, 로컬 환경을 띄워주시길 바랍니다.

```shell
// 예시: 풀의 정보 가져오기
$ yarn hardhat pool:info 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817


┌────────────────────────────────────────────┬────────┬────────┬─────────┬────────────┬───────────────────────────┬───────────────────────────┬────────────────────┐
│ pool Address                               │ token0 │ token1 │ swapFee │ priceRatio │ reserve0                  │ reserve1                  │ totalValueLock ($) │
├────────────────────────────────────────────┼────────┼────────┼─────────┼────────────┼───────────────────────────┼───────────────────────────┼────────────────────┤
│ 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 │ KDAI   │ WKLAY  │ 0.002   │ 0.92336    │ 1052510019943583677983227 │ 1000189271702431420936569 │ 2142716            │
└────────────────────────────────────────────┴────────┴────────┴─────────┴────────────┴───────────────────────────┴───────────────────────────┴────────────────────┘
```

## tasks

### accounts

로컬 환경 테스트 내 계정 정보 리스트 반환

```shell
yarn hardhat accounts

┌───────────────┬────────────────────────────────────────────┬───────────────────────────────┐
│ name          │ address                                    │ balance                       │
├───────────────┼────────────────────────────────────────────┼───────────────────────────────┤
│ deployer      │ 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 │ 9999999329713343500000000000  │
├───────────────┼────────────────────────────────────────────┼───────────────────────────────┤
│ dev           │ 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 │ 10000000000000000000000000000 │
├───────────────┼────────────────────────────────────────────┼───────────────────────────────┤
│ user100       │ 0x90F79bf6EB2c4f870365E785982E1f101E93b906 │ 9998999998657649250000000000  │
├───────────────┼────────────────────────────────────────────┼───────────────────────────────┤
```

### addresses

로컬 환경 테스트 내 판게아 컨트랙트의 주소 반환

```shell
yarn hardhat addresses

{
  AirdropDistributor: '0x0165878A594ca255338adfa4d48449f69242Eb8F',
  ConcentratedLiquidityPoolFactory: '0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1',
  ConcentratedLiquidityPoolHelper: '0x68B1D87F95878fE05B998F19b66F4baba5De1aed',
  ConcentratedLiquidityPoolManager: '0x59b670e9fA9D0A427751Af201D676719a970857b',
  ...
}
```

### dashboard:tokens

테스트 환경 내 토큰 정보 반환

* 주의 : 토큰 가격은 임의로 산정하였습니다.

```shell
yarn hardhat dashboard:tokens

┌─────────────────────────────────┬────────┬──────────┬──────────┬────────────────────────────────────────────┐
│ name                            │ symbol │ decimals │ price($) │ address                                    │
├─────────────────────────────────┼────────┼──────────┼──────────┼────────────────────────────────────────────┤
│ Wrapped KLAY v10                │ WKLAY  │ 18       │ 1.09     │ 0xdB83e471d49c12789092593fE9a229744e73eb41 │
├─────────────────────────────────┼────────┼──────────┼──────────┼────────────────────────────────────────────┤
│ Klaytn DAI                      │ KDAI   │ 18       │ 1        │ 0x10cc453eA2d3d8C89Efb9EDf1Df7c237CC9b25Da │
├─────────────────────────────────┼────────┼──────────┼──────────┼────────────────────────────────────────────┤
│ Orbit Bridge Klaytn Ethereum    │ KETH   │ 18       │ 2709.05  │ 0x7B4A0dCCdcae601C61e66C64CfA01Ff951e465e5 │
├─────────────────────────────────┼────────┼──────────┼──────────┼────────────────────────────────────────────┤
```

### dashboard:pools

테스트 환경 내 모든 풀의 정보 조회하기

```shell
yarn hardhat dashboard:pools

┌────────────────────────────────────────────┬────────┬────────┬─────────┬─────────────┬────────────┬──────────┬──────────┬────────────────────┐
│ pool Address                               │ token0 │ token1 │ swapFee │ tickSpacing │ priceRatio │ reserve0 │ reserve1 │ totalValueLock ($) │
├────────────────────────────────────────────┼────────┼────────┼─────────┼─────────────┼────────────┼──────────┼──────────┼────────────────────┤
│ 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 │ KDAI   │ WKLAY  │ 0.002   │ 40          │ 0.92336    │ 1052510  │ 1000189  │ 2142716            │
├────────────────────────────────────────────┼────────┼────────┼─────────┼─────────────┼────────────┼──────────┼──────────┼────────────────────┤
│ 0x7B63D1288D0A486FCf7180773C010DDf38912937 │ KETH   │ WKLAY  │ 0.002   │ 40          │ 2380.95238 │ 509      │ 1000099  │ 2470287            │
├────────────────────────────────────────────┼────────┼────────┼─────────┼─────────────┼────────────┼──────────┼──────────┼────────────────────┤
│ 0x583579E9fe3b5aDE4dED3113bD8a20358BdEe551 │ KSP    │ WKLAY  │ 0.002   │ 40          │ 4.99999    │ 193848   │ 1000153  │ 2144722            │
├────────────────────────────────────────────┼────────┼────────┼─────────┼─────────────┼────────────┼──────────┼──────────┼────────────────────┤

```

### dashboard:positions

테스트 환경 내 모든 포지션의 정보 조회하기

```shell
yarn hardhat dashboard:positions

┌───────┬─────────┬────────────────────────────────────────────┬────────┬────────┬────────────┬────────────┬───────────────────────────┬──────────────────┬──────────────────┐
│ nftId │ owner   │ pool                                       │ token0 │ token1 │ lower      │ upper      │ liquidity                 │ fee0             │ fee1             │
├───────┼─────────┼────────────────────────────────────────────┼────────┼────────┼────────────┼────────────┼───────────────────────────┼──────────────────┼──────────────────┤
│ 1     │ user100 │ 0xF518f82F7E2739D0fc3b60ee4d95965F223856FB │ KUSDT  │ KETH   │ 0.00019    │ 0.00076    │ 346693996190808338        │ 577              │ 577665416539282  │
├───────┼─────────┼────────────────────────────────────────────┼────────┼────────┼────────────┼────────────┼───────────────────────────┼──────────────────┼──────────────────┤
│ 2     │ user101 │ 0xF518f82F7E2739D0fc3b60ee4d95965F223856FB │ KUSDT  │ KETH   │ 0.00007    │ 0.00153    │ 184542166574024376        │ 307              │ 307486223281393  │
├───────┼─────────┼────────────────────────────────────────────┼────────┼────────┼────────────┼────────────┼───────────────────────────┼──────────────────┼──────────────────┤
│ 3     │ user103 │ 0xF518f82F7E2739D0fc3b60ee4d95965F223856FB │ KUSDT  │ KETH   │ 0.00034    │ 0.00042    │ 1998786737516867651       │ 3330             │ 3330400831820018 │
├───────┼─────────┼────────────────────────────────────────────┼────────┼────────┼────────────┼────────────┼───────────────────────────┼──────────────────┼──────────────────┤
│ 4     │ user104 │ 0xF518f82F7E2739D0fc3b60ee4d95965F223856FB │ KUSDT  │ KETH   │ 0.00019    │ 0.00038    │ 346693996190808338        │ 577              │ 577665416539282  │
├───────┼─────────┼────────────────────────────────────────────┼────────┼────────┼────────────┼────────────┼───────────────────────────┼──────────────────┼──────────────────┤
```

### pool:create

신규 풀 생성하기

```shell
yarn hardhat pool:create <owner> <token0> <token1> <swapFee> <amount0> <amount1> <tickSpacing>

# example (user101이  0.2% 수수료의 KSP /KDAI 풀 생성 (교환비 KSP : KDAI = 10 : 20)
yarn hardhat pool:create user101 KSP KDAI 2000 10 20
```

### position:mint

포지션 생성하기

```shell
yarn hardhat position:mint 
<owner> <pool> <lowerRate> <upperRate> <amount0Desired> <amount1Desired>

# user100이 KDAI/WKLAY 풀에 50% ~15000% 범위로 40 KDAI / 40 WKLAY 예치
yarn hardhat position:mint 
user100 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 5000 15000 
40000000000000000000 40000000000000000000 
```

### position:addLiquidity

포지션에 추가 예치하기

```shell
yarn hardhat position:addLiquidity <owner> <tokenId> <amount0Desired> <amount1Desired>

# user100이 43번 NFT에 40 KDAI / 40 KLAY 를 추가 예치
yarn hardhat position:addLiquidity user100 43 4000000000000000000 4000000000000000000
```

### position:burn

포지션 소각하기

(amount가 보유한 유동성보다 크면, 수수료까지 모두 수취후 NFT가 소각됩니다.)

```shell
yarn hardhat position:burn <owner> <tokenId> <amount> <recipient>

# user100이 44번 토큰에서 100,000,000,000의 자산 출금 후 user100으로 전송
yarn hardhat position:burn user100 44 100000000000 user100 
```

### position:collect

포지션에서 수수료 수취하기

```shell
yarn hardhat position:collect <owner> <tokenId> <recipient>

# user100이 44번 토큰에서 100,000,000,000의 자산 출금 후 user100으로 전송
yarn hardhat position:collect user100 44 user100
```

### swap:exactInputSingle

풀에서 토큰을 교환하기 (입력값 기준)

```shell
yarn hardhat swap:exactInputSingle <owner> <tokenIn> <amountIn> <pool> <to>

# user100가 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 풀에서 KDAI ==> KLAY로 스왑 요청
yarn hardhat swap:exactInputSingle user100 KDAI 1000000000000  0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 user100
```

### swap:exactOutputSingle

풀에서 토큰을 교환하기 (출력값 기준)

```shell
yarn hardhat swap:exactOutputSingle <owner> <tokenIn> <amountOut> <pool> <to>

# user100가 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 풀에서 KDAI ==> KLAY로 스왑 요청
yarn hardhat swap:exactOutputSingle user100 KDAI 1000000000000  0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 user100
```

### erc20:balanceOf

유저가 보유한 토큰 잔액 조회하기

```shell
yarn hardhat erc20:balanceOf <owner>

# user100의 자산 조회하기
yarn hardhat erc20:balanceOf user100
┌──────────────────────────────┬────────┬─────────────────────────┬─────────────────────┬──────┬────────────────────────┬──────────────┬───────┬────────────────────────┐
│ klay                         │ WKLAY  │ KDAI                    │ KETH                │ KORC │ KSP                    │ KUSDT        │ KWBTC │ WEMIX                  │
├──────────────────────────────┼────────┼─────────────────────────┼─────────────────────┼──────┼────────────────────────┼──────────────┼───────┼────────────────────────┤
│ 9998999998725332500000000000 │ 330816 │ 20449002984303316073525 │ 7887949398267321649 │ 0    │ 3817526685307753417416 │ 532894420041 │ 0     │ 4806473531128610147717 │
└──────────────────────────────┴────────┴─────────────────────────┴─────────────────────┴──────┴────────────────────────┴──────────────┴───────┴────────────────────────┘
```

### erc20:faucet

테스트를 위한 토큰 생성하기

```shell
yarn hardhat erc20:faucet <token> <to> <amount>

# user100에게 KUSDT 1,000,000 제공
yarn hardhat erc20:faucet KUSDT user100 1000000
```


---

# 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://pangeaswap.gitbook.io/pangeaswap/developers/interacting-with-the-protocol/undefined/undefined.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.
