@panoptic-eng/sdk 1.0.4 → 1.0.6
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/LICENSE +21 -0
- package/README.md +75 -20
- package/dist/cow/index.d.ts +5 -0
- package/dist/cow/index.js +5 -0
- package/dist/cow/types.d.ts +4 -0
- package/dist/cow/types.js +0 -0
- package/dist/cow-Dy-Cd09v.js +1405 -0
- package/dist/cow-Dy-Cd09v.js.map +1 -0
- package/dist/index-BuJcj5aO.d.ts +275 -0
- package/dist/index-BuJcj5aO.d.ts.map +1 -0
- package/dist/index-DVMjZi1E.d.ts +1801 -0
- package/dist/index-DVMjZi1E.d.ts.map +1 -0
- package/dist/index.d.ts +6192 -2513
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3242 -5537
- package/dist/index.js.map +1 -1
- package/dist/irm-CBrX8bjH.js +2375 -0
- package/dist/irm-CBrX8bjH.js.map +1 -0
- package/dist/irm-CGykVo3q.d.ts +32 -0
- package/dist/irm-CGykVo3q.d.ts.map +1 -0
- package/dist/irm-zWjtffWA.d.ts +85 -0
- package/dist/irm-zWjtffWA.d.ts.map +1 -0
- package/dist/panoptic/v2/index.d.ts +9370 -0
- package/dist/panoptic/v2/index.d.ts.map +1 -0
- package/dist/panoptic/v2/index.js +10765 -0
- package/dist/panoptic/v2/index.js.map +1 -0
- package/dist/panoptic/v2/types/index.d.ts +3 -0
- package/dist/panoptic/v2/types/index.js +0 -0
- package/dist/position-FxaZi608.js +10530 -0
- package/dist/position-FxaZi608.js.map +1 -0
- package/dist/router-gzYGM1OO.js +1012 -0
- package/dist/router-gzYGM1OO.js.map +1 -0
- package/dist/types-BQejAFnu.d.ts +245 -0
- package/dist/types-BQejAFnu.d.ts.map +1 -0
- package/dist/types-CRvvn2ce.d.ts +128 -0
- package/dist/types-CRvvn2ce.d.ts.map +1 -0
- package/dist/uniswap/index.d.ts +291 -0
- package/dist/uniswap/index.d.ts.map +1 -0
- package/dist/uniswap/index.js +5 -0
- package/dist/writes-CVCD6Ers.js +4302 -0
- package/dist/writes-CVCD6Ers.js.map +1 -0
- package/package.json +24 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Axicon Labs Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
51
|
-
|
|
52
|
-
|
|
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(
|
|
58
|
-
|
|
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,
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
##
|
|
91
|
+
## Feature Overview
|
|
70
92
|
|
|
71
|
-
|
|
|
93
|
+
| Category | Capabilities |
|
|
72
94
|
|----------|-------------|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
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
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { APP_DATA_DOC$1 as APP_DATA_DOC, APP_DATA_HASH$1 as APP_DATA_HASH, BestVenue, COW_API_URLS$1 as COW_API_URLS, COW_CANCELLATION_TYPES$1 as COW_CANCELLATION_TYPES, COW_NATIVE_ETH$1 as COW_NATIVE_ETH, COW_ORDER_TYPES$1 as COW_ORDER_TYPES, COW_SETTLEMENT$1 as COW_SETTLEMENT, COW_VAULT_RELAYER$1 as COW_VAULT_RELAYER, CowApiError$1 as CowApiError, CowNativeTokenError$1 as CowNativeTokenError, CowOrderTooSmallError$1 as CowOrderTooSmallError, CowTokenInfo, CowUnsupportedChainError$1 as CowUnsupportedChainError, DEFAULT_VALID_FOR_SECONDS$1 as DEFAULT_VALID_FOR_SECONDS, FindCowTokenParams, PickBestVenueParams, SwapVenue, XSTOCK_WRAPPERS$1 as XSTOCK_WRAPPERS, XstockWrapperInfo, XstockWrapperRegistry, approveErc20ForCow$1 as approveErc20ForCow, cancelCowOrder$1 as cancelCowOrder, checkCowApproval$1 as checkCowApproval, cowDomain$1 as cowDomain, findCowToken$1 as findCowToken, getCowOrderStatus$1 as getCowOrderStatus, getXstockUnderlying$1 as getXstockUnderlying, getXstockWrapper$1 as getXstockWrapper, isCowSupportedChain$1 as isCowSupportedChain, isXstockUnderlying$1 as isXstockUnderlying, isXstockWrapper$1 as isXstockWrapper, pickBestVenue$1 as pickBestVenue, quoteCowSwap$1 as quoteCowSwap, signAndSubmitCowOrder$1 as signAndSubmitCowOrder } from "../index-BuJcj5aO.js";
|
|
2
|
+
import "../index-DVMjZi1E.js";
|
|
3
|
+
import "../irm-CGykVo3q.js";
|
|
4
|
+
import { ApproveErc20ForCowParams, CancelCowOrderParams, CheckCowApprovalParams, CowApprovalStatus, CowOrderKind, CowOrderResult, CowOrderState, CowOrderStatus, CowQuote, GetCowOrderStatusParams, QuoteCowSwapParams, SignAndSubmitCowOrderParams } from "../types-CRvvn2ce.js";
|
|
5
|
+
export { APP_DATA_DOC, APP_DATA_HASH, ApproveErc20ForCowParams, BestVenue, COW_API_URLS, COW_CANCELLATION_TYPES, COW_NATIVE_ETH, COW_ORDER_TYPES, COW_SETTLEMENT, COW_VAULT_RELAYER, CancelCowOrderParams, CheckCowApprovalParams, CowApiError, CowApprovalStatus, CowNativeTokenError, CowOrderKind, CowOrderResult, CowOrderState, CowOrderStatus, CowOrderTooSmallError, CowQuote, CowTokenInfo, CowUnsupportedChainError, DEFAULT_VALID_FOR_SECONDS, FindCowTokenParams, GetCowOrderStatusParams, PickBestVenueParams, QuoteCowSwapParams, SignAndSubmitCowOrderParams, SwapVenue, XSTOCK_WRAPPERS, XstockWrapperInfo, XstockWrapperRegistry, approveErc20ForCow, cancelCowOrder, checkCowApproval, cowDomain, findCowToken, getCowOrderStatus, getXstockUnderlying, getXstockWrapper, isCowSupportedChain, isXstockUnderlying, isXstockWrapper, pickBestVenue, quoteCowSwap, signAndSubmitCowOrder };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "../position-FxaZi608.js";
|
|
2
|
+
import { APP_DATA_DOC, APP_DATA_HASH, COW_API_URLS, COW_CANCELLATION_TYPES, COW_NATIVE_ETH, COW_ORDER_TYPES, COW_SETTLEMENT, COW_VAULT_RELAYER, CowApiError, CowNativeTokenError, CowOrderTooSmallError, CowUnsupportedChainError, DEFAULT_VALID_FOR_SECONDS, XSTOCK_WRAPPERS, approveErc20ForCow, cancelCowOrder, checkCowApproval, cowDomain, findCowToken, getCowOrderStatus, getXstockUnderlying, getXstockWrapper, isCowSupportedChain, isXstockUnderlying, isXstockWrapper, pickBestVenue, quoteCowSwap, signAndSubmitCowOrder } from "../cow-Dy-Cd09v.js";
|
|
3
|
+
import "../writes-CVCD6Ers.js";
|
|
4
|
+
|
|
5
|
+
export { APP_DATA_DOC, APP_DATA_HASH, COW_API_URLS, COW_CANCELLATION_TYPES, COW_NATIVE_ETH, COW_ORDER_TYPES, COW_SETTLEMENT, COW_VAULT_RELAYER, CowApiError, CowNativeTokenError, CowOrderTooSmallError, CowUnsupportedChainError, DEFAULT_VALID_FOR_SECONDS, XSTOCK_WRAPPERS, approveErc20ForCow, cancelCowOrder, checkCowApproval, cowDomain, findCowToken, getCowOrderStatus, getXstockUnderlying, getXstockWrapper, isCowSupportedChain, isXstockUnderlying, isXstockWrapper, pickBestVenue, quoteCowSwap, signAndSubmitCowOrder };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "../index-DVMjZi1E.js";
|
|
2
|
+
import "../irm-CGykVo3q.js";
|
|
3
|
+
import { ApproveErc20ForCowParams, CancelCowOrderParams, CheckCowApprovalParams, CowApprovalStatus, CowOrderKind, CowOrderResult, CowOrderState, CowOrderStatus, CowQuote, GetCowOrderStatusParams, QuoteCowSwapParams, SignAndSubmitCowOrderParams } from "../types-CRvvn2ce.js";
|
|
4
|
+
export { ApproveErc20ForCowParams, CancelCowOrderParams, CheckCowApprovalParams, CowApprovalStatus, CowOrderKind, CowOrderResult, CowOrderState, CowOrderStatus, CowQuote, GetCowOrderStatusParams, QuoteCowSwapParams, SignAndSubmitCowOrderParams };
|
|
File without changes
|