> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/providing-liquidity.md).

# Providing Liquidity

Range shares, deposits, withdrawals and execution limits for liquidity integrations.

Provide liquidity to a PoolKey and tick range through its supported Hook. ERC-6909 shares represent liquidity, not a fixed token balance or guaranteed redemption value.

This SDK flow follows `@masterpeach/market-sdk@1.0.1`, `main@b5fc5ba`. Its ABI provenance is `53cb71c7…`; the earlier contract reference uses `314ed215…`. Verify deployment and version-sensitive behavior before execution.

### Understand the position

Price relative to `tickLower` and `tickUpper` determines whether a deposit or withdrawal contains one asset or both. In-range liquidity earns trading fees; out-of-range liquidity resumes earning when price returns. Narrower ranges concentrate exposure and can leave range sooner. Fee income alone is not profit.

Obtain the complete PoolKey from `getPool(poolId)` or Registry discovery. Check currency order, supported Hook, initialization, tick spacing and lower < upper. Use `getMarketRangeId`; its hash uses standard ABI encoding with signed ticks. Token amounts use integer base units; liquidity/shares are separate units.

### Add liquidity

Reuse the [Quickstart](https://docs.peach.ag/documentation/arc/adaptive-pools/quickstart) client created with `prepare: true`, its explicit `verifyDeployment()` check and `submitConfirmed(client, prepared, onSent)` helper. Default `prepare: false` skips transaction preflight; deployment verification is a separate code-and-wiring check.

Supply the connected `owner`, chosen liquidity/slippage/deadline in `params`, and user-approved maximum token budgets. This prepares one action without broadcasting:

```typescript
import { type MarketClient, type MarketLiquidityParams } from '@masterpeach/market-sdk';
import { isAddressEqual, type Address } from 'viem';

export async function prepareDepositStep(
  client: MarketClient, owner: Address, params: MarketLiquidityParams,
  maxAmount0: bigint, maxAmount1: bigint,
) {
  const quote = await client.previewDeposit(params);
  if (quote.data.limit0 > maxAmount0 || quote.data.limit1 > maxAmount1)
    throw new Error('Quote exceeds approved token budgets');
  const spend = await client.getSpendStatus({
    key: params.key, owner, amount0: quote.data.limit0, amount1: quote.data.limit1,
    ...quote.block,
  });
  if (spend.data.tokens.some(token => !token.sufficientBalance))
    throw new Error('Insufficient balance');
  const token = spend.data.tokens.find(token => token.kind === 'erc20' && token.needsApproval);
  const prepared = token
    ? await client.prepareApproval({
        key: params.key, currency: isAddressEqual(token.token, params.key.currency0) ? 0 : 1,
        amount: token.requiredAmount,
      })
    : await client.prepareDeposit(quote);
  if (!prepared.context.preflight || !isAddressEqual(prepared.request.account, owner))
    throw new Error('Use the checked client and connected owner');
  return { kind: token ? 'approval' : 'deposit', quote, spend, prepared };
}
```

Display the action, network, spender and amounts before calling `submitConfirmed`. After **each confirmed approval**, call `prepareDepositStep` again for a fresh quote and spend check; review new limits before depositing. Direct deposits approve the Hook for the complete `requiredAmount`, not an allowance shortfall. Reset-required tokens need a separate confirmed zero approval first. Native currency needs no approval.

`limit0/1` are maximum spends, rounded up with token-amount slippage (`50` bps = 0.5%). Choose a deadline from current chain time; never silently extend the user's deadline or budgets. Quotes normally expire after 60 seconds, bounded by that deadline (`validForSeconds`: 1–300). Deposits checkpoint prior earnings before minting shares. Simulation cannot guarantee later execution; use confirmed events for actual amounts/shares.

### Withdraw or claim

| SDK preparation                                   | Principal                                 | Earnings                                |
| ------------------------------------------------- | ----------------------------------------- | --------------------------------------- |
| `prepareWithdraw(preview, to)`                    | Burns selected shares and returns assets. | Settles accounting without paying fees. |
| `prepareClaim({ …, to, maxFeeBps })`              | Keeps shares/principal.                   | Claims net earnings.                    |
| `prepareWithdrawAndClaim(preview, to, maxFeeBps)` | Withdraws selected principal.             | Also claims net earnings.               |

Use a fresh `previewWithdraw(params)`, then review its `limit0/1` minimum principal, recipient and deadline. Small/one-sided positions may have a zero minimum for one asset; show the actual protection. Withdraw only owned shares. Full withdrawal can leave fees claimable. `maxFeeBps` caps the effective claim fee (0–2000), not a promised return. Standalone claims have no on-chain deadline. See [Fees & Claims](https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/fees-and-claims).

### Native funds and Router operations

Only RampETH supports native `currency0 = zeroAddress`. Direct SDK deposits prepay exactly `limit0`; unused input refunds atomically. Wrapped tokens remain ERC-20. Spend-status balance checks exclude gas; checked native preparation requires `balance >= value + gas × maxFeePerGas`. Refunds cannot prefund gas. Arc native gas USDC differs from ERC-20 USDC.

ZapIn approves the selected Router for **total input**, then refreshes the quote, protects shares/output, simulates and prepares with quoted `swapIn`. The Helper receives no approvals. ZapOut needs share permission and withdraws principal only. Compound/Rebalance require their authorization reads, confirmed permissions, fresh full-operation simulation and protected positive share/principal minima. They use internal funds; shares go to the owner. `includeFees: true` invests **all** old-range fees, even for partial migration.

Claim permission is independent of share permission: an operator can choose the fee recipient until revoked. Mainnet `claimOperator` remains `unverified`; checked Compound/fee-including Rebalance need separate reviewed acceptance. See the [Router guide](https://git.techpilots.org/web/peach/peach-ts-sdk/-/blob/b5fc5bacdbee2364128044a4afe793682fa323f4/packages/market/docs/liquidity-router.md).

### Execution and recovery

The earlier `314ed215…` reference blocks withdrawals during pauses; the current SDK baseline documents a principal-only withdrawal exemption. Claims/combined withdrawals remain pause-sensitive. Verify actual deployment behavior and simulate the exact request; RWA CLOSED and Registry activity are separate states.

Keep the client and persist the hash through `onSent`. After timeout, wait on the same hash; after ambiguous broadcast, inspect its receipt/wallet history before retrying. Check confirmed status and matching events. Reverts can consume gas; prior approvals remain effective. Earlier ABI/ledger details: [Ramp](https://github.com/peachbuild/adaptive-pools/blob/314ed2151367d3edb6f9045f05f5eb18567f5aa6/src/core/Ramp.sol), [RampETH](https://github.com/peachbuild/adaptive-pools/blob/314ed2151367d3edb6f9045f05f5eb18567f5aa6/src/core/RampETH.sol).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/providing-liquidity.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
