Crate zeta_abi

Source
Expand description

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.

Re-exports§

pub use crate::account::*;
pub use crate::constants::*;
pub use crate::context::*;
pub use crate::dex::*;
pub use crate::errors::*;
pub use crate::id::*;
pub use crate::utils::*;

Modules§

account
accounts
An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is a Pubkey. This is useful for specifying accounts for a client.
constants
context
cpi
dex
errors
id
instruction
An Anchor generated module containing the program’s set of instructions, where each method handler in the #[program] mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client.
program
Module representing the program.
utils

Functions§

entry
The Anchor codegen exposes a programming model where a user defines a set of methods inside of a #[program] module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana.