@switch-win/sdk 1.2.9 → 1.3.1
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/CHANGELOG.md +34 -0
- package/GASLESS.md +434 -0
- package/LIMIT-ORDERS.md +213 -205
- package/README.md +134 -105
- package/ROBINHOOD.md +201 -198
- package/abi/GaslessSwitchV2ABI.json +1095 -0
- package/dist/constants.d.ts +276 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +403 -0
- package/dist/constants.js.map +1 -0
- package/dist/gasless-client.d.ts +82 -0
- package/dist/gasless-client.d.ts.map +1 -0
- package/dist/gasless-client.js +467 -0
- package/dist/gasless-client.js.map +1 -0
- package/dist/gasless-index.d.ts +5 -0
- package/dist/gasless-index.d.ts.map +1 -0
- package/dist/gasless-index.js +5 -0
- package/dist/gasless-index.js.map +1 -0
- package/dist/gasless-operators.d.ts +32 -0
- package/dist/gasless-operators.d.ts.map +1 -0
- package/dist/gasless-operators.js +132 -0
- package/dist/gasless-operators.js.map +1 -0
- package/dist/gasless-store.d.ts +18 -0
- package/dist/gasless-store.d.ts.map +1 -0
- package/dist/gasless-store.js +83 -0
- package/dist/gasless-store.js.map +1 -0
- package/dist/gasless-types.d.ts +222 -0
- package/dist/gasless-types.d.ts.map +1 -0
- package/dist/gasless-types.js +2 -0
- package/dist/gasless-types.js.map +1 -0
- package/dist/gasless.d.ts +135 -0
- package/dist/gasless.d.ts.map +1 -0
- package/dist/gasless.js +513 -0
- package/dist/gasless.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/limit-orders.d.ts +440 -0
- package/dist/limit-orders.d.ts.map +1 -0
- package/dist/limit-orders.js +387 -0
- package/dist/limit-orders.js.map +1 -0
- package/dist/networks/index.d.ts +3 -0
- package/dist/networks/index.d.ts.map +1 -0
- package/dist/networks/index.js +2 -0
- package/dist/networks/index.js.map +1 -0
- package/dist/networks/robinhood.d.ts +536 -0
- package/dist/networks/robinhood.d.ts.map +1 -0
- package/dist/networks/robinhood.js +489 -0
- package/dist/networks/robinhood.js.map +1 -0
- package/dist/types.d.ts +436 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/examples/gasless-nextjs-proxy.ts +87 -0
- package/examples/gasless-operator.ts +76 -0
- package/examples/gasless-swap.ts +173 -0
- package/examples/limit-order-ethers.ts +195 -0
- package/examples/nextjs-proxy.ts +82 -0
- package/examples/react-hooks.tsx +396 -0
- package/examples/swap-ethers.ts +209 -0
- package/examples/swap-web3py.py +267 -0
- package/package.json +53 -12
- package/src/constants.ts +184 -182
- package/src/gasless-client.ts +824 -0
- package/src/gasless-index.ts +4 -0
- package/src/gasless-operators.ts +227 -0
- package/src/gasless-store.ts +137 -0
- package/src/gasless-types.ts +262 -0
- package/src/gasless.ts +756 -0
- package/src/index.ts +69 -63
- package/src/limit-orders.ts +206 -195
- package/src/types.ts +80 -55
package/src/constants.ts
CHANGED
|
@@ -37,14 +37,14 @@ export const CHAIN_ID = 369;
|
|
|
37
37
|
*
|
|
38
38
|
* **Important:** Do NOT hardcode this address as the `to` field when sending
|
|
39
39
|
* swap transactions. Always use `tx.to` from the quote response — the router
|
|
40
|
-
* contract may be redeployed. This constant is the current approval target;
|
|
41
|
-
* a router migration requires a fresh ERC-20 allowance for the new spender.
|
|
42
|
-
*/
|
|
43
|
-
export const SWITCH_ROUTER = "0x2dFc8B6e13fF7F04e37Ef97006084805D65a6F19";
|
|
44
|
-
|
|
45
|
-
/** Previous PulseChain Router retained for historical transactions and trusted legacy drain tooling. */
|
|
46
|
-
export const LEGACY_SWITCH_ROUTER =
|
|
47
|
-
"0x0305fcb5dA680EA6fd1B01A96C1949175B99d406";
|
|
40
|
+
* contract may be redeployed. This constant is the current approval target;
|
|
41
|
+
* a router migration requires a fresh ERC-20 allowance for the new spender.
|
|
42
|
+
*/
|
|
43
|
+
export const SWITCH_ROUTER = "0x2dFc8B6e13fF7F04e37Ef97006084805D65a6F19";
|
|
44
|
+
|
|
45
|
+
/** Previous PulseChain Router retained for historical transactions and trusted legacy drain tooling. */
|
|
46
|
+
export const LEGACY_SWITCH_ROUTER =
|
|
47
|
+
"0x0305fcb5dA680EA6fd1B01A96C1949175B99d406";
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Native PLS sentinel address.
|
|
@@ -52,62 +52,62 @@ export const LEGACY_SWITCH_ROUTER =
|
|
|
52
52
|
*/
|
|
53
53
|
export const NATIVE_PLS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
54
54
|
|
|
55
|
-
/** Wrapped PLS (WPLS) ERC-20 token address */
|
|
56
|
-
export const WPLS = "0xA1077a294dDE1B09bB078844df40758a5D0f9a27";
|
|
57
|
-
|
|
58
|
-
/** Finvesta's production Liberty-style V3 adapter index in SwitchRouter. */
|
|
59
|
-
export const FINVESTA_V3_ADAPTER_INDEX = 20;
|
|
60
|
-
|
|
61
|
-
/** Verified Finvesta V3 adapter. Not safe for transfer-tax-sensitive hops. */
|
|
62
|
-
export const FINVESTA_V3_ADAPTER =
|
|
63
|
-
"0x012c44d0C465819eF3CeAC208e0c1B272087a8b4";
|
|
64
|
-
|
|
65
|
-
/** Finvesta V3 factory queried by the adapter. */
|
|
66
|
-
export const FINVESTA_V3_FACTORY =
|
|
67
|
-
"0x7f5c7C5144b4B4c6e954A5b2D75C318C5467EFDc";
|
|
68
|
-
|
|
69
|
-
/** Factory-enabled Finvesta fee tiers, in hundredths of one basis point. */
|
|
70
|
-
export const FINVESTA_V3_FEE_TIERS = [100, 500, 2500, 10000] as const;
|
|
71
|
-
|
|
72
|
-
/** Trench V2's production direct-pair adapter index in SwitchRouter. */
|
|
73
|
-
export const TRENCH_V2_ADAPTER_INDEX = 21;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Verified Trench V2 direct-pair adapter.
|
|
77
|
-
* Eligible for transfer-tax-sensitive hops because input is sent directly to
|
|
78
|
-
* the pair and execution measures the amount actually received.
|
|
79
|
-
*/
|
|
80
|
-
export const TRENCH_V2_ADAPTER =
|
|
81
|
-
"0xAf48bb0936D9fA522650236917321D89978A8591";
|
|
82
|
-
|
|
83
|
-
/** Trench V2 factory queried for pairs and pair-specific fees. */
|
|
84
|
-
export const TRENCH_V2_FACTORY =
|
|
85
|
-
"0xA024e4574406BEf89e624c75758c700B5bED27C7";
|
|
86
|
-
|
|
87
|
-
/** Trench V3's production self-quoter adapter index in SwitchRouter. */
|
|
88
|
-
export const TRENCH_V3_ADAPTER_INDEX = 22;
|
|
89
|
-
|
|
90
|
-
/** Verified Trench V3 adapter. Not safe for transfer-tax-sensitive hops. */
|
|
91
|
-
export const TRENCH_V3_ADAPTER =
|
|
92
|
-
"0x01957eC5FCC079f1bB388b9f261278daC42cf2E9";
|
|
93
|
-
|
|
94
|
-
/** Trench V3 factory queried by the adapter. */
|
|
95
|
-
export const TRENCH_V3_FACTORY =
|
|
96
|
-
"0xCAeF0a906F3323595A8faA14DF7eDee6F59220af";
|
|
97
|
-
|
|
98
|
-
/** Factory-enabled Trench V3 fee tiers, in hundredths of one basis point. */
|
|
99
|
-
export const TRENCH_V3_FEE_TIERS = [100, 500, 2500, 3000, 10000] as const;
|
|
55
|
+
/** Wrapped PLS (WPLS) ERC-20 token address */
|
|
56
|
+
export const WPLS = "0xA1077a294dDE1B09bB078844df40758a5D0f9a27";
|
|
57
|
+
|
|
58
|
+
/** Finvesta's production Liberty-style V3 adapter index in SwitchRouter. */
|
|
59
|
+
export const FINVESTA_V3_ADAPTER_INDEX = 20;
|
|
60
|
+
|
|
61
|
+
/** Verified Finvesta V3 adapter. Not safe for transfer-tax-sensitive hops. */
|
|
62
|
+
export const FINVESTA_V3_ADAPTER =
|
|
63
|
+
"0x012c44d0C465819eF3CeAC208e0c1B272087a8b4";
|
|
64
|
+
|
|
65
|
+
/** Finvesta V3 factory queried by the adapter. */
|
|
66
|
+
export const FINVESTA_V3_FACTORY =
|
|
67
|
+
"0x7f5c7C5144b4B4c6e954A5b2D75C318C5467EFDc";
|
|
68
|
+
|
|
69
|
+
/** Factory-enabled Finvesta fee tiers, in hundredths of one basis point. */
|
|
70
|
+
export const FINVESTA_V3_FEE_TIERS = [100, 500, 2500, 10000] as const;
|
|
71
|
+
|
|
72
|
+
/** Trench V2's production direct-pair adapter index in SwitchRouter. */
|
|
73
|
+
export const TRENCH_V2_ADAPTER_INDEX = 21;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Verified Trench V2 direct-pair adapter.
|
|
77
|
+
* Eligible for transfer-tax-sensitive hops because input is sent directly to
|
|
78
|
+
* the pair and execution measures the amount actually received.
|
|
79
|
+
*/
|
|
80
|
+
export const TRENCH_V2_ADAPTER =
|
|
81
|
+
"0xAf48bb0936D9fA522650236917321D89978A8591";
|
|
82
|
+
|
|
83
|
+
/** Trench V2 factory queried for pairs and pair-specific fees. */
|
|
84
|
+
export const TRENCH_V2_FACTORY =
|
|
85
|
+
"0xA024e4574406BEf89e624c75758c700B5bED27C7";
|
|
86
|
+
|
|
87
|
+
/** Trench V3's production self-quoter adapter index in SwitchRouter. */
|
|
88
|
+
export const TRENCH_V3_ADAPTER_INDEX = 22;
|
|
89
|
+
|
|
90
|
+
/** Verified Trench V3 adapter. Not safe for transfer-tax-sensitive hops. */
|
|
91
|
+
export const TRENCH_V3_ADAPTER =
|
|
92
|
+
"0x01957eC5FCC079f1bB388b9f261278daC42cf2E9";
|
|
93
|
+
|
|
94
|
+
/** Trench V3 factory queried by the adapter. */
|
|
95
|
+
export const TRENCH_V3_FACTORY =
|
|
96
|
+
"0xCAeF0a906F3323595A8faA14DF7eDee6F59220af";
|
|
97
|
+
|
|
98
|
+
/** Factory-enabled Trench V3 fee tiers, in hundredths of one basis point. */
|
|
99
|
+
export const TRENCH_V3_FEE_TIERS = [100, 500, 2500, 3000, 10000] as const;
|
|
100
100
|
|
|
101
101
|
// ── Limit Order contract ────────────────────────────────────────────────
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* SwitchLimitOrder contract address on PulseChain.
|
|
105
105
|
*
|
|
106
|
-
* This is the current protected production limit order contract.
|
|
107
|
-
* For integrators, treat this as user-facing V3.
|
|
108
|
-
* The EIP-712 domain `verifyingContract` MUST match this address.
|
|
109
|
-
*/
|
|
110
|
-
export const SWITCH_LIMIT_ORDER = "0x2afBf0aB8d958a0227742F7a8BdA00c96372E4D7";
|
|
106
|
+
* This is the current protected production limit order contract.
|
|
107
|
+
* For integrators, treat this as user-facing V3.
|
|
108
|
+
* The EIP-712 domain `verifyingContract` MUST match this address.
|
|
109
|
+
*/
|
|
110
|
+
export const SWITCH_LIMIT_ORDER = "0x2afBf0aB8d958a0227742F7a8BdA00c96372E4D7";
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Previous production SwitchLimitOrder contract on PulseChain.
|
|
@@ -117,15 +117,15 @@ export const SWITCH_LIMIT_ORDER = "0x2afBf0aB8d958a0227742F7a8BdA00c96372E4D7";
|
|
|
117
117
|
export const SWITCH_LIMIT_ORDER_V1 = "0x0e884072a891b406c0d814907a1e2310fe5f5deb";
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* Second production SwitchLimitOrder deployment, retained for legacy orders.
|
|
120
|
+
* Second production SwitchLimitOrder deployment, retained for legacy orders.
|
|
121
121
|
*
|
|
122
122
|
* Use this if you want explicit user-facing version naming in integrations.
|
|
123
123
|
*/
|
|
124
|
-
export const SWITCH_LIMIT_ORDER_V2 =
|
|
125
|
-
"0x8e3881bdF81Fc0211383B2e576076B654F7aFD86";
|
|
126
|
-
|
|
127
|
-
/** Current protected production SwitchLimitOrder contract alias. */
|
|
128
|
-
export const SWITCH_LIMIT_ORDER_V3 = SWITCH_LIMIT_ORDER;
|
|
124
|
+
export const SWITCH_LIMIT_ORDER_V2 =
|
|
125
|
+
"0x8e3881bdF81Fc0211383B2e576076B654F7aFD86";
|
|
126
|
+
|
|
127
|
+
/** Current protected production SwitchLimitOrder contract alias. */
|
|
128
|
+
export const SWITCH_LIMIT_ORDER_V3 = SWITCH_LIMIT_ORDER;
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* SwitchPLSFlow contract address on PulseChain.
|
|
@@ -134,10 +134,10 @@ export const SWITCH_LIMIT_ORDER_V3 = SWITCH_LIMIT_ORDER;
|
|
|
134
134
|
* which wraps to WPLS and creates the limit order on their behalf.
|
|
135
135
|
* No EIP-712 signing required — single transaction.
|
|
136
136
|
*
|
|
137
|
-
* This is the current protected production PLSFlow contract.
|
|
138
|
-
* For integrators, treat this as user-facing V3.
|
|
139
|
-
*/
|
|
140
|
-
export const SWITCH_PLS_FLOW = "0x0362177FF2ad25a33a879c881a5055575C63a4cE";
|
|
137
|
+
* This is the current protected production PLSFlow contract.
|
|
138
|
+
* For integrators, treat this as user-facing V3.
|
|
139
|
+
*/
|
|
140
|
+
export const SWITCH_PLS_FLOW = "0x0362177FF2ad25a33a879c881a5055575C63a4cE";
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Previous production SwitchPLSFlow contract on PulseChain.
|
|
@@ -147,31 +147,31 @@ export const SWITCH_PLS_FLOW = "0x0362177FF2ad25a33a879c881a5055575C63a4cE";
|
|
|
147
147
|
export const SWITCH_PLS_FLOW_V1 = "0x88c9e2C83b6B7c707602e548481e58E920694E64";
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Second production SwitchPLSFlow deployment, retained for legacy orders.
|
|
150
|
+
* Second production SwitchPLSFlow deployment, retained for legacy orders.
|
|
151
151
|
*
|
|
152
152
|
* Use this if you want explicit user-facing version naming in integrations.
|
|
153
153
|
*/
|
|
154
|
-
export const SWITCH_PLS_FLOW_V2 =
|
|
155
|
-
"0xCf5606bdC750d8626Cec32CA2E1BB207968db1D5";
|
|
156
|
-
|
|
157
|
-
/** Current protected production SwitchPLSFlow contract alias. */
|
|
158
|
-
export const SWITCH_PLS_FLOW_V3 = SWITCH_PLS_FLOW;
|
|
159
|
-
|
|
160
|
-
/** Direct-fill market-price guard bound to the current PulseChain Router. */
|
|
161
|
-
export const SWITCH_DIRECT_FILL_QUOTER =
|
|
162
|
-
"0x23A95b0f69c993CFe6180a266A93F7560102e929";
|
|
163
|
-
|
|
164
|
-
/** Router adapter for current protected limit-order liquidity (adapter index 17). */
|
|
165
|
-
export const SWITCH_LIMIT_ORDER_ADAPTER =
|
|
166
|
-
"0x7B9761484301a8FE4a2BA47194F7646eEF8e1cDd";
|
|
167
|
-
|
|
168
|
-
/** Narrow PulseChain bridge used to add and remove limit-order operators. */
|
|
169
|
-
export const LIMIT_ORDER_ADMIN =
|
|
170
|
-
"0x9C8B9012AfC0489dE612F7039665212EB88be127";
|
|
171
|
-
|
|
172
|
-
/** PulseChain paid operator-seat and adapter-access registry. */
|
|
173
|
-
export const OPERATOR_ACCESS_REGISTRY =
|
|
174
|
-
"0x7dA1AB04A712479569cCaD783Ca6114b763e36Ad";
|
|
154
|
+
export const SWITCH_PLS_FLOW_V2 =
|
|
155
|
+
"0xCf5606bdC750d8626Cec32CA2E1BB207968db1D5";
|
|
156
|
+
|
|
157
|
+
/** Current protected production SwitchPLSFlow contract alias. */
|
|
158
|
+
export const SWITCH_PLS_FLOW_V3 = SWITCH_PLS_FLOW;
|
|
159
|
+
|
|
160
|
+
/** Direct-fill market-price guard bound to the current PulseChain Router. */
|
|
161
|
+
export const SWITCH_DIRECT_FILL_QUOTER =
|
|
162
|
+
"0x23A95b0f69c993CFe6180a266A93F7560102e929";
|
|
163
|
+
|
|
164
|
+
/** Router adapter for current protected limit-order liquidity (adapter index 17). */
|
|
165
|
+
export const SWITCH_LIMIT_ORDER_ADAPTER =
|
|
166
|
+
"0x7B9761484301a8FE4a2BA47194F7646eEF8e1cDd";
|
|
167
|
+
|
|
168
|
+
/** Narrow PulseChain bridge used to add and remove limit-order operators. */
|
|
169
|
+
export const LIMIT_ORDER_ADMIN =
|
|
170
|
+
"0x9C8B9012AfC0489dE612F7039665212EB88be127";
|
|
171
|
+
|
|
172
|
+
/** PulseChain paid operator-seat and adapter-access registry. */
|
|
173
|
+
export const OPERATOR_ACCESS_REGISTRY =
|
|
174
|
+
"0x7dA1AB04A712479569cCaD783Ca6114b763e36Ad";
|
|
175
175
|
|
|
176
176
|
// ── Limit Order API endpoints ───────────────────────────────────────────────
|
|
177
177
|
|
|
@@ -192,17 +192,19 @@ export const LIMIT_ORDER_STATS_ENDPOINT = `${LIMIT_ORDERS_ENDPOINT}/stats`;
|
|
|
192
192
|
/** Fee denominator — all fees are in basis points (1 bps = 0.01%) */
|
|
193
193
|
export const FEE_DENOMINATOR = 10_000;
|
|
194
194
|
|
|
195
|
-
/** Maximum allowed fee (basis points). 100 bps = 1% */
|
|
196
|
-
export const MAX_FEE_BPS = 100;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
195
|
+
/** Maximum allowed fee (basis points). 100 bps = 1% */
|
|
196
|
+
export const MAX_FEE_BPS = 100;
|
|
197
|
+
|
|
198
|
+
/** Default integration quote fee. The Switch frontend may explicitly request
|
|
199
|
+
* a higher Regular fee; display protocolFeeBps returned by the selected quote.
|
|
200
|
+
* GaslessSwitch has its own fixed fee and dedicated quote flow. */
|
|
201
|
+
export const DEFAULT_SWAP_FEE_BPS = 10;
|
|
202
|
+
|
|
203
|
+
/** Current limit-order protocol fee on both supported networks. */
|
|
204
|
+
export const LIMIT_ORDER_FEE_BPS = 30;
|
|
205
|
+
|
|
206
|
+
/** Maximum operator excess retained by protected limit-order contracts. */
|
|
207
|
+
export const MAX_OPERATOR_EXCESS_BPS = 500;
|
|
206
208
|
|
|
207
209
|
/** Maximum allowed slippage (basis points). 5000 bps = 50% */
|
|
208
210
|
export const MAX_SLIPPAGE_BPS = 5_000;
|
|
@@ -247,9 +249,9 @@ export const ERC20_ABI = [
|
|
|
247
249
|
* Normally you don't need this — the API returns pre-encoded calldata in `tx.data`.
|
|
248
250
|
* Useful only if you want to decode or manually construct calldata.
|
|
249
251
|
*/
|
|
250
|
-
export const GO_SWITCH_ABI = [
|
|
251
|
-
"function goSwitch(tuple(uint256 amountIn, tuple(address tokenIn, address tokenOut, tuple(address adapter, uint256 amountIn, uint24 fee, bytes data)[] legs)[] hops)[] _routes, address _to, uint256 _minTotalAmountOut, uint256 _fee, bool _feeOnOutput, bool _unwrapOutput, address _partnerAddress) payable",
|
|
252
|
-
] as const;
|
|
252
|
+
export const GO_SWITCH_ABI = [
|
|
253
|
+
"function goSwitch(tuple(uint256 amountIn, tuple(address tokenIn, address tokenOut, tuple(address adapter, uint256 amountIn, uint24 fee, bytes data)[] legs)[] hops)[] _routes, address _to, uint256 _minTotalAmountOut, uint256 _fee, bool _feeOnOutput, bool _unwrapOutput, address _partnerAddress) payable",
|
|
254
|
+
] as const;
|
|
253
255
|
|
|
254
256
|
/**
|
|
255
257
|
* SwitchRouter custom error signatures for decoding reverts.
|
|
@@ -350,14 +352,14 @@ export const LIMIT_ORDER_EIP712_TYPES = {
|
|
|
350
352
|
*
|
|
351
353
|
* The full ABI is available at `@switch-win/sdk/abi/limit-order`.
|
|
352
354
|
*/
|
|
353
|
-
export const LIMIT_ORDER_ABI = [
|
|
354
|
-
"function SWITCH_ROUTER() view returns (address)",
|
|
355
|
-
"function MAX_OPERATOR_EXCESS_BPS() view returns (uint256)",
|
|
356
|
-
"function getFee() view returns (uint256)",
|
|
357
|
-
"function operatorGateEnabled() view returns (bool)",
|
|
358
|
-
"function directFillQuoter() view returns (address)",
|
|
359
|
-
"function plsFlowContract() view returns (address)",
|
|
360
|
-
"function invalidateNonce(uint256 _nonce) external",
|
|
355
|
+
export const LIMIT_ORDER_ABI = [
|
|
356
|
+
"function SWITCH_ROUTER() view returns (address)",
|
|
357
|
+
"function MAX_OPERATOR_EXCESS_BPS() view returns (uint256)",
|
|
358
|
+
"function getFee() view returns (uint256)",
|
|
359
|
+
"function operatorGateEnabled() view returns (bool)",
|
|
360
|
+
"function directFillQuoter() view returns (address)",
|
|
361
|
+
"function plsFlowContract() view returns (address)",
|
|
362
|
+
"function invalidateNonce(uint256 _nonce) external",
|
|
361
363
|
"function invalidateNonces(uint256[] calldata _nonces) external",
|
|
362
364
|
"function isNonceUsed(address maker, uint256 nonce) view returns (bool)",
|
|
363
365
|
"function canFillOrder(tuple(address maker, address tokenIn, address tokenOut, uint256 amountIn, uint256 minAmountOut, uint256 deadline, uint256 nonce, bool feeOnOutput, address recipient, bool unwrapOutput, address partnerAddress) order, bytes signature) view returns (bool)",
|
|
@@ -366,7 +368,7 @@ export const LIMIT_ORDER_ABI = [
|
|
|
366
368
|
/**
|
|
367
369
|
* SwitchLimitOrder custom error signatures for decoding reverts.
|
|
368
370
|
*/
|
|
369
|
-
export const LIMIT_ORDER_ERRORS = [
|
|
371
|
+
export const LIMIT_ORDER_ERRORS = [
|
|
370
372
|
"error InvalidSignature()",
|
|
371
373
|
"error NonceAlreadyUsed()",
|
|
372
374
|
"error OrderExpired()",
|
|
@@ -376,15 +378,15 @@ export const LIMIT_ORDER_ERRORS = [
|
|
|
376
378
|
"error RouteInputExceedsMax()",
|
|
377
379
|
"error InvalidTokens()",
|
|
378
380
|
"error TransferFailed()",
|
|
379
|
-
"error OperatorOnly()",
|
|
380
|
-
"error NativeFlowInputNotFullyConsumed()",
|
|
381
|
-
"error RouteTokenInMismatch()",
|
|
382
|
-
"error RouteTokenOutMismatch()",
|
|
383
|
-
"error InvalidDirectFillQuoter()",
|
|
384
|
-
"error DirectFillQuoteUnavailable()",
|
|
385
|
-
"error DirectFillPriceTooLow()",
|
|
386
|
-
"error OperatorManagerOnly()",
|
|
387
|
-
] as const;
|
|
381
|
+
"error OperatorOnly()",
|
|
382
|
+
"error NativeFlowInputNotFullyConsumed()",
|
|
383
|
+
"error RouteTokenInMismatch()",
|
|
384
|
+
"error RouteTokenOutMismatch()",
|
|
385
|
+
"error InvalidDirectFillQuoter()",
|
|
386
|
+
"error DirectFillQuoteUnavailable()",
|
|
387
|
+
"error DirectFillPriceTooLow()",
|
|
388
|
+
"error OperatorManagerOnly()",
|
|
389
|
+
] as const;
|
|
388
390
|
|
|
389
391
|
/**
|
|
390
392
|
* 4-byte error selectors for SwitchLimitOrder reverts.
|
|
@@ -405,75 +407,75 @@ export const LIMIT_ORDER_ERROR_SELECTORS: Record<string, string> = {
|
|
|
405
407
|
"0xb6972a87": "RouteInputExceedsMax",
|
|
406
408
|
"0x672215de": "InvalidTokens",
|
|
407
409
|
"0x90b8ec18": "TransferFailed",
|
|
408
|
-
"0xae5e3e00": "OperatorOnly",
|
|
409
|
-
"0x42e89a78": "NativeFlowInputNotFullyConsumed",
|
|
410
|
-
"0x54346455": "RouteTokenInMismatch",
|
|
411
|
-
"0xa587e83b": "RouteTokenOutMismatch",
|
|
412
|
-
"0xdcd56106": "InvalidDirectFillQuoter",
|
|
413
|
-
"0x0e4c7aa9": "DirectFillQuoteUnavailable",
|
|
414
|
-
"0xca8ecf0e": "DirectFillPriceTooLow",
|
|
415
|
-
"0xb68f3df5": "OperatorManagerOnly",
|
|
416
|
-
};
|
|
410
|
+
"0xae5e3e00": "OperatorOnly",
|
|
411
|
+
"0x42e89a78": "NativeFlowInputNotFullyConsumed",
|
|
412
|
+
"0x54346455": "RouteTokenInMismatch",
|
|
413
|
+
"0xa587e83b": "RouteTokenOutMismatch",
|
|
414
|
+
"0xdcd56106": "InvalidDirectFillQuoter",
|
|
415
|
+
"0x0e4c7aa9": "DirectFillQuoteUnavailable",
|
|
416
|
+
"0xca8ecf0e": "DirectFillPriceTooLow",
|
|
417
|
+
"0xb68f3df5": "OperatorManagerOnly",
|
|
418
|
+
};
|
|
417
419
|
|
|
418
420
|
/**
|
|
419
421
|
* Minimal ABI for the SwitchPLSFlow contract.
|
|
420
422
|
*
|
|
421
|
-
* Used for creating native PLS limit orders in a single transaction.
|
|
422
|
-
* The contract wraps PLS to WPLS and places the limit order on behalf
|
|
423
|
-
* of the sender. `recipient` is required in calldata by current deployments;
|
|
424
|
-
* pass the zero address to default settlement to `msg.sender`.
|
|
425
|
-
*/
|
|
426
|
-
export const PLS_FLOW_ABI = [
|
|
427
|
-
"function createOrder(address tokenOut, uint256 minAmountOut, uint256 deadline, bool feeOnOutput, bool unwrapOutput, address partnerAddress, address recipient) payable returns (uint256 nonce)",
|
|
428
|
-
"function cancelOrder(uint256 nonce) external",
|
|
429
|
-
"function getOrder(uint256 nonce) view returns (tuple(address originalMaker, address tokenOut, uint256 amountIn, uint256 minAmountOut, uint256 deadline, uint256 createdAt, bool feeOnOutput, bool unwrapOutput, bool active, address recipient, address partnerAddress))",
|
|
430
|
-
"function globalNonceCounter() view returns (uint256)",
|
|
431
|
-
"function getGlobalNonce() view returns (uint256)",
|
|
432
|
-
"function orderCreationEnabled() view returns (bool)",
|
|
433
|
-
"function isOrderActive(uint256 nonce) view returns (bool)",
|
|
434
|
-
"function totalLockedWPLS() view returns (uint256)",
|
|
435
|
-
"function SWITCH_LIMIT_ORDER() view returns (address)",
|
|
436
|
-
"function SWITCH_ROUTER() view returns (address)",
|
|
437
|
-
"function WNATIVE() view returns (address)",
|
|
438
|
-
"event PLSOrderCreated(address indexed originalMaker, uint256 indexed nonce, address tokenOut, uint256 amountIn, uint256 minAmountOut, uint256 deadline, address recipient)",
|
|
439
|
-
"event PLSOrderCancelled(address indexed originalMaker, uint256 indexed nonce, uint256 refundAmount)",
|
|
440
|
-
"event PLSOrderFilled(address indexed originalMaker, uint256 indexed nonce, uint256 amountIn)",
|
|
441
|
-
"event PLSOrderInputExcessRefunded(address indexed originalMaker, uint256 indexed nonce, uint256 amount)",
|
|
442
|
-
"event OrderCreationEnabledUpdated(bool enabled)",
|
|
443
|
-
] as const;
|
|
423
|
+
* Used for creating native PLS limit orders in a single transaction.
|
|
424
|
+
* The contract wraps PLS to WPLS and places the limit order on behalf
|
|
425
|
+
* of the sender. `recipient` is required in calldata by current deployments;
|
|
426
|
+
* pass the zero address to default settlement to `msg.sender`.
|
|
427
|
+
*/
|
|
428
|
+
export const PLS_FLOW_ABI = [
|
|
429
|
+
"function createOrder(address tokenOut, uint256 minAmountOut, uint256 deadline, bool feeOnOutput, bool unwrapOutput, address partnerAddress, address recipient) payable returns (uint256 nonce)",
|
|
430
|
+
"function cancelOrder(uint256 nonce) external",
|
|
431
|
+
"function getOrder(uint256 nonce) view returns (tuple(address originalMaker, address tokenOut, uint256 amountIn, uint256 minAmountOut, uint256 deadline, uint256 createdAt, bool feeOnOutput, bool unwrapOutput, bool active, address recipient, address partnerAddress))",
|
|
432
|
+
"function globalNonceCounter() view returns (uint256)",
|
|
433
|
+
"function getGlobalNonce() view returns (uint256)",
|
|
434
|
+
"function orderCreationEnabled() view returns (bool)",
|
|
435
|
+
"function isOrderActive(uint256 nonce) view returns (bool)",
|
|
436
|
+
"function totalLockedWPLS() view returns (uint256)",
|
|
437
|
+
"function SWITCH_LIMIT_ORDER() view returns (address)",
|
|
438
|
+
"function SWITCH_ROUTER() view returns (address)",
|
|
439
|
+
"function WNATIVE() view returns (address)",
|
|
440
|
+
"event PLSOrderCreated(address indexed originalMaker, uint256 indexed nonce, address tokenOut, uint256 amountIn, uint256 minAmountOut, uint256 deadline, address recipient)",
|
|
441
|
+
"event PLSOrderCancelled(address indexed originalMaker, uint256 indexed nonce, uint256 refundAmount)",
|
|
442
|
+
"event PLSOrderFilled(address indexed originalMaker, uint256 indexed nonce, uint256 amountIn)",
|
|
443
|
+
"event PLSOrderInputExcessRefunded(address indexed originalMaker, uint256 indexed nonce, uint256 amount)",
|
|
444
|
+
"event OrderCreationEnabledUpdated(bool enabled)",
|
|
445
|
+
] as const;
|
|
444
446
|
|
|
445
447
|
/**
|
|
446
448
|
* SwitchPLSFlow custom error signatures for decoding reverts.
|
|
447
449
|
*/
|
|
448
|
-
export const PLS_FLOW_ERRORS = [
|
|
449
|
-
"error ZeroAmount()",
|
|
450
|
-
"error InvalidToken()",
|
|
451
|
-
"error OrderNotActive()",
|
|
452
|
-
"error NotOrderOwner()",
|
|
453
|
-
"error TransferFailed()",
|
|
454
|
-
"error OrderAlreadyFilled()",
|
|
455
|
-
"error AccountingMismatch()",
|
|
456
|
-
"error OrderNotEligibleForAdminCancel()",
|
|
457
|
-
"error OnlyLimitOrder()",
|
|
458
|
-
"error OrderNotFilled()",
|
|
459
|
-
"error InvalidDeadline()",
|
|
460
|
-
"error OrderCreationDisabled()",
|
|
461
|
-
] as const;
|
|
450
|
+
export const PLS_FLOW_ERRORS = [
|
|
451
|
+
"error ZeroAmount()",
|
|
452
|
+
"error InvalidToken()",
|
|
453
|
+
"error OrderNotActive()",
|
|
454
|
+
"error NotOrderOwner()",
|
|
455
|
+
"error TransferFailed()",
|
|
456
|
+
"error OrderAlreadyFilled()",
|
|
457
|
+
"error AccountingMismatch()",
|
|
458
|
+
"error OrderNotEligibleForAdminCancel()",
|
|
459
|
+
"error OnlyLimitOrder()",
|
|
460
|
+
"error OrderNotFilled()",
|
|
461
|
+
"error InvalidDeadline()",
|
|
462
|
+
"error OrderCreationDisabled()",
|
|
463
|
+
] as const;
|
|
462
464
|
|
|
463
465
|
/**
|
|
464
466
|
* 4-byte error selectors for SwitchPLSFlow reverts.
|
|
465
467
|
*/
|
|
466
|
-
export const PLS_FLOW_ERROR_SELECTORS: Record<string, string> = {
|
|
467
|
-
"0x1f2a2005": "ZeroAmount",
|
|
468
|
-
"0xc1ab6dc1": "InvalidToken",
|
|
469
|
-
"0x1d4ecc5b": "OrderNotActive",
|
|
470
|
-
"0xf6412b5a": "NotOrderOwner",
|
|
471
|
-
"0x90b8ec18": "TransferFailed",
|
|
472
|
-
"0xee3b3d4b": "OrderAlreadyFilled",
|
|
473
|
-
"0xc5ec2f3b": "AccountingMismatch",
|
|
474
|
-
"0x40db5c93": "OrderNotEligibleForAdminCancel",
|
|
475
|
-
"0x08ff2059": "OnlyLimitOrder",
|
|
476
|
-
"0x789bae35": "OrderNotFilled",
|
|
477
|
-
"0x769d11e4": "InvalidDeadline",
|
|
478
|
-
"0x86ec3378": "OrderCreationDisabled",
|
|
479
|
-
};
|
|
468
|
+
export const PLS_FLOW_ERROR_SELECTORS: Record<string, string> = {
|
|
469
|
+
"0x1f2a2005": "ZeroAmount",
|
|
470
|
+
"0xc1ab6dc1": "InvalidToken",
|
|
471
|
+
"0x1d4ecc5b": "OrderNotActive",
|
|
472
|
+
"0xf6412b5a": "NotOrderOwner",
|
|
473
|
+
"0x90b8ec18": "TransferFailed",
|
|
474
|
+
"0xee3b3d4b": "OrderAlreadyFilled",
|
|
475
|
+
"0xc5ec2f3b": "AccountingMismatch",
|
|
476
|
+
"0x40db5c93": "OrderNotEligibleForAdminCancel",
|
|
477
|
+
"0x08ff2059": "OnlyLimitOrder",
|
|
478
|
+
"0x789bae35": "OrderNotFilled",
|
|
479
|
+
"0x769d11e4": "InvalidDeadline",
|
|
480
|
+
"0x86ec3378": "OrderCreationDisabled",
|
|
481
|
+
};
|