> For the complete documentation index, see [llms.txt](https://docs.tranchess.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tranchess.com/tech-support/protocol-overview/primary-market.md).

# Primary Market

## Getting PrimaryMarket Info

#### `PrimaryMarket.fund() → address`

The address of the fund contract.

```bash
>>> primaryMarket.fund()
'0x69c53679EC1C06f3275b64C428e8Cd069a2d3966'
```

## Creating/Redeeming Tranches

#### `PrimaryMarket.getCreation(uint256 underlying) → uint256`

Get the amount of QUEEN created by `underlying` amount of the underlying asset.

```bash
>>> primaryMarket.getCreation(1000000000000000000)
'998239992407933623'
```

#### `PrimaryMarket.getCreationForQ(uint256 minOutQ) → uint256`

Get the amount of the underlying asset to create at least `minOutQ` amount of QUEEN.

* Note that this only works with non-empty fund for simplicity.

```bash
>>> primaryMarket.getCreationForQ(1000000000000000000)
'1001763110680249269'
>>> primaryMarket.getCreation(1001763110680249269)
'1000000000000000000'
```

#### `PrimaryMarket.getRedemption(uint256 inQ) → uint256, uint256`

Get the amount of the underlying asset redeemed by `inQ` amount of QUEEN.

```bash
>>> primaryMarket.getRedemption(1000000000000000000)
underlying: '1001763110680249268'
feeQ: '0'
```

#### `PrimaryMarket.getRedemptionForUnderlying(uint256 minUnderlying) → uint256`

Get the amount of QUEEN to redeem at least `minUnderlying` amount of the underlying asset.

```bash
>>> primaryMarket.getRedemptionForUnderlying(1000000000000000000)
'998239992407933624'
>>> primaryMarket.getRedemption(998239992407933624)
underlying: '1000000000000000000'
feeQ: '0'
```

#### `PrimaryMarket.redeem(address recipient, uint256 inQ, uint256 minUnderlying, uint256 version) → uint256`

Redeem `inQ` amount of QUEEN and transfer the resulting underlying asset to `recipient`. It enforces the resulting underlying asset to be at least `minUnderlying` and the `version` to be the current rebalance version.

* Note that the function would revert if there were queued redemptions that cannot be claimed at the moment.

#### `PrimaryMarket.redeemAndUnwrap(address recipient, uint256 inQ, uint256 minUnderlying, uint256 version) → uint256`

Redeem `inQ` amount of QUEEN, unwrap the underlying asset to its native currency, and transfer the resulting underlying asset to `recipient`. It enforces the resulting underlying asset to be at least `minUnderlying` and the `version` to be the current rebalance version. The underlying asset must be a wrapped token of the native currency.

* Note that the function would revert if there were queued redemptions that cannot be claimed at the moment.

#### `PrimaryMarket.queueRedemption(address recipient, uint256 inQ, uint256 minUnderlying, uint256 version) → uint256, uint256`

Submit a redemption request for `inQ` amount of QUEEN. The resulting underlying asset will be claimable when the fund has enough balance to pay this redemption and all the previous ones in the queue. It enforces the resulting underlying asset to be at least `minUnderlying` and the `version` to be the current rebalance version.

#### `PrimaryMarket.claimRedemptions(address account, uint256[] calldata indices) → uint256`

Claim the underlying asset of an array of queued redemption requests by `account` and transfer the underlying asset to `account`.

#### `PrimaryMarket.claimRedemptionsAndUnwrap(address account, uint256[] calldata indices) → uint256`

Claim the underlying asset of an array of queued redemption requests by `account`, unwrap the underlying asset to its native currency, and transfer the underlying asset to `account`. The underlying asset must be a wrapped token of the native currency.

## Splitting/Merging Tranches

#### `PrimaryMarket.getSplit(uint256 inQ) → uint256`

Get the amount of BISHOP and ROOK split from `inQ` amount of QUEEN.

```bash
>>> primaryMarket.getSplit(1000000000000000000)
'594418130555555555274'
```

#### `PrimaryMarket.getSplitForB(uint256 minOutB) → uint256`

Get the amount of QUEEN to split at least `minOutB` amount of BISHOP and ROOK.

```bash
>>> primaryMarket.getSplitForB(1000000000000000000)
'1682317460716381'
>>> primaryMarket.getSplit(1682317460716381)
'000000000000000465'
```

#### `PrimaryMarket.getMerge(uint256 inB) → uint256, uint256`

Get the amount of QUEEN merged from `inB` amount of BISHOP and ROOK.

```bash
>>> primaryMarket.getMerge(1000000000000000000)
outQ: '1680635143255664'
feeQ: '1682317460716'
```

#### `PrimaryMarket.getMergeForQ(uint256 minOutQ) → uint256`

Get the amount of BISHOP and ROOK to merge into at least `minOutQ` amount of QUEEN.

```bash
>>> primaryMarket.getMergeForQ(1000000000000000000)
'595013143699254810084'
>>> primaryMarket.getMerge(595013143699254810084)
outQ: '1000000000000000000'
feeQ: '1001001001001001'
```

#### `PrimaryMarket.split(address recipient, uint256 inQ, uint256 version) → uint256`

Split `inQ` amount of QUEEN into BISHOP and ROOK and send the resulting shares to `recipient`. It enforces the `version` to be the current rebalance version.

#### `PrimaryMarket.merge(address recipient, uint256 inB, uint256 version) → uint256`

Merge `inB` amount of BISHOP and ROOK into QUEEN and send the resulting shares to `recipient`. It enforces the `version` to be the current rebalance version.


---

# 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://docs.tranchess.com/tech-support/protocol-overview/primary-market.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.
