zerc20-client-sdk 0.2.0 → 0.2.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.
Files changed (52) hide show
  1. package/README.md +70 -0
  2. package/dist/assets/abi/Verifier.json +2093 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.d.ts +2 -0
  8. package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.d.ts.map +1 -0
  9. package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.js +157 -0
  10. package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.js.map +1 -0
  11. package/dist/operations/liquidityManager/adaptorWithdraw.d.ts +82 -0
  12. package/dist/operations/liquidityManager/adaptorWithdraw.d.ts.map +1 -0
  13. package/dist/operations/liquidityManager/adaptorWithdraw.js +107 -0
  14. package/dist/operations/liquidityManager/adaptorWithdraw.js.map +1 -0
  15. package/dist/operations/liquidityManager/index.d.ts +3 -1
  16. package/dist/operations/liquidityManager/index.d.ts.map +1 -1
  17. package/dist/operations/liquidityManager/index.js +2 -1
  18. package/dist/operations/liquidityManager/index.js.map +1 -1
  19. package/dist/operations/receive/__tests__/cache.test.js +33 -0
  20. package/dist/operations/receive/__tests__/cache.test.js.map +1 -1
  21. package/dist/operations/receive/__tests__/redeemTransaction.test.js +38 -0
  22. package/dist/operations/receive/__tests__/redeemTransaction.test.js.map +1 -1
  23. package/dist/operations/receive/cache.d.ts +1 -1
  24. package/dist/operations/receive/cache.d.ts.map +1 -1
  25. package/dist/operations/receive/cache.js +6 -5
  26. package/dist/operations/receive/cache.js.map +1 -1
  27. package/dist/operations/receive/index.d.ts +1 -1
  28. package/dist/operations/receive/index.d.ts.map +1 -1
  29. package/dist/operations/receive/index.js.map +1 -1
  30. package/dist/operations/receive/redeemTransaction.d.ts +2 -1
  31. package/dist/operations/receive/redeemTransaction.d.ts.map +1 -1
  32. package/dist/operations/receive/redeemTransaction.js +11 -5
  33. package/dist/operations/receive/redeemTransaction.js.map +1 -1
  34. package/dist/operations/receive/types.d.ts +25 -2
  35. package/dist/operations/receive/types.d.ts.map +1 -1
  36. package/dist/operations/relay/__tests__/relay.test.d.ts +2 -0
  37. package/dist/operations/relay/__tests__/relay.test.d.ts.map +1 -0
  38. package/dist/operations/relay/__tests__/relay.test.js +270 -0
  39. package/dist/operations/relay/__tests__/relay.test.js.map +1 -0
  40. package/dist/operations/relay/index.d.ts +3 -0
  41. package/dist/operations/relay/index.d.ts.map +1 -0
  42. package/dist/operations/relay/index.js +2 -0
  43. package/dist/operations/relay/index.js.map +1 -0
  44. package/dist/operations/relay/relay.d.ts +18 -0
  45. package/dist/operations/relay/relay.d.ts.map +1 -0
  46. package/dist/operations/relay/relay.js +103 -0
  47. package/dist/operations/relay/relay.js.map +1 -0
  48. package/dist/operations/relay/types.d.ts +63 -0
  49. package/dist/operations/relay/types.d.ts.map +1 -0
  50. package/dist/operations/relay/types.js +2 -0
  51. package/dist/operations/relay/types.js.map +1 -0
  52. package/package.json +1 -1
package/README.md CHANGED
@@ -94,6 +94,7 @@ src/
94
94
  │ ├── invoice.ts # Invoice creation
95
95
  │ ├── teleport.ts # Single teleport proof
96
96
  │ ├── teleportProof.ts # Batch teleport proof (Nova + Decider)
97
+ │ ├── relay/ # Relay node HTTP client (redeem/swap)
97
98
  │ ├── liquidityManager/ # Wrap/unwrap with slippage protection
98
99
  │ └── layerzeroScan/ # LayerZero message tracking & decoding
99
100
  ├── wasm/ # WASM runtime & bindings
@@ -170,6 +171,75 @@ const quote = await buildCrossUnwrapQuote({
170
171
  });
171
172
  ```
172
173
 
174
+ ### Relay Operations
175
+
176
+ Interact with a relay node for relayer-based redeem and token-to-native swap flows:
177
+
178
+ ```typescript
179
+ import {
180
+ estimateRelayFee,
181
+ fetchSwapQuote,
182
+ submitRelaySwap,
183
+ submitRelayTeleport,
184
+ } from "zerc20-client-sdk";
185
+
186
+ const fee = await estimateRelayFee("https://relay.example", 1);
187
+
188
+ const quote = await fetchSwapQuote("https://relay.example", 1, 1_000_000n);
189
+ if (quote.priceFallback) {
190
+ console.warn("Relay is using fallback oracle prices");
191
+ }
192
+
193
+ await submitRelaySwap("https://relay.example", {
194
+ chainId: 1,
195
+ tokenAmount: 1_000_000n,
196
+ minNativeAmount: 900_000n,
197
+ maxNativeAmount: quote.nativeAmount,
198
+ recipient: "0x...",
199
+ owner: "0x...",
200
+ permitDeadline: 1_700_000_000n,
201
+ permitV: 27,
202
+ permitR: "0x...",
203
+ permitS: "0x...",
204
+ });
205
+ ```
206
+
207
+ ### Adaptor Withdraw (Stuck Fund Recovery)
208
+
209
+ When a cross-chain unwrap fails (e.g. due to Stargate liquidity shortage), user funds may remain in the destination chain's Adaptor contract. The SDK provides functions to detect and recover these stuck funds:
210
+
211
+ ```typescript
212
+ import {
213
+ fetchAdaptorBalances,
214
+ hasStuckFunds,
215
+ withdrawFromAdaptor,
216
+ NATIVE_TOKEN_ADDRESS,
217
+ } from "zerc20-client-sdk";
218
+
219
+ // Check if a user has stuck funds in an adaptor
220
+ const stuck = await hasStuckFunds({
221
+ provider: readProvider,
222
+ account: "0xUser...",
223
+ adaptorAddress: "0xAdaptor...",
224
+ });
225
+
226
+ // Fetch detailed balances
227
+ const balances = await fetchAdaptorBalances({
228
+ provider: readProvider,
229
+ account: "0xUser...",
230
+ adaptorAddress: "0xAdaptor...",
231
+ });
232
+ // balances.underlyingTokenBalance, balances.zerc20Balance, balances.nativeBalance
233
+
234
+ // Withdraw stuck funds
235
+ const result = await withdrawFromAdaptor({
236
+ writeProvider,
237
+ adaptorAddress: "0xAdaptor...",
238
+ token: balances.underlyingTokenAddress, // or zerc20TokenAddress, or NATIVE_TOKEN_ADDRESS
239
+ amount: balances.underlyingTokenBalance,
240
+ });
241
+ ```
242
+
173
243
  ### LayerZero Scan
174
244
 
175
245
  Track and decode LayerZero cross-chain messages. Configuration and providers are injected as parameters, making this module framework-agnostic: