# Methods

> Every method of Plach 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 Plach docs. Plach is the DEX `slimedragon.near/xyk` on the Intear DEX contract, `dex.intear.near`, and every call goes to that contract. https://docs.intear.tech/plach/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), which calls Plach's `swap` with a [route](https://docs.intear.tech/plach/guides/swaps.md#the-message) as `message`. All other methods are called through the engine on `"dex_id": "slimedragon.near/xyk"`: 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/plach/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 Plach uses what the call stores and sends the rest to the caller's wallet.

### Pools

| Method | Arguments | Attach | Response | Who |
| --- | --- | --- | --- | --- |
| `create_pool` | `CreatePoolArgs` | NEAR for storage, the initial liquidity or the launched token | `CreatePoolResponse { pool_id: u32 }` | Anyone |
| `edit_fees` | `EditFeesArgs { pool_id: u32, fees: FeeConfiguration }` | NEAR for the storage the new configuration adds, or nothing | nothing | The owner of an unlocked private pool |
| `lock_pool` | `LockPoolArgs { pool_id: u32 }` | Nothing | nothing | The owner of a private pool |

See [Pools](https://docs.intear.tech/plach/guides/pools.md).

### Liquidity

| Method | Arguments | Attach | Response | Who |
| --- | --- | --- | --- | --- |
| `register_liquidity` | `RegisterLiquidityArgs { pool_id: u32 }` | NEAR for storage | nothing | Anyone, for a public pool |
| `add_liquidity` | `AddLiquidityArgs { pool_id: u32, min_shares_received: Option<u128> }` | Both assets of the pool | nothing | Registered accounts in public pools, the owner in private pools |
| `remove_liquidity` | `RemoveLiquidityArgs { pool_id: u32, shares_to_remove: Option<u128>, min_assets_received: Option<(u128, u128)> }` | Nothing | nothing | Shareholders of public pools, the owner of an unlocked private pool |
| `set_liquidity_fee_payout` | `SetLiquidityFeePayoutArgs { pool_id: u32, payout_type: FeePayoutType }` | NEAR for storage, or nothing | nothing | Registered accounts in public pools |
| `collect_liquidity_fees` | `CollectLiquidityFeesArgs { pool_id: u32 }` | Nothing | nothing | Registered accounts in public pools |

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. See [Liquidity](https://docs.intear.tech/plach/guides/liquidity.md).

### Fees

| Method | Arguments | Attach | Response | Who |
| --- | --- | --- | --- | --- |
| `register_fee_assets` | `RegisterFeeAssetsArgs { asset_ids: Vec<AssetId> }` | NEAR for storage | nothing | Anyone, for themselves |
| `withdraw_fees` | `WithdrawFeesArgs { assets: Vec<AssetId> }` | Nothing | nothing | Anyone, for themselves |
| `claim_fees_anyone` | `ClaimFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> }` | Nothing | nothing | Anyone, for any account |

`withdraw_fees` moves the caller's collected fees to their inner balance. `claim_fees_anyone` sends the fees of an `Account` receiver with `claim_mode: Anyone` to its wallet. See [Fees](https://docs.intear.tech/plach/guides/fees.md).

### Admin

`set_fee_discount_signer` (`SetFeeDiscountSignerArgs { fee_discount_signer_public_key: Option<PublicKey> }`) sets the key that signs [fee discounts](https://docs.intear.tech/plach/guides/fees.md#fee-discounts), or turns them off. Only `slimedragon.near` can call it.

## 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 or not a public pool. 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 or not a public pool. 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, for the registered fee assets |
| `get_claimable_fees` | `GetClaimableFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> }` | `HashMap<AssetId, u128>`: fees anyone can claim for the account, for its assets |
| `get_fee_discount_signer` | none | `Option<PublicKey>`: the key that signs fee discounts. See [`PublicKey`](https://docs.intear.tech/plach/reference/types.md#publickey) for its layout |
| `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`.
