@friktion-labs/entropy-client v1.7.3
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),
);
}
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago