> For the complete documentation index, see [llms.txt](https://docs.swivel.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.swivel.finance/swivel-v2.0.0/developers/contract/contracts/marketplace.md).

# MarketPlace

### Functions

#### setSwivelAddress

```solidity
  function setSwivelAddress(
    address s
  ) external returns (bool)
```

We only allow this to be set once

**Parameters:**

| Name | Type    | Description                             |
| ---- | ------- | --------------------------------------- |
| `s`  | address | Address of the deployed swivel contract |

#### transferAdmin

```solidity
  function transferAdmin(
    address a
  ) external returns (bool)
```

**Parameters:**

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| `a`  | address | Address of a new admin |

#### createMarket

```solidity
  function createMarket(
    uint256 m,
    address c,
    string n,
    string s
  ) external returns (bool)
```

Allows the owner to create new markets

**Parameters:**

| Name | Type    | Description                                                  |
| ---- | ------- | ------------------------------------------------------------ |
| `m`  | uint256 | Maturity timestamp of the new market                         |
| `c`  | address | cToken address associated with underlying for the new market |
| `n`  | string  | Name of the new zcToken market                               |
| `s`  | string  | Symbol of the new zcToken market                             |

#### matureMarket

```solidity
  function matureMarket(
    address u,
    uint256 m
  ) public returns (bool)
```

Can be called after maturity, allowing all of the zcTokens to earn floating interest on Compound until they release their funds

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |

#### mintZcTokenAddingNotional

```solidity
  function mintZcTokenAddingNotional(
    address u,
    uint256 m,
    address t,
    uint256 a
  ) external returns (bool)
```

Allows Swivel caller to deposit their underlying, in the process splitting it - minting both zcTokens and vault notional.

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `t`  | address | Address of the depositing user                      |
| `a`  | uint256 | Amount of notional being added                      |

#### burnZcTokenRemovingNotional

```solidity
  function burnZcTokenRemovingNotional(
    address u,
    uint256 m,
    address t,
    uint256 a
  ) external returns (bool)
```

Allows Swivel caller to deposit/burn both zcTokens + vault notional. This process is "combining" the two and redeeming underlying.

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `t`  | address | Address of the combining/redeeming user             |
| `a`  | uint256 | Amount of zcTokens being burned                     |

#### redeemZcToken

```solidity
  function redeemZcToken(
    address u,
    uint256 m,
    address t,
    uint256 a
  ) external returns (uint256)
```

Allows (via swivel) zcToken holders to redeem their tokens for underlying tokens after maturity has been reached.

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `t`  | address | Address of the redeeming user                       |
| `a`  | uint256 | Amount of zcTokens being redeemed                   |

#### redeemVaultInterest

```solidity
  function redeemVaultInterest(
    address u,
    uint256 m,
    address t
  ) external returns (uint256)
```

Allows Vault owners (via Swivel) to redeem any currently accrued interest

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `t`  | address | Address of the redeeming user                       |

#### calculateReturn

```solidity
  function calculateReturn(
    address u,
    uint256 m,
    uint256 a
  ) internal returns (uint256)
```

Calculates the total amount of underlying returned including interest generated since the `matureMarket` function has been called

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `a`  | uint256 | Amount of zcTokens being redeemed                   |

#### cTokenAddress

```solidity
  function cTokenAddress(
    address u,
    uint256 m
  ) external returns (address)
```

Return the ctoken address for a given market

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |

#### custodialInitiate

```solidity
  function custodialInitiate(
    address u,
    uint256 m,
    address z,
    address n,
    uint256 a
  ) external returns (bool)
```

Called by swivel IVFZI && IZFVI

Call with underlying, maturity, mint-target, add-notional-target and an amount

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `z`  | address | Recipient of the minted zcToken                     |
| `n`  | address | Recipient of the added notional                     |
| `a`  | uint256 | Amount of zcToken minted and notional added         |

#### custodialExit

```solidity
  function custodialExit(
    address u,
    uint256 m,
    address z,
    address n,
    uint256 a
  ) external returns (bool)
```

Called by swivel EVFZE FF EZFVE

Call with underlying, maturity, burn-target, remove-notional-target and an amount

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `z`  | address | Owner of the zcToken to be burned                   |
| `n`  | address | Target to remove notional from                      |
| `a`  | uint256 | Amount of zcToken burned and notional removed       |

#### p2pZcTokenExchange

```solidity
  function p2pZcTokenExchange(
    address u,
    uint256 m,
    address f,
    address t,
    uint256 a
  ) external returns (bool)
```

Called by swivel IZFZE, EZFZI

Call with underlying, maturity, transfer-from, transfer-to, amount

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `f`  | address | Owner of the zcToken to be burned                   |
| `t`  | address | Target to be minted to                              |
| `a`  | uint256 | Amount of zcToken transfer                          |

#### p2pVaultExchange

```solidity
  function p2pVaultExchange(
    address u,
    uint256 m,
    address f,
    address t,
    uint256 a
  ) external returns (bool)
```

Called by swivel IVFVE, EVFVI

Call with underlying, maturity, remove-from, add-to, amount

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `f`  | address | Owner of the notional to be transferred             |
| `t`  | address | Target to be transferred to                         |
| `a`  | uint256 | Amount of notional transfer                         |

#### transferVaultNotional

```solidity
  function transferVaultNotional(
    address u,
    uint256 m,
    address t,
    uint256 a
  ) external returns (bool)
```

External method giving access to this functionality within a given vault

Note that this method calculates yield and interest as well

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `t`  | address | Target to be transferred to                         |
| `a`  | uint256 | Amount of notional to be transferred                |

#### transferVaultNotionalFee

```solidity
  function transferVaultNotionalFee(
    address u,
    uint256 m,
    address f,
    uint256 a
  ) external returns (bool)
```

Transfers notional fee to the Swivel contract without recalculating marginal interest for from

**Parameters:**

| Name | Type    | Description                                         |
| ---- | ------- | --------------------------------------------------- |
| `u`  | address | Underlying token address associated with the market |
| `m`  | uint256 | Maturity timestamp of the market                    |
| `f`  | address | Owner of the amount                                 |
| `a`  | uint256 | Amount to transfer                                  |

#### pause

```solidity
  function pause(
    bool b
  ) external returns (bool)
```

Called by admin at any point to pause / unpause market transactions

**Parameters:**

| Name | Type | Description                                       |
| ---- | ---- | ------------------------------------------------- |
| `b`  | bool | Boolean which indicates the markets paused status |

### Events

#### Create

```solidity
  event Create(
  )
```

#### Mature

```solidity
  event Mature(
  )
```

#### RedeemZcToken

```solidity
  event RedeemZcToken(
  )
```

#### RedeemVaultInterest

```solidity
  event RedeemVaultInterest(
  )
```

#### CustodialInitiate

```solidity
  event CustodialInitiate(
  )
```

#### CustodialExit

```solidity
  event CustodialExit(
  )
```

#### P2pZcTokenExchange

```solidity
  event P2pZcTokenExchange(
  )
```

#### P2pVaultExchange

```solidity
  event P2pVaultExchange(
  )
```

#### TransferVaultNotional

```solidity
  event TransferVaultNotional(
  )
```


---

# 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.swivel.finance/swivel-v2.0.0/developers/contract/contracts/marketplace.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.
