serum-dev-tools/ts
Sayantan Karmakar 0f331b5653 configure tsconfig for proper build 2022-05-27 21:47:44 +05:30
..
.husky createCoin done 2022-04-04 21:18:38 +05:30
docs add publish-docs workflow 2022-05-17 21:34:26 +05:30
scripts ignore scripts/keys 2022-05-24 17:04:37 +05:30
src Merge remote-tracking branch 'origin/main' 2022-05-24 17:02:07 +05:30
tests updated tests 2022-05-10 17:39:27 +05:30
.DS_Store add typedocs 2022-05-17 21:15:50 +05:30
.eslintrc remove eslint-airbnb 2022-04-02 21:47:19 +05:30
.gitignore ignore .npmrc 2022-05-27 15:26:31 +05:30
.npmignore added readme, changed to v0.0.1 2022-05-27 21:00:02 +05:30
.prettierrc setup prettier, eslint, husky 2022-04-02 21:09:14 +05:30
README.md learn markdown 2022-05-27 21:04:15 +05:30
package.json configure tsc build, bump patch version to 0.0.2 2022-05-27 21:47:13 +05:30
tsconfig.cjs.json configure tsconfig for proper build 2022-05-27 21:47:44 +05:30
tsconfig.json configure tsconfig for proper build 2022-05-27 21:47:44 +05:30
yarn.lock install typedoc 2022-05-15 08:22:26 +05:30

README.md

Serum DevTools 🛠️

A developer tooling SDK for building on serum-dex.

Prerequisites

You will need to use the FileKeypair class that extends the Keypair class from @solana/web3.js to provide easy file-based keypair management, which is required for the market making features provided by this package.

const owner = FileKeypair.generate("./scripts/keys/owner.json");

const airdropSig = await connection.requestAirdrop(
    owner.keypair.publicKey,
    10 * LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(airdropSig);

You need to have a serum-dex program deployed on the cluster you wish to interact with.

You can either,

  • Use the serum-dev-tools CLI to deploy the program.

  • use the already deployed serum-dex programs, 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin on mainnet-beta and DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY on devnet.

Get Started

Initialize a Dex

const connection = new Connection("http://localhost:8899", "confirmed");

const dexAddress = new PublicKey(
    "7zo7HCQAZPRb4pYiQQ6fLjC8ssN3E8LkavVs8JUA5NMn"
);

const dex = new Dex(dexAddress, connection);

Create Coin instances for your Market

const baseCoin = await dex.createCoin(
    "SAYA",
    9,
    owner.keypair,
    owner.keypair,
    owner.keypair,
);

const quoteCoin = await dex.createCoin(
    "SRM",
    9,
    owner.keypair,
    owner.keypair,
    owner.keypair,
);

// Fund the FileKeypair object to place orders.

await baseCoin.fundAccount(1000000, owner.keypair, connection);

await quoteCoin.fundAccount(2000000, owner.keypair, connection);

Initialize a Market

const market = await dex.initDexMarket(
    owner.keypair,
    baseCoin,
    quoteCoin,
    {
        lotSize: 1e-3,
        tickSize: 1e-2,
        feeRate: 10,
        quoteDustThreshold: new BN(100),
    }
);

Run a Market Maker

dex.runMarketMaker(
    market,
    owner,
    {
        unref: true,
        durationInSecs: 30,
        orderCount: 3,
        initialBidSize: 1000,
        baseGeckoSymbol: "solana",
        quoteGeckoSymbol: "usd",
    }
);