@panoptic-eng/sdk 1.0.4 → 1.0.5

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 CHANGED
@@ -13,10 +13,16 @@ import { createPublicClient, createWalletClient, http, parseUnits } from 'viem'
13
13
  import { sepolia } from 'viem/chains'
14
14
  import { privateKeyToAccount } from 'viem/accounts'
15
15
  import {
16
- getPool, fetchPoolId, approveAndWait, depositAndWait,
17
- createTokenIdBuilder, simulateOpenPosition, openPositionAndWait,
18
- tickLimits, formatTokenAmount,
19
- } from '@panoptic-eng/sdk'
16
+ getPool,
17
+ fetchPoolId,
18
+ approveAndWait,
19
+ depositAndWait,
20
+ createTokenIdBuilder,
21
+ simulateOpenPosition,
22
+ openPositionAndWait,
23
+ tickLimits,
24
+ formatTokenAmount,
25
+ } from '@panoptic-eng/sdk/v2'
20
26
 
21
27
  // 1. Setup clients
22
28
  const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY')
@@ -28,13 +34,17 @@ const pool = await getPool({ client, poolAddress: '0x...', chainId: 11155111n })
28
34
 
29
35
  // 3. Approve + deposit collateral
30
36
  await approveAndWait({
31
- client, walletClient, account: account.address,
37
+ client,
38
+ walletClient,
39
+ account: account.address,
32
40
  tokenAddress: pool.poolKey.currency0,
33
41
  spenderAddress: pool.collateralTracker0.address,
34
42
  amount: 2n ** 256n - 1n,
35
43
  })
36
44
  await depositAndWait({
37
- client, walletClient, account: account.address,
45
+ client,
46
+ walletClient,
47
+ account: account.address,
38
48
  collateralTrackerAddress: pool.collateralTracker0.address,
39
49
  assets: parseUnits('1', 18),
40
50
  })
@@ -47,32 +57,77 @@ const tokenId = createTokenIdBuilder(poolId)
47
57
 
48
58
  const limits = tickLimits(pool.currentTick, 500n)
49
59
  const sim = await simulateOpenPosition({
50
- client, poolAddress: '0x...', account: account.address,
51
- tokenId, positionSize: 10n ** 15n, existingPositionIds: [],
52
- tickLimitLow: limits.low, tickLimitHigh: limits.high,
60
+ client,
61
+ poolAddress: '0x...',
62
+ account: account.address,
63
+ tokenId,
64
+ positionSize: 10n ** 15n,
65
+ existingPositionIds: [],
66
+ tickLimitLow: limits.low,
67
+ tickLimitHigh: limits.high,
53
68
  })
54
69
 
55
70
  if (!sim.success) throw new Error(`Simulation failed: ${sim.error}`)
56
71
  console.log('Gas estimate:', sim.gasEstimate)
57
- console.log('Token0 required:', formatTokenAmount(
58
- sim.data.amount0Required, BigInt(pool.collateralTracker0.decimals), 6n
59
- ))
72
+ console.log(
73
+ 'Token0 required:',
74
+ formatTokenAmount(sim.data.amount0Required, BigInt(pool.collateralTracker0.decimals), 6n),
75
+ )
60
76
 
61
77
  // 5. Execute
62
78
  await openPositionAndWait({
63
- client, walletClient, account: account.address, poolAddress: '0x...',
64
- tokenId, positionSize: 10n ** 15n, existingPositionIds: [],
65
- tickLimitLow: limits.low, tickLimitHigh: limits.high,
79
+ client,
80
+ walletClient,
81
+ account: account.address,
82
+ poolAddress: '0x...',
83
+ tokenId,
84
+ positionSize: 10n ** 15n,
85
+ existingPositionIds: [],
86
+ tickLimitLow: limits.low,
87
+ tickLimitHigh: limits.high,
66
88
  })
