# Op Codes

## Token transfer payloads

| Name         | Value      | Description                                                           |
| ------------ | ---------- | --------------------------------------------------------------------- |
| `swap`       | 0x6664de2a | Token transfer payload `op` for swap                                  |
| `provide_lp` | 0x37c096df | Token transfer payload `op` for liquidity addition                    |
| `cross_swap` | 0x69cf1a5b | Custom payload op in swap payload to chain swaps on the same `Router` |

## Router admin

| Name                   | Value      | Description                                                               |
| ---------------------- | ---------- | ------------------------------------------------------------------------- |
| `set_fees`             | 0x58274069 | Sent by admin to `Router` to set new `Pool` fees                          |
| `reset_gas`            | 0x29d22935 | Sent by admin to `Router` to reset gas                                    |
| `reset_pool_gas`       | 0x66d0dff2 | Sent by admin to `Router` to reset `Pool` gas                             |
| `update_status`        | 0x38a6022f | Sent by admin to `Router` to change `Router` lock status                  |
| `init_code_upgrade`    | 0x03601fc8 | Sent by admin to `Router` to initiate code upgrade                        |
| `init_admin_upgrade`   | 0x0b02fd5b | Sent by admin to `Router` to initiate admin update                        |
| `cancel_code_upgrade`  | 0x1f72111a | Sent by admin to `Router` to cancel code upgrade                          |
| `cancel_admin_upgrade` | 0x72d6b3b4 | Sent by admin to `Router` to cancel admin update                          |
| `finalize_upgrades`    | 0x4e6707b7 | Sent by admin to `Router` to apply all pending updates if cooldown passed |
| `update_pool_status`   | 0x2af4607c | Sent by admin to `Router` to change `Pool` lock status                    |
| `set_params`           | 0x2b8b3b62 | Sent by admin to `Router` to update pool-specific params if present       |

## Other calls

| Name                   | Value      | Description                                                    |
| ---------------------- | ---------- | -------------------------------------------------------------- |
| `direct_add_liquidity` | 0x0ff8bfc6 | Sent by user to `LpAccount` to initiate liquidity addition     |
| `refund_me`            | 0x132b9a2c | Sent by user to `LpAccount` to refund deposited tokens         |
| `withdraw_fee`         | 0x354bcdf4 | Sent by user to `Vault` to collect their tokens                |
| `set_rate`             | 0x4a2bddb0 | Sent by setter to `Pool` to change ratio variable (if present) |
| `collect_fees`         | 0x1ee4911e | Sent by protocol address to `Pool` to collect fees             |

## Internal transactions

| Name                     | Value      | Description                                                            |
| ------------------------ | ---------- | ---------------------------------------------------------------------- |
| `internal_set_fees`      | 0x58274069 | Sent from `Router` to `Pool` to change fees                            |
| `reset_gas`              | 0x29d22935 | Sent from `Router` to `Pool` to rest gas                               |
| `internal_update_status` | 0x62752512 | Sent from `Router` to `Pool` to change `Pool` lock status              |
| `internal_set_params`    | 0x7163444a | Sent from `Router` to `Pool` to update pool-specific params if present |
| `deposit_ref_fee`        | 0x0490f09b | Sent from `Router` to `Vault` to deposit tokens in `Vault`             |
| `pay_to`                 | 0x657b54f5 | Sent from `Pool` to `Router` to initiate token transfer                |
| `add_liquidity`          | 0x50c6a654 | Sent from `Pool` to `LpAccount` to add tokens                          |
| `pay_vault`              | 0x63381632 | Sent from `Pool` to `Router` to deposit tokens in `Vault`              |
| `cb_add_liquidity`       | 0x06ecd527 | Sent from `LpAccount` to `Pool` to add liquidity                       |
| `cb_refund_me`           | 0x0f98e2b8 | Sent from `LpAccount` to `Pool` to refund tokens                       |
| `burn_notification_ext`  | 0x297437cf | Sent from `LpWallet` to `Pool` after lp tokens `burn`                  |
| `vault_pay_to`           | 0x2100c922 | Sent from `Vault` to `Router` to transfer tokens from `Vault` to user  |

## Transfer exit codes

| Name                              | Value      | Description                                               |
| --------------------------------- | ---------- | --------------------------------------------------------- |
| `swap_refund_no_liq`              | 0x5ffe1295 | No liquidity in `Pool`                                    |
| `swap_refund_tx_expired`          | 0x1ec28412 | Swap transaction expired on `Pool`                        |
| `swap_refund_reserve_err`         | 0x38976e9b | Not enough liquidity to perform a swap                    |
| `swap_refund_0_out`               | 0x5f954434 | Swap out token amount is 0                                |
| `swap_refund_slippage`            | 0x39603190 | Swap out token amount is less than provided minimum value |
| `swap_pool_locked`                | 0x365c484d | `Pool` is locked                                          |
| `swap_fee_out_of_bounds`          | 0xa768c0d1 | Ref fee (referrer fee) is too big                         |
| `swap_ok`                         | 0xc64370e5 | Transfer after swap                                       |
| `burn_ok`                         | 0xdda48b6a | Transfer after liquidity withdraw (lp token burn)         |
| `refund_ok`                       | 0xde7dbbc2 | Transfer after `LpAccount` refund                         |
| `transfer_bounce_locked`          | 0x0a0dbdcb | `Router` is locked                                        |
| `transfer_bounce_invalid_pool`    | 0x09a8afbf | Incorrect `Pool` (both token addresses are the same)      |
| `transfer_bounce_wrong_wc`        | 0x720f5b17 | Call was done from the wrong workchain                    |
| `transfer_bounce_low_gas`         | 0x8368a711 | Not enough gas to preform operation                       |
| `transfer_bounce_invalid_request` | 0x19727ea8 | Incorrect token transfer payload op                       |
| `transfer_bounce_tx_expired`      | 0x0f5681d3 | Transaction expired on `Router`                           |
| `provide_refund_wrong_workchain`  | 0x4e7405a8 | Receiver of liquidity is in the wrong workchain           |
| `provide_refund_tx_expired`       | 0xd6a53fd8 | Provide transaction expired on `Pool`                     |

## Getters

| Name                        | Value      | Description                                                           |
| --------------------------- | ---------- | --------------------------------------------------------------------- |
| `provide_wallet_address`    | 0x2c76b973 | Received by `Pool` to return lp wallet address for a specified user   |
| `take_wallet_address`       | 0xd1735400 | Send as a response to `provide_wallet_address` with lp wallet address |
| `getter_lp_account_data`    | 0x24cfc100 | On-chain getter with `LpAccount` data                                 |
| `getter_pool_data`          | 0x26df39fc | On-chain getter with `Pool` common data                               |
| `getter_lp_account_address` | 0x15fbca95 | On-chain getter with `LpAccount` address                              |
| `getter_pool_address`       | 0x2993ade0 | On-chain getter with `Pool` address                                   |


---

# 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://docs.ston.fi/developer-section/dex/smart-contracts/v2/op-codes.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.
