v1.0.0 final changes
This commit is contained in:
parent
b844766d2b
commit
c808fb572b
|
@ -2443,7 +2443,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serum-dev-tools"
|
name = "serum-dev-tools"
|
||||||
version = "0.0.4"
|
version = "1.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anchor-client",
|
"anchor-client",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "serum-dev-tools"
|
name = "serum-dev-tools"
|
||||||
version = "0.0.4"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Sayantan Karmakar <sayantankarmakar@outlook.com>"]
|
authors = ["Sayantan Karmakar <sayantankarmakar@outlook.com>"]
|
||||||
homepage = "https://github.com/project-serum/serum-dev-tools"
|
homepage = "https://github.com/project-serum/serum-dev-tools"
|
||||||
repository = "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"
|
description = "Developer Tooling Suite for building on Serum Dex"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
keywords = ["solana", "project-serum", "serum-dex", "devtools"]
|
keywords = ["solana", "project-serum", "serum-dex", "developer", "tools", "dex"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "serum-dev-tools"
|
name = "serum-dev-tools"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
# Serum DevTools 🛠️
|
# 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).
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
pub fn deploy(
|
pub fn deploy(
|
||||||
cfg_override: &ConfigOverride,
|
cfg_override: &ConfigOverride,
|
||||||
cluster: Cluster,
|
cluster: Cluster,
|
||||||
script: Option<String>,
|
command: Option<String>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
with_config(cfg_override, |cfg| {
|
with_config(cfg_override, |cfg| {
|
||||||
if !is_initialized() {
|
if !is_initialized() {
|
||||||
|
@ -51,10 +51,10 @@ pub fn deploy(
|
||||||
|
|
||||||
println!("Deploy Successful");
|
println!("Deploy Successful");
|
||||||
|
|
||||||
if script.is_some() {
|
if command.is_some() {
|
||||||
let script_exit = std::process::Command::new("bash")
|
let script_exit = std::process::Command::new("bash")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(script.unwrap())
|
.arg(command.unwrap())
|
||||||
.stdout(Stdio::inherit())
|
.stdout(Stdio::inherit())
|
||||||
.stderr(Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.output()
|
.output()
|
||||||
|
|
|
@ -29,9 +29,9 @@ pub enum Command {
|
||||||
/// The cluster to deploy to
|
/// The cluster to deploy to
|
||||||
cluster: Cluster,
|
cluster: Cluster,
|
||||||
|
|
||||||
/// The script to run after deploying
|
/// The command to run after deploying
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
script: Option<String>,
|
command: Option<String>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ pub fn entry(opts: Opts) -> Result<()> {
|
||||||
match opts.command {
|
match opts.command {
|
||||||
Command::Init => commands::init(),
|
Command::Init => commands::init(),
|
||||||
Command::Instance => commands::instance(),
|
Command::Instance => commands::instance(),
|
||||||
Command::Deploy { cluster, script } => {
|
Command::Deploy { cluster, command } => {
|
||||||
commands::deploy(&opts.cfg_override, cluster, script)
|
commands::deploy(&opts.cfg_override, cluster, command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,6 @@ const market = await dex.initDexMarket(
|
||||||
{
|
{
|
||||||
lotSize: 1e-3,
|
lotSize: 1e-3,
|
||||||
tickSize: 1e-2,
|
tickSize: 1e-2,
|
||||||
feeRate: 10,
|
|
||||||
quoteDustThreshold: new BN(100),
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
@ -88,7 +86,6 @@ dex.runMarketMaker(
|
||||||
market,
|
market,
|
||||||
owner,
|
owner,
|
||||||
{
|
{
|
||||||
unref: true,
|
|
||||||
durationInSecs: 30,
|
durationInSecs: 30,
|
||||||
orderCount: 3,
|
orderCount: 3,
|
||||||
initialBidSize: 1000,
|
initialBidSize: 1000,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@project-serum/serum-dev-tools",
|
"name": "@project-serum/serum-dev-tools",
|
||||||
"version": "0.0.6",
|
"version": "1.0.0",
|
||||||
"description": "developer tooling suite for building on serum",
|
"description": "developer tooling suite for building on serum",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -10,6 +10,14 @@
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"author": "Sayantan Karmakar",
|
"author": "Sayantan Karmakar",
|
||||||
|
"keywords": [
|
||||||
|
"solana",
|
||||||
|
"serum",
|
||||||
|
"developer",
|
||||||
|
"tools",
|
||||||
|
"serum-dex",
|
||||||
|
"project-serum"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|
|
@ -32,6 +32,13 @@ export class Coin {
|
||||||
this.freezeAuthority = freezeAuthority;
|
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(
|
public async getBalance(
|
||||||
owner: Keypair,
|
owner: Keypair,
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
|
@ -53,6 +60,13 @@ export class Coin {
|
||||||
return tokenAmount;
|
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(
|
public async fundAccount(
|
||||||
decimalAmount: number,
|
decimalAmount: number,
|
||||||
owner: Keypair,
|
owner: Keypair,
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import { Keypair } from "@solana/web3.js";
|
import { Keypair } from "@solana/web3.js";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper class around @solana/web3.js `Keypair` that allows persisting key-pairs in your local filesystem.
|
||||||
|
*/
|
||||||
export class FileKeypair {
|
export class FileKeypair {
|
||||||
public filePath: string;
|
public filePath: string;
|
||||||
public keypair: Keypair;
|
public keypair: Keypair;
|
||||||
|
|
||||||
constructor(filePath: string, keypair: Keypair) {
|
private constructor(filePath: string, keypair: Keypair) {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
this.keypair = keypair;
|
this.keypair = keypair;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class DexMarket {
|
||||||
|
|
||||||
private _marketSymbol: string;
|
private _marketSymbol: string;
|
||||||
|
|
||||||
constructor(
|
private constructor(
|
||||||
address: PublicKey,
|
address: PublicKey,
|
||||||
serumMarket: Market,
|
serumMarket: Market,
|
||||||
baseCoin: Coin,
|
baseCoin: Coin,
|
||||||
|
@ -273,7 +273,7 @@ export class DexMarket {
|
||||||
* Create a `Transaction` object for placing an order.
|
* Create a `Transaction` object for placing an order.
|
||||||
*
|
*
|
||||||
* @param connection The `Connection` object to connect to Solana.
|
* @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 serumMarket The `Market` object from `serum-ts` package.
|
||||||
* @param side The `Side` of the order.
|
* @param side The `Side` of the order.
|
||||||
* @param orderType The `OrderType` of the order.
|
* @param orderType The `OrderType` of the order.
|
||||||
|
@ -359,7 +359,7 @@ export class DexMarket {
|
||||||
* Place an order on the DexMarket.
|
* Place an order on the DexMarket.
|
||||||
*
|
*
|
||||||
* @param connection The `Connection` object to connect to Solana.
|
* @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 serumMarket The `Market` object from `serum-ts` package.
|
||||||
* @param side The `Side` of the order.
|
* @param side The `Side` of the order.
|
||||||
* @param orderType The `OrderType` 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.
|
* Create a `Transaction` object for cancelling an order.
|
||||||
*
|
*
|
||||||
* @param connection The `Connection` object to connect to Solana.
|
* @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 serumMarket The `Market` object from `serum-ts` package.
|
||||||
* @param order The `Order` object to cancel.
|
* @param order The `Order` object to cancel.
|
||||||
* @returns
|
* @returns
|
||||||
|
@ -447,6 +447,14 @@ export class DexMarket {
|
||||||
return txSig;
|
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(
|
static async getOrdersForOwner(
|
||||||
owner: Keypair,
|
owner: Keypair,
|
||||||
serumMarket: SerumMarket,
|
serumMarket: SerumMarket,
|
||||||
|
@ -460,6 +468,14 @@ export class DexMarket {
|
||||||
return orders;
|
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(
|
static async getOrCreateOpenOrderAccount(
|
||||||
owner: Keypair,
|
owner: Keypair,
|
||||||
serumMarket: SerumMarket,
|
serumMarket: SerumMarket,
|
||||||
|
|
Loading…
Reference in New Issue