@switch-win/sdk 1.0.8 → 1.1.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 +7 -5
- package/package.json +1 -1
- package/src/constants.ts +18 -1
- package/src/limit-orders.ts +9 -0
- package/src/types.ts +14 -0
package/README.md
CHANGED
|
@@ -623,13 +623,13 @@ GET /swap/quote?network=pulsechain&from=0xA1077a294dDE1B09bB078844df40758a5D0f9a
|
|
|
623
623
|
// Transaction object — only present when `sender` is provided
|
|
624
624
|
// ⚠️ Always use tx.to from this response — do NOT hardcode the router address
|
|
625
625
|
"tx": {
|
|
626
|
-
"to": "
|
|
626
|
+
"to": "0x0305fcb5dA680EA6fd1B01A96C1949175B99d406",
|
|
627
627
|
"data": "0x...", // ABI-encoded goSwitch() calldata with feeOnOutput = false
|
|
628
628
|
"value": "0" // "0" for ERC-20 input; amountIn for native PLS input
|
|
629
629
|
},
|
|
630
630
|
// Same swap but with fee taken from the output token instead
|
|
631
631
|
"txFeeOnOutput": {
|
|
632
|
-
"to": "
|
|
632
|
+
"to": "0x0305fcb5dA680EA6fd1B01A96C1949175B99d406",
|
|
633
633
|
"data": "0x...", // ABI-encoded goSwitch() calldata with feeOnOutput = true
|
|
634
634
|
"value": "0"
|
|
635
635
|
}
|
|
@@ -897,9 +897,11 @@ All constants are importable from [`src/constants.ts`](src/constants.ts).
|
|
|
897
897
|
| Name | Value |
|
|
898
898
|
|---|---|
|
|
899
899
|
| **Chain** | PulseChain (Chain ID `369`) |
|
|
900
|
-
| **SwitchRouter** | `
|
|
901
|
-
| **SwitchLimitOrder** | `
|
|
902
|
-
| **
|
|
900
|
+
| **SwitchRouter** | `0x0305fcb5dA680EA6fd1B01A96C1949175B99d406` |
|
|
901
|
+
| **SwitchLimitOrder** (V2 — current) | `0x8e3881bdF81Fc0211383B2e576076B654F7aFD86` |
|
|
902
|
+
| **SwitchLimitOrder** (V1 — legacy) | `0x0e884072a891b406C0D814907A1E2310fE5F5Deb` |
|
|
903
|
+
| **SwitchPLSFlow** (V2 — current) | `0xCf5606bdC750d8626Cec32CA2E1BB207968db1D5` |
|
|
904
|
+
| **SwitchPLSFlow** (V1 — legacy) | `0x88c9e2C83b6B7c707602e548481e58E920694E64` |
|
|
903
905
|
| **Native PLS sentinel** | `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` |
|
|
904
906
|
| **WPLS** | `0xA1077a294dDE1B09bB078844df40758a5D0f9a27` |
|
|
905
907
|
| **Fee denominator** | `10000` (basis points) |
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -82,8 +82,25 @@ export const SWITCH_LIMIT_ORDER_V2 = SWITCH_LIMIT_ORDER;
|
|
|
82
82
|
* Used for native PLS limit orders. Users send PLS to this contract,
|
|
83
83
|
* which wraps to WPLS and creates the limit order on their behalf.
|
|
84
84
|
* No EIP-712 signing required — single transaction.
|
|
85
|
+
*
|
|
86
|
+
* This is the current production PLSFlow contract.
|
|
87
|
+
* For integrators, treat this as user-facing V2.
|
|
88
|
+
*/
|
|
89
|
+
export const SWITCH_PLS_FLOW = "0xCf5606bdC750d8626Cec32CA2E1BB207968db1D5";
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Previous production SwitchPLSFlow contract on PulseChain.
|
|
93
|
+
*
|
|
94
|
+
* For integrators, treat this as user-facing V1.
|
|
95
|
+
*/
|
|
96
|
+
export const SWITCH_PLS_FLOW_V1 = "0x88c9e2C83b6B7c707602e548481e58E920694E64";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Current production SwitchPLSFlow contract alias.
|
|
100
|
+
*
|
|
101
|
+
* Use this if you want explicit user-facing version naming in integrations.
|
|
85
102
|
*/
|
|
86
|
-
export const
|
|
103
|
+
export const SWITCH_PLS_FLOW_V2 = SWITCH_PLS_FLOW;
|
|
87
104
|
|
|
88
105
|
// ── Limit Order API endpoints ───────────────────────────────────────────────
|
|
89
106
|
|
package/src/limit-orders.ts
CHANGED
|
@@ -361,6 +361,8 @@ export interface ListLimitOrdersOptions {
|
|
|
361
361
|
* where the maker is the PLSFlow contract but the user is the recipient.
|
|
362
362
|
*/
|
|
363
363
|
owner?: string;
|
|
364
|
+
/** Filter by partner address */
|
|
365
|
+
partnerAddress?: string;
|
|
364
366
|
/** Filter by input token address */
|
|
365
367
|
tokenIn?: string;
|
|
366
368
|
/** Filter by output token address */
|
|
@@ -393,6 +395,12 @@ export interface ListLimitOrdersOptions {
|
|
|
393
395
|
* tokenOut: "0xPLSXAddress",
|
|
394
396
|
* status: "FILLED",
|
|
395
397
|
* });
|
|
398
|
+
*
|
|
399
|
+
* // Orders attributed to a specific partner
|
|
400
|
+
* const partnerOrders = await fetchLimitOrders({
|
|
401
|
+
* partnerAddress: "0xPartnerAddress",
|
|
402
|
+
* status: "ACTIVE",
|
|
403
|
+
* });
|
|
396
404
|
* ```
|
|
397
405
|
*/
|
|
398
406
|
export async function fetchLimitOrders(
|
|
@@ -402,6 +410,7 @@ export async function fetchLimitOrders(
|
|
|
402
410
|
if (options.status) params.set("status", options.status);
|
|
403
411
|
if (options.maker) params.set("maker", options.maker);
|
|
404
412
|
if (options.owner) params.set("owner", options.owner);
|
|
413
|
+
if (options.partnerAddress) params.set("partnerAddress", options.partnerAddress);
|
|
405
414
|
if (options.tokenIn) params.set("tokenIn", options.tokenIn);
|
|
406
415
|
if (options.tokenOut) params.set("tokenOut", options.tokenOut);
|
|
407
416
|
if (options.pair) params.set("pair", options.pair);
|
package/src/types.ts
CHANGED
|
@@ -363,16 +363,30 @@ export interface LimitOrderRecord {
|
|
|
363
363
|
unwrapOutput: boolean;
|
|
364
364
|
/** Partner address for fee sharing */
|
|
365
365
|
partnerAddress: string;
|
|
366
|
+
/** LO contract address this order targets for cancellation/fill */
|
|
367
|
+
limitOrderContract?: string;
|
|
366
368
|
/** EIP-712 signature */
|
|
367
369
|
signature: string;
|
|
368
370
|
/** Pair key in format `tokenIn:tokenOut` (lowercased) */
|
|
369
371
|
pairKey: string;
|
|
372
|
+
/** Sell tax on input token in basis points, when known */
|
|
373
|
+
tokenInSellTaxBps?: number;
|
|
374
|
+
/** Buy tax on input token in basis points, when known */
|
|
375
|
+
tokenInBuyTaxBps?: number;
|
|
376
|
+
/** Sell tax on output token in basis points, when known */
|
|
377
|
+
tokenOutSellTaxBps?: number;
|
|
378
|
+
/** Buy tax on output token in basis points, when known */
|
|
379
|
+
tokenOutBuyTaxBps?: number;
|
|
370
380
|
/** Current order status */
|
|
371
381
|
status: LimitOrderStatus;
|
|
372
382
|
/** ISO 8601 creation timestamp */
|
|
373
383
|
createdAt: string;
|
|
374
384
|
/** ISO 8601 last update timestamp */
|
|
375
385
|
updatedAt: string;
|
|
386
|
+
/** Filler address for filled orders */
|
|
387
|
+
filler?: string | null;
|
|
388
|
+
/** Filler profit in tokenIn units for filled orders */
|
|
389
|
+
fillerProfit?: string | null;
|
|
376
390
|
/** Block number where the order was filled (if status is FILLED) */
|
|
377
391
|
filledBlock?: number | null;
|
|
378
392
|
/** Transaction hash of the fill (if status is FILLED) */
|