67
89
  ```
68
90
 
69
- ## Documentation
91
+ ## Feature Overview
70
92
 
71
- | Document | Description |
93
+ | Category | Capabilities |
72
94
  |----------|-------------|
73
- | [Getting Started](./docs/GETTING_STARTED.md) | Full walkthrough: setup, deposit, build positions, simulate, trade, monitor, close |
74
- | [API Reference](./docs/SDK_API_REFERENCE.md) | Every exported function grouped by module with signatures and descriptions |
75
- | [Examples](./src/panoptic/v2/examples/) | Runnable example scripts (bots, fork tests, common workflows) |
95
+ | **Pool Data** | Full pool state, utilization, oracle, risk parameters, liquidity distribution, interest rates |
96
+ | **Trading** | Open, close, roll positions with simulation-first workflow; tick limit slippage control |
97
+ | **Collateral** | ERC-4626 vault deposits/withdrawals, approval helpers, collateral estimation, max position sizing |
98
+ | **TokenId Builder** | Chainable builder for calls, puts, loans, credits; multi-leg spreads (up to 4 legs) |
99
+ | **Risk & Margin** | Margin buffer, liquidation prices, net liquidation value, collateral-across-ticks analysis |
100
+ | **Liquidation** | Liquidation checks, simulation, execution; force exercise for ITM longs |
101
+ | **Greeks** | Client-side value, delta, gamma in natural token units; swap-aware delta; loan effective delta |
102
+ | **Events** | WebSocket watcher, resilient subscription with auto-reconnect, HTTP polling |
103
+ | **Position Tracking** | Event-based sync with resumable checkpoints; file and memory storage adapters |
104
+ | **Trade History** | Local trade history with filters, realized PnL aggregation |
105
+ | **Price History** | Historical tick/sqrtPriceX96 data, streamia (premia) history, Uniswap fee history |
106
+ | **Bot Utilities** | Data freshness assertions, pool health checks, safe mode guards, RPC error classifiers |
107
+ | **Oracle** | Oracle state reads, poke with epoch rate-limit handling |
108
+ | **Pool Deployment** | Mine vanity pool addresses, simulate and deploy new Panoptic pools |
109
+ | **Formatters** | Prices, token amounts, BPS, utilization, WAD values — all with explicit precision |
110
+ | **Errors** | Typed error classes for every failure mode (revert decoding, RPC, validation) |
111
+
112
+ ## Documentation
113
+
114
+ | Document | Description |
115
+ | -------------------------------------------- | ---------------------------------------------------------------------------------- |
116
+ | [Getting Started](./docs/GETTING_STARTED.md) | Full walkthrough: setup → deposit → trade → greeks → risk → events → bots → deployment |
117
+ | [API Reference](./docs/SDK_API_REFERENCE.md) | Every exported function grouped by module with signatures and descriptions |
118
+ | [Examples](./src/panoptic/v2/examples/) | Runnable example scripts (bots, fork tests, common workflows) |
119
+
120
+ ## Notes
121
+
122
+ - `GetVaultHistory` applies `first`/`skip` independently per event stream. For unified timeline pagination, merge and sort all streams client-side first, then page that merged array (for example, with a helper like `fetchVaultHistoryRows`).
123
+
124
+ ### Example Bots
125
+
126
+ | Directory | Description |
127
+ |-----------|-------------|
128
+ | [`examples/liquidation-bot/`](./src/panoptic/v2/examples/liquidation-bot/) | Monitors accounts, detects undercollateralized positions, and executes liquidations |
129
+ | [`examples/oracle-poker/`](./src/panoptic/v2/examples/oracle-poker/) | Keeps Panoptic oracle observations fresh by poking within epoch constraints |
130
+ | [`examples/reverse-gamma-scalping/`](./src/panoptic/v2/examples/reverse-gamma-scalping/) | Delta-hedged strategy using loans, credits, and swap-aware greeks |
76
131
 
77
132
  ---
78
133