From 22b494b4702c5ce649f8758977b34cd215540cbf Mon Sep 17 00:00:00 2001 From: sayantank <40912636+sayantank@users.noreply.github.com> Date: Wed, 8 Jun 2022 13:35:49 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20project-?= =?UTF-8?q?serum/serum-dev-tools@ce3d1ffe59a14dd122a47f011e7b118f5ff2fdd5?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Coin.html | 4 ++-- classes/Dex.html | 10 +++++----- classes/DexMarket.html | 20 ++++++++++---------- classes/FileKeypair.html | 2 +- index.html | 12 +++++++----- interfaces/MarketAccounts.html | 2 +- modules.html | 6 +++--- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/classes/Coin.html b/classes/Coin.html index 9134f01..7c443e7 100644 --- a/classes/Coin.html +++ b/classes/Coin.html @@ -1,4 +1,4 @@ -Coin | @project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Coin

Index

Constructors

  • new Coin(symbol: string, decimals: number, mint: PublicKey, mintAuthority: Keypair, freezeAuthority: Keypair): Coin
  • Parameters

    • symbol: string
    • decimals: number
    • mint: PublicKey
    • mintAuthority: Keypair
    • freezeAuthority: Keypair

    Returns Coin

Properties

decimals: number
freezeAuthority: Keypair
mint: PublicKey
mintAuthority: Keypair
symbol: string

Methods

  • fundAccount(decimalAmount: number, owner: Keypair, connection: Connection): Promise<void>
  • +Coin | @project-serum/serum-dev-tools
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Hierarchy

    • Coin

    Index

    Constructors

    • new Coin(symbol: string, decimals: number, mint: PublicKey, mintAuthority: Keypair, freezeAuthority: Keypair): Coin
    • Parameters

      • symbol: string
      • decimals: number
      • mint: PublicKey
      • mintAuthority: Keypair
      • freezeAuthority: Keypair

      Returns Coin

    Properties

    decimals: number
    freezeAuthority: Keypair
    mint: PublicKey
    mintAuthority: Keypair
    symbol: string

    Methods

    • fundAccount(decimalAmount: number, owner: Keypair, connection: Connection): Promise<void>
    • Fund the owner key-pair with the specified amount of this coin.

      Parameters

      • decimalAmount: number

        The amount of tokens to fund account with, in decimal notation.

        @@ -6,7 +6,7 @@

        The Keypair to fund.

      • connection: Connection

        The Connection object to connect to Solana.

        -

      Returns Promise<void>

    • getBalance(owner: Keypair, connection: Connection): Promise<RpcResponseAndContext<TokenAmount>>

    Returns Promise<void>

  • getBalance(owner: Keypair, connection: Connection): Promise<RpcResponseAndContext<TokenAmount>>
  • Get the token balance for the specified owner.

    Parameters

    • owner: Keypair

      The Keypair whose balance to fetch.

      diff --git a/classes/Dex.html b/classes/Dex.html index 583146f..1ceaf23 100644 --- a/classes/Dex.html +++ b/classes/Dex.html @@ -1,6 +1,6 @@ Dex | @project-serum/serum-dev-tools
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Dex is a wrapper class for a deployed Serum Dex program.

      -

      Hierarchy

      • Dex

      Index

      Constructors

      • new Dex(address: PublicKey, connection: Connection): Dex
      • Parameters

        • address: PublicKey
        • connection: Connection

        Returns Dex

      Properties

      address: PublicKey
      coins: Coin[]
      connection: Connection
      markets: DexMarket[]

      Methods

      • createCoin(symbol: string, decimals: number, payer: Keypair, mintAuthority: Keypair, freezeAuthority: Keypair): Promise<Coin>

      Hierarchy

      • Dex

      Index

      Constructors

      • new Dex(address: PublicKey, connection: Connection): Dex
      • Parameters

        • address: PublicKey
        • connection: Connection

        Returns Dex

      Properties

      address: PublicKey
      coins: Coin[]
      connection: Connection
      markets: DexMarket[]

      Methods

      • createCoin(symbol: string, decimals: number, payer: Keypair, mintAuthority: Keypair, freezeAuthority: Keypair): Promise<Coin>
      • Create a Coin object to be associated with the Dex.

        Parameters

        • symbol: string

          The symbol of the coin to create

          @@ -12,17 +12,17 @@

          The mint authority Keypair to use for the mint

        • freezeAuthority: Keypair

          The freeze authority Keypair to use for the mint

          -

        Returns Promise<Coin>

      • getCoin(symbol: string): Coin

      Returns Promise<Coin>

  • getCoin(symbol: string): Coin
  • Fetch one of the Coin objects associated with the Dex by symbol.

    Parameters

    • symbol: string

      The symbol of the coin to fetch

      -

    Returns Coin

Returns Coin

  • Fetch a DexMarket object associated with the Dex by the base coin and quote coin.

    Parameters

    • baseCoin: Coin

      The base Coin of the market to fetch

    • quoteCoin: Coin

      The quote Coin of the market to fetch

      -

    Returns DexMarket

