Ocean.sol

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

WRAPPED_ETHER_ID()

/// @notice this is the oceanId used for shETH
/// @dev hexadecimal(ascii("shETH"))
uint256 public immutable WRAPPED_ETHER_ID;

This function is automatically created because WRAPPED_ETHER_ID variable is declared as public.

It should...

  1. Return the Ocean ID for Ether (Wrapping Ether into Ocean would result in shETH, so it would be a shETH ID actually).

unwrapFeeDivisor()

/// @notice Used to calculate the unwrap fee
/// unwrapFee = unwrapAmount / unwrapFeeDivisor
/// Because this uses integer division, the fee is always rounded down
/// If unwrapAmount < unwrapFeeDivisor, unwrapFee == 0
uint256 public unwrapFeeDivisor;

This function is automatically created because unwrapFeeDivisor variable is declared as public. A fee is charged by the Ocean on each unwrap.

It should...

  1. Return the correct unwrap fee divisor.

doInteraction()

Parameter Name
Type
Description

interaction

Interaction struct

one of nine different interactions types encoded via the Interaction struct

Interaction Struct Params:

Parameter Name
Type
Description

interactionTypeAndAddress

bytes32

a bytes32 array that combines both the interaction type and the address of the external contract called during this interaction

inputToken

uint256

input token Ocean ID

outputToken

uint256

output token Ocean ID

specifiedAmount

uint256

amount of the specified token

metadata

bytes32

bytes32 array of arbitrary data, during 721/1155 and wraps and unwraps we use this filed to pass token ID

This function executes a single interaction.

It should...

  1. Execute a single forwarded interaction.

doMultipleInteractions()

Parameter Name
Type
Description

interactions

Interaction struct[]

an array of interactions which can be one of nine different interactions types encoded via the Interaction struct

ids

uint256[]

an array of tokens Ocean IDs used by the interactions forwarded by the interactions param

Interaction Struct Params:

Parameter Name
Type
Description

interactionTypeAndAddress

bytes32

a bytes32 array that combines both the interaction type and the address of the external contract called during this interaction

inputToken

uint256

input token Ocean ID

outputToken

uint256

output token Ocean ID

specifiedAmount

uint256

amount of the specified token

metadata

bytes32

bytes32 array of arbitrary data, during 721/1155 and wraps and unwraps we use this filed to pass token ID

This function executes multiple interactions in order they were stacked in the array of interactions. Use this function to compose different interactions, i.e. Ocean native primitives.

It should...

  1. Execute a a list of forwarded interactions.

forwardedDoInteraction()

Parameter Name
Type
Description

interaction

Interaction struct

one of nine different interactions types encoded via the Interaction struct

userAddress

address

address on which behalf to execute interactions

Interaction Struct Params:

Parameter Name
Type
Description

interactionTypeAndAddress

bytes32

a bytes32 array that combines both the interaction type and the address of the external contract called during this interaction

inputToken

uint256

input token Ocean ID

outputToken

uint256

output token Ocean ID

specifiedAmount

uint256

amount of the specified token

metadata

bytes32

bytes32 array of arbitrary data, during 721/1155 and wraps and unwraps we use this filed to pass token ID

This function executes a single interaction on behalf the address that was forwarded as userAddress param.

It should...

  1. Revert if address forwarded as userAddress param hasn't approved message sender to pass interactions on its behalf via isApprovedForAll ERC1155 method.

  2. Execute a single forwarded interaction.

forwardedDoMultipleInteractions()

Parameter Name
Type
Description

interactions

Interaction struct[]

an array of interactions which can be one of nine different interactions types encoded via the Interaction struct

ids

unit256[]

an array of interaction IDs forwarded by the first param Interaction struct[]

userAddress

address

address on which behalf to execute interactions

Interaction Struct Params:

Parameter Name
Type
Description

interactionTypeAndAddress

bytes32

a bytes32 array that combines both the interaction type and the address of the external contract called during this interaction

inputToken

uint256

input token Ocean ID

outputToken

uint256

output token Ocean ID

specifiedAmount

uint256

amount of the specified token

metadata

bytes32

bytes32 array of arbitrary data, during 721/1155 and wraps and unwraps we use this filed to pass token ID

This function executes multiple interactions in order they were stacked in the array of interactions on behalf the address that was forwarded as the userAddress param. Use this function to compose different interactions, i.e. Ocean native primitives.

It should...

  1. Revert if address forwarded as userAddress param hasn't approved message sender to pass interactions on its behalf via isApprovedForAll ERC1155 method.

  2. Execute a single forwarded interaction.

registerNewTokens()

Parameter Name
Type
Description

currentNumberOfTokens

uint256

current number of tokens as a starting nonce

numberOfAdditionalTokens

unit256

the number of new tokens to be registered

This functions should register new tokens that are issued directly on the Ocean's ERC-1155 ledger.

supportsInterface()

A standard implementation of ERC165 supportsInterface method which checks for IERC1155, IERC1155MetadataURI or IERC165 implementations. For more details see check the official EIP-165 page or OpenZeppelin Introspection page.

Other methods

Below is a list of other public and external methods accessible in the Ocean smart contract, which may not be as relevant. Most of these methods are implemented as part of the ERC-1155 specification.

uri()

This function is an implementation of the ERC-1155 uri method. For more details, check the Metadata section of the EIP-1155 page.

onERC721Received()

This function is an implementation of the onERC721Received method from the IERC721Receiver interface contract. For more details, check the interface ERC721TokenReceiver part of the specification section of the EIP-721 page.

onERC1155Received()

This function is an implementation of the onERC1155Received method from the IERC1155TokenReceiver interface contract. For more details, check the ERC-1155 Token Receiver section of the EIP-1155 page.

onERC1155BatchReceived()

This function is an implementation of the onERC1155BatchReceived method from the IERC1155TokenReceiver interface contract. For more details check the ERC-1155 Token Receiver section of the EIP-1155 page.

balanceOf()

This function is an implementation of the balanceOf method from the IERC1155 interface contract. For more details, check the specification section of the EIP-1155 page.

balanceOfBatch()

This function is an implementation of the balanceOfBatch method from the IERC1155 interface contract. For more details, check the specification and Batch Balance sections of the EIP-1155 page.

setApprovalForAll()

This function is an implementation of the setApprovalForAll method from the IERC1155 interface contract. For more details, check the specification and Approval sections of the EIP-1155 page.

isApprovedForAll()

This function is an implementation of the isApprovedForAll method from the IERC1155 interface contract. For more details, check the specification and Approval sections of the EIP-1155 page.

safeTransferFrom()

This function is an implementation of the safeTransferFrom method from the IERC1155 interface contract. For more details, check the specification and Safe Transfer Rules sections of the EIP-1155 page.

safeBatchTransferFrom()

This function is an implementation of the safeBatchTransferFrom method from the IERC1155 interface contract. For more details, check the specification and Batch Transfers sections of the EIP-1155 page.

Last updated