> For the complete documentation index, see [llms.txt](https://docs.tonco.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonco.io/contracts-v1.6-forthcoming/account.md).

# Account

### account

* [Description](#description)
* [Data Storage](#data-storage)
* [Interface](#interface)
* [Messages](#messages)

## Description

The **Account** is a per-user sub-contract of a pool, with a deterministic address derived from `{user, pool}`. It acts as a barrier that collects the two token deposits of a mint independently of the order in which they arrive: it accumulates `amount0`/`amount1`, and once both satisfy the order's thresholds it sends the reforge (mint) request to the [Pool](/contracts-v1.6-forthcoming/pool.md). The pool funds it and returns excess/refunds to it; the owning user can set the pending order or reclaim excess gas. Because the address encodes the user, funds can only ever reach the rightful owner's Account.

## Interface

### get\_account\_data

(address, address, coins, coins, int, Cell?, Cell) get\_account\_data ()

This function provides current state of the user account

#### Return Values

| # | Type    | Description                                                                 |
| - | ------- | --------------------------------------------------------------------------- |
| 0 | address | account::user\_address Address of the owner of the account                  |
| 1 | address | account::pool\_address Address of the pool that this account is attached to |
| 2 | coins   | account::amount0 Amount of jetton0 that was deposited for mint              |
| 3 | coins   | account::amount1 Amount of jetton1 that was deposited for mint              |
| 4 | int     | account::posCount Number of positions currently stored in the account       |
| 5 | Cell?   | account::order Pending mint order cell, or null if none                     |
| 6 | Cell    | account::positions Cell with the stored burn positions                      |

## Messages

### ACCOUNT\_ADD\_LIQUIDITY

Opcode : **0x3ebe5431**

This operation adds liquidity and a minting request to the account. This contract is used as a barrier to collect together data about the proofs of funding two tokens and the request to mint some liquidity. Common usage is as follows - send one jetton with the mint instructions and the second jetton with the mint instructions. And as soon as they will both arrive AccountV3 would trigger the minting request in the pool. This makes minting independent of the order in which jettons arrive. Account refers to jettons in the pool order\
Access Rights: Accepted only from the pool this Account belongs to. The pool relays each verified jetton deposit here, and once both sides satisfy the order the Account triggers the mint in the pool.<br>

<table data-full-width="true"><thead><tr><th width="90">Path</th><th width="200">Mnemonic</th><th width="180">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>op</td><td>Uint(32),op</td><td></td></tr><tr><td></td><td>query_id</td><td>Uint(64)</td><td>queryid as of the TON documentation</td></tr><tr><td></td><td>new_amount0</td><td>Coins(124)</td><td>Amount of jetton0 that is funded for the mint</td></tr><tr><td></td><td>new_amount1</td><td>Coins(124)</td><td>Amount of jetton1 that is funded for the mint</td></tr><tr><td></td><td>enough0</td><td>Coins(124)</td><td>When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger</td></tr><tr><td></td><td>enough1</td><td>Coins(124)</td><td>When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger</td></tr><tr><td></td><td>needPos</td><td>Uint(64)</td><td>Amount of positions that are enough for the order to be executed</td></tr><tr><td></td><td>passthrough</td><td>Uint(4)</td><td>Amount of positions that will be untouched</td></tr><tr><td></td><td>target_action</td><td>Uint(32)</td><td>Routing of the reforge result (ACTION_TARGET_DEFAULT / ACTION_TARGET_ALM) — see target_action in ACCOUNT_SET_ORDER for details</td></tr><tr><td></td><td>0</td><td>Maybe Cell(1) MintOrder0</td><td>Cell with mint order</td></tr><tr><td>0</td><td>op0</td><td>Uint(32)</td><td>Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details</td></tr><tr><td>0</td><td>liquidity0</td><td>Uint(128)</td><td>Amount of liquidity to mint</td></tr><tr><td>0</td><td>tickLower0</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>0</td><td>tickUpper0</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>0</td><td>receiver0</td><td>Address(267)</td><td>Address of receiver of the NFT</td></tr><tr><td></td><td>1</td><td>Maybe Cell(1) MintOrder1</td><td>Cell with mint order</td></tr><tr><td>1</td><td>op1</td><td>Uint(32)</td><td>Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details</td></tr><tr><td>1</td><td>liquidity1</td><td>Uint(128)</td><td>Amount of liquidity to mint</td></tr><tr><td>1</td><td>tickLower1</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>1</td><td>tickUpper1</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>1</td><td>receiver1</td><td>Address(267)</td><td>Address of receiver of the NFT</td></tr><tr><td></td><td>2</td><td>Maybe Cell(1) MintOrder2</td><td>Cell with mint order</td></tr><tr><td>2</td><td>op2</td><td>Uint(32)</td><td>Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details</td></tr><tr><td>2</td><td>liquidity2</td><td>Uint(128)</td><td>Amount of liquidity to mint</td></tr><tr><td>2</td><td>tickLower2</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>2</td><td>tickUpper2</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>2</td><td>receiver2</td><td>Address(267)</td><td>Address of receiver of the NFT</td></tr><tr><td></td><td>3</td><td>Maybe Cell(1) MintOrder3</td><td>Cell with mint order</td></tr><tr><td>3</td><td>op3</td><td>Uint(32)</td><td>Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details</td></tr><tr><td>3</td><td>liquidity3</td><td>Uint(128)</td><td>Amount of liquidity to mint</td></tr><tr><td>3</td><td>tickLower3</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>3</td><td>tickUpper3</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>3</td><td>receiver3</td><td>Address(267)</td><td>Address of receiver of the NFT</td></tr></tbody></table>

<details>

<summary>TL-B Description</summary>

This is a preliminary tl-b - subject to change

{% code title="Tlb for ACCOUNT\_ADD\_LIQUIDITY" overflow="wrap" lineNumbers="true" %}

```javascript
ACCOUNT_ADD_LIQUIDITY#3ebe5431 
    query_id:uint64
    new_amount0:(VarUInteger 16)
    new_amount1:(VarUInteger 16)
    enough0:(VarUInteger 16)
    enough1:(VarUInteger 16)
    needPos:uint64
    passthrough:uint4
    target_action:uint32
    MintOrder0:(Maybe ^MintOrder0Type)
    MintOrder1:(Maybe ^MintOrder1Type)
    MintOrder2:(Maybe ^MintOrder2Type)
    MintOrder3:(Maybe ^MintOrder3Type)
= ContractMessages;
_ 
    op0:uint32
    liquidity0:uint128
    tickLower0:int24
    tickUpper0:int24
    receiver0:MsgAddress
= MintOrder0Type;
_ 
    op1:uint32
    liquidity1:uint128
    tickLower1:int24
    tickUpper1:int24
    receiver1:MsgAddress
= MintOrder1Type;
_ 
    op2:uint32
    liquidity2:uint128
    tickLower2:int24
    tickUpper2:int24
    receiver2:MsgAddress
= MintOrder2Type;
_ 
    op3:uint32
    liquidity3:uint128
    tickLower3:int24
    tickUpper3:int24
    receiver3:MsgAddress
= MintOrder3Type;
```

{% endcode %}

</details>

### ACCOUNT\_RESET\_GAS

Opcode : **0x42a0fb43**

This operation allows user to get back the gas it too much was sent\
Access Rights: Allowed only for the user who owns this Account. Returns excess TON that accumulated on the contract.<br>

<table data-full-width="true"><thead><tr><th width="90">Path</th><th width="200">Mnemonic</th><th width="180">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>op</td><td>Uint(32),op</td><td></td></tr><tr><td></td><td>query_id</td><td>Uint(64)</td><td>queryid as of the TON documentation</td></tr></tbody></table>

<details>

<summary>TL-B Description</summary>

This is a preliminary tl-b - subject to change

{% code title="Tlb for ACCOUNT\_RESET\_GAS" overflow="wrap" lineNumbers="true" %}

```javascript
ACCOUNT_RESET_GAS#42a0fb43 
    query_id:uint64
= ContractMessages;
```

{% endcode %}

</details>

### ACCOUNT\_SET\_ORDER

Opcode : **0x61d86ffe**

This operation allows user to set an order (usually for minting or refunding) that will be executed if the preconditions are satisfied\
Access Rights: Allowed only for the user who owns this Account. Sets the order (mint or refund) that runs once its preconditions are met.<br>

<table data-full-width="true"><thead><tr><th width="90">Path</th><th width="200">Mnemonic</th><th width="180">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>op</td><td>Uint(32),op</td><td></td></tr><tr><td></td><td>query_id</td><td>Uint(64)</td><td>queryid as of the TON documentation</td></tr><tr><td></td><td>enough0</td><td>Coins(124)</td><td>When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger</td></tr><tr><td></td><td>enough1</td><td>Coins(124)</td><td>When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger</td></tr><tr><td></td><td>needPos</td><td>Uint(64)</td><td>Amount of positions that are enough for the order to be executed</td></tr><tr><td></td><td>passthrough</td><td>Uint(4)</td><td>Amount of positions that will be untouched</td></tr><tr><td></td><td>target_action</td><td>Uint(32)</td><td>Routing of the reforge result: ACTION_TARGET_DEFAULT (0) sends minted NFT/refunds to the normal recipients; ACTION_TARGET_ALM (1) sends all coins to the pool's ALM role address (used by ALM flows). See action_target in pool_reforge.func</td></tr><tr><td></td><td>0</td><td>Maybe Cell(1) mint0</td><td>Cell with mint order 0</td></tr><tr><td>0</td><td>mintOp[0]</td><td>Uint(32)</td><td>Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).</td></tr><tr><td>0</td><td>liquidity[0]</td><td>Uint(128)</td><td>Amount of liquidity to mint for this order (interpreted per mintOp mode)</td></tr><tr><td>0</td><td>tickLower[0]</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>0</td><td>tickUpper[0]</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>0</td><td>nftReceiver[0]</td><td>Address(267)</td><td>Address that would receive the minted NFT, excesses and refunds</td></tr><tr><td></td><td>1</td><td>Maybe Cell(1) mint1</td><td>Cell with mint order 1</td></tr><tr><td>1</td><td>mintOp[1]</td><td>Uint(32)</td><td>Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).</td></tr><tr><td>1</td><td>liquidity[1]</td><td>Uint(128)</td><td>Amount of liquidity to mint for this order (interpreted per mintOp mode)</td></tr><tr><td>1</td><td>tickLower[1]</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>1</td><td>tickUpper[1]</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>1</td><td>nftReceiver[1]</td><td>Address(267)</td><td>Address that would receive the minted NFT, excesses and refunds</td></tr><tr><td></td><td>2</td><td>Maybe Cell(1) mint2</td><td>Cell with mint order 2</td></tr><tr><td>2</td><td>mintOp[2]</td><td>Uint(32)</td><td>Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).</td></tr><tr><td>2</td><td>liquidity[2]</td><td>Uint(128)</td><td>Amount of liquidity to mint for this order (interpreted per mintOp mode)</td></tr><tr><td>2</td><td>tickLower[2]</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>2</td><td>tickUpper[2]</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>2</td><td>nftReceiver[2]</td><td>Address(267)</td><td>Address that would receive the minted NFT, excesses and refunds</td></tr><tr><td></td><td>3</td><td>Maybe Cell(1) mint3</td><td>Cell with mint order 3</td></tr><tr><td>3</td><td>mintOp[3]</td><td>Uint(32)</td><td>Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).</td></tr><tr><td>3</td><td>liquidity[3]</td><td>Uint(128)</td><td>Amount of liquidity to mint for this order (interpreted per mintOp mode)</td></tr><tr><td>3</td><td>tickLower[3]</td><td>Int(24)</td><td>lower bound of the range in which to mint</td></tr><tr><td>3</td><td>tickUpper[3]</td><td>Int(24)</td><td>upper bound of the range in which to mint</td></tr><tr><td>3</td><td>nftReceiver[3]</td><td>Address(267)</td><td>Address that would receive the minted NFT, excesses and refunds</td></tr></tbody></table>

<details>

<summary>TL-B Description</summary>

This is a preliminary tl-b - subject to change

{% code title="Tlb for ACCOUNT\_SET\_ORDER" overflow="wrap" lineNumbers="true" %}

```javascript
ACCOUNT_SET_ORDER#61d86ffe 
    query_id:uint64
    enough0:(VarUInteger 16)
    enough1:(VarUInteger 16)
    needPos:uint64
    passthrough:uint4
    target_action:uint32
    mint0:(Maybe ^Mint0Type)
    mint1:(Maybe ^Mint1Type)
    mint2:(Maybe ^Mint2Type)
    mint3:(Maybe ^Mint3Type)
= ContractMessages;
_ 
    mintOp_0:uint32
    liquidity_0:uint128
    tickLower_0:int24
    tickUpper_0:int24
    nftReceiver_0:MsgAddress
= Mint0Type;
_ 
    mintOp_1:uint32
    liquidity_1:uint128
    tickLower_1:int24
    tickUpper_1:int24
    nftReceiver_1:MsgAddress
= Mint1Type;
_ 
    mintOp_2:uint32
    liquidity_2:uint128
    tickLower_2:int24
    tickUpper_2:int24
    nftReceiver_2:MsgAddress
= Mint2Type;
_ 
    mintOp_3:uint32
    liquidity_3:uint128
    tickLower_3:int24
    tickUpper_3:int24
    nftReceiver_3:MsgAddress
= Mint3Type;
```

{% endcode %}

</details>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonco.io/contracts-v1.6-forthcoming/account.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.
