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

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,15 +177,13 @@ async function getQuote(params) {
177
177
  tokenOut: params.tokenOut.address,
178
178
  amount: params.amount
179
179
  });
180
- const inputSlippage = params.slippage ?? 0.05;
181
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
182
- const slippage = slippagePercent / 100;
180
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
183
181
  let warning;
184
182
  if (slippagePercent > 10) {
185
183
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
186
184
  }
187
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
188
- const slippageBps = BigInt(Math.round(slippage * 1e4));
185
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
186
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
189
187
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
190
188
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
191
189
  return {
@@ -206,7 +204,6 @@ async function getQuote(params) {
206
204
  amountIn: params.amount,
207
205
  pricePerInputToken,
208
206
  slippage: slippagePercent,
209
- // keep % form in output for clarity
210
207
  internal: {
211
208
  ...data,
212
209
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/dist/core.js CHANGED
@@ -139,15 +139,13 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- const inputSlippage = params.slippage ?? 0.05;
143
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
144
- const slippage = slippagePercent / 100;
142
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
145
143
  let warning;
146
144
  if (slippagePercent > 10) {
147
145
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
148
146
  }
149
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
150
- const slippageBps = BigInt(Math.round(slippage * 1e4));
147
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
148
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
151
149
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
152
150
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
153
151
  return {
@@ -168,7 +166,6 @@ async function getQuote(params) {
168
166
  amountIn: params.amount,
169
167
  pricePerInputToken,
170
168
  slippage: slippagePercent,
171
- // keep % form in output for clarity
172
169
  internal: {
173
170
  ...data,
174
171
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/dist/index.cjs CHANGED
@@ -182,15 +182,13 @@ async function getQuote(params) {
182
182
  tokenOut: params.tokenOut.address,
183
183
  amount: params.amount
184
184
  });
185
- const inputSlippage = params.slippage ?? 0.05;
186
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
187
- const slippage = slippagePercent / 100;
185
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
188
186
  let warning;
189
187
  if (slippagePercent > 10) {
190
188
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
191
189
  }
192
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
193
- const slippageBps = BigInt(Math.round(slippage * 1e4));
190
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
191
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
194
192
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
195
193
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
196
194
  return {
@@ -211,7 +209,6 @@ async function getQuote(params) {
211
209
  amountIn: params.amount,
212
210
  pricePerInputToken,
213
211
  slippage: slippagePercent,
214
- // keep % form in output for clarity
215
212
  internal: {
216
213
  ...data,
217
214
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/dist/index.js CHANGED
@@ -139,15 +139,13 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- const inputSlippage = params.slippage ?? 0.05;
143
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
144
- const slippage = slippagePercent / 100;
142
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
145
143
  let warning;
146
144
  if (slippagePercent > 10) {
147
145
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
148
146
  }
149
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
150
- const slippageBps = BigInt(Math.round(slippage * 1e4));
147
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
148
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
151
149
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
152
150
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
153
151
  return {
@@ -168,7 +166,6 @@ async function getQuote(params) {
168
166
  amountIn: params.amount,
169
167
  pricePerInputToken,
170
168
  slippage: slippagePercent,
171
- // keep % form in output for clarity
172
169
  internal: {
173
170
  ...data,
174
171
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/dist/react.cjs CHANGED
@@ -651,15 +651,13 @@ async function getQuote(params) {
651
651
  tokenOut: params.tokenOut.address,
652
652
  amount: params.amount
653
653
  });
654
- const inputSlippage = params.slippage ?? 0.05;
655
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
656
- const slippage = slippagePercent / 100;
654
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
657
655
  let warning;
658
656
  if (slippagePercent > 10) {
659
657
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
660
658
  }
661
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
662
- const slippageBps = BigInt(Math.round(slippage * 1e4));
659
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
660
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
663
661
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
664
662
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
665
663
  return {
@@ -680,7 +678,6 @@ async function getQuote(params) {
680
678
  amountIn: params.amount,
681
679
  pricePerInputToken,
682
680
  slippage: slippagePercent,
683
- // keep % form in output for clarity
684
681
  internal: {
685
682
  ...data,
686
683
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/dist/react.js CHANGED
@@ -630,15 +630,13 @@ async function getQuote(params) {
630
630
  tokenOut: params.tokenOut.address,
631
631
  amount: params.amount
632
632
  });
633
- const inputSlippage = params.slippage ?? 0.05;
634
- const slippagePercent = Math.min(Math.max(inputSlippage, 0), 50);
635
- const slippage = slippagePercent / 100;
633
+ const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
636
634
  let warning;
637
635
  if (slippagePercent > 10) {
638
636
  warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
639
637
  }
640
- const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
641
- const slippageBps = BigInt(Math.round(slippage * 1e4));
638
+ const estimatedAmountOut = BigInt(data.estimatedAmountOut);
639
+ const slippageBps = BigInt(Math.round(slippagePercent * 100));
642
640
  const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
643
641
  const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
644
642
  return {
@@ -659,7 +657,6 @@ async function getQuote(params) {
659
657
  amountIn: params.amount,
660
658
  pricePerInputToken,
661
659
  slippage: slippagePercent,
662
- // keep % form in output for clarity
663
660
  internal: {
664
661
  ...data,
665
662
  estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogun-sdk/swap",
3
- "version": "0.0.2-test.6",
3
+ "version": "0.0.2-test.7",
4
4
  "type": "module",
5
5
  "description": "Shogun Network Swap utilities and helpers",
6
6
  "author": "Shogun Network",