> For the complete documentation index, see [llms.txt](https://yupana-finance.gitbook.io/yupana-document-portal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yupana-finance.gitbook.io/yupana-document-portal/developer-space/ytoken-contract-methods/lending-methods/mint.md).

# mint

Add token to protocol and mints related yToken `token` for caller.

{% hint style="info" %}
Underlying token must be approved before calling this operation for an `amount`
{% endhint %}

{% hint style="warning" %}
The `yToken` contract expects that underlying token info of `tokenId` is updated by calling [PriceFeed.getPrice](/yupana-document-portal/developer-space/pricefeed-contract/getprice.md) and [updateInterest](/yupana-document-portal/developer-space/ytoken-contract-methods/updateinterest.md) in the same block **before** this contract method.
{% endhint %}

### Types

```pascaligo
type yAssetParams       is [@layout:comb] record [
  tokenId                 : nat; // yToken token Id
  amount                  : nat; // amount of underlying token to send to Yupana
]
```

| Parameter | Type | Description                                       |
| :-------: | :--: | ------------------------------------------------- |
|  tokenId  |  nat | yToken identifier                                 |
|   amount  |  nat | amount of underlying token to be sent to protocol |

### Usage

{% tabs %}
{% tab title="🌮   Taquito" %}

```typescript
const tokenId = 0; // or new BigNumber(0) or "0"
const amount = 10_000_000; // or new BigNumber(10_000_000) or "10000000"
const yupana = await tezos.contract.at(yTokenAddress);
const proxy = await tezos.contract.at(proxyAddress);
const batchArray = [
      {
        kind: "transaction",
        ...yupana.methods.updateInterest(tokenId).toTransferParams(),
      },
      {
        kind: "transaction",
        ...proxy.methods.getPrice([tokenId]).toTransferParams(),
      },
      {
        kind: "transaction",
        ...yupana.methods.mint(tokenId, amount).toTransferParams(),
      },
    ];
const batch = await tezos.wallet.batch(batchArray);
const operation = await batch.send();
await operation.confirmation();
```

{% endtab %}

{% tab title="🐍   Pytezos" %}

```python
token_id = 0
amount = 10_000_000
yupana = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
proxy = ContractInterface.from_michelson(prx_code) # or client.contract(prx_contract_address)...proxy = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
call = pytezos.bulk(
        yupana.updateInterest(token_id),
        proxy.getPrice([token_id]),
        yupana.mint(token_id, amount)
    ).autofill().sign()
opg = call.inject()
```

{% endtab %}
{% endtabs %}

### Errors

* `token/cant-get-contract-token` - FA12 token contract address does not contain `transfer` entrypoint from FA12 interface.
* `token/cant-get-contract-fa2-token` - FA2 token contract address does not contain `transfer` entrypoint from FA2 interface.
* `underflow/liquidity - reserves` - liquidity more than reserves.
* `yToken/amount-is-zero` - passed zero `amount`.
* `yToken/need-update` - token price and interest not updated (see <mark style="color:orange;">warning</mark> above)
* `yToken/yToken-undefined` - token identifier is not assigned to any known yTokens.


---

# 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, and the optional `goal` query parameter:

```
GET https://yupana-finance.gitbook.io/yupana-document-portal/developer-space/ytoken-contract-methods/lending-methods/mint.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
