> For the complete documentation index, see [llms.txt](https://docs.shellprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shellprotocol.io/smart-contracts-specification/ocean/ioceanprimitive.sol.md).

# 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.
