Skip to content

Commit

Permalink
remove duplicate import, remove duplicate swap call
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime committed Dec 28, 2024
1 parent 6dbc977 commit 377154f
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions packages/plugin-evm/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import {
generateObjectDeprecated,
ModelClass,
} from "@elizaos/core";
import {
composeContext,
generateObjectDeprecated,
ModelClass,
} from "@elizaos/core";
import {
createConfig,
executeRoute,
Expand Down Expand Up @@ -113,27 +108,6 @@ export const swapAction = {
callback?: any
) => {
console.log("Swap action handler called");
const walletProvider = initWalletProvider(runtime);
const action = new SwapAction(walletProvider);

// Compose swap context
const swapContext = composeContext({
state,
template: swapTemplate,
});
const content = await generateObjectDeprecated({
runtime,
context: swapContext,
modelClass: ModelClass.LARGE,
});

const swapOptions: SwapParams = {
chain: content.chain,
fromToken: content.inputToken,
toToken: content.outputToken,
amount: content.amount,
slippage: content.slippage,
};

try {
const walletProvider = initWalletProvider(runtime);
Expand All @@ -149,12 +123,20 @@ export const swapAction = {
);

// Generate swap details object
const swapDetails = (await generateObjectDeprecated({
const content = (await generateObjectDeprecated({
runtime,
context: contextWithChains,
modelClass: ModelClass.SMALL,
})) as SwapParams;

const swapOptions: SwapParams = {
chain: content.chain,
fromToken: content.fromToken,
toToken: content.toToken,
amount: content.amount,
slippage: content.slippage,
};

const action = new SwapAction(walletProvider);
const swapResp = await action.swap(swapOptions);
if (callback) {
Expand Down

0 comments on commit 377154f

Please sign in to comment.