@t2000/engine 1.15.0 → 1.15.1
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 +49 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3647,26 +3647,35 @@ var swapExecuteTool = buildTool({
|
|
|
3647
3647
|
},
|
|
3648
3648
|
async call(input, context) {
|
|
3649
3649
|
const agent = requireAgent(context);
|
|
3650
|
-
const
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3650
|
+
const sink = getTelemetrySink();
|
|
3651
|
+
const start = Date.now();
|
|
3652
|
+
try {
|
|
3653
|
+
const result = await agent.swap({
|
|
3654
|
+
from: input.from,
|
|
3655
|
+
to: input.to,
|
|
3656
|
+
amount: input.amount,
|
|
3657
|
+
byAmountIn: input.byAmountIn,
|
|
3658
|
+
slippage: input.slippage
|
|
3659
|
+
});
|
|
3660
|
+
sink.histogram("cetus.swap_execute_total_ms", Date.now() - start);
|
|
3661
|
+
sink.counter("cetus.swap_execute_count", { outcome: "success" });
|
|
3662
|
+
return {
|
|
3663
|
+
data: {
|
|
3664
|
+
tx: result.tx,
|
|
3665
|
+
fromToken: result.fromToken,
|
|
3666
|
+
toToken: result.toToken,
|
|
3667
|
+
fromAmount: result.fromAmount,
|
|
3668
|
+
toAmount: result.toAmount,
|
|
3669
|
+
priceImpact: result.priceImpact,
|
|
3670
|
+
route: result.route,
|
|
3671
|
+
gasCost: result.gasCost
|
|
3672
|
+
},
|
|
3673
|
+
displayText: `Swapped ${result.fromAmount} ${result.fromToken} for ${result.toAmount.toFixed(4)} ${result.toToken} (tx: ${result.tx.slice(0, 8)}...)`
|
|
3674
|
+
};
|
|
3675
|
+
} catch (err) {
|
|
3676
|
+
sink.counter("cetus.swap_execute_count", { outcome: "error" });
|
|
3677
|
+
throw err;
|
|
3678
|
+
}
|
|
3670
3679
|
}
|
|
3671
3680
|
});
|
|
3672
3681
|
var swapQuoteTool = buildTool({
|
|
@@ -3691,17 +3700,26 @@ var swapQuoteTool = buildTool({
|
|
|
3691
3700
|
isReadOnly: true,
|
|
3692
3701
|
async call(input, context) {
|
|
3693
3702
|
const walletAddress = context.agent ? context.agent.address() : getWalletAddress(context);
|
|
3694
|
-
const
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3703
|
+
const sink = getTelemetrySink();
|
|
3704
|
+
const start = Date.now();
|
|
3705
|
+
try {
|
|
3706
|
+
const result = await getSwapQuote({
|
|
3707
|
+
walletAddress,
|
|
3708
|
+
from: input.from,
|
|
3709
|
+
to: input.to,
|
|
3710
|
+
amount: input.amount,
|
|
3711
|
+
byAmountIn: input.byAmountIn
|
|
3712
|
+
});
|
|
3713
|
+
sink.histogram("cetus.find_route_ms", Date.now() - start);
|
|
3714
|
+
sink.counter("cetus.find_route_count", { outcome: "success" });
|
|
3715
|
+
return {
|
|
3716
|
+
data: result,
|
|
3717
|
+
displayText: `${result.fromAmount} ${result.fromToken} \u2192 ${result.toAmount.toFixed(4)} ${result.toToken} (impact: ${(result.priceImpact * 100).toFixed(2)}%, via ${result.route})`
|
|
3718
|
+
};
|
|
3719
|
+
} catch (err) {
|
|
3720
|
+
sink.counter("cetus.find_route_count", { outcome: "error" });
|
|
3721
|
+
throw err;
|
|
3722
|
+
}
|
|
3705
3723
|
}
|
|
3706
3724
|
});
|
|
3707
3725
|
var voloStakeTool = buildTool({
|