3 unstable releases

0.4.0 Aug 9, 2021
0.3.0-beta.2 Jul 5, 2021

#11 in #serum

28 downloads per month

Apache-2.0

29KB
481 lines

Swap

Crates.io Docs.rs

Swap provides a convenient API to the Serum DEX for performing instantly settled token swaps directly on the order book.

Developing

This program requires building the Serum DEX from source, which is done using git submodules.

Install Submodules

Pull the source

git submodule init
git submodule update

Build the DEX

Build it

cd deps/serum-dex/dex/ && cargo build-bpf && cd ../../../

Build

Anchor is used for developoment, and it's recommended workflow is used here. To get started, see the guide.

anchor build --verifiable

The --verifiable flag should be used before deploying so that your build artifacts can be deterministically generated with docker.

Test

anchor test

Verify

To verify the program deployed on Solana matches your local source code, install docker, cd programs/swap, and run

anchor verify <program-id | write-buffer>

A list of build artifacts can be found under releases.

Run the Test

Run the test

anchor test

lib.rs:

Program to perform instantly settled token swaps on the Serum DEX.

Before using any instruction here, a user must first create an open orders account on all markets being used. This only needs to be done once, either via the system program create account instruction in the same transaction as the user's first trade or via the explicit init_account and close_account instructions provided here, which can be included in transactions.

Dependencies

~19–29MB
~483K SLoC