Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion typescript/agentkit/src/action-providers/enso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enso/
- `tokenIn`: Address of the token to swap from (for ETH, use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`)
- `tokenOut`: Address of the token to swap to (for ETH, use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`)
- `amountIn`: Amount of tokenIn to swap in whole units (e.g., "100 USDC")
- `slippage`: Optional slippage tolerance in basis points (1/10000). Default is 50 (0.5%)
- `slippage`: Optional slippage tolerance in basis points (0-10000). Default is 50 (0.5%). Values above 10000 are rejected.

## Network Support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,68 @@ describe("Enso Route Schema", () => {

expect(result.success).toBe(false);
});

it("should accept null slippage (API/default path)", () => {
const result = EnsoRouteSchema.safeParse({
tokenIn: USDC,
tokenOut: WETH,
amountIn: "100",
slippage: null,
});

expect(result.success).toBe(true);
if (result.success) {
expect(result.data.slippage).toBeNull();
}
});

it("should accept boundary slippage 0 and 10000", () => {
for (const slippage of [0, 10000]) {
const result = EnsoRouteSchema.safeParse({
tokenIn: USDC,
tokenOut: WETH,
amountIn: "100",
slippage,
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.slippage).toBe(slippage);
}
}
});

it("should reject slippage above 10000 bps", () => {
const result = EnsoRouteSchema.safeParse({
tokenIn: USDC,
tokenOut: WETH,
amountIn: "100",
slippage: 10001,
});

expect(result.success).toBe(false);
});

it("should reject negative slippage", () => {
const result = EnsoRouteSchema.safeParse({
tokenIn: USDC,
tokenOut: WETH,
amountIn: "100",
slippage: -1,
});

expect(result.success).toBe(false);
});

it("should reject non-integer slippage", () => {
const result = EnsoRouteSchema.safeParse({
tokenIn: USDC,
tokenOut: WETH,
amountIn: "100",
slippage: 50.5,
});

expect(result.success).toBe(false);
});
});

describe("Enso Route Action", () => {
Expand Down
10 changes: 9 additions & 1 deletion typescript/agentkit/src/action-providers/enso/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export const EnsoRouteSchema = z
"Address of the token to swap to, For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
),
amountIn: z.string().describe("Amount of tokenIn to swap in whole units (e.g. 100 USDC)"),
slippage: z.number().nullable().describe("Slippage in basis points (1/10000). Default - 50"),
slippage: z
.number()
.int()
.min(0)
.max(10000)
.nullable()
.describe(
"Slippage in basis points (0-10000, 1/10000 units). Default 50 (0.5%). Caps match Jupiter/0x.",
),
})
.describe("Instructions for routing through Enso API");
Loading