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