@shogun-sdk/swap 0.0.2-test.7 → 0.0.2-test.9

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/core.cjs CHANGED
@@ -177,7 +177,7 @@ async function getQuote(params) {
177
177
  tokenOut: params.tokenOut.address,
178
178
  amount: params.amount
179
179
  });
180
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
180
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
181
181
  let warning;
182
182
  if (slippagePercent > 10) {
183
183
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -185,12 +185,17 @@ async function getQuote(params) {
185
185
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
186
186
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
187
187
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
188
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
189
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
190
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
191
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
188
192
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
189
193
  return {
190
- amountOut: estimatedAmountOut,
191
- amountOutUsd: data.estimatedAmountOutUsd,
194
+ amountOut: estimatedAmountOutAfterSlippage,
195
+ amountOutUsd: amountOutUsdAfterSlippage,
192
196
  amountInUsd: data.amountInUsd,
193
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
197
+ // Input USD stays the same
198
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
194
199
  tokenIn: {
195
200
  address: params.tokenIn.address,
196
201
  decimals: params.tokenIn.decimals ?? 18,
@@ -206,7 +211,8 @@ async function getQuote(params) {
206
211
  slippage: slippagePercent,
207
212
  internal: {
208
213
  ...data,
209
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
214
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
215
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
210
216
  },
211
217
  warning
212
218
  };
@@ -354,10 +360,10 @@ var DEFAULT_STAGE_MESSAGES = {
354
360
  processing: "Preparing transaction for execution",
355
361
  approving: "Approving token allowance",
356
362
  approved: "Token approved successfully",
357
- signing: "Signing order for submission",
358
- submitting: "Submitting order to Auctioneer",
359
- success: "Order executed successfully",
360
- error: "Order execution failed"
363
+ signing: "Signing transaction for submission",
364
+ submitting: "Submitting transaction",
365
+ success: "Transaction initiated successfully",
366
+ error: "Transaction failed during submission"
361
367
  };
362
368
 
363
369
  // src/core/executeOrder/buildOrder.ts
package/dist/core.js CHANGED
@@ -139,7 +139,7 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
142
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
143
143
  let warning;
144
144
  if (slippagePercent > 10) {
145
145
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -147,12 +147,17 @@ async function getQuote(params) {
147
147
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
148
148
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
149
149
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
150
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
151
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
152
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
153
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
150
154
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
151
155
  return {
152
- amountOut: estimatedAmountOut,
153
- amountOutUsd: data.estimatedAmountOutUsd,
156
+ amountOut: estimatedAmountOutAfterSlippage,
157
+ amountOutUsd: amountOutUsdAfterSlippage,
154
158
  amountInUsd: data.amountInUsd,
155
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
159
+ // Input USD stays the same
160
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
156
161
  tokenIn: {
157
162
  address: params.tokenIn.address,
158
163
  decimals: params.tokenIn.decimals ?? 18,
@@ -168,7 +173,8 @@ async function getQuote(params) {
168
173
  slippage: slippagePercent,
169
174
  internal: {
170
175
  ...data,
171
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
176
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
177
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
172
178
  },
173
179
  warning
174
180
  };
@@ -322,10 +328,10 @@ var DEFAULT_STAGE_MESSAGES = {
322
328
  processing: "Preparing transaction for execution",
323
329
  approving: "Approving token allowance",
324
330
  approved: "Token approved successfully",
325
- signing: "Signing order for submission",
326
- submitting: "Submitting order to Auctioneer",
327
- success: "Order executed successfully",
328
- error: "Order execution failed"
331
+ signing: "Signing transaction for submission",
332
+ submitting: "Submitting transaction",
333
+ success: "Transaction initiated successfully",
334
+ error: "Transaction failed during submission"
329
335
  };
330
336
 
331
337
  // src/core/executeOrder/buildOrder.ts
package/dist/index.cjs CHANGED
@@ -182,7 +182,7 @@ async function getQuote(params) {
182
182
  tokenOut: params.tokenOut.address,
183
183
  amount: params.amount
184
184
  });
185
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
185
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
186
186
  let warning;
187
187
  if (slippagePercent > 10) {
188
188
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -190,12 +190,17 @@ async function getQuote(params) {
190
190
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
191
191
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
192
192
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
193
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
194
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
195
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
196
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
193
197
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
194
198
  return {
195
- amountOut: estimatedAmountOut,
196
- amountOutUsd: data.estimatedAmountOutUsd,
199
+ amountOut: estimatedAmountOutAfterSlippage,
200
+ amountOutUsd: amountOutUsdAfterSlippage,
197
201
  amountInUsd: data.amountInUsd,
198
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
202
+ // Input USD stays the same
203
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
199
204
  tokenIn: {
200
205
  address: params.tokenIn.address,
201
206
  decimals: params.tokenIn.decimals ?? 18,
@@ -211,7 +216,8 @@ async function getQuote(params) {
211
216
  slippage: slippagePercent,
212
217
  internal: {
213
218
  ...data,
214
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
219
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
220
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
215
221
  },
216
222
  warning
217
223
  };
@@ -438,10 +444,10 @@ var DEFAULT_STAGE_MESSAGES = {
438
444
  processing: "Preparing transaction for execution",
439
445
  approving: "Approving token allowance",
440
446
  approved: "Token approved successfully",
441
- signing: "Signing order for submission",
442
- submitting: "Submitting order to Auctioneer",
443
- success: "Order executed successfully",
444
- error: "Order execution failed"
447
+ signing: "Signing transaction for submission",
448
+ submitting: "Submitting transaction",
449
+ success: "Transaction initiated successfully",
450
+ error: "Transaction failed during submission"
445
451
  };
446
452
 
447
453
  // src/core/executeOrder/buildOrder.ts
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
142
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
143
143
  let warning;
144
144
  if (slippagePercent > 10) {
145
145
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -147,12 +147,17 @@ async function getQuote(params) {
147
147
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
148
148
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
149
149
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
150
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
151
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
152
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
153
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
150
154
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
151
155
  return {
152
- amountOut: estimatedAmountOut,
153
- amountOutUsd: data.estimatedAmountOutUsd,
156
+ amountOut: estimatedAmountOutAfterSlippage,
157
+ amountOutUsd: amountOutUsdAfterSlippage,
154
158
  amountInUsd: data.amountInUsd,
155
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
159
+ // Input USD stays the same
160
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
156
161
  tokenIn: {
157
162
  address: params.tokenIn.address,
158
163
  decimals: params.tokenIn.decimals ?? 18,
@@ -168,7 +173,8 @@ async function getQuote(params) {
168
173
  slippage: slippagePercent,
169
174
  internal: {
170
175
  ...data,
171
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
176
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
177
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
172
178
  },
173
179
  warning
174
180
  };
@@ -403,10 +409,10 @@ var DEFAULT_STAGE_MESSAGES = {
403
409
  processing: "Preparing transaction for execution",
404
410
  approving: "Approving token allowance",
405
411
  approved: "Token approved successfully",
406
- signing: "Signing order for submission",
407
- submitting: "Submitting order to Auctioneer",
408
- success: "Order executed successfully",
409
- error: "Order execution failed"
412
+ signing: "Signing transaction for submission",
413
+ submitting: "Submitting transaction",
414
+ success: "Transaction initiated successfully",
415
+ error: "Transaction failed during submission"
410
416
  };
411
417
 
412
418
  // src/core/executeOrder/buildOrder.ts
package/dist/react.cjs CHANGED
@@ -297,10 +297,10 @@ var DEFAULT_STAGE_MESSAGES = {
297
297
  processing: "Preparing transaction for execution",
298
298
  approving: "Approving token allowance",
299
299
  approved: "Token approved successfully",
300
- signing: "Signing order for submission",
301
- submitting: "Submitting order to Auctioneer",
302
- success: "Order executed successfully",
303
- error: "Order execution failed"
300
+ signing: "Signing transaction for submission",
301
+ submitting: "Submitting transaction",
302
+ success: "Transaction initiated successfully",
303
+ error: "Transaction failed during submission"
304
304
  };
305
305
 
306
306
  // src/core/executeOrder/buildOrder.ts
@@ -651,7 +651,7 @@ async function getQuote(params) {
651
651
  tokenOut: params.tokenOut.address,
652
652
  amount: params.amount
653
653
  });
654
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
654
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
655
655
  let warning;
656
656
  if (slippagePercent > 10) {
657
657
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -659,12 +659,17 @@ async function getQuote(params) {
659
659
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
660
660
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
661
661
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
662
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
663
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
664
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
665
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
662
666
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
663
667
  return {
664
- amountOut: estimatedAmountOut,
665
- amountOutUsd: data.estimatedAmountOutUsd,
668
+ amountOut: estimatedAmountOutAfterSlippage,
669
+ amountOutUsd: amountOutUsdAfterSlippage,
666
670
  amountInUsd: data.amountInUsd,
667
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
671
+ // Input USD stays the same
672
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
668
673
  tokenIn: {
669
674
  address: params.tokenIn.address,
670
675
  decimals: params.tokenIn.decimals ?? 18,
@@ -680,7 +685,8 @@ async function getQuote(params) {
680
685
  slippage: slippagePercent,
681
686
  internal: {
682
687
  ...data,
683
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
688
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
689
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
684
690
  },
685
691
  warning
686
692
  };
package/dist/react.d.cts CHANGED
@@ -29,13 +29,6 @@ type ExecuteOrderResult = Awaited<ReturnType<typeof executeOrder>>;
29
29
  * built-in stage tracking, loading states, and error handling.
30
30
  *
31
31
  * ---
32
- * ## Features
33
- * - Live stage updates (processing, approving, signing, submitting, etc.)
34
- * - Built-in 20-min deadline by default (current timestamp + 1200s)
35
- * - Safe state handling with unmount guards
36
- * - Works for both EVM and Solana wallets
37
- *
38
- * ---
39
32
  * ## Example
40
33
  * ```tsx
41
34
  * import { useExecuteOrder } from "@shogun-sdk/swap/react"
package/dist/react.d.ts CHANGED
@@ -29,13 +29,6 @@ type ExecuteOrderResult = Awaited<ReturnType<typeof executeOrder>>;
29
29
  * built-in stage tracking, loading states, and error handling.
30
30
  *
31
31
  * ---
32
- * ## Features
33
- * - Live stage updates (processing, approving, signing, submitting, etc.)
34
- * - Built-in 20-min deadline by default (current timestamp + 1200s)
35
- * - Safe state handling with unmount guards
36
- * - Works for both EVM and Solana wallets
37
- *
38
- * ---
39
32
  * ## Example
40
33
  * ```tsx
41
34
  * import { useExecuteOrder } from "@shogun-sdk/swap/react"
package/dist/react.js CHANGED
@@ -272,10 +272,10 @@ var DEFAULT_STAGE_MESSAGES = {
272
272
  processing: "Preparing transaction for execution",
273
273
  approving: "Approving token allowance",
274
274
  approved: "Token approved successfully",
275
- signing: "Signing order for submission",
276
- submitting: "Submitting order to Auctioneer",
277
- success: "Order executed successfully",
278
- error: "Order execution failed"
275
+ signing: "Signing transaction for submission",
276
+ submitting: "Submitting transaction",
277
+ success: "Transaction initiated successfully",
278
+ error: "Transaction failed during submission"
279
279
  };
280
280
 
281
281
  // src/core/executeOrder/buildOrder.ts
@@ -630,7 +630,7 @@ async function getQuote(params) {
630
630
  tokenOut: params.tokenOut.address,
631
631
  amount: params.amount
632
632
  });
633
- const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
633
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
634
634
  let warning;
635
635
  if (slippagePercent > 10) {
636
636
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
@@ -638,12 +638,17 @@ async function getQuote(params) {
638
638
  const estimatedAmountOut = BigInt(data.estimatedAmountOut);
639
639
  const slippageBps = BigInt(Math.round(slippagePercent * 100));
640
640
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
641
+ const pricePerTokenOutInUsd = data.estimatedAmountOutUsd / Number(data.estimatedAmountOut);
642
+ const amountOutUsdAfterSlippage = Number(estimatedAmountOutAfterSlippage) * pricePerTokenOutInUsd;
643
+ const minStablecoinsAmountValue = BigInt(data.estimatedAmountInAsMinStablecoinAmount);
644
+ const minStablecoinsAmountAfterSlippage = minStablecoinsAmountValue * (10000n - slippageBps) / 10000n;
641
645
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
642
646
  return {
643
- amountOut: estimatedAmountOut,
644
- amountOutUsd: data.estimatedAmountOutUsd,
647
+ amountOut: estimatedAmountOutAfterSlippage,
648
+ amountOutUsd: amountOutUsdAfterSlippage,
645
649
  amountInUsd: data.amountInUsd,
646
- minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
650
+ // Input USD stays the same
651
+ minStablecoinsAmount: minStablecoinsAmountAfterSlippage,
647
652
  tokenIn: {
648
653
  address: params.tokenIn.address,
649
654
  decimals: params.tokenIn.decimals ?? 18,
@@ -659,7 +664,8 @@ async function getQuote(params) {
659
664
  slippage: slippagePercent,
660
665
  internal: {
661
666
  ...data,
662
- estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
667
+ estimatedAmountOutReduced: estimatedAmountOutAfterSlippage,
668
+ estimatedAmountOutUsdReduced: amountOutUsdAfterSlippage
663
669
  },
664
670
  warning
665
671
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogun-sdk/swap",
3
- "version": "0.0.2-test.7",
3
+ "version": "0.0.2-test.9",
4
4
  "type": "module",
5
5
  "description": "Shogun Network Swap utilities and helpers",
6
6
  "author": "Shogun Network",