2 releases

0.1.1 Feb 22, 2023
0.1.0 Feb 22, 2023

#16 in #defi

Apache-2.0

44KB
1K SLoC

Zeta ABI 🧬

Discord Chat License

Zeta ABI

ABI is Zeta's cross-program integration ecosystem.

This repository contains the Zeta Cross Program Invocation (CPI) interface as well as a usage example abi-wrapper.

build

Cross Program Invocations

Instructions

The instructions currently supported are as follows:

  • initialize_margin_account - create and initialize a user's margin account
  • initialize_open_orders - create and initialize user's open orders account
  • deposit - deposit USDC collateral into the margin account
  • withdraw - withdraw USDC collateral from the margin account
  • place_order_v4 - place a futures order of (price, size, side) on the relevant market
  • place_perp_order_v2 - place a perp order of (price, size, side) on the relevant market
  • cancel_order_xxx - collection of order cancellation functions, by orderId, clientOrderId, market, etc
  • close_open_orders - close open orders account
  • liquidate - trigger liquidation

Accounts

The accounts and relevant data that is currently supported (non-exhaustive):

  • ZetaGroup - contains information relating to all derivatives market for an underlying
    • Underlying
    • Serum Market
    • Strike
    • Kind (Call, Put, Future)
    • Expiry
  • Greeks
    • Mark Price
    • Delta
    • Vega
    • IV
  • MarginAccount
    • Balance
    • Positions
    • helper functions: get_initial_margin(), get_maintenance_margin(), get_unrealized_pnl()

Programs

abi-wrapper

Basic usage example outlined in a dummy wrapper program, which simply calls the main zeta program instructions. Also includes account layouts and outlines how to read all relevant on-chain data from the Zeta program. This should give all the boilerplate needed to execute core program functionality both as the smart contract and off-chain client.

Dependencies

~19–30MB
~489K SLoC