1.7.3 • Published 2 years ago

@friktion-labs/entropy-client v1.7.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Entropy Markets Client Library

Typescript client library for interacting with Entropy Markets, inspired heavily by Entropy Markets.

Installation

git clone git@github.com:Friktion-Labs/entropy-client
cd entropy-client
yarn

Running the keeper

Adding Phantom Wallet into Solana CLI: https://mattmazur.com/2021/11/18/using-a-phantom-wallet-address-with-the-solana-cli/

Ensure a SOL funded private keypair is in this file location:

~/.config/solana/entropy-mainnet-authority.json

Run the keeper

yarn keeper

Package Installation

Using npm:

npm install @friktion-labs/entropy-client

Using yarn:

yarn add @friktion-labs/entropy-client

Usage Example

This example assumes that you have a wallet that is already setup with devnet tokens. The private key should be stored in ~/.config/solana/entropy-mainnet-authority.json. You can find the full source code in example.ts.

// Fetch orderbooks
const bids = await perpMarket.loadBids(connection);
const asks = await perpMarket.loadAsks(connection);

// L2 orderbook data
for (const [price, size] of bids.getL2(20)) {
  console.log(price, size);
}

// L3 orderbook data
for (const order of asks) {
  console.log(
    order.owner.toBase58(),
    order.orderId.toString('hex'),
    order.price,
    order.size,
    order.side, // 'buy' or 'sell'
  );
}

// Place order
await client.placePerpOrder(
  entropyGroup,
  entropyAccount,
  entropyGroup.entropyCache,
  perpMarket,
  owner,
  'buy', // or 'sell'
  39000,
  0.0001,
  'limit', // or 'ioc' or 'postOnly'
);

// retrieve open orders for account
const openOrders = await perpMarket.loadOrdersForAccount(
  connection,
  entropyAccount,
);

// cancel orders
for (const order of openOrders) {
  await client.cancelPerpOrder(
    entropyGroup,
    entropyAccount,
    owner,
    perpMarket,
    order,
  );
}

// Retrieve fills
for (const fill of await perpMarket.loadFills(connection)) {
  console.log(
    fill.owner.toBase58(),
    fill.maker ? 'maker' : 'taker',
    fill.baseChange.toNumber(),
    fill.quoteChange.toNumber(),
    fill.longFunding.toFixed(3),
    fill.shortFunding.toFixed(3),
  );
}
1.4.79

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.4.62

2 years ago

1.4.61

2 years ago

1.4.64

2 years ago

1.4.63

2 years ago

1.4.66

2 years ago

1.4.65

2 years ago

1.4.68

2 years ago

1.4.67

2 years ago

1.4.69

2 years ago

1.4.71

2 years ago

1.4.70

2 years ago

1.4.73

2 years ago

1.4.75

2 years ago

1.4.74

2 years ago

1.4.77

2 years ago

1.4.76

2 years ago

1.4.35

2 years ago

1.4.78

2 years ago

1.4.34

2 years ago

1.4.37

2 years ago

1.4.36

2 years ago

1.4.38

2 years ago

1.4.42

2 years ago

1.4.41

2 years ago

1.6.68

2 years ago

1.4.44

2 years ago

1.4.43

2 years ago

1.4.46

2 years ago

1.4.45

2 years ago

1.4.48

2 years ago

1.4.47

2 years ago

1.4.49

2 years ago

1.4.51

2 years ago

1.4.53

2 years ago

1.4.52

2 years ago

1.4.9

2 years ago

1.4.55

2 years ago

1.4.11

2 years ago

1.4.8

2 years ago

1.4.54

2 years ago

1.4.10

2 years ago

1.4.7

2 years ago

1.4.57

2 years ago

1.4.13

2 years ago

1.4.56

2 years ago

1.4.12

2 years ago

1.4.59

2 years ago

1.4.58

2 years ago

1.4.14

2 years ago

1.2.0

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.1.8

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.1.6

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

3.2.25

2 years ago