@rekt-trading/wheelman 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -38,7 +38,7 @@ SESSION_KEYPAIR_PATH=
38
38
  # --- What to trade ---
39
39
  # knockout-momentum, knockout-fade, knockout-straddle, minute-trend, minute-schedule or template.
40
40
  STRATEGY=knockout-momentum
41
- # BTC, ETH, SOL or XRP. XAU needs PRICE_SOURCE=pyth (your own Pyth key) or PRICE_SOURCE=replay.
41
+ # BTC, ETH, SOL, XRP or HYPE.
42
42
  MARKET=BTC
43
43
  # Strategy parameters are PARAM_<NAME>. The names, defaults and bounds of each strategy are in README.md.
44
44
  PARAM_STAKE_USDC=1
package/README.md CHANGED
@@ -5,7 +5,7 @@ Knockout and Minute. You run it on your own machine, with your own wallet and yo
5
5
  It uses the Rekt SDK, `@rekt-trading/1000x` from npm, for both games, and it sends nothing the risk
6
6
  limits have not allowed.
7
7
 
8
- **Status: 1.0.0, on mainnet.** Install it from npm as `@rekt-trading/wheelman`, or run it from a clone of this repository.
8
+ **Status: 1.0.2, on mainnet.** Install it from npm as `@rekt-trading/wheelman`, or run it from a clone of this repository.
9
9
 
10
10
  - Documentation: <https://docs.rekt.money>
11
11
  - Contact: support@asymmetra.xyz
@@ -245,7 +245,7 @@ A price is needed only for a strategy's signal and for paper fills. Pick the sou
245
245
 
246
246
  | `PRICE_SOURCE` | What it reads | Needs |
247
247
  |---|---|---|
248
- | `coinbase` (the default) | Coinbase's public ticker, for BTC, ETH, SOL and XRP | nothing: no key, no account |
248
+ | `coinbase` (the default) | Coinbase's public ticker, for BTC, ETH, SOL, XRP and HYPE | nothing: no key, no account |
249
249
  | `pyth` | Pyth Pro's price stream, with your own key | `PYTH_API_KEY` (or `PYTH_API_KEY_FILE`) |
250
250
  | `auto` | Pyth when a key is set, Coinbase when not | optional: `PYTH_API_KEY` |
251
251
  | `replay` | a tape, for paper mode: one JSON line a price, `{"time": 1767225600000, "market": "BTC", "price": 100000}` | `REPLAY_FILE` |
@@ -283,6 +283,13 @@ you run Wheelman, with your own wallet; nobody hosts it for you.
283
283
  - Never commit `.env`, `wallets/` or a keypair file; `.gitignore` excludes them.
284
284
  - Use `--paper` and `--dry-run` before trading, and after every change you make.
285
285
 
286
+ ## Changes
287
+
288
+ - **1.0.2:** works on every live market with `@rekt-trading/1000x` 0.6.0 (install 0.6.0 or later). Opens, Minute
289
+ rounds and close requests take their accounts from the market's feed kind, read on every request. HYPE is
290
+ added; gold (XAU) is removed while its market is paused.
291
+ - **1.0.1:** the first release through the publish workflow.
292
+
286
293
  ## Development
287
294
 