Returns DexMarket

  • Initialize a DexMarket instance associated with the Dex.

    Parameters

    • payer: Keypair

      The payer Keypair to use for the transactions

      @@ -32,7 +32,7 @@

      The quote Coin of the market to create

    • marketParams: MarketParams

      The parameters required to create the market

      -

    Returns Promise<DexMarket>

Returns Promise<DexMarket>

  • createMarketAccountsInstructions(accounts: MarketAccounts, payer: Keypair, connection: Connection, programID: PublicKey): Promise<TransactionInstruction[]>
  • Create a Transaction object for creating the accounts required for a DexMarket.

    Parameters

    • accounts: MarketAccounts

      The MarketAccounts object containing the accounts needed for initializing the market.

      @@ -20,7 +20,7 @@

      The Connection object to connect to Solana.

    • programID: PublicKey

      The address of the serum-dex program deployed.

      -

    Returns Promise<TransactionInstruction[]>

  • createMarketVaultsTransaction(payer: Keypair, vaultOwner: PublicKey, baseVault: Keypair, quoteVault: Keypair, baseCoin: Coin, quoteCoin: Coin, connection: Connection): Promise<Transaction>

Returns Promise<TransactionInstruction[]>

  • createMarketVaultsTransaction(payer: Keypair, vaultOwner: PublicKey, baseVault: Keypair, quoteVault: Keypair, baseCoin: Coin, quoteCoin: Coin, connection: Connection): Promise<Transaction>
  • Create a Transaction object for creating the vaults required for a DexMarket.

    Parameters

    • payer: Keypair

      The Keypair of the account that will pay for the transaction.

      @@ -36,7 +36,7 @@

      The quote Coin object provided by the Coin class.

    • connection: Connection

      The Connection object to connect to Solana.

      -

    Returns Promise<Transaction>

  • getCancelOrderTransaction(connection: Connection, owner: Keypair, serumMarket: Market, order: Order): Promise<TransactionWithSigners>

Returns Promise<Transaction>

  • getCancelOrderTransaction(connection: Connection, owner: Keypair, serumMarket: Market, order: Order): Promise<TransactionWithSigners>
  • Create a Transaction object for cancelling an order.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

      @@ -46,7 +46,7 @@

      The Market object from serum-ts package.

    • order: Order

      The Order object to cancel.

      -

    Returns Promise<TransactionWithSigners>

  • getOrCreateOpenOrderAccount(owner: Keypair, serumMarket: Market, connection: Connection): Promise<OpenOrders>

Returns Promise<TransactionWithSigners>

  • getOrCreateOpenOrderAccount(owner: Keypair, serumMarket: Market, connection: Connection): Promise<OpenOrders>
  • Get or create an OpenOrder account for the specified owner.

    Parameters

    • owner: Keypair

      The Keypair for which OpenOrders account is required.

      @@ -54,7 +54,7 @@

      The Market object from serum-ts package.

    • connection: Connection

      The Connection object to connect to Solana.

      -

    Returns Promise<OpenOrders>

  • getOrdersForOwner(owner: Keypair, serumMarket: Market, connection: Connection): Promise<Order[]>

Returns Promise<OpenOrders>

  • getOrdersForOwner(owner: Keypair, serumMarket: Market, connection: Connection): Promise<Order[]>
  • Get all orders placed by a keypair.

    Parameters

    • owner: Keypair

      The Keypair for which orders have to be fetched.

      @@ -62,7 +62,7 @@

      The Market object from serum-ts package.

    • connection: Connection

      The Connection object to connect to Solana.

      -

    Returns Promise<Order[]>

  • getPlaceOrderTransaction(connection: Connection, owner: Keypair, serumMarket: Market, side: "buy" | "sell", orderType: OrderType, size: number, price: number): Promise<TransactionWithSigners>

Returns Promise<Order[]>

  • getPlaceOrderTransaction(connection: Connection, owner: Keypair, serumMarket: Market, side: "buy" | "sell", orderType: OrderType, size: number, price: number): Promise<TransactionWithSigners>
  • Create a Transaction object for placing an order.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

      @@ -78,7 +78,7 @@

      The size of the order.

    • price: number

      The price of the order.

      -

    Returns Promise<TransactionWithSigners>

  • load(connection: Connection, programID: PublicKey, marketAddress: PublicKey, baseCoin: Coin, quoteCoin: Coin): Promise<DexMarket>

Returns Promise<TransactionWithSigners>

  • load(connection: Connection, programID: PublicKey, marketAddress: PublicKey, baseCoin: Coin, quoteCoin: Coin): Promise<DexMarket>
  • Load a DexMarket instance from a given market address.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

      @@ -90,7 +90,7 @@

      The base Coin object provided by the Coin class.

    • quoteCoin: Coin

      The quote Coin object provided by the Coin class.

      -

    Returns Promise<DexMarket>

  • placeOrder(connection: Connection, owner: Keypair, serumMarket: Market, side: "buy" | "sell", orderType: OrderType, size: number, price: number): Promise<string>

