@aspan/sdk 0.2.2 → 0.3.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/dist/index.d.mts CHANGED
@@ -212,6 +212,8 @@ interface RouterSwapParams {
212
212
  }
213
213
  /** Router mint parameters */
214
214
  interface RouterMintParams {
215
+ /** true = mint xBNB, false = mint apUSD */
216
+ mintXBNB: boolean;
215
217
  /** Minimum output to receive (slippage protection) */
216
218
  minMintOut: bigint;
217
219
  /** Recipient of minted tokens (address(0) = msg.sender) */
@@ -1672,6 +1674,9 @@ declare const RouterABI: readonly [{
1672
1674
  readonly name: "mintParams";
1673
1675
  readonly type: "tuple";
1674
1676
  readonly components: readonly [{
1677
+ readonly name: "mintXBNB";
1678
+ readonly type: "bool";
1679
+ }, {
1675
1680
  readonly name: "minMintOut";
1676
1681
  readonly type: "uint256";
1677
1682
  }, {
@@ -1716,6 +1721,9 @@ declare const RouterABI: readonly [{
1716
1721
  readonly name: "mintParams";
1717
1722
  readonly type: "tuple";
1718
1723
  readonly components: readonly [{
1724
+ readonly name: "mintXBNB";
1725
+ readonly type: "bool";
1726
+ }, {
1719
1727
  readonly name: "minMintOut";
1720
1728
  readonly type: "uint256";
1721
1729
  }, {
package/dist/index.d.ts CHANGED
@@ -212,6 +212,8 @@ interface RouterSwapParams {
212
212
  }
213
213
  /** Router mint parameters */
214
214
  interface RouterMintParams {
215
+ /** true = mint xBNB, false = mint apUSD */
216
+ mintXBNB: boolean;
215
217
  /** Minimum output to receive (slippage protection) */
216
218
  minMintOut: bigint;
217
219
  /** Recipient of minted tokens (address(0) = msg.sender) */
@@ -1672,6 +1674,9 @@ declare const RouterABI: readonly [{
1672
1674
  readonly name: "mintParams";
1673
1675
  readonly type: "tuple";
1674
1676
  readonly components: readonly [{
1677
+ readonly name: "mintXBNB";
1678
+ readonly type: "bool";
1679
+ }, {
1675
1680
  readonly name: "minMintOut";
1676
1681
  readonly type: "uint256";
1677
1682
  }, {
@@ -1716,6 +1721,9 @@ declare const RouterABI: readonly [{
1716
1721
  readonly name: "mintParams";
1717
1722
  readonly type: "tuple";
1718
1723
  readonly components: readonly [{
1724
+ readonly name: "mintXBNB";
1725
+ readonly type: "bool";
1726
+ }, {
1719
1727
  readonly name: "minMintOut";
1720
1728
  readonly type: "uint256";
1721
1729
  }, {
package/dist/index.js CHANGED
@@ -1483,6 +1483,7 @@ var RouterABI = [
1483
1483
  name: "mintParams",
1484
1484
  type: "tuple",
1485
1485
  components: [
1486
+ { name: "mintXBNB", type: "bool" },
1486
1487
  { name: "minMintOut", type: "uint256" },
1487
1488
  { name: "recipient", type: "address" },
1488
1489
  { name: "deadline", type: "uint256" }
@@ -1515,6 +1516,7 @@ var RouterABI = [
1515
1516
  name: "mintParams",
1516
1517
  type: "tuple",
1517
1518
  components: [
1519
+ { name: "mintXBNB", type: "bool" },
1518
1520
  { name: "minMintOut", type: "uint256" },
1519
1521
  { name: "recipient", type: "address" },
1520
1522
  { name: "deadline", type: "uint256" }
@@ -2184,6 +2186,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2184
2186
  poolFee: params.swapParams.poolFee
2185
2187
  },
2186
2188
  {
2189
+ mintXBNB: false,
2190
+ // swapAndMintApUSD always mints apUSD
2187
2191
  minMintOut: params.mintParams.minMintOut,
2188
2192
  recipient: params.mintParams.recipient,
2189
2193
  deadline: params.mintParams.deadline
@@ -2212,6 +2216,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2212
2216
  poolFee: params.swapParams.poolFee
2213
2217
  },
2214
2218
  {
2219
+ mintXBNB: true,
2220
+ // swapAndMintXBNB always mints xBNB
2215
2221
  minMintOut: params.mintParams.minMintOut,
2216
2222
  recipient: params.mintParams.recipient,
2217
2223
  deadline: params.mintParams.deadline
package/dist/index.mjs CHANGED
@@ -1443,6 +1443,7 @@ var RouterABI = [
1443
1443
  name: "mintParams",
1444
1444
  type: "tuple",
1445
1445
  components: [
1446
+ { name: "mintXBNB", type: "bool" },
1446
1447
  { name: "minMintOut", type: "uint256" },
1447
1448
  { name: "recipient", type: "address" },
1448
1449
  { name: "deadline", type: "uint256" }
@@ -1475,6 +1476,7 @@ var RouterABI = [
1475
1476
  name: "mintParams",
1476
1477
  type: "tuple",
1477
1478
  components: [
1479
+ { name: "mintXBNB", type: "bool" },
1478
1480
  { name: "minMintOut", type: "uint256" },
1479
1481
  { name: "recipient", type: "address" },
1480
1482
  { name: "deadline", type: "uint256" }
@@ -2144,6 +2146,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2144
2146
  poolFee: params.swapParams.poolFee
2145
2147
  },
2146
2148
  {
2149
+ mintXBNB: false,
2150
+ // swapAndMintApUSD always mints apUSD
2147
2151
  minMintOut: params.mintParams.minMintOut,
2148
2152
  recipient: params.mintParams.recipient,
2149
2153
  deadline: params.mintParams.deadline
@@ -2172,6 +2176,8 @@ var AspanRouterClient = class extends AspanRouterReadClient {
2172
2176
  poolFee: params.swapParams.poolFee
2173
2177
  },
2174
2178
  {
2179
+ mintXBNB: true,
2180
+ // swapAndMintXBNB always mints xBNB
2175
2181
  minMintOut: params.mintParams.minMintOut,
2176
2182
  recipient: params.mintParams.recipient,
2177
2183
  deadline: params.mintParams.deadline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspan/sdk",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "TypeScript SDK for Aspan Protocol - LST-backed stablecoin on BNB Chain",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@ const TOKENS = {
33
33
  };
34
34
 
35
35
  // Minimal amounts
36
- const BNB_AMOUNT = parseEther("0.002"); // ~$1.20
36
+ const BNB_AMOUNT = parseEther("0.0005"); // ~$0.30
37
37
  const USDT_AMOUNT = parseAmount("0.5"); // $0.50
38
38
 
39
39
  const ERC20_ABI = [
@@ -44,6 +44,9 @@ const ERC20_ABI = [
44
44
  // Check env at module level
45
45
  const HAS_PRIVATE_KEY = !!process.env.PRIVATE_KEY;
46
46
 
47
+ // Helper to wait for RPC state sync
48
+ const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
49
+
47
50
  // ============ Tests ============
48
51
 
49
52
  describe("AspanRouter SDK", () => {
@@ -69,6 +72,7 @@ describe("AspanRouter SDK", () => {
69
72
  args: [ROUTER, amount],
70
73
  });
71
74
  await publicClient.waitForTransactionReceipt({ hash });
75
+ await sleep(1000);
72
76
  };
73
77
 
74
78
  beforeAll(() => {
@@ -136,7 +140,7 @@ describe("AspanRouter SDK", () => {
136
140
 
137
141
  // ============ E2E Tests (Sequential) ============
138
142
 
139
- describe("E2E Flows", () => {
143
+ describe.sequential("E2E Flows", () => {
140
144
  // Test 1: BNB → apUSD → slisBNB
141
145
  it.skipIf(!HAS_PRIVATE_KEY)("BNB → apUSD → slisBNB", async () => {
142
146
  console.log(`\n[E2E 1] BNB → apUSD → slisBNB`);
@@ -147,7 +151,9 @@ describe("AspanRouter SDK", () => {
147
151
 
148
152
  const mintHash = await writeClient.stakeAndMintApUSD(0n, BNB_AMOUNT);
149
153
  const mintReceipt = await publicClient.waitForTransactionReceipt({ hash: mintHash });
154
+ await sleep(2000);
150
155
  expect(mintReceipt.status).toBe("success");
156
+ await sleep(2000); // Wait for RPC state sync
151
157
 
152
158
  const apUSDAfter = await getBalance(TOKENS.apUSD);
153
159
  const apUSDMinted = apUSDAfter - apUSDBefore;
@@ -166,6 +172,7 @@ describe("AspanRouter SDK", () => {
166
172
  minOut: 0n,
167
173
  });
168
174
  const redeemReceipt = await publicClient.waitForTransactionReceipt({ hash: redeemHash });
175
+ await sleep(2000);
169
176
  expect(redeemReceipt.status).toBe("success");
170
177
 
171
178
  const slisBNBAfter = await getBalance(TOKENS.slisBNB);
@@ -184,6 +191,7 @@ describe("AspanRouter SDK", () => {
184
191
  minOut: 0n,
185
192
  });
186
193
  await publicClient.waitForTransactionReceipt({ hash: directMintHash });
194
+ await sleep(2000);
187
195
 
188
196
  const apUSDAfter2 = await getBalance(TOKENS.apUSD);
189
197
  const directMinted = apUSDAfter2 - apUSDBefore2;
@@ -197,6 +205,7 @@ describe("AspanRouter SDK", () => {
197
205
  const indicesBefore = await readClient.getUserWithdrawalIndices(account.address);
198
206
  const unstakeHash = await writeClient.redeemApUSDAndRequestUnstake(directMinted);
199
207
  await publicClient.waitForTransactionReceipt({ hash: unstakeHash });
208
+ await sleep(2000);
200
209
 
201
210
  const indicesAfter = await readClient.getUserWithdrawalIndices(account.address);
202
211
  expect(indicesAfter.length).toBeGreaterThan(indicesBefore.length);
@@ -213,6 +222,7 @@ describe("AspanRouter SDK", () => {
213
222
 
214
223
  const mintHash = await writeClient.stakeAndMintXBNB(0n, BNB_AMOUNT);
215
224
  const mintReceipt = await publicClient.waitForTransactionReceipt({ hash: mintHash });
225
+ await sleep(2000);
216
226
  expect(mintReceipt.status).toBe("success");
217
227
 
218
228
  const xBNBAfter = await getBalance(TOKENS.xBNB);
@@ -232,6 +242,7 @@ describe("AspanRouter SDK", () => {
232
242
  minOut: 0n,
233
243
  });
234
244
  const redeemReceipt = await publicClient.waitForTransactionReceipt({ hash: redeemHash });
245
+ await sleep(2000);
235
246
  expect(redeemReceipt.status).toBe("success");
236
247
 
237
248
  const slisBNBAfter = await getBalance(TOKENS.slisBNB);
@@ -250,6 +261,7 @@ describe("AspanRouter SDK", () => {
250
261
  minOut: 0n,
251
262
  });
252
263
  await publicClient.waitForTransactionReceipt({ hash: directMintHash });
264
+ await sleep(2000);
253
265
 
254
266
  const xBNBAfter2 = await getBalance(TOKENS.xBNB);
255
267
  console.log(` Minted: ${formatAmount(xBNBAfter2 - xBNBBefore2, 8)} xBNB ✓`);
@@ -288,6 +300,7 @@ describe("AspanRouter SDK", () => {
288
300
  },
289
301
  });
290
302
  const mintReceipt = await publicClient.waitForTransactionReceipt({ hash: mintHash });
303
+ await sleep(2000);
291
304
  expect(mintReceipt.status).toBe("success");
292
305
 
293
306
  const apUSDAfter = await getBalance(TOKENS.apUSD);
@@ -310,6 +323,7 @@ describe("AspanRouter SDK", () => {
310
323
  deadline: BigInt(Math.floor(Date.now() / 1000) + 3600),
311
324
  });
312
325
  const redeemReceipt = await publicClient.waitForTransactionReceipt({ hash: redeemHash });
326
+ await sleep(2000);
313
327
  expect(redeemReceipt.status).toBe("success");
314
328
 
315
329
  const usdtAfter = await getBalance(TOKENS.USDT);
@@ -349,6 +363,7 @@ describe("AspanRouter SDK", () => {
349
363
  },
350
364
  });
351
365
  const mintReceipt = await publicClient.waitForTransactionReceipt({ hash: mintHash });
366
+ await sleep(2000);
352
367
  expect(mintReceipt.status).toBe("success");
353
368
 
354
369
  const xBNBAfter = await getBalance(TOKENS.xBNB);
@@ -368,6 +383,7 @@ describe("AspanRouter SDK", () => {
368
383
  minOut: 0n,
369
384
  });
370
385
  const redeemReceipt = await publicClient.waitForTransactionReceipt({ hash: redeemHash });
386
+ await sleep(2000);
371
387
  expect(redeemReceipt.status).toBe("success");
372
388
 
373
389
  const slisBNBAfter = await getBalance(TOKENS.slisBNB);
package/src/abi/router.ts CHANGED
@@ -27,6 +27,7 @@ export const RouterABI = [
27
27
  name: "mintParams",
28
28
  type: "tuple",
29
29
  components: [
30
+ { name: "mintXBNB", type: "bool" },
30
31
  { name: "minMintOut", type: "uint256" },
31
32
  { name: "recipient", type: "address" },
32
33
  { name: "deadline", type: "uint256" },
@@ -60,6 +61,7 @@ export const RouterABI = [
60
61
  name: "mintParams",
61
62
  type: "tuple",
62
63
  components: [
64
+ { name: "mintXBNB", type: "bool" },
63
65
  { name: "minMintOut", type: "uint256" },
64
66
  { name: "recipient", type: "address" },
65
67
  { name: "deadline", type: "uint256" },
package/src/router.ts CHANGED
@@ -313,6 +313,7 @@ export class AspanRouterClient extends AspanRouterReadClient {
313
313
  poolFee: params.swapParams.poolFee,
314
314
  },
315
315
  {
316
+ mintXBNB: false, // swapAndMintApUSD always mints apUSD
316
317
  minMintOut: params.mintParams.minMintOut,
317
318
  recipient: params.mintParams.recipient,
318
319
  deadline: params.mintParams.deadline,
@@ -346,6 +347,7 @@ export class AspanRouterClient extends AspanRouterReadClient {
346
347
  poolFee: params.swapParams.poolFee,
347
348
  },
348
349
  {
350
+ mintXBNB: true, // swapAndMintXBNB always mints xBNB
349
351
  minMintOut: params.mintParams.minMintOut,
350
352
  recipient: params.mintParams.recipient,
351
353
  deadline: params.mintParams.deadline,
package/src/types.ts CHANGED
@@ -262,6 +262,8 @@ export interface RouterSwapParams {
262
262
 
263
263
  /** Router mint parameters */
264
264
  export interface RouterMintParams {
265
+ /** true = mint xBNB, false = mint apUSD */
266
+ mintXBNB: boolean;
265
267
  /** Minimum output to receive (slippage protection) */
266
268
  minMintOut: bigint;
267
269
  /** Recipient of minted tokens (address(0) = msg.sender) */