# IOceanPrimitive.sol

Github link: <https://github.com/Shell-Protocol/Shell-Protocol/blob/main/src/ocean/IOceanPrimitive.sol>

## computeOutputAmount()

{% code overflow="wrap" %}

```solidity
function computeOutputAmount(
    uint256 inputToken,
    uint256 outputToken,
    uint256 inputAmount,
    address userAddress,
    bytes32 metadata
) external returns (
    uint256 outputAmount
);
```

{% endcode %}

| Parameter Name | Type    | Description                                                                      |
| -------------- | ------- | -------------------------------------------------------------------------------- |
| inputToken     | unit256 | input token Ocean ID                                                             |
| outputToken    | unit256 | output token Ocean ID                                                            |
| inputAmount    | unit256 | amount of the specified input token                                              |
| userAddress    | address | address which may be used or ignored by the Ocean Primitive                      |
| metadata       | bytes32 | bytes32 array of arbitrary data which Ocean Primitive may use or chose to ignore |

This function calculates the amount of the output token should be received for the provided amount of the input token. For example, in case of AMM: here's 100 DAIs how many USDCs can I get? Where 100 is inputAmount, DAI is inputToken and USDC is outputToken.

## computeInputAmount()

{% code overflow="wrap" %}

```solidity
function computeOutputAmount(
    uint256 inputToken,
    uint256 outputToken,
    uint256 inputAmount,
    address userAddress,
    bytes32 metadata
) external returns (
    uint256 inputAmount
);
```

{% endcode %}

| Parameter Name | Type    | Description                                                                      |
| -------------- | ------- | -------------------------------------------------------------------------------- |
| inputToken     | unit256 | input token Ocean ID                                                             |
| outputToken    | unit256 | output token Ocean ID                                                            |
| outputAmount   | unit256 | amount of the specified input token                                              |
| userAddress    | address | address which may be used or ignored by the Ocean Primitive                      |
| metadata       | bytes32 | bytes32 array of arbitrary data which Ocean Primitive may use or chose to ignore |

This function calculates the amount of the input token should be given for the provided amount of the output token. For example, in case of AMM: How much DAIs should I give to receive a 100 USDC? Where DAI is inputToken, outputAmount is 100 and USDC is outputToken.

## getTokenSupply()

{% code overflow="wrap" %}

```solidity
function getTokenSupply(
    uint256 tokenId
) external view returns (
    uint256 totalSupply
);
```

{% endcode %}

| Parameter Name | Type    | Description          |
| -------------- | ------- | -------------------- |
| tokenId        | unit256 | input token Ocean ID |

This function returns a total supply of the Ocean Primitive's registered tokens.\
\
It's optional and Ocean Primitives don't have to implement it if they don't want to expose the the total supply of their registered tokens.


---

# 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.shellprotocol.io/smart-contracts-specification/ocean/ioceanprimitive.sol.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.
