Contract Interfaces

A high level description of key contract functions

Collateral

The Collateral contract stores collateral balances for { user, product } pairs. There is a single Collateral contract in the protocol.

Deposit

Deposit pulls collateral (DSU) from the msg.sender and credits the product's collateral balance for the specified account.

function depositTo(address account, address product, uint256 amount) external
  • account - The address of the user account

  • product - The address of the Perennial product

  • amount - Amount of DSU to deposit

Withdraw

Withdraw decrements the balance of msg.sender product collateral balance and pushes the DSU to the specified receiver.

function withdrawTo(address receiver, address product, uint256 amount) external
  • account - The address of the user account

  • product - The address of the Perennial product

  • amount - Amount of DSU to deposit

Liquidate

Liquidate closes account 's position for the specified product. Liquidate will revert if the user is not eligible for liquidation.

To check if a user is liquidateable, call

  • account - The address of the user account

  • product - The address of the Perennial product

Product

The Product contract is a market in the Perennial protocol. A new product contract is deployed for each launched market via the Controller's createProduct method.

Open/Close Make

Maker positions provide liquidity for a given product. The maximum size of a maker position is determined by the account's collateral and the product's maintenance requirement.

  • amount - Size of the maker position to open or close

Open/Close Take

Taker positions are traders in the system. The maximum size of a taker position is determined by the account's collateral, the product's maintenance requirement, and the product's liquidity (open maker positons)

  • amount - Size of the taker position to open or close

Lens

The Lens contract provides convenience functions for reading Protocol, Product, and Accounts state. The functions on the Lens contracts are designed to be called via Ether's callStatic method (or similar, depending on your Web3 library of choice). You can find the lens address for each deployed chain in Deployed Contracts

Snapshots

Snapshot functions return batched data for the Protocol, and one or more Products or Accounts. For struct fields, refer to the Lens interface.

  • account - The address of the user account

  • product - The address of the Perennial product

MultiInvoker

The MultiInvoker allows for multiple interactions with the Perennial protocol in a single transaction.

The entrypoint to MultiInvoker is invoke. Each invocation can take one or multiple Actions, and will perform each action in order. For common chains, see our integration tests.

Where each Invocation has an action and args field. The args are ABI encoded arguments, you can use the following typescript snippet to generate payloads for each action.

Last updated