Skip to content

Commit 377154f

Browse files
committed
remove duplicate import, remove duplicate swap call
1 parent 6dbc977 commit 377154f

File tree

1 file changed

+9
-27
lines changed
  • packages/plugin-evm/src/actions

1 file changed

+9
-27
lines changed

packages/plugin-evm/src/actions/swap.ts

+9-27
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import {
66
generateObjectDeprecated,
77
ModelClass,
88
} from "@elizaos/core";
9-
import {
10-
composeContext,
11-
generateObjectDeprecated,
12-
ModelClass,
13-
} from "@elizaos/core";
149
import {
1510
createConfig,
1611
executeRoute,
@@ -113,27 +108,6 @@ export const swapAction = {
113108
callback?: any
114109
) => {
115110
console.log("Swap action handler called");
116-
const walletProvider = initWalletProvider(runtime);
117-
const action = new SwapAction(walletProvider);
118-
119-
// Compose swap context
120-
const swapContext = composeContext({
121-
state,
122-
template: swapTemplate,
123-
});
124-
const content = await generateObjectDeprecated({
125-
runtime,
126-
context: swapContext,
127-
modelClass: ModelClass.LARGE,
128-
});
129-
130-
const swapOptions: SwapParams = {
131-
chain: content.chain,
132-
fromToken: content.inputToken,
133-
toToken: content.outputToken,
134-
amount: content.amount,
135-
slippage: content.slippage,
136-
};
137111

138112
try {
139113
const walletProvider = initWalletProvider(runtime);
@@ -149,12 +123,20 @@ export const swapAction = {
149123
);
150124

151125
// Generate swap details object
152-
const swapDetails = (await generateObjectDeprecated({
126+
const content = (await generateObjectDeprecated({
153127
runtime,
154128
context: contextWithChains,
155129
modelClass: ModelClass.SMALL,
156130
})) as SwapParams;
157131

132+
const swapOptions: SwapParams = {
133+
chain: content.chain,
134+
fromToken: content.fromToken,
135+
toToken: content.toToken,
136+
amount: content.amount,
137+
slippage: content.slippage,
138+
};
139+
158140
const action = new SwapAction(walletProvider);
159141
const swapResp = await action.swap(swapOptions);
160142
if (callback) {

0 commit comments

Comments
 (0)