LogoLogo
WebsiteAppWiki
  • 🤙Start here
    • Overview
    • Shell Protocol Basics
    • Quickstart: Deploy a liquidity pool
    • Tutorial: Executing swap with Shell Protocol
    • Reference Library
      • Contract addresses
  • 🤿Deep dive
    • Important concepts
      • Separating accounting logic & business logic
      • Ocean Primitives
    • The Ocean
    • Primitives
      • Adapters
      • Proteus AMM Engine
      • NFT Fractionalizer
  • 📜Smart Contracts Specification
    • Ocean
      • Ocean.sol
      • IOceanPrimitive.sol
      • IOceanToken.sol
      • OceanAdapter.sol
    • Proteus
      • Proteus.sol
      • EvolvingProteus.sol
      • LiquidityPoolProxy.sol
    • Fractionalizer
      • FractionalizerFactory.sol
  • 🧠Tutorials
    • Build an AMM with Proteus
    • Build an NFT Fractionalizer
    • Build an NFT AMM
Powered by GitBook
On this page
  • computeOutputAmount()
  • computeInputAmount()
  • getTokenSupply()
  1. Smart Contracts Specification
  2. Ocean

IOceanPrimitive.sol

PreviousOcean.solNextIOceanToken.sol

Last updated 1 year ago

Github link:

computeOutputAmount()

function computeOutputAmount(
    uint256 inputToken,
    uint256 outputToken,
    uint256 inputAmount,
    address userAddress,
    bytes32 metadata
) external returns (
    uint256 outputAmount
);
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()

function computeOutputAmount(
    uint256 inputToken,
    uint256 outputToken,
    uint256 inputAmount,
    address userAddress,
    bytes32 metadata
) external returns (
    uint256 inputAmount
);
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()

function getTokenSupply(
    uint256 tokenId
) external view returns (
    uint256 totalSupply
);
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.

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