outsmart 2.0.0-alpha.1 → 2.0.0-alpha.10
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/README.md +211 -4
- package/dist/cli.js +383 -10
- package/dist/cli.js.map +1 -1
- package/dist/dex/meteora-dlmm.d.ts.map +1 -1
- package/dist/dex/meteora-dlmm.js +13 -1
- package/dist/dex/meteora-dlmm.js.map +1 -1
- package/dist/dex/percolator/adapter.d.ts +145 -0
- package/dist/dex/percolator/adapter.d.ts.map +1 -0
- package/dist/dex/percolator/adapter.js +856 -0
- package/dist/dex/percolator/adapter.js.map +1 -0
- package/dist/dex/percolator/core/abi/accounts.d.ts +45 -0
- package/dist/dex/percolator/core/abi/accounts.d.ts.map +1 -0
- package/dist/dex/percolator/core/abi/accounts.js +212 -0
- package/dist/dex/percolator/core/abi/accounts.js.map +1 -0
- package/dist/dex/percolator/core/abi/encode.d.ts +17 -0
- package/dist/dex/percolator/core/abi/encode.d.ts.map +1 -0
- package/dist/dex/percolator/core/abi/encode.js +102 -0
- package/dist/dex/percolator/core/abi/encode.js.map +1 -0
- package/dist/dex/percolator/core/abi/errors.d.ts +19 -0
- package/dist/dex/percolator/core/abi/errors.d.ts.map +1 -0
- package/dist/dex/percolator/core/abi/errors.js +72 -0
- package/dist/dex/percolator/core/abi/errors.js.map +1 -0
- package/dist/dex/percolator/core/abi/index.d.ts +5 -0
- package/dist/dex/percolator/core/abi/index.d.ts.map +1 -0
- package/dist/dex/percolator/core/abi/index.js +21 -0
- package/dist/dex/percolator/core/abi/index.js.map +1 -0
- package/dist/dex/percolator/core/abi/instructions.d.ts +176 -0
- package/dist/dex/percolator/core/abi/instructions.d.ts.map +1 -0
- package/dist/dex/percolator/core/abi/instructions.js +208 -0
- package/dist/dex/percolator/core/abi/instructions.js.map +1 -0
- package/dist/dex/percolator/core/config/program-ids.d.ts +25 -0
- package/dist/dex/percolator/core/config/program-ids.d.ts.map +1 -0
- package/dist/dex/percolator/core/config/program-ids.js +50 -0
- package/dist/dex/percolator/core/config/program-ids.js.map +1 -0
- package/dist/dex/percolator/core/index.d.ts +15 -0
- package/dist/dex/percolator/core/index.d.ts.map +1 -0
- package/dist/dex/percolator/core/index.js +31 -0
- package/dist/dex/percolator/core/index.js.map +1 -0
- package/dist/dex/percolator/core/math/index.d.ts +2 -0
- package/dist/dex/percolator/core/math/index.d.ts.map +1 -0
- package/dist/dex/percolator/core/math/index.js +18 -0
- package/dist/dex/percolator/core/math/index.js.map +1 -0
- package/dist/dex/percolator/core/math/trading.d.ts +14 -0
- package/dist/dex/percolator/core/math/trading.d.ts.map +1 -0
- package/dist/dex/percolator/core/math/trading.js +77 -0
- package/dist/dex/percolator/core/math/trading.js.map +1 -0
- package/dist/dex/percolator/core/runtime/index.d.ts +2 -0
- package/dist/dex/percolator/core/runtime/index.d.ts.map +1 -0
- package/dist/dex/percolator/core/runtime/index.js +18 -0
- package/dist/dex/percolator/core/runtime/index.js.map +1 -0
- package/dist/dex/percolator/core/runtime/tx.d.ts +29 -0
- package/dist/dex/percolator/core/runtime/tx.d.ts.map +1 -0
- package/dist/dex/percolator/core/runtime/tx.js +71 -0
- package/dist/dex/percolator/core/runtime/tx.js.map +1 -0
- package/dist/dex/percolator/core/solana/ata.d.ts +9 -0
- package/dist/dex/percolator/core/solana/ata.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/ata.js +12 -0
- package/dist/dex/percolator/core/solana/ata.js.map +1 -0
- package/dist/dex/percolator/core/solana/discovery.d.ts +38 -0
- package/dist/dex/percolator/core/solana/discovery.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/discovery.js +139 -0
- package/dist/dex/percolator/core/solana/discovery.js.map +1 -0
- package/dist/dex/percolator/core/solana/index.d.ts +6 -0
- package/dist/dex/percolator/core/solana/index.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/index.js +22 -0
- package/dist/dex/percolator/core/solana/index.js.map +1 -0
- package/dist/dex/percolator/core/solana/pda.d.ts +16 -0
- package/dist/dex/percolator/core/solana/pda.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/pda.js +39 -0
- package/dist/dex/percolator/core/solana/pda.js.map +1 -0
- package/dist/dex/percolator/core/solana/slab.d.ts +131 -0
- package/dist/dex/percolator/core/solana/slab.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/slab.js +376 -0
- package/dist/dex/percolator/core/solana/slab.js.map +1 -0
- package/dist/dex/percolator/core/solana/token-program.d.ts +9 -0
- package/dist/dex/percolator/core/solana/token-program.d.ts.map +1 -0
- package/dist/dex/percolator/core/solana/token-program.js +21 -0
- package/dist/dex/percolator/core/solana/token-program.js.map +1 -0
- package/dist/dex/percolator/core/validation.d.ts +16 -0
- package/dist/dex/percolator/core/validation.d.ts.map +1 -0
- package/dist/dex/percolator/core/validation.js +99 -0
- package/dist/dex/percolator/core/validation.js.map +1 -0
- package/dist/dex/types.d.ts +5 -0
- package/dist/dex/types.d.ts.map +1 -1
- package/dist/dex/types.js.map +1 -1
- package/dist/helpers/util.d.ts +0 -7
- package/dist/helpers/util.d.ts.map +1 -1
- package/dist/helpers/util.js +0 -20
- package/dist/helpers/util.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -1
- package/dist/index.js.map +1 -1
- package/dist/transactions/bloXroute_tips_tx_executor.d.ts.map +1 -1
- package/dist/transactions/bloXroute_tips_tx_executor.js +42 -22
- package/dist/transactions/bloXroute_tips_tx_executor.js.map +1 -1
- package/dist/transactions/index.d.ts +2 -0
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/transactions/index.js +7 -1
- package/dist/transactions/index.js.map +1 -1
- package/dist/transactions/landing/providers/bloxroute.d.ts +3 -4
- package/dist/transactions/landing/providers/bloxroute.d.ts.map +1 -1
- package/dist/transactions/landing/providers/bloxroute.js +55 -24
- package/dist/transactions/landing/providers/bloxroute.js.map +1 -1
- package/dist/transactions/send-rpc.d.ts +37 -0
- package/dist/transactions/send-rpc.d.ts.map +1 -1
- package/dist/transactions/send-rpc.js +160 -5
- package/dist/transactions/send-rpc.js.map +1 -1
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# outsmart
|
|
2
2
|
|
|
3
|
-
**Solana trading CLI — buy, sell, and
|
|
3
|
+
**Solana trading CLI — buy, sell, LP, and operate perp exchanges across 18 DEXes with 12 TX landing providers.**
|
|
4
|
+
|
|
5
|
+
**[Documentation](https://outsmartchad.github.io/outsmart-cli/)** | **[npm](https://www.npmjs.com/package/outsmart)** | **[Discord](https://discord.gg/dc3Kh3Y3yJ)**
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
8
|
npm install -g outsmart@alpha
|
|
@@ -8,8 +10,6 @@ outsmart init
|
|
|
8
10
|
outsmart buy --dex raydium-cpmm --pool <POOL> --amount 0.1
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
> **This branch (`agent-trading-infra`) is under active development.** For the stable version, use [`typescript-main`](https://github.com/outsmartchad/outsmart-cli/tree/typescript-main).
|
|
12
|
-
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
@@ -286,6 +286,101 @@ outsmart create-damm-config-pool --base <MINT> --base-amount 1000000 --quote-amo
|
|
|
286
286
|
--config <CONFIG_ADDRESS>
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
+
### Perpetual Futures (Percolator)
|
|
290
|
+
|
|
291
|
+
Create and operate on-chain perpetual futures exchanges. All prices in USD, all amounts in SOL.
|
|
292
|
+
|
|
293
|
+
#### perp create-market
|
|
294
|
+
|
|
295
|
+
Create a new perp market. You become the admin/oracle authority.
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
outsmart perp create-market --price 150 --lp 2
|
|
299
|
+
outsmart perp create-market --price 0.00001 --lp 5 --tier medium --network mainnet
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
| Flag | Description | Default |
|
|
303
|
+
|------|-------------|---------|
|
|
304
|
+
| `--price <usd>` | Initial oracle price in USD (required) | |
|
|
305
|
+
| `--lp <sol>` | Initial LP collateral in SOL (required) | |
|
|
306
|
+
| `--tier <size>` | `small` \| `medium` \| `large` | `small` |
|
|
307
|
+
| `--network <net>` | `devnet` \| `mainnet` | `devnet` |
|
|
308
|
+
|
|
309
|
+
#### perp long / short
|
|
310
|
+
|
|
311
|
+
Open a leveraged position.
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
outsmart perp long -m <MARKET> -s 0.1
|
|
315
|
+
outsmart perp short -m <MARKET> -s 0.05
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
| Flag | Description |
|
|
319
|
+
|------|-------------|
|
|
320
|
+
| `-m, --market <address>` | Market (slab) address (required) |
|
|
321
|
+
| `-s, --size <sol>` | Position size in SOL (required) |
|
|
322
|
+
|
|
323
|
+
#### perp close
|
|
324
|
+
|
|
325
|
+
Close your open position.
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
outsmart perp close -m <MARKET>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### perp status
|
|
332
|
+
|
|
333
|
+
View your position and market state.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
outsmart perp status -m <MARKET>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
#### perp deposit / withdraw
|
|
340
|
+
|
|
341
|
+
Manage collateral in your trading account.
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
outsmart perp deposit -m <MARKET> -a 1.0
|
|
345
|
+
outsmart perp withdraw -m <MARKET> -a 0.5
|
|
346
|
+
outsmart perp withdraw -m <MARKET> -a all
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### perp init-user
|
|
350
|
+
|
|
351
|
+
Register a trading account on a market (required before first deposit/trade).
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
outsmart perp init-user -m <MARKET>
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### perp set-price
|
|
358
|
+
|
|
359
|
+
Push a new oracle price (admin-oracle markets only).
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
outsmart perp set-price -m <MARKET> --price 155.50
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### perp crank
|
|
366
|
+
|
|
367
|
+
Run the permissionless keeper crank (updates funding rates).
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
outsmart perp crank -m <MARKET>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### perp markets
|
|
374
|
+
|
|
375
|
+
Discover all markets on-chain.
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
outsmart perp markets
|
|
379
|
+
outsmart perp markets --network mainnet
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
289
384
|
### Utilities
|
|
290
385
|
|
|
291
386
|
#### info
|
|
@@ -387,6 +482,113 @@ All swap commands (`buy`, `sell`) accept these options:
|
|
|
387
482
|
|
|
388
483
|
All ✅ adapters confirmed on Solana mainnet with real transactions.
|
|
389
484
|
|
|
485
|
+
## Percolator — Permissionless Perpetual Futures
|
|
486
|
+
|
|
487
|
+
Create and operate your own on-chain perpetual futures exchange on Solana. The `PercolatorAdapter` is a standalone class (not `IDexAdapter` — perps are fundamentally different from spot).
|
|
488
|
+
|
|
489
|
+
### Why This Matters
|
|
490
|
+
|
|
491
|
+
First mover creates the perp market for a trending token and captures ALL leveraged volume fees. Nobody else has done AI-operated perp exchanges yet. This is the Percolator alpha.
|
|
492
|
+
|
|
493
|
+
### Quick Start (Programmatic API)
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
import { PercolatorAdapter } from "outsmart";
|
|
497
|
+
|
|
498
|
+
const percolator = new PercolatorAdapter();
|
|
499
|
+
|
|
500
|
+
// 1. Create a perp market (devnet, BONK collateral, $1 initial price)
|
|
501
|
+
const market = await percolator.createMarket({
|
|
502
|
+
collateralMint: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK
|
|
503
|
+
initialPriceE6: 1_000_000n, // $1.00
|
|
504
|
+
tier: "small",
|
|
505
|
+
network: "devnet",
|
|
506
|
+
lpCollateral: 1_000_000_000n, // 1B BONK for LP
|
|
507
|
+
});
|
|
508
|
+
console.log("Market:", market.slabAddress);
|
|
509
|
+
|
|
510
|
+
// 2. Register a trader
|
|
511
|
+
const { userIdx } = await percolator.initUser(market.slabAddress, "devnet");
|
|
512
|
+
|
|
513
|
+
// 3. Deposit collateral
|
|
514
|
+
await percolator.deposit(market.slabAddress, userIdx, 500_000_000n, "devnet");
|
|
515
|
+
|
|
516
|
+
// 4. Open a long position (positive size = long, negative = short)
|
|
517
|
+
await percolator.trade({
|
|
518
|
+
slabAddress: market.slabAddress,
|
|
519
|
+
userIdx,
|
|
520
|
+
lpIdx: market.lpIndex,
|
|
521
|
+
size: 100_000_000n, // long 100M units
|
|
522
|
+
network: "devnet",
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// 5. Push oracle price (admin-oracle mode)
|
|
526
|
+
await percolator.pushOraclePrice(market.slabAddress, 1_100_000n, "devnet"); // $1.10
|
|
527
|
+
|
|
528
|
+
// 6. Read market state
|
|
529
|
+
const state = await percolator.getMarketState(market.slabAddress, "devnet");
|
|
530
|
+
console.log("Open interest:", state.engine.openInterestLong);
|
|
531
|
+
|
|
532
|
+
// 7. Check your position
|
|
533
|
+
const pos = await percolator.getMyPosition(market.slabAddress, "devnet");
|
|
534
|
+
console.log("PnL:", pos?.account.unrealizedPnl);
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### PercolatorAdapter Methods (20)
|
|
538
|
+
|
|
539
|
+
| Method | Description |
|
|
540
|
+
|--------|-------------|
|
|
541
|
+
| `createMarket(params)` | Full 10-step market creation (slab → init → oracle → crank → vAMM → LP) |
|
|
542
|
+
| `initUser(slab, network?, tier?)` | Register a trader account, returns assigned index |
|
|
543
|
+
| `deposit(slab, idx, amount, network?, tier?)` | Deposit collateral |
|
|
544
|
+
| `withdraw(slab, idx, amount, network?, tier?)` | Withdraw collateral |
|
|
545
|
+
| `trade(params)` | Open/close/modify positions via TradeCpi |
|
|
546
|
+
| `closeAccount(slab, idx, network?, tier?)` | Close account and recover rent |
|
|
547
|
+
| `crank(slab, network?, tier?)` | Permissionless keeper crank |
|
|
548
|
+
| `pushOraclePrice(slab, priceE6, network?, tier?)` | Update oracle price (admin only) |
|
|
549
|
+
| `liquidate(slab, targetIdx, network?, tier?)` | Permissionless liquidation |
|
|
550
|
+
| `createInsuranceMint(slab, network?, tier?)` | One-time insurance LP mint creation |
|
|
551
|
+
| `depositInsuranceLP(slab, amount, network?, tier?)` | Deposit into insurance fund |
|
|
552
|
+
| `withdrawInsuranceLP(slab, lpAmount, network?, tier?)` | Withdraw from insurance fund |
|
|
553
|
+
| `getMarketState(slab, network?)` | Read full slab state (header, config, engine, params, accounts) |
|
|
554
|
+
| `getMyPosition(slab, network?)` | Find user's account by owner pubkey |
|
|
555
|
+
| `discoverMarkets(network?)` | Find all markets across all program tiers |
|
|
556
|
+
| `adminForceClose(slab, targetIdx, network?, tier?)` | Admin force-close a position |
|
|
557
|
+
| `resolveMarket(slab, network?, tier?)` | Resolve/freeze market (admin only) |
|
|
558
|
+
| `withdrawInsurance(slab, network?, tier?)` | Withdraw insurance fund balance |
|
|
559
|
+
| `closeSlab(slab, network?, tier?)` | Close slab account and recover rent |
|
|
560
|
+
| `teardownMarket(slab, network?, tier?)` | Full teardown: resolve → force-close all → withdraw → close |
|
|
561
|
+
|
|
562
|
+
### Math Utilities
|
|
563
|
+
|
|
564
|
+
Exported for PnL calculation, risk analysis, and pre-trade simulation:
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
import {
|
|
568
|
+
computeMarkPnl,
|
|
569
|
+
computeLiqPrice,
|
|
570
|
+
computePreTradeLiqPrice,
|
|
571
|
+
computeTradingFee,
|
|
572
|
+
computePnlPercent,
|
|
573
|
+
computeEstimatedEntryPrice,
|
|
574
|
+
computeFundingRateAnnualized,
|
|
575
|
+
computeRequiredMargin,
|
|
576
|
+
computeMaxLeverage,
|
|
577
|
+
computeVammQuote,
|
|
578
|
+
} from "outsmart";
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Deployed Programs
|
|
582
|
+
|
|
583
|
+
| Tier | Devnet | Mainnet |
|
|
584
|
+
|------|--------|---------|
|
|
585
|
+
| Small | `FxfD37s1AZTeWfFQps9Zpebi2dNQ9QSSDtfMKdbsfKrD` | `GM8zjJ8LTBMv9xEsverh6H6wLyevgMHEJXcEzyY3rY24` |
|
|
586
|
+
| Medium | `FwfBKZXbYr4vTK23bMFkbgKq3npJ3MSDxEaKmq9Aj4Qn` | — |
|
|
587
|
+
| Large | `g9msRSV3sJmmE3r5Twn9HuBsxzuuRGTjKCVTKudm9in` | — |
|
|
588
|
+
| Matcher | `4HcGCsyjAqnFua5ccuXyt8KRRQzKFbGTJkVChpS7Yfzy` | `DHP6DtwXP1yJsz8YzfoeigRFPB979gzmumkmCxDLSkUX` |
|
|
589
|
+
|
|
590
|
+
---
|
|
591
|
+
|
|
390
592
|
## TX Landing Providers
|
|
391
593
|
|
|
392
594
|
12 providers with concurrent, race, random, and sequential submission strategies:
|
|
@@ -427,6 +629,7 @@ Set any provider's API key and it's automatically enabled. The orchestrator send
|
|
|
427
629
|
| `DEFAULT_TIP_SOL` | MEV tip in SOL | `0.001` |
|
|
428
630
|
| `DEFAULT_SLIPPAGE_BPS` | Slippage in basis points | `300` |
|
|
429
631
|
| `DEFAULT_PRIORITY_FEE` | Priority fee in microLamports per CU | `4000` |
|
|
632
|
+
| `DEVNET_ENDPOINT` | Solana devnet RPC endpoint (for Percolator) | not set |
|
|
430
633
|
| `JUPITER_API_KEY` | Jupiter Ultra API key ([portal.jup.ag](https://portal.jup.ag)) | works without key |
|
|
431
634
|
| `DFLOW_API_KEY` | DFlow intent API key ([pond.dflow.net](https://pond.dflow.net/build/api-key)) | required for dflow |
|
|
432
635
|
|
|
@@ -485,9 +688,10 @@ npm run test:orca # Orca Whirlpool (mainnet)
|
|
|
485
688
|
npm run test:clmm # Byreal + PancakeSwap CLMM (mainnet)
|
|
486
689
|
npm run test:fusion # Fusion + Futarchy AMM (mainnet)
|
|
487
690
|
npm run test:api # Jupiter Ultra + DFlow (mainnet)
|
|
691
|
+
npm run test:percolator # Percolator perps (devnet)
|
|
488
692
|
```
|
|
489
693
|
|
|
490
|
-
Mainnet tests require `PRIVATE_KEY` and `MAINNET_ENDPOINT` env vars. Tests use tiny amounts (0.
|
|
694
|
+
Mainnet tests require `PRIVATE_KEY` and `MAINNET_ENDPOINT` env vars. Percolator tests require `DEVNET_ENDPOINT`. Tests use tiny amounts (0.002 SOL per buy). Run suites one at a time — tests share a wallet and cannot run in parallel.
|
|
491
695
|
|
|
492
696
|
---
|
|
493
697
|
|
|
@@ -501,6 +705,9 @@ src/
|
|
|
501
705
|
│ ├── types.ts # IDexAdapter interface
|
|
502
706
|
│ ├── index.ts # DexRegistry singleton
|
|
503
707
|
│ ├── shared/clmm-base.ts
|
|
708
|
+
│ ├── percolator/
|
|
709
|
+
│ │ ├── adapter.ts # PercolatorAdapter (15 methods)
|
|
710
|
+
│ │ └── core/ # Vendored @percolator/core SDK
|
|
504
711
|
│ └── 18 adapter files
|
|
505
712
|
├── dexscreener/ # Market data (DexScreener API)
|
|
506
713
|
├── helpers/
|