serum-dev-tools/ts
Sayantan Karmakar 2fc82de6ab v1.0.5 2022-06-23 20:59:28 +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
examples minor nit fixes and improvements 2022-06-23 20:50:55 +05:30
src minor nit fixes and improvements 2022-06-23 20:50:55 +05:30
tests added getters, docs, tests, and isEqual for coin 2022-06-22 17:46:48 +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 added getters, docs, tests, and isEqual for coin 2022-06-22 17:46:48 +05:30
package.json v1.0.5 2022-06-23 20:59:28 +05:30
tsconfig.cjs.json configure tsconfig for proper build 2022-05-27 21:47:44 +05:30
tsconfig.json added support for loading coins 2022-06-22 02:01:42 +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

yarn add @project-serum/serum-dev-tools

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,
});

Run a Market Maker

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

Run a crank

dex.runCrank(market, owner, {
  durationInSecs: 20,
  verbose: true,
});