# Test env. commands

Using the Hardhat framework, interacting with a contract deployed in the local environment is implemented as a CLI. All commands can be called with `yarn hardhat <command>`. The implementation is under the **tasks/** folder, so please refer to the task.

When testing on the local environment, first run **yarn hardhat:deploy** to open the local environment.

```shell
// example: get pool info
$ 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

Returns accounts list of local test environment

```shell
yarn hardhat accounts

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

### addresses

Returns Pangea contracts list of local test environment

```shell
yarn hardhat addresses

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

### dashboard:tokens

Returns token info in local test environment

* caution : token prices are set randomly

```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

Returns every pools' info in local test environment

```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

Returns every positions' info in local test environment

```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

Creates a new pool

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

# example (user101 creates  0.2% swap fee rate KSP /KDAI Pool (Initial Price => KSP : KDAI = 10 : 20)
yarn hardhat pool:create user101 KSP KDAI 2000 10 20
```

### position:mint

Mints a new position

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

# user100 deposits [40 KDAI + 40 WKLAY] in KDAI/WKLAY Pool on 50% ~15000% price range
yarn hardhat position:mint 
user100 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 5000 15000 
40000000000000000000 40000000000000000000 
```

### position:addLiquidity

Adds liquidity to existing position

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

# user100 deposits additional [40 KDAI / 40 KLAY ] to NFT(position) #43
yarn hardhat position:addLiquidity user100 43 4000000000000000000 4000000000000000000
```

### position:burn

Burns existing position

(If the amount is larger than existing liquidity, NFT will be burn after claiming liquidity+fees)

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

# user100 withdraws 100,000,000,000 liquidity from NFT #44 and sends to user100
yarn hardhat position:burn user100 44 100000000000 user100 
```

### position:collect

Claims fee from position

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

# user100 claims fee from NFT #44 and sends to user100
yarn hardhat position:collect user100 44 user100
```

### swap:exactInputSingle

Swaps token in pool (Based on Input amount)

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

# user100 swaps KDAI ==> KLAY in pool 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 
yarn hardhat swap:exactInputSingle user100 KDAI 1000000000000  0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 user100
```

### swap:exactOutputSingle

Swaps token in pool (Based on Output amount)

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

# user100 swaps KDAI ==> KLAY in pool 0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 
yarn hardhat swap:exactOutputSingle user100 KDAI 1000000000000  0xe7de38237a4ED33fbf30f5aaD683F99Bc6c15817 user100
```

### erc20:balanceOf

Returns balance of user

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

# balance of 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

Gets token for test

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

# Provide 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/en/developers/interacting-with-the-protocol/setting-up-local-test-environment/test-env.-commands.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.
