13 releases

0.2.8 Oct 14, 2024
0.2.7 Sep 20, 2024
0.2.5 Aug 15, 2024
0.2.3 Jul 29, 2024
0.1.2 Jan 23, 2024

#8 in #sanity

Download history 122/week @ 2024-08-31 57/week @ 2024-09-07 310/week @ 2024-09-14 239/week @ 2024-09-21 145/week @ 2024-09-28 118/week @ 2024-10-05 254/week @ 2024-10-12 39/week @ 2024-10-19 17/week @ 2024-10-26 19/week @ 2024-11-02 1/week @ 2024-11-09 65/week @ 2024-11-16 116/week @ 2024-11-23 249/week @ 2024-11-30 172/week @ 2024-12-07 146/week @ 2024-12-14

693 downloads per month

MIT/Apache

2.5MB
39K SLoC

Vertex Protocol Rust SDK

Crates.io

This is the Rust SDK for the Vertex Protocol API.

Documentation

Quickstart

Instantiate a client on the chain you would like to interact with. For example, ClientMode::Prod to use Arbitrum and ClientMode::BaseProd to use Base, etc. A signer (private key) is required for executes. A signer is not required for queries. For requests with many parameters, use the client to build and send requests. For simple queries (1-2 params) like get_market_price, call directly from the client.

See basic_usage.rs for an E2E example including depositing into Vertex.

use vertex_sdk::prelude::*;

async fn main() {
    let client = VertexClient::new(ClientMode::Prod)
        .with_signer(private_key())
        .await
        .unwrap();

    const BTC_PERP: u32 = 2;

    // query market data
    let market_price = client.get_market_price(BTC_PERP).await.unwrap();

    // place orders
    let place_order_response = client
        .place_order_builder()
        .product_id(BTC_PERP)
        .amount(to_i128_x18(1))
        .price_x18(market_price.ask_x18)
        .execute()
        .await
        .unwrap();

    let digest = place_order_response.unwrap().digest;

    // cancel orders
    client
        .cancellation_builder()
        .digests(vec![digest])
        .product_ids(vec![BTC_PERP])
        .execute()
        .await
        .unwrap();
}

Installation

Add the following line to your Cargo.toml file:

[dependencies]
vertex_sdk = "0.2.8"

Usage

See the examples and sanity directories.

Running locally

Run sanity checks

  • cargo run -- --execute-sanity: runs sanity checks for executes.
  • cargo run -- --query-sanity: runs sanity checks for engine queries.
  • cargo run -- --indexer-sanity: runs sanity checks for indexer queries.

Dependencies

~30–49MB
~889K SLoC