IOceanPrimitive.sol

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

computeOutputAmount()

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

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()

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

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()

function getTokenSupply(
    uint256 tokenId
) external view returns (
    uint256 totalSupply
);
Parameter NameTypeDescription

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.

Last updated