# Developer Overview

> The GIWA Sepolia network, its test tokens, and how Giwater's contracts fit together.

Giwater is a deployment of the PancakeSwap Infinity contracts — concentrated-liquidity (CL) pools, a singleton Vault with flash accounting, hooks, UniversalRouter and Permit2 — on GIWA Sepolia. The contracts are the upstream releases compiled without local patches, so Infinity's interfaces, action encodings and SDK conventions apply unchanged.

{/* Source repository link: pending decision, add here once published. */}

These pages are for developers building a frontend, bot or indexer against the deployment. [Contracts](/docs/developers/contracts) lists every address and ABI; [Integration](/docs/developers/integration) walks through quoting, swapping and providing liquidity.

## Network

- Network: GIWA Sepolia
- Chain ID: 91342
- RPC: https://sepolia-rpc.giwa.io
- Explorer: https://sepolia-explorer.giwa.io
- Currency: ETH

The deployment lives on testnet only. It runs CL pools and nothing else: the router supports Infinity CL swaps, and there are no bin or stable-swap pools. The seeded pools pair each test token with USDC at fixed fee tiers, and none of them has a hook (`hooks` is the zero address in each pool key). Anyone can create further pools through CLPositionManager.

The explorer runs Blockscout, which also serves an Etherscan-compatible API.

## Test Tokens

You need two things: GIWA Sepolia ETH for gas, and the test tokens the pools trade.

- **ETH** — from the [Nodit Faucet](https://faucet.lambda256.io/giwa-sepolia) or the [GIWA Official Faucet](https://faucet.giwa.io/).
- **Test tokens** — from the [Faucet](/faucet) page. One claim sends a fixed amount of each token, plus `ethAmount()` of ETH (which can be zero), to the signed-in wallet.

The bundle is BTC (8 decimals), USDC (6), and AAPL, SPCX and SKHY (18 each).

The faucet contract (`faucet` in the deployment manifest) is not open to arbitrary callers. Its `claim(bytes32 eligibilityId, uint256 deadline, bytes signature)` requires an authorization signed by the faucet's claim signer, which Giwater issues only after the account links X, and the app's relayer submits the claim and pays its gas. To fund a bot, sign in on the Faucet page with the bot's wallet. The contract's read functions are public: `tokens(i)` and `amounts(i)` for the bundle (`i` from 0 to 4), `ethAmount()`, `COOLDOWN()` (currently 24 hours) and `nextClaimAt(eligibilityId)`.

## Architecture

An app or bot calls UniversalRouter to swap and CLPositionManager to manage liquidity, after approving tokens through Permit2. Both open a lock on the Vault, which holds every balance and settles net amounts through flash accounting; inside that lock they call CLPoolManager, which owns pool state and ticks and invokes a pool's hooks when it has them. CLQuoter and CLTickLens read pool state for quotes and tick data.

### State

- **Vault** — the only contract that holds pool tokens. It tracks a delta per locker and currency for the current lock, and per-app reserves.
- **CLPoolManager** — every CL pool's slot0 (`sqrtPriceX96`, tick, fees), tick bitmap, liquidity and positions, keyed by `PoolId = keccak256(abi.encode(PoolKey))`. Pools are storage entries, not contracts. It reports each operation's balance change to the Vault (`accountAppBalanceDelta`).
- **Hooks** — optional per pool, named in `PoolKey.hooks`; the enabled callbacks are encoded in `PoolKey.parameters`. All seeded pools use the zero address.

### Lock and Settle

Every state change runs inside one Vault lock:

```text
caller ──▶ UniversalRouter.execute / CLPositionManager.modifyLiquidities
             └─▶ Vault.lock(data)
                   └─▶ caller.lockAcquired(data)
                         ├─ CLPoolManager.swap / modifyLiquidity / donate   → delta(currency) ± amount
                         ├─ Vault.sync(currency) + token transfer + Vault.settle()   → pay a negative delta
                         └─ Vault.take(currency, to, amount)                → receive a positive delta
             lock returns only if every delta is zero; otherwise the transaction reverts
```

Consequences for integrators:

- A multi-hop swap transfers only the first input and the final output; intermediate currencies net to zero inside the Vault.
- Slippage is enforced inside the plan (`amountOutMinimum` / `amountInMaximum`) and by the `execute` deadline, not after settlement.
- Contracts that call the Vault directly must implement `lockAcquired` and close every delta themselves.

### Entry Points

- **Swaps** — `UniversalRouter.execute(commands, inputs, deadline)` with the `INFI_SWAP` command and a CL swap action plan ending in settle/take actions. Spends tokens through Permit2.
- **Liquidity** — `CLPositionManager.modifyLiquidities(payload, deadline)`; positions are ERC-721 tokens. Mint, increase, decrease and burn are actions in one plan.
- **Approvals** — ERC-20 `approve(Permit2, …)` once, then a Permit2 allowance per spender, from `Permit2.approve` or a signed permit (`PERMIT2_PERMIT` command, `permitBatch` on the position manager).
- **Quotes** — `CLQuoter.quoteExactInputSingle` and friends; they simulate the swap and revert internally, so call them with `eth_call` only.
- **Reads** — `CLPoolManager.getSlot0`, `getLiquidity`, `getPoolTickInfo`, and `CLTickLens.getPopulatedTicksInWord` for initialized ticks.

Protocol mechanics: [Concentrated Liquidity](/docs/product/concentrated-liquidity), [Swaps](/docs/product/swaps), [Settlement](/docs/product/settlement), [Hooks](/docs/product/hooks).
