61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { StrategyCompiler } from "../../src/planner/compiler.js";
|
|
|
|
describe("Execution Integration", () => {
|
|
it("should compile a simple strategy", async () => {
|
|
const compiler = new StrategyCompiler("mainnet");
|
|
const strategy = {
|
|
name: "Test",
|
|
chain: "mainnet",
|
|
steps: [
|
|
{
|
|
id: "supply",
|
|
action: {
|
|
type: "aaveV3.supply",
|
|
asset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
amount: "1000000",
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
const plan = await compiler.compile(strategy as any);
|
|
expect(plan.calls.length).toBeGreaterThan(0);
|
|
expect(plan.requiresFlashLoan).toBe(false);
|
|
});
|
|
|
|
it("should compile flash loan strategy", async () => {
|
|
const compiler = new StrategyCompiler("mainnet");
|
|
const strategy = {
|
|
name: "Flash Loan Test",
|
|
chain: "mainnet",
|
|
steps: [
|
|
{
|
|
id: "flashLoan",
|
|
action: {
|
|
type: "aaveV3.flashLoan",
|
|
assets: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"],
|
|
amounts: ["1000000"],
|
|
},
|
|
},
|
|
{
|
|
id: "swap",
|
|
action: {
|
|
type: "uniswapV3.swap",
|
|
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
tokenOut: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
fee: 3000,
|
|
amountIn: "1000000",
|
|
exactInput: true,
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
const plan = await compiler.compile(strategy as any, "0x1234567890123456789012345678901234567890");
|
|
expect(plan.requiresFlashLoan).toBe(true);
|
|
expect(plan.flashLoanAsset).toBe("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
|
|
});
|
|
});
|
|
|