288
295
  `npm run check` runs the type check and the tests (Node's own test runner, no network).
package/dist/client.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // history() settled positions build.open/close the same, as unsigned instructions
7
7
  // A refusal is thrown as a Refusal with `retryable`. Money is bigint USDC base units.
8
8
  import { PublicKey } from '@solana/web3.js';
9
- import { MICRO_PER_BP, assetId, barrierMicroBps, closableFromSlotOf, commitOpen, computeUnitLimit, configPda, connectionReader, decodeConfig, decodeFeeTermsTable, decodeMarket, decodeTraderAccount, decodeVault, delegatePda, exitFeeBpsFor, feeTermsTablePda, findBySeq, heldPositions, inEventWindow, ix, levels, marketPda, memoReader, newRules, openFeeTerms, openTenorS, ourInstruction, parseUsdc, phase, priceAccountsFor, readTradeHistory, receiptOf, sideRoom, sizeForTotal, toBase58, toHex, traderPda, vaultPda, venueEventsNamed, } from '@rekt-trading/1000x';
9
+ import { MICRO_PER_BP, assetId, barrierMicroBps, closableFromSlotOf, commitOpen, computeUnitLimit, configPda, connectionReader, decodeConfig, decodeFeeTermsTable, decodeMarket, decodeTraderAccount, decodeVault, delegatePda, exitFeeBpsFor, feeTermsTablePda, findBySeq, heldPositions, inEventWindow, ix, levels, marketPda, memoReader, newRules, openFeeTerms, openTenorS, ourInstruction, parseUsdc, phase, priceAccountsFor, readTradeHistory, receiptOf, requestCloseFor, sideRoom, sizeForTotal, toBase58, toHex, traderPda, vaultPda, venueEventsNamed, } from '@rekt-trading/1000x';
10
10
  import { MARKETS } from "./config.js";
11
11
  import { Refusal } from "./errors.js";
12
12
  import { payoutAt, scaled, termsFor } from "./paper.js";
@@ -145,11 +145,13 @@ export function createKnockoutClient(o) {
145
145
  throw new Refusal('venue', 'PositionNotFound', `no open position has seq ${seq}`);
146
146
  const marketAddress = new PublicKey(toBase58(p.market));
147
147
  const m = await o.rpc.conn.getAccountInfo(marketAddress, 'confirmed');
148
- const from = closableFromSlotOf(p, decodeConfig(new Uint8Array(c.data)), decodeMarket(new Uint8Array(m.data)));
148
+ const market = decodeMarket(new Uint8Array(m.data));
149
+ const from = closableFromSlotOf(p, decodeConfig(new Uint8Array(c.data)), market);
149
150
  if (from === null || from > clockOf(new Uint8Array(k.data)).slot) {
150
151
  throw new Refusal('venue', 'CLOSE_NOT_YET', `position ${seq} cannot be closed yet (an order, or inside the minimum hold)`, true, 5_000);
151
152
  }
152
- return bundleOf([ix.requestClose({
153
+ // requestCloseFor reads the market's feed kind on every request: the accounts a close carries depend on it.
154
+ return bundleOf([requestCloseFor(market, {
153
155
  authority: toHex(authority), config: toHex(configPda().address), market: toHex(marketAddress), positions: toHex(book),
154
156
  delegate: session ? toHex(delegatePda(owner).address) : null,
155
157
  }, seq)]);
package/dist/config.js CHANGED
@@ -5,8 +5,9 @@ import { Keypair, PublicKey } from '@solana/web3.js';
5
5
  import { parseUsdc } from '@rekt-trading/1000x';
6
6
  import { Refusal } from "./errors.js";
7
7
  import { addSecret } from "./journal.js";
8
- import { PRICE_SOURCES, pythFeeds, pythKey, resolveSourceName } from "./prices.js";
9
- export const MARKETS = ['BTC', 'ETH', 'SOL', 'XRP', 'XAU'];
8
+ import { EXCHANGE_MARKETS, PRICE_SOURCES, pythFeeds, pythKey, resolveSourceName } from "./prices.js";
9
+ /** The markets Wheelman trades. A market the venue has paused is not listed here. */
10
+ export const MARKETS = ['BTC', 'ETH', 'SOL', 'XRP', 'HYPE'];
10
11
  export class ConfigError extends Refusal {
11
12
  constructor(message) {
12
13
  super('config', 'BAD_CONFIG', message);
@@ -165,8 +166,8 @@ export function parseConfig(env, needs, strategies) {
165
166
  problems.push(`STRATEGY is required: one of ${[...strategies.keys()].join(', ')}`);
166
167
  else if (strategy === null)
167
168
  problems.push(`STRATEGY ${id} does not exist: use one of ${[...strategies.keys()].join(', ')}`);
168
- if (strategy?.game === 'knockout' && exchangeFeed && market === 'XAU') {
169
- problems.push('the exchange feed has no XAU price; set PRICE_SOURCE=pyth with your Pyth key (PYTH_API_KEY), use replay, or add an adapter in src/prices.ts');
169
+ if (strategy?.game === 'knockout' && exchangeFeed && MARKETS.includes(market) && !EXCHANGE_MARKETS.includes(market)) {
170
+ problems.push(`the exchange feed has no ${market} price; set PRICE_SOURCE=pyth with your Pyth key (PYTH_API_KEY), use replay, or add an adapter in src/prices.ts`);
170
171
  }
171
172
  }
172
173
  if (strategy !== null) {
package/dist/minute.js CHANGED
@@ -1,12 +1,22 @@
1
1
  // Minute rounds, in the same shape as the Knockout client: rounds, preview, round, history, build.
2
2
  // A round runs on Minute's own clock and has no early exit; the venue's keepers settle it.
3
3
  import { PublicKey } from '@solana/web3.js';
4
- import { PROGRAM_ID, assetId, collateralForTotal, configPda, connectionReader, decodeConfig, decodeFeeTermsTable, decodeMarket, decodeTraderAccount, decodeVault, feeTermsTablePda, findBySeq, marketPda, memoReader, parseUsdc, pricingRemainingAccounts, readTradeHistory, toBase58, toHex, vaultPda, withFeeTermsTable, } from '@rekt-trading/1000x';
4
+ import { PROGRAM_ID, assetId, collateralForTotal, configPda, connectionReader, decodeConfig, decodeFeeTermsTable, decodeMarket, decodeTraderAccount, decodeVault, feeTermsTablePda, findBySeq, isKind3Market, marketPda, memoReader, parseUsdc, priceAccountsFor, pricingRemainingAccounts, readTradeHistory, toBase58, toHex, vaultPda, withFeeTermsTable, } from '@rekt-trading/1000x';
5
5
  import { ROUND_STATUS, decodeMinuteConfig, decodeMinuteEvent, decodePlayerAccount, minuteConfigPda, minuteEventPayloads, minuteIx, minutePlayerPda, minutePlayerTokenPda, minuteTraderBookFor, } from '@rekt-trading/1000x'; // Minute's API ships in the same package
6
6
  import { ata, bundleOf, marketSymbol } from "./client.js";
7
7
  import { Refusal } from "./errors.js";
8
8
  import { payoutAt, scaled, termsFor } from "./paper.js";
9
9
  import { CLOCK, transact } from "./rpc.js";
10
+ /**
11
+ * The accounts a round's venue open reads, by the market's feed kind, read on every round (a market's kind can change).
12
+ * On feed kind 3, priceAccountsFor. On the other kinds, the market's pricing accounts and its fee terms, as before:
13
+ * Minute refuses an empty list, and priceAccountsFor can return one on kind 2 when opens are orders.
14
+ */
15
+ export function openRoundAccounts(market, config) {
16
+ return isKind3Market(market)
17
+ ? priceAccountsFor(market, config, 'open')
18
+ : withFeeTermsTable(pricingRemainingAccounts(market), market, config, 'open');
19
+ }
10
20
  export function createMinuteClient(o) {
11
21
  const owner = o.owner;
12
22
  const player = minutePlayerPda(owner);
@@ -82,7 +92,7 @@ export function createMinuteClient(o) {
82
92
  }
83
93
  // A session key pays, and spends the owner's USDC as the SPL delegate the owner approved.
84
94
  built.push(minuteIx.openRound({ ...accounts, payer: toHex(signer), player_wallet: toHex(owner), funder: toHex(signer), wallet_token: walletToken,
85
- knockout_config: toHex(configPda().address), knockout_market: toHex(marketPda(assetId(order.market)).address), knockout_protocol_token: r.config.treasury }, { game_kind: 0, direction: order.side === 'long' ? 0 : 1, total_in: total, min_collateral_out: predicted }, withFeeTermsTable(pricingRemainingAccounts(r.market), r.market, r.config, 'open')));
95
+ knockout_config: toHex(configPda().address), knockout_market: toHex(marketPda(assetId(order.market)).address), knockout_protocol_token: r.config.treasury }, { game_kind: 0, direction: order.side === 'long' ? 0 : 1, total_in: total, min_collateral_out: predicted }, openRoundAccounts(r.market, r.config)));
86
96
  // A round names Minute's accounts and the venue's: compile it against Minute's lookup table (frozen, read once).
87
97
  lookupTables ??= await (async () => {
88
98
  const t = (await o.rpc.conn.getAddressLookupTable(new PublicKey(toBase58(m.lookupTable)), { commitment: 'confirmed' })).value;
package/dist/prices.js CHANGED
@@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs';
8
8
  */
9
9
  export function replay(file) {
10
10
  return {
11
- markets: ['BTC', 'ETH', 'SOL', 'XRP', 'XAU'],
11
+ markets: ['BTC', 'ETH', 'SOL', 'XRP', 'HYPE'],
12
12
  async *ticks(markets) {
13
13
  const lines = readFileSync(file, 'utf8').split('\n');
14
14
  for (const [i, line] of lines.entries()) {
@@ -32,13 +32,15 @@ export function replay(file) {
32
32
  },
33
33
  };
34
34
  }
35
+ /** The markets the public exchange feed quotes in USD. */
36
+ export const EXCHANGE_MARKETS = ['BTC', 'ETH', 'SOL', 'XRP', 'HYPE'];
35
37
  /**
36
38
  * Coinbase Exchange's public ticker websocket. No key and no account. It reconnects with a backoff
37
39
  * (1 s, doubling to 30 s, with jitter), and it reconnects when a minute passes with no ticker.
38
40
  */
39
41
  export function coinbase(url = 'wss://ws-feed.exchange.coinbase.com', Socket = WebSocket) {
40
42
  return {
41
- markets: ['BTC', 'ETH', 'SOL', 'XRP'],
43
+ markets: [...EXCHANGE_MARKETS],
42
44
  async latest(market) {
43
45
  const res = await fetch(`https://api.exchange.coinbase.com/products/${market}-USD/ticker`, { signal: AbortSignal.timeout(10_000) });
44
46
  const body = (await res.json());
package/dist/setup.js CHANGED
@@ -84,7 +84,7 @@ export async function setup(o) {
84
84
  for (const id of ids)
85
85
  say(` ${id}: ${strategies.get(id).description}`);
86
86
  env.STRATEGY = await ask('Strategy', from('STRATEGY') ?? ids[0], (v) => (ids.includes(v) ? null : `one of ${ids.join(', ')}`));
87
- env.MARKET = (await ask(`Market (${MARKETS.slice(0, 4).join(', ')})`, from('MARKET') ?? 'BTC', (v) => MARKETS.slice(0, 4).includes(v.toUpperCase()) ? null : `one of ${MARKETS.slice(0, 4).join(', ')}`)).toUpperCase();
87
+ env.MARKET = (await ask(`Market (${MARKETS.join(', ')})`, from('MARKET') ?? 'BTC', (v) => MARKETS.includes(v.toUpperCase()) ? null : `one of ${MARKETS.join(', ')}`)).toUpperCase();
88
88
  const strategy = strategies.get(env.STRATEGY);
89
89
  for (const [key, p] of Object.entries(strategy.params)) {
90
90
  const name = `PARAM_${key.toUpperCase()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rekt-trading/wheelman",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Wheelman, the Rekt trading bot and CLI, for Knockout and Minute: a bot, a command line and an MCP server for agents.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "prepack": "npm run build"
23
23
  },
24
24
  "dependencies": {
25
- "@rekt-trading/1000x": "^0.5.0",
25
+ "@rekt-trading/1000x": "^0.6.0",
26
26
  "@solana/web3.js": "^1.98.4"
27
27
  },
28
28
  "devDependencies": {