Returns Promise<DexMarket>

  • placeOrder(connection: Connection, owner: Keypair, serumMarket: Market, side: "buy" | "sell", orderType: OrderType, size: number, price: number): Promise<string>
  • Place an order on the DexMarket.

    Parameters

    • connection: Connection

      The Connection object to connect to Solana.

      @@ -106,4 +106,4 @@

      The size of the order.

    • price: number

      The price of the order.

      -

    Returns Promise<string>

  • sanityCheck(serumMarket: Market, price: number, size: number): void
  • Parameters

    • serumMarket: Market
    • price: number
    • size: number

    Returns void

Generated using TypeDoc

\ No newline at end of file +

Returns Promise<string>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/FileKeypair.html b/classes/FileKeypair.html index ea73730..01d71a5 100644 --- a/classes/FileKeypair.html +++ b/classes/FileKeypair.html @@ -1,3 +1,3 @@ FileKeypair | @project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

A wrapper class around @solana/web3.js Keypair that allows persisting key-pairs in your local filesystem.

-

Hierarchy

  • FileKeypair

Index

Constructors

  • new FileKeypair(filePath: string, keypair: Keypair): FileKeypair

Properties

filePath: string
keypair: Keypair

Methods

  • withKeypair(filePath: string, keypair: Keypair): FileKeypair

Generated using TypeDoc

\ No newline at end of file +

Hierarchy

Index

Constructors

Properties

filePath: string
keypair: Keypair

Methods

Generated using TypeDoc

\ No newline at end of file diff --git a/index.html b/index.html index a7c49fe..669e3bb 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@

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

@@ -22,28 +22,30 @@

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); +
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);
+
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,
}
); +
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",
}
); +
dex.runMarketMaker(market, owner, {
durationInSecs: 30,
orderCount: 3,
initialBidSize: 1000,
baseGeckoSymbol: "solana",
quoteGeckoSymbol: "usd",
});

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Private property
  • Static method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/MarketAccounts.html b/interfaces/MarketAccounts.html index 19427a1..f5365a1 100644 --- a/interfaces/MarketAccounts.html +++ b/interfaces/MarketAccounts.html @@ -1 +1 @@ -MarketAccounts | @project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MarketAccounts

Index

Properties

asks: Keypair
bids: Keypair
eventQueue: Keypair
market: Keypair
requestQueue: Keypair

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Private property
  • Static method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +MarketAccounts | @project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MarketAccounts

Index

Properties

asks: Keypair
bids: Keypair
eventQueue: Keypair
market: Keypair
requestQueue: Keypair

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Private property
  • Static method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/modules.html b/modules.html index 9b8b5fe..3b6cc1b 100644 --- a/modules.html +++ b/modules.html @@ -1,8 +1,8 @@ -@project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

@project-serum/serum-dev-tools

Index

Type aliases

MarketMakerOpts: { baseGeckoSymbol: string; durationInSecs: number; initialBidSize: number; orderCount: number; quoteGeckoSymbol: string }
param durationInSecs

The duration in seconds for which the market maker will run.

+@project-serum/serum-dev-tools
Options
All
  • Public
  • Public/Protected
  • All
Menu

@project-serum/serum-dev-tools

Index

Type aliases

MarketMakerOpts: { baseGeckoSymbol: string; durationInSecs: number; initialBidSize: number; orderCount: number; quoteGeckoSymbol: string }
param durationInSecs

The duration in seconds for which the market maker will run.

param orderCount

The number of orders to place per side in each iteration.

param initialBidSize

The initial bid size for the market maker.

param baseGeckoSymbol

The symbol used by CoinGecko for the base coin.

param quoteGeckoSymbol

The symbol used by CoinGecko for the quote coin.

-

Type declaration

  • baseGeckoSymbol: string
  • durationInSecs: number
  • initialBidSize: number
  • orderCount: number
  • quoteGeckoSymbol: string
MarketParams: { lotSize: number; tickSize: number }
param lotSize

This is the smallest representable amount of the base coin .

+

Type declaration

  • baseGeckoSymbol: string
  • durationInSecs: number
  • initialBidSize: number
  • orderCount: number
  • quoteGeckoSymbol: string
MarketParams: { lotSize: number; tickSize: number }
param lotSize

This is the smallest representable amount of the base coin .

param tickSize

This is the smallest representable amount of the quote coin.

-

Type declaration

  • lotSize: number
  • tickSize: number
OrderType: "limit" | "ioc" | "postOnly"
TransactionWithSigners: { signers: Signer[]; transaction: Transaction }

Type declaration

  • signers: Signer[]
  • transaction: Transaction

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Private property
  • Static method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Type declaration

  • lotSize: number
  • tickSize: number
OrderType: "limit" | "ioc" | "postOnly"
TransactionWithSigners: { signers: Signer[]; transaction: Transaction }

Type declaration

  • signers: Signer[]
  • transaction: Transaction

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Private property
  • Static method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file