diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 9c80d84..ea0951a 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -2443,7 +2443,7 @@ dependencies = [ [[package]] name = "serum-dev-tools" -version = "0.0.4" +version = "1.0.0" dependencies = [ "anchor-client", "anyhow", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index f015c62..59275ee 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "serum-dev-tools" -version = "0.0.4" +version = "1.0.0" edition = "2021" authors = ["Sayantan Karmakar "] homepage = "https://github.com/project-serum/serum-dev-tools" repository = "https://github.com/project-serum/serum-dev-tools" description = "Developer Tooling Suite for building on Serum Dex" license = "Apache-2.0" -keywords = ["solana", "project-serum", "serum-dex", "devtools"] +keywords = ["solana", "project-serum", "serum-dex", "developer", "tools", "dex"] [[bin]] name = "serum-dev-tools" diff --git a/cli/README.md b/cli/README.md index 7919771..790e661 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,3 +1,5 @@ # Serum DevTools 🛠️ -A developer tooling SDK for building on [serum-dex](https://github.com/project-serum/serum-dex/). +A developer tooling CLI for building on [serum-dex](https://github.com/project-serum/serum-dex/). + +To get started, check out this guide [here](https://sayantanxyz.hashnode.dev/serum-dev-tools). diff --git a/cli/src/commands/deploy.rs b/cli/src/commands/deploy.rs index 9bebc83..427af56 100644 --- a/cli/src/commands/deploy.rs +++ b/cli/src/commands/deploy.rs @@ -15,7 +15,7 @@ use crate::{ pub fn deploy( cfg_override: &ConfigOverride, cluster: Cluster, - script: Option, + command: Option, ) -> Result<()> { with_config(cfg_override, |cfg| { if !is_initialized() { @@ -51,10 +51,10 @@ pub fn deploy( println!("Deploy Successful"); - if script.is_some() { + if command.is_some() { let script_exit = std::process::Command::new("bash") .arg("-c") - .arg(script.unwrap()) + .arg(command.unwrap()) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) .output() diff --git a/cli/src/lib.rs b/cli/src/lib.rs index f53b4ac..555d010 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -29,9 +29,9 @@ pub enum Command { /// The cluster to deploy to cluster: Cluster, - /// The script to run after deploying + /// The command to run after deploying #[clap(long)] - script: Option, + command: Option, }, } @@ -39,8 +39,8 @@ pub fn entry(opts: Opts) -> Result<()> { match opts.command { Command::Init => commands::init(), Command::Instance => commands::instance(), - Command::Deploy { cluster, script } => { - commands::deploy(&opts.cfg_override, cluster, script) + Command::Deploy { cluster, command } => { + commands::deploy(&opts.cfg_override, cluster, command) } } } diff --git a/ts/README.md b/ts/README.md index 0eef113..bad9f11 100644 --- a/ts/README.md +++ b/ts/README.md @@ -75,8 +75,6 @@ const market = await dex.initDexMarket( { lotSize: 1e-3, tickSize: 1e-2, - feeRate: 10, - quoteDustThreshold: new BN(100), } ); ``` @@ -88,7 +86,6 @@ dex.runMarketMaker( market, owner, { - unref: true, durationInSecs: 30, orderCount: 3, initialBidSize: 1000, diff --git a/ts/package.json b/ts/package.json index bc13549..7ff63aa 100644 --- a/ts/package.json +++ b/ts/package.json @@ -1,6 +1,6 @@ { "name": "@project-serum/serum-dev-tools", - "version": "0.0.6", + "version": "1.0.0", "description": "developer tooling suite for building on serum", "repository": { "type": "git", @@ -10,6 +10,14 @@ "module": "./dist/index.js", "types": "./dist/index.d.ts", "author": "Sayantan Karmakar", + "keywords": [ + "solana", + "serum", + "developer", + "tools", + "serum-dex", + "project-serum" + ], "license": "MIT", "files": [ "dist" diff --git a/ts/src/coin.ts b/ts/src/coin.ts index 2f602b5..400f782 100644 --- a/ts/src/coin.ts +++ b/ts/src/coin.ts @@ -32,6 +32,13 @@ export class Coin { this.freezeAuthority = freezeAuthority; } + /** + * Get the token balance for the specified owner. + * + * @param owner The `Keypair` whose balance to fetch. + * @param connection The `Connection` object to connect to Solana. + * @returns + */ public async getBalance( owner: Keypair, connection: Connection, @@ -53,6 +60,13 @@ export class Coin { return tokenAmount; } + /** + * Fund the owner key-pair with the specified amount of this coin. + * + * @param decimalAmount The amount of tokens to fund account with, in decimal notation. + * @param owner The `Keypair` to fund. + * @param connection The `Connection` object to connect to Solana. + */ public async fundAccount( decimalAmount: number, owner: Keypair, diff --git a/ts/src/fileKeypair.ts b/ts/src/fileKeypair.ts index aa17d80..31b5c25 100644 --- a/ts/src/fileKeypair.ts +++ b/ts/src/fileKeypair.ts @@ -1,11 +1,14 @@ import { Keypair } from "@solana/web3.js"; import fs from "fs"; +/** + * A wrapper class around @solana/web3.js `Keypair` that allows persisting key-pairs in your local filesystem. + */ export class FileKeypair { public filePath: string; public keypair: Keypair; - constructor(filePath: string, keypair: Keypair) { + private constructor(filePath: string, keypair: Keypair) { this.filePath = filePath; this.keypair = keypair; } diff --git a/ts/src/market.ts b/ts/src/market.ts index cff47da..05af787 100644 --- a/ts/src/market.ts +++ b/ts/src/market.ts @@ -48,7 +48,7 @@ export class DexMarket { private _marketSymbol: string; - constructor( + private constructor( address: PublicKey, serumMarket: Market, baseCoin: Coin, @@ -273,7 +273,7 @@ export class DexMarket { * Create a `Transaction` object for placing an order. * * @param connection The `Connection` object to connect to Solana. - * @param owner The `PublicKey` of the owner of the order. + * @param owner The `Keypair` of the owner of the order. * @param serumMarket The `Market` object from `serum-ts` package. * @param side The `Side` of the order. * @param orderType The `OrderType` of the order. @@ -359,7 +359,7 @@ export class DexMarket { * Place an order on the DexMarket. * * @param connection The `Connection` object to connect to Solana. - * @param owner The `PublicKey` of the owner of the order. + * @param owner The `Keypair` of the owner of the order. * @param serumMarket The `Market` object from `serum-ts` package. * @param side The `Side` of the order. * @param orderType The `OrderType` of the order. @@ -396,7 +396,7 @@ export class DexMarket { * Create a `Transaction` object for cancelling an order. * * @param connection The `Connection` object to connect to Solana. - * @param owner The `PublicKey` of the owner of the order. + * @param owner The `Keypair` of the owner of the order. * @param serumMarket The `Market` object from `serum-ts` package. * @param order The `Order` object to cancel. * @returns @@ -447,6 +447,14 @@ export class DexMarket { return txSig; } + /** + * Get all orders placed by a keypair. + * + * @param owner The `Keypair` for which orders have to be fetched. + * @param serumMarket The `Market` object from `serum-ts` package. + * @param connection The `Connection` object to connect to Solana. + * @returns + */ static async getOrdersForOwner( owner: Keypair, serumMarket: SerumMarket, @@ -460,6 +468,14 @@ export class DexMarket { return orders; } + /** + * Get or create an OpenOrder account for the specified owner. + * + * @param owner The `Keypair` for which OpenOrders account is required. + * @param serumMarket The `Market` object from `serum-ts` package. + * @param connection The `Connection` object to connect to Solana. + * @returns + */ static async getOrCreateOpenOrderAccount( owner: Keypair, serumMarket: SerumMarket,