# Methods

> Every method of Qoq on Intear DEX: the dex_call methods with their Borsh arguments, attached assets and who can call them, and the dex_view methods.

This page is part of the Qoq docs. Qoq is the DEX `slimedragon.near/amp` on the Intear DEX contract, `dex.intear.near`, and every call goes to that contract. https://docs.intear.tech/qoq/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

Swaps go through the engine's [`swap_simple`](https://docs.intear.tech/intear-dex/guides/swaps.md#swap_simple) or [operations](https://docs.intear.tech/intear-dex/guides/operations.md), which call Qoq's `swap` with [routes](https://docs.intear.tech/qoq/guides/swaps.md#the-message) as `message`. Swaps through a pool that an oracle prices start with an [oracle request](https://docs.intear.tech/qoq/guides/swaps.md#pools-an-oracle-prices). All other methods are called through the engine on `"dex_id": "slimedragon.near/amp"`: calls with [`dex_call`](https://docs.intear.tech/intear-dex/guides/dexes.md#dex_call), and views with [`dex_view`](https://docs.intear.tech/intear-dex/guides/dexes.md#dex_view). Arguments and responses are Borsh, in base64. Types are in [Types](https://docs.intear.tech/qoq/reference/types.md).

Every call has to come [directly](https://docs.intear.tech/intear-dex/guides/dexes.md#what-a-dex-sees) from the caller: a `dex_call`, or a `DexCall` in `execute_operations`, not in the operations of a deposit.

## Calls

"Attach" is the `attached_assets` of the `dex_call`, from the caller's inner balance. "NEAR for storage" means Qoq uses what the call stores and sends the rest to the caller's wallet.

### Liquidity

| Method | Arguments | Attach | Response | Who |
| --- | --- | --- | --- | --- |
| `register_liquidity` | `RegisterLiquidityArgs { pool_id: u32 }` | NEAR for storage | nothing | Anyone |
| `add_liquidity` | `AddLiquidityArgs { pool_id: u32, min_shares_received: Option<u128> }` | Both assets of the pool | nothing | Registered accounts |
| `remove_liquidity` | `RemoveLiquidityArgs { pool_id: u32, shares_to_remove: Option<u128>, min_assets_received: Option<(u128, u128)> }` | Nothing | nothing | Shareholders |
| `set_liquidity_fee_payout` | `SetLiquidityFeePayoutArgs { pool_id: u32, payout_type: FeePayoutType }` | NEAR for storage, or nothing | nothing | Registered accounts |
| `collect_liquidity_fees` | `CollectLiquidityFeesArgs { pool_id: u32 }` | Nothing | nothing | Registered accounts |
| `withdraw_fees` | `WithdrawFeesArgs { assets: Vec<AssetId> }` | Nothing | nothing | Anyone, for themselves |

What an addition doesn't use, and the assets of removed liquidity, are sent to the caller's wallet. Adding, removing, `set_liquidity_fee_payout` and `collect_liquidity_fees` collect the provider's part of the pool's fees to its collected fees, which `withdraw_fees` moves to its inner balance. See [Liquidity](https://docs.intear.tech/qoq/guides/liquidity.md).

### Owner

Only Qoq's owner, slimedragon.near, can call these. See [Owner settings](https://docs.intear.tech/qoq/guides/pools.md#owner-settings).

| Method | Arguments | Attach | Response |
| --- | --- | --- | --- |
| `create_pool` | [`CreatePoolArgs`](https://docs.intear.tech/qoq/reference/types.md#createpoolargs) | NEAR for storage, and the initial liquidity | `CreatePoolResponse { pool_id: u32 }` |
| `set_amplification` | `SetAmplificationArgs { pool_id: u32, amplification: u32 }` | Nothing | nothing |
| `set_fee` | `SetFeeArgs { pool_id: u32, fee: u32 }` | Nothing | nothing |
| `set_oracle_key` | `SetOracleKeyArgs { pool_id: u32, oracle_key: PublicKey }` | NEAR for storage, or nothing | nothing |

`migrate`, with no arguments, updates the state of Qoq for a new version of its code, after it's deployed.

## Views

| Method | Arguments | Response |
| --- | --- | --- |
| `get_pool` | `GetPoolArgs { pool_id: u32 }` | `Option<PoolView>` |
| `get_pools` | `GetPoolsArgs { start_index: u32, limit: u32 }` | `Vec<PoolView>`: the pools from `start_index`, so each one's ID is `start_index` plus its position |
| `get_pool_count` | none | `u32` |
| `get_pool_shares` | `GetPoolSharesArgs { pool_ids: Vec<u32>, account_id: AccountId }` | `Vec<Option<u128>>`: shares in each pool, `None` if not registered. Fails with `Pool <id> not found` for an unknown pool |
| `get_liquidity_position` | `GetLiquidityPositionArgs { pool_id: u32, account_id: AccountId }` | `Option<LiquidityPositionView>`: the provider's payout and its fees not collected yet, `None` if not registered. Fails with `Pool <id> not found` for an unknown pool |
| `get_pending_fees` | `GetPendingFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> }` | `HashMap<AssetId, u128>`: collected fees, in the assets the account can be paid in |
| `contract_source_metadata` | none | [NEP-330](https://github.com/near/NEPs/blob/master/neps/nep-0330.md) metadata, in JSON: the `version` |

For views without arguments, pass `""` as `args`.
