-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathschemas.ts
More file actions
69 lines (63 loc) · 2.59 KB
/
Copy pathschemas.ts
File metadata and controls
69 lines (63 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { z } from "zod";
import { SUPPORTED_CHAINS } from "../../types/index.js";
import { approvalCapSchema } from "../shared/approval.js";
const chainEnum = z.enum(SUPPORTED_CHAINS as unknown as [string, ...string[]]);
const walletSchema = z
.string()
.regex(/^0x[a-fA-F0-9]{40}$/)
.describe("0x-prefixed EVM wallet address (40 hex chars) that will execute this action.");
const addressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/);
export const getCompoundPositionsInput = z.object({
wallet: walletSchema,
chains: z
.array(chainEnum)
.optional()
.describe(
"Subset of chains to scan for Compound V3 markets. Omit to scan all supported chains."
),
});
const baseCometAction = z.object({
wallet: walletSchema,
chain: chainEnum
.default("ethereum")
.describe("EVM chain the Comet market lives on. Defaults to ethereum."),
market: addressSchema.describe(
"Comet market address (e.g. cUSDCv3). Discover via get_compound_positions or the Compound registry."
),
asset: addressSchema.describe(
"ERC-20 token address being supplied or withdrawn — either the market's base token or a listed collateral token."
),
amount: z
.string()
.describe(
'Human-readable decimal amount of `asset`, NOT raw wei/base units. ' +
'Example: "10" for 10 USDC. Pass "max" for full-balance withdraw.'
),
});
export const prepareCompoundSupplyInput = baseCometAction.extend({
approvalCap: approvalCapSchema,
});
export const prepareCompoundWithdrawInput = baseCometAction;
/** Convenience wrappers — borrow = withdraw(baseToken); repay = supply(baseToken). */
export const prepareCompoundBorrowInput = z.object({
wallet: walletSchema,
chain: chainEnum
.default("ethereum")
.describe("EVM chain the Comet market lives on. Defaults to ethereum."),
market: addressSchema.describe(
"Comet market address (e.g. cUSDCv3). The base token is resolved on-chain."
),
amount: z
.string()
.describe(
'Human-readable decimal amount of the market base token, NOT raw wei/base units. Example: "100" for 100 USDC.'
),
});
export const prepareCompoundRepayInput = prepareCompoundBorrowInput.extend({
approvalCap: approvalCapSchema,
});
export type GetCompoundPositionsArgs = z.infer<typeof getCompoundPositionsInput>;
export type PrepareCompoundSupplyArgs = z.infer<typeof prepareCompoundSupplyInput>;
export type PrepareCompoundWithdrawArgs = z.infer<typeof prepareCompoundWithdrawInput>;
export type PrepareCompoundBorrowArgs = z.infer<typeof prepareCompoundBorrowInput>;
export type PrepareCompoundRepayArgs = z.infer<typeof prepareCompoundRepayInput>;