@t2000/sdk 0.16.28 → 0.16.29
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/adapters/index.cjs +52 -23
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +52 -23
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +80 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +80 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -951,12 +951,20 @@ async function buildSwapTx(params) {
|
|
|
951
951
|
}
|
|
952
952
|
const rawAmount = BigInt(Math.floor(amount * 10 ** fromInfo.decimals));
|
|
953
953
|
const aggClient = createAggregatorClient(client, address);
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
954
|
+
const _origLog = console.log;
|
|
955
|
+
console.log = () => {
|
|
956
|
+
};
|
|
957
|
+
let result;
|
|
958
|
+
try {
|
|
959
|
+
result = await aggClient.findRouters({
|
|
960
|
+
from: fromInfo.type,
|
|
961
|
+
target: toInfo.type,
|
|
962
|
+
amount: rawAmount,
|
|
963
|
+
byAmountIn: true
|
|
964
|
+
});
|
|
965
|
+
} finally {
|
|
966
|
+
console.log = _origLog;
|
|
967
|
+
}
|
|
960
968
|
if (!result || result.insufficientLiquidity) {
|
|
961
969
|
throw new T2000Error(
|
|
962
970
|
"ASSET_NOT_SUPPORTED",
|
|
@@ -965,11 +973,17 @@ async function buildSwapTx(params) {
|
|
|
965
973
|
}
|
|
966
974
|
const tx = new Transaction();
|
|
967
975
|
const slippage = maxSlippageBps / 1e4;
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
976
|
+
console.log = () => {
|
|
977
|
+
};
|
|
978
|
+
try {
|
|
979
|
+
await aggClient.fastRouterSwap({
|
|
980
|
+
router: result,
|
|
981
|
+
txb: tx,
|
|
982
|
+
slippage
|
|
983
|
+
});
|
|
984
|
+
} finally {
|
|
985
|
+
console.log = _origLog;
|
|
986
|
+
}
|
|
973
987
|
const estimatedOut = Number(result.amountOut.toString());
|
|
974
988
|
return {
|
|
975
989
|
tx,
|
|
@@ -986,12 +1000,20 @@ async function addSwapToTx(params) {
|
|
|
986
1000
|
}
|
|
987
1001
|
const rawAmount = BigInt(Math.floor(amount * 10 ** fromInfo.decimals));
|
|
988
1002
|
const aggClient = createAggregatorClient(client, address);
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1003
|
+
const _origLog = console.log;
|
|
1004
|
+
console.log = () => {
|
|
1005
|
+
};
|
|
1006
|
+
let result;
|
|
1007
|
+
try {
|
|
1008
|
+
result = await aggClient.findRouters({
|
|
1009
|
+
from: fromInfo.type,
|
|
1010
|
+
target: toInfo.type,
|
|
1011
|
+
amount: rawAmount,
|
|
1012
|
+
byAmountIn: true
|
|
1013
|
+
});
|
|
1014
|
+
} finally {
|
|
1015
|
+
console.log = _origLog;
|
|
1016
|
+
}
|
|
995
1017
|
if (!result || result.insufficientLiquidity) {
|
|
996
1018
|
throw new T2000Error(
|
|
997
1019
|
"ASSET_NOT_SUPPORTED",
|
|
@@ -999,12 +1021,19 @@ async function addSwapToTx(params) {
|
|
|
999
1021
|
);
|
|
1000
1022
|
}
|
|
1001
1023
|
const slippage = maxSlippageBps / 1e4;
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1024
|
+
console.log = () => {
|
|
1025
|
+
};
|
|
1026
|
+
let outputCoin;
|
|
1027
|
+
try {
|
|
1028
|
+
outputCoin = await aggClient.routerSwap({
|
|
1029
|
+
router: result,
|
|
1030
|
+
txb: tx,
|
|
1031
|
+
inputCoin,
|
|
1032
|
+
slippage
|
|
1033
|
+
});
|
|
1034
|
+
} finally {
|
|
1035
|
+
console.log = _origLog;
|
|
1036
|
+
}
|
|
1008
1037
|
const estimatedOut = Number(result.amountOut.toString());
|
|
1009
1038
|
return {
|
|
1010
1039
|
outputCoin,
|