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.
- package/README.md +70 -0
- package/dist/assets/abi/Verifier.json +2093 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.d.ts +2 -0
- package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.d.ts.map +1 -0
- package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.js +157 -0
- package/dist/operations/liquidityManager/__tests__/adaptorWithdraw.test.js.map +1 -0
- package/dist/operations/liquidityManager/adaptorWithdraw.d.ts +82 -0
- package/dist/operations/liquidityManager/adaptorWithdraw.d.ts.map +1 -0
- package/dist/operations/liquidityManager/adaptorWithdraw.js +107 -0
- package/dist/operations/liquidityManager/adaptorWithdraw.js.map +1 -0
- package/dist/operations/liquidityManager/index.d.ts +3 -1
- package/dist/operations/liquidityManager/index.d.ts.map +1 -1
- package/dist/operations/liquidityManager/index.js +2 -1
- package/dist/operations/liquidityManager/index.js.map +1 -1
- package/dist/operations/receive/__tests__/cache.test.js +33 -0
- package/dist/operations/receive/__tests__/cache.test.js.map +1 -1
- package/dist/operations/receive/__tests__/redeemTransaction.test.js +38 -0
- package/dist/operations/receive/__tests__/redeemTransaction.test.js.map +1 -1
- package/dist/operations/receive/cache.d.ts +1 -1
- package/dist/operations/receive/cache.d.ts.map +1 -1
- package/dist/operations/receive/cache.js +6 -5
- package/dist/operations/receive/cache.js.map +1 -1
- package/dist/operations/receive/index.d.ts +1 -1
- package/dist/operations/receive/index.d.ts.map +1 -1
- package/dist/operations/receive/index.js.map +1 -1
- package/dist/operations/receive/redeemTransaction.d.ts +2 -1
- package/dist/operations/receive/redeemTransaction.d.ts.map +1 -1
- package/dist/operations/receive/redeemTransaction.js +11 -5
- package/dist/operations/receive/redeemTransaction.js.map +1 -1
- package/dist/operations/receive/types.d.ts +25 -2
- package/dist/operations/receive/types.d.ts.map +1 -1
- package/dist/operations/relay/__tests__/relay.test.d.ts +2 -0
- package/dist/operations/relay/__tests__/relay.test.d.ts.map +1 -0
- package/dist/operations/relay/__tests__/relay.test.js +270 -0
- package/dist/operations/relay/__tests__/relay.test.js.map +1 -0
- package/dist/operations/relay/index.d.ts +3 -0
- package/dist/operations/relay/index.d.ts.map +1 -0
- package/dist/operations/relay/index.js +2 -0
- package/dist/operations/relay/index.js.map +1 -0
- package/dist/operations/relay/relay.d.ts +18 -0
- package/dist/operations/relay/relay.d.ts.map +1 -0
- package/dist/operations/relay/relay.js +103 -0
- package/dist/operations/relay/relay.js.map +1 -0
- package/dist/operations/relay/types.d.ts +63 -0
- package/dist/operations/relay/types.d.ts.map +1 -0
- package/dist/operations/relay/types.js +2 -0
- package/dist/operations/relay/types.js.map +1 -0
- 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:
|