@apex_labs/sdk 0.1.1 → 0.1.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/README.md CHANGED
@@ -242,7 +242,9 @@ SmartRouter.exactInputCallParameters(
242
242
  );
243
243
  ```
244
244
 
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 and support cleanup calls such as `refundETH`, `sweepToken`, and `unwrapWETH9`.
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.
246
+
247
+ 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
248
 
247
249
  The mixed periphery is exact-input only. Use the CL-only `SwapRouter`/`QuoterV2` for CL exact-output routes.
248
250
 
package/dist/index.cjs CHANGED
@@ -22631,10 +22631,15 @@ var SmartRouter = class _SmartRouter {
22631
22631
  };
22632
22632
  var ApexSmartRouter = SmartRouter;
22633
22633
  function callParameters(_calldatas, _options) {
22634
- for (const payment of _options.payments ?? []) _calldatas.push(encodePayment(payment));
22634
+ const value = toBigInt3(_options.value ?? 0n);
22635
+ const payments = [..._options.payments ?? []];
22636
+ if (value > 0n && !payments.some((payment) => payment.kind === "REFUND_ETH")) {
22637
+ payments.push({ kind: "REFUND_ETH" });
22638
+ }
22639
+ for (const payment of payments) _calldatas.push(encodePayment(payment));
22635
22640
  return {
22636
22641
  calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22637
- value: toHexValue2(_options.value ?? 0n)
22642
+ value: toHexValue2(value)
22638
22643
  };
22639
22644
  }
22640
22645
  function encodePayment(_payment) {
package/dist/index.js CHANGED
@@ -22436,10 +22436,15 @@ var SmartRouter = class _SmartRouter {
22436
22436
  };
22437
22437
  var ApexSmartRouter = SmartRouter;
22438
22438
  function callParameters(_calldatas, _options) {
22439
- for (const payment of _options.payments ?? []) _calldatas.push(encodePayment(payment));
22439
+ const value = toBigInt3(_options.value ?? 0n);
22440
+ const payments = [..._options.payments ?? []];
22441
+ if (value > 0n && !payments.some((payment) => payment.kind === "REFUND_ETH")) {
22442
+ payments.push({ kind: "REFUND_ETH" });
22443
+ }
22444
+ for (const payment of payments) _calldatas.push(encodePayment(payment));
22440
22445
  return {
22441
22446
  calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22442
- value: toHexValue2(_options.value ?? 0n)
22447
+ value: toHexValue2(value)
22443
22448
  };
22444
22449
  }
22445
22450
  function encodePayment(_payment) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apex_labs/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Apex SDK with a pinned internal Pancake v3 SDK fork plus Apex CL, Classic, and periphery helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",