@shogun-sdk/swap 0.0.2-test.5 → 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 +6 -8
- package/dist/core.js +6 -8
- package/dist/index.cjs +6 -8
- package/dist/index.js +6 -8
- package/dist/react.cjs +6 -8
- package/dist/react.js +6 -8
- package/package.json +1 -1
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
|
|
181
|
-
const slippageDecimal = inputSlippage / 100;
|
|
182
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
180
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
183
181
|
let warning;
|
|
184
|
-
if (
|
|
185
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
182
|
+
if (slippagePercent > 10) {
|
|
183
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
186
184
|
}
|
|
187
|
-
const estimatedAmountOut = BigInt(data.
|
|
188
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -205,7 +203,7 @@ async function getQuote(params) {
|
|
|
205
203
|
},
|
|
206
204
|
amountIn: params.amount,
|
|
207
205
|
pricePerInputToken,
|
|
208
|
-
slippage,
|
|
206
|
+
slippage: slippagePercent,
|
|
209
207
|
internal: {
|
|
210
208
|
...data,
|
|
211
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
|
|
143
|
-
const slippageDecimal = inputSlippage / 100;
|
|
144
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
142
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
145
143
|
let warning;
|
|
146
|
-
if (
|
|
147
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
144
|
+
if (slippagePercent > 10) {
|
|
145
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
148
146
|
}
|
|
149
|
-
const estimatedAmountOut = BigInt(data.
|
|
150
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -167,7 +165,7 @@ async function getQuote(params) {
|
|
|
167
165
|
},
|
|
168
166
|
amountIn: params.amount,
|
|
169
167
|
pricePerInputToken,
|
|
170
|
-
slippage,
|
|
168
|
+
slippage: slippagePercent,
|
|
171
169
|
internal: {
|
|
172
170
|
...data,
|
|
173
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
|
|
186
|
-
const slippageDecimal = inputSlippage / 100;
|
|
187
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
185
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
188
186
|
let warning;
|
|
189
|
-
if (
|
|
190
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
187
|
+
if (slippagePercent > 10) {
|
|
188
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
191
189
|
}
|
|
192
|
-
const estimatedAmountOut = BigInt(data.
|
|
193
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -210,7 +208,7 @@ async function getQuote(params) {
|
|
|
210
208
|
},
|
|
211
209
|
amountIn: params.amount,
|
|
212
210
|
pricePerInputToken,
|
|
213
|
-
slippage,
|
|
211
|
+
slippage: slippagePercent,
|
|
214
212
|
internal: {
|
|
215
213
|
...data,
|
|
216
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
|
|
143
|
-
const slippageDecimal = inputSlippage / 100;
|
|
144
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
142
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
145
143
|
let warning;
|
|
146
|
-
if (
|
|
147
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
144
|
+
if (slippagePercent > 10) {
|
|
145
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
148
146
|
}
|
|
149
|
-
const estimatedAmountOut = BigInt(data.
|
|
150
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -167,7 +165,7 @@ async function getQuote(params) {
|
|
|
167
165
|
},
|
|
168
166
|
amountIn: params.amount,
|
|
169
167
|
pricePerInputToken,
|
|
170
|
-
slippage,
|
|
168
|
+
slippage: slippagePercent,
|
|
171
169
|
internal: {
|
|
172
170
|
...data,
|
|
173
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
|
|
655
|
-
const slippageDecimal = inputSlippage / 100;
|
|
656
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
654
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
657
655
|
let warning;
|
|
658
|
-
if (
|
|
659
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
656
|
+
if (slippagePercent > 10) {
|
|
657
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
660
658
|
}
|
|
661
|
-
const estimatedAmountOut = BigInt(data.
|
|
662
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -679,7 +677,7 @@ async function getQuote(params) {
|
|
|
679
677
|
},
|
|
680
678
|
amountIn: params.amount,
|
|
681
679
|
pricePerInputToken,
|
|
682
|
-
slippage,
|
|
680
|
+
slippage: slippagePercent,
|
|
683
681
|
internal: {
|
|
684
682
|
...data,
|
|
685
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
|
|
634
|
-
const slippageDecimal = inputSlippage / 100;
|
|
635
|
-
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
633
|
+
const slippagePercent = Math.min(Math.max(params.slippage ?? 0.05, 0), 50);
|
|
636
634
|
let warning;
|
|
637
|
-
if (
|
|
638
|
-
warning = `\u26A0\uFE0F High slippage tolerance (${
|
|
635
|
+
if (slippagePercent > 10) {
|
|
636
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${slippagePercent.toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
639
637
|
}
|
|
640
|
-
const estimatedAmountOut = BigInt(data.
|
|
641
|
-
const slippageBps = BigInt(Math.round(
|
|
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 {
|
|
@@ -658,7 +656,7 @@ async function getQuote(params) {
|
|
|
658
656
|
},
|
|
659
657
|
amountIn: params.amount,
|
|
660
658
|
pricePerInputToken,
|
|
661
|
-
slippage,
|
|
659
|
+
slippage: slippagePercent,
|
|
662
660
|
internal: {
|
|
663
661
|
...data,
|
|
664
662
|
estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
|