@jimmygu/sfa-sdk-test 1.0.11 → 1.0.12
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.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -659,6 +659,7 @@ var OneClickService = class {
|
|
|
659
659
|
swapType = "EXACT_INPUT",
|
|
660
660
|
...restParams
|
|
661
661
|
} = params;
|
|
662
|
+
const isExactOutput = swapType === "EXACT_OUTPUT";
|
|
662
663
|
const response = await request(OpenAPI, {
|
|
663
664
|
method: "POST",
|
|
664
665
|
url: "/v0/quote",
|
|
@@ -690,7 +691,7 @@ var OneClickService = class {
|
|
|
690
691
|
res.data.outputAmount = numberRemoveEndZero((0, import_big.default)(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals).toFixed(params.toToken.decimals, 0));
|
|
691
692
|
try {
|
|
692
693
|
let netFee = (0, import_big.default)(params.amount).div(10 ** params.fromToken.decimals).minus((0, import_big.default)(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals));
|
|
693
|
-
if (
|
|
694
|
+
if (isExactOutput) {
|
|
694
695
|
netFee = (0, import_big.default)(res.data?.quote?.amountIn || 0).div(10 ** params.toToken.decimals).minus((0, import_big.default)(params.amount).div(10 ** params.fromToken.decimals));
|
|
695
696
|
}
|
|
696
697
|
const bridgeFeeValue = BridgeFee.reduce((acc, item) => {
|
|
@@ -732,7 +733,7 @@ var OneClickService = class {
|
|
|
732
733
|
fromToken: params.fromToken,
|
|
733
734
|
refundTo: params.refundTo,
|
|
734
735
|
recipient: params.recipient,
|
|
735
|
-
amountWei: params.amount,
|
|
736
|
+
amountWei: isExactOutput ? res.data?.quote?.amountIn : params.amount,
|
|
736
737
|
prices: params.prices,
|
|
737
738
|
depositAddress: res.data?.quote?.depositAddress || DefaultAddresses[params.fromToken.chainType]
|
|
738
739
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -597,6 +597,7 @@ var OneClickService = class {
|
|
|
597
597
|
swapType = "EXACT_INPUT",
|
|
598
598
|
...restParams
|
|
599
599
|
} = params;
|
|
600
|
+
const isExactOutput = swapType === "EXACT_OUTPUT";
|
|
600
601
|
const response = await request(OpenAPI, {
|
|
601
602
|
method: "POST",
|
|
602
603
|
url: "/v0/quote",
|
|
@@ -628,7 +629,7 @@ var OneClickService = class {
|
|
|
628
629
|
res.data.outputAmount = numberRemoveEndZero(Big(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals).toFixed(params.toToken.decimals, 0));
|
|
629
630
|
try {
|
|
630
631
|
let netFee = Big(params.amount).div(10 ** params.fromToken.decimals).minus(Big(res.data?.quote?.amountOut || 0).div(10 ** params.toToken.decimals));
|
|
631
|
-
if (
|
|
632
|
+
if (isExactOutput) {
|
|
632
633
|
netFee = Big(res.data?.quote?.amountIn || 0).div(10 ** params.toToken.decimals).minus(Big(params.amount).div(10 ** params.fromToken.decimals));
|
|
633
634
|
}
|
|
634
635
|
const bridgeFeeValue = BridgeFee.reduce((acc, item) => {
|
|
@@ -670,7 +671,7 @@ var OneClickService = class {
|
|
|
670
671
|
fromToken: params.fromToken,
|
|
671
672
|
refundTo: params.refundTo,
|
|
672
673
|
recipient: params.recipient,
|
|
673
|
-
amountWei: params.amount,
|
|
674
|
+
amountWei: isExactOutput ? res.data?.quote?.amountIn : params.amount,
|
|
674
675
|
prices: params.prices,
|
|
675
676
|
depositAddress: res.data?.quote?.depositAddress || DefaultAddresses[params.fromToken.chainType]
|
|
676
677
|
});
|