@apex_labs/sdk 0.1.1 → 0.2.0
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 +12 -14
- package/dist/index.cjs +27 -1158
- package/dist/index.d.cts +629 -7905
- package/dist/index.d.ts +629 -7905
- package/dist/index.js +23 -1058
- package/package.json +3 -4
- package/vendor/pancake-v3-sdk/README.md +0 -5
- package/vendor/pancake-v3-sdk/package.json +0 -19
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Apex SDK
|
|
2
2
|
|
|
3
|
-
SDK for Apex CL and Classic pools. It
|
|
3
|
+
SDK for Apex CL and Classic pools. It provides Apex fee tiers, deterministic pool address helpers, Classic AMM quoting, mixed CL/Classic path encoding, transaction builders, and exact ABI exports for Apex contracts.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
@@ -49,7 +49,6 @@ export const apex: ApexDeploymentConfig = {
|
|
|
49
49
|
import {
|
|
50
50
|
CLFeeAmount,
|
|
51
51
|
APEX_CL_POOL_INIT_CODE_HASH,
|
|
52
|
-
APEX_CL_TICK_SPACINGS,
|
|
53
52
|
APEX_CLASSIC_PAIR_INIT_CODE_HASH,
|
|
54
53
|
ClassicChef,
|
|
55
54
|
CLMasterChef,
|
|
@@ -61,7 +60,7 @@ import {
|
|
|
61
60
|
computeClassicPoolAddress,
|
|
62
61
|
quoteClassicExactInput,
|
|
63
62
|
encodeMixedRouteToPath,
|
|
64
|
-
|
|
63
|
+
encodeMixedRouteToQuoteParams,
|
|
65
64
|
decodeMixedRoutePath,
|
|
66
65
|
parseProtocolFeePacked,
|
|
67
66
|
clPoolAbi,
|
|
@@ -111,7 +110,7 @@ const pool = createCLPool({
|
|
|
111
110
|
});
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
`createCLPool` returns
|
|
113
|
+
`createCLPool` returns an Apex CL `Pool` model with Apex fee tiers installed. Position, trade, route, quoter, swap-router, and NFT-position-manager logic should use the classes exported by `@apex_labs/sdk`.
|
|
115
114
|
|
|
116
115
|
### Periphery ABIs
|
|
117
116
|
|
|
@@ -198,8 +197,7 @@ const path = encodeMixedRouteToPath([
|
|
|
198
197
|
```
|
|
199
198
|
|
|
200
199
|
Quote that path through `MixedQuoter.quoteExactInput(path, amountIn)`, then execute it with
|
|
201
|
-
`SmartRouter`. The high-level helpers
|
|
202
|
-
they encode the swap, then wrap it in `SmartRouter.multicall(deadlineOrPreviousBlockhash, data)`.
|
|
200
|
+
`SmartRouter`. The high-level helpers encode the swap, then wrap it in `SmartRouter.multicall(deadlineOrPreviousBlockhash, data)`.
|
|
203
201
|
|
|
204
202
|
```ts
|
|
205
203
|
const swap = SmartRouter.mixedExactInputCallParameters(
|
|
@@ -208,10 +206,10 @@ const swap = SmartRouter.mixedExactInputCallParameters(
|
|
|
208
206
|
);
|
|
209
207
|
```
|
|
210
208
|
|
|
211
|
-
|
|
209
|
+
For `MixedQuoter.quoteExactInput`, encode the route path and Classic-hop flags:
|
|
212
210
|
|
|
213
211
|
```ts
|
|
214
|
-
const { path, flags } =
|
|
212
|
+
const { path, flags } = encodeMixedRouteToQuoteParams(hops);
|
|
215
213
|
const quote = await publicClient.readContract({
|
|
216
214
|
address: apex.mixedQuoter,
|
|
217
215
|
abi: mixedQuoterAbi,
|
|
@@ -220,7 +218,7 @@ const quote = await publicClient.readContract({
|
|
|
220
218
|
});
|
|
221
219
|
```
|
|
222
220
|
|
|
223
|
-
For routes
|
|
221
|
+
For routes split by protocol:
|
|
224
222
|
|
|
225
223
|
```ts
|
|
226
224
|
// Classic volatile section
|
|
@@ -242,7 +240,9 @@ SmartRouter.exactInputCallParameters(
|
|
|
242
240
|
);
|
|
243
241
|
```
|
|
244
242
|
|
|
245
|
-
Use the raw `encode*` helpers only when deliberately assembling a custom multicall. User-facing swaps should use `*CallParameters`, or `SmartRouter.swapCallParameters(rawCalls, options)` for custom batches. These require a deadline or previous blockhash
|
|
243
|
+
Use the raw `encode*` helpers only when deliberately assembling a custom multicall. User-facing swaps should use `*CallParameters`, or `SmartRouter.swapCallParameters(rawCalls, options)` for custom batches. These require a deadline or previous blockhash.
|
|
244
|
+
|
|
245
|
+
When `value` is nonzero, `SmartRouter` call-parameter helpers append `refundETH()` automatically. Token sweeps and WETH unwraps require explicit cleanup entries because the SDK cannot infer the intended token, recipient, or minimum amount for every route.
|
|
246
246
|
|
|
247
247
|
The mixed periphery is exact-input only. Use the CL-only `SwapRouter`/`QuoterV2` for CL exact-output routes.
|
|
248
248
|
|
|
@@ -301,7 +301,7 @@ const close = CLMasterChef.closeAndBurnCallParameters(
|
|
|
301
301
|
);
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
This encodes `harvest -> decreaseLiquidity -> collectTo -> burn`. The harvest happens before liquidity is removed, so it is safe even when rewards are zero and keeps `burn` compatible with
|
|
304
|
+
This encodes `harvest -> decreaseLiquidity -> collectTo -> burn`. The harvest happens before liquidity is removed, so it is safe even when rewards are zero and keeps `burn` compatible with strict empty-position semantics.
|
|
305
305
|
|
|
306
306
|
### ApexVault UX
|
|
307
307
|
|
|
@@ -363,10 +363,8 @@ npm run build --prefix apex-sdk
|
|
|
363
363
|
|
|
364
364
|
## Notes
|
|
365
365
|
|
|
366
|
-
- Apex CL callbacks remain Pancake-compatible, so Pancake v3 periphery assumptions are preserved.
|
|
367
|
-
- The Pancake v3 SDK base is vendored under `vendor/pancake-v3-sdk`; Apex does not depend on the live `@pancakeswap/v3-sdk` npm package at runtime.
|
|
368
366
|
- Apex periphery exports include `NonfungiblePositionManager`, `SwapRouter`, `SmartRouter`, `Quoter`, `QuoterV2`, `MixedQuoter`, `TickLens`, and `InterfaceMulticall`.
|
|
369
|
-
- `MixedQuoter` supports
|
|
367
|
+
- `MixedQuoter` supports `quoteExactInput(bytes,uint256)` and `quoteExactInput(bytes,uint256[],uint256)` for Classic+CL route discovery.
|
|
370
368
|
- Apex CL pool addresses use the Apex `CLPoolDeployer`, not the factory, matching the contract salt `keccak256(abi.encode(token0, token1, fee))`.
|
|
371
369
|
- Apex Classic pair addresses use the Classic factory salt `keccak256(abi.encodePacked(token0, token1, stable))`.
|
|
372
370
|
- `APEX_CL_POOL_INIT_CODE_HASH` and `APEX_CLASSIC_PAIR_INIT_CODE_HASH` are exported and used by default; override them only if the compiled contract bytecode changes